2013-08-11 21:49:11 +02:00
|
|
|
#pragma once
|
|
|
|
|
2013-08-13 20:10:19 +02:00
|
|
|
// stl includes
|
2013-08-11 21:49:11 +02:00
|
|
|
#include <string>
|
|
|
|
|
2013-08-13 20:10:19 +02:00
|
|
|
// Qt includes
|
2013-08-11 21:49:11 +02:00
|
|
|
#include <QColor>
|
|
|
|
#include <QImage>
|
2013-08-13 19:31:56 +02:00
|
|
|
#include <QTcpSocket>
|
2013-08-17 11:54:16 +02:00
|
|
|
#include <QMap>
|
2013-08-11 21:49:11 +02:00
|
|
|
|
2013-08-13 20:10:19 +02:00
|
|
|
// jsoncpp includes
|
2013-08-11 21:49:11 +02:00
|
|
|
#include <json/json.h>
|
|
|
|
|
2013-08-13 20:10:19 +02:00
|
|
|
// hyperion-remote includes
|
2013-08-13 19:45:17 +02:00
|
|
|
#include "ColorTransformValues.h"
|
2013-08-13 19:31:56 +02:00
|
|
|
|
2013-08-13 20:10:19 +02:00
|
|
|
/// Connection class to setup an connection to the hyperion server and execute commands
|
2013-08-17 11:54:16 +02:00
|
|
|
class JsonConnection
|
2013-08-11 21:49:11 +02:00
|
|
|
{
|
|
|
|
public:
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief COnstructor
|
|
|
|
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
|
|
|
|
/// @param printJson Boolean indicating if the sent and received json is written to stdout
|
2013-08-17 11:54:16 +02:00
|
|
|
JsonConnection(const std::string & address, bool printJson);
|
2013-08-31 14:36:54 +02:00
|
|
|
|
|
|
|
/// @brief Destructor
|
2013-08-17 11:54:16 +02:00
|
|
|
~JsonConnection();
|
2013-08-11 21:49:11 +02:00
|
|
|
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Set all leds to the specified color
|
|
|
|
/// @param color The color
|
|
|
|
/// @param priority The priority
|
|
|
|
/// @param duration The duration in milliseconds
|
2013-08-17 11:54:16 +02:00
|
|
|
void setColor(QColor color, int priority, int duration);
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Set the leds according to the given image (assume the image is stretched to the display size)
|
|
|
|
/// @param image The image
|
|
|
|
/// @param priority The priority
|
|
|
|
/// @param duration The duration in milliseconds
|
2013-08-17 11:54:16 +02:00
|
|
|
void setImage(QImage image, int priority, int duration);
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Retrieve a list of all occupied priority channels
|
|
|
|
/// @return String with the server info
|
2013-08-17 11:54:16 +02:00
|
|
|
QString getServerInfo();
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Clear the given priority channel
|
|
|
|
/// @param priority The priority
|
2013-08-17 11:54:16 +02:00
|
|
|
void clear(int priority);
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Clear all priority channels
|
2013-08-17 11:54:16 +02:00
|
|
|
void clearAll();
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Set the color transform of the leds
|
|
|
|
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
|
|
|
/// @param saturation The HSV saturation gain
|
|
|
|
/// @param value The HSV value gain
|
|
|
|
/// @param threshold The threshold
|
|
|
|
/// @param blacklevel The blacklevel
|
|
|
|
/// @param whitelevel The whitelevel
|
2013-08-21 21:50:17 +02:00
|
|
|
void setTransform(
|
|
|
|
double * saturation,
|
|
|
|
double * value,
|
|
|
|
ColorTransformValues * threshold,
|
|
|
|
ColorTransformValues * gamma,
|
|
|
|
ColorTransformValues * blacklevel,
|
|
|
|
ColorTransformValues * whitelevel);
|
2013-08-11 21:49:11 +02:00
|
|
|
|
|
|
|
private:
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Send a json command message and receive its reply
|
|
|
|
/// @param message The message to send
|
|
|
|
/// @return The returned reply
|
2013-08-13 20:10:19 +02:00
|
|
|
Json::Value sendMessage(const Json::Value & message);
|
2013-08-11 21:49:11 +02:00
|
|
|
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @brief Parse a reply message
|
|
|
|
/// @param reply The received reply
|
|
|
|
/// @return true if the reply indicates success
|
2013-08-13 22:35:50 +02:00
|
|
|
bool parseReply(const Json::Value & reply);
|
|
|
|
|
2013-08-11 21:49:11 +02:00
|
|
|
private:
|
2013-08-13 20:10:19 +02:00
|
|
|
bool _printJson;
|
2013-08-13 19:31:56 +02:00
|
|
|
|
2013-08-13 20:10:19 +02:00
|
|
|
QTcpSocket _socket;
|
2013-08-11 21:49:11 +02:00
|
|
|
};
|