hyperion.ng/src/hyperion-remote/JsonConnection.h

84 lines
2.4 KiB
C
Raw Normal View History

#pragma once
// stl includes
#include <string>
// Qt includes
#include <QColor>
#include <QImage>
#include <QTcpSocket>
2013-08-17 11:54:16 +02:00
#include <QMap>
// jsoncpp includes
#include <json/json.h>
// hyperion-remote includes
#include "ColorTransformValues.h"
/// Connection class to setup an connection to the hyperion server and execute commands
2013-08-17 11:54:16 +02:00
class JsonConnection
{
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-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-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-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-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-31 14:36:54 +02:00
/// @brief Clear all priority channels
2013-08-17 11:54:16 +02:00
void clearAll();
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
void setTransform(
double * saturation,
double * value,
ColorTransformValues * threshold,
ColorTransformValues * gamma,
ColorTransformValues * blacklevel,
ColorTransformValues * whitelevel);
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
Json::Value sendMessage(const Json::Value & message);
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);
private:
bool _printJson;
QTcpSocket _socket;
};