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

61 lines
1.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-17 11:54:16 +02:00
JsonConnection(const std::string & address, bool printJson);
~JsonConnection();
/// Set all leds to the specified color
2013-08-17 11:54:16 +02:00
void setColor(QColor color, int priority, int duration);
/// Set the leds according to the given image (assume the image is stretched to the display size)
2013-08-17 11:54:16 +02:00
void setImage(QImage image, int priority, int duration);
/// Retrieve a list of all occupied priority channels
2013-08-17 11:54:16 +02:00
QString getServerInfo();
/// Clear the given priority channel
2013-08-17 11:54:16 +02:00
void clear(int priority);
/// Clear all priority channels
2013-08-17 11:54:16 +02:00
void clearAll();
/// Set the color transform of the leds
/// Note that providing a NULL will leave the settings on the server unchanged
void setTransform(
double * saturation,
double * value,
ColorTransformValues * threshold,
ColorTransformValues * gamma,
ColorTransformValues * blacklevel,
ColorTransformValues * whitelevel);
private:
/// Send a json command message and receive its reply
Json::Value sendMessage(const Json::Value & message);
2013-08-13 22:35:50 +02:00
bool parseReply(const Json::Value & reply);
private:
bool _printJson;
QTcpSocket _socket;
};