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-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-13 20:10:19 +02:00
|
|
|
/// Connection class to setup an connection to the hyperion server and execute commands
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-17 11:54:16 +02:00
|
|
|
class JsonConnection
|
2013-08-11 21:49:11 +02:00
|
|
|
{
|
|
|
|
public:
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Constructor
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @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-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-17 11:54:16 +02:00
|
|
|
JsonConnection(const std::string & address, bool printJson);
|
2013-08-31 14:36:54 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Destructor
|
|
|
|
///
|
2013-08-17 11:54:16 +02:00
|
|
|
~JsonConnection();
|
2013-08-11 21:49:11 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Set all leds to the specified color
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param color The color
|
|
|
|
/// @param priority The priority
|
|
|
|
/// @param duration The duration in milliseconds
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-12-13 00:01:48 +01:00
|
|
|
void setColor(std::vector<QColor> color, int priority, int duration);
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Set the leds according to the given image (assume the image is stretched to the display size)
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param image The image
|
|
|
|
/// @param priority The priority
|
|
|
|
/// @param duration The duration in milliseconds
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
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-11-24 16:10:48 +01:00
|
|
|
///
|
|
|
|
/// Start the given effect
|
|
|
|
///
|
|
|
|
/// @param effect The name of the effect
|
2013-12-01 14:09:01 +01:00
|
|
|
/// @param effectArgs The arguments to use instead of the default ones
|
2013-11-24 16:10:48 +01:00
|
|
|
/// @param priority The priority
|
|
|
|
/// @param duration The duration in milliseconds
|
|
|
|
///
|
2013-12-01 14:09:01 +01:00
|
|
|
void setEffect(const std::string & effectName, const std::string &effectArgs, int priority, int duration);
|
2013-11-24 16:10:48 +01:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Retrieve a list of all occupied priority channels
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @return String with the server info
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-17 11:54:16 +02:00
|
|
|
QString getServerInfo();
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Clear the given priority channel
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param priority The priority
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-17 11:54:16 +02:00
|
|
|
void clear(int priority);
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Clear all priority channels
|
|
|
|
///
|
2013-08-17 11:54:16 +02:00
|
|
|
void clearAll();
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Set the color transform of the leds
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-11-22 11:48:10 +01:00
|
|
|
/// @param transformId The identifier of the transform to set
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param saturation The HSV saturation gain
|
|
|
|
/// @param value The HSV value gain
|
|
|
|
/// @param threshold The threshold
|
2013-09-09 22:35:28 +02:00
|
|
|
/// @param gamma The gamma value
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param blacklevel The blacklevel
|
|
|
|
/// @param whitelevel The whitelevel
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-21 21:50:17 +02:00
|
|
|
void setTransform(
|
2013-11-22 11:48:10 +01:00
|
|
|
std::string * transformId,
|
2013-08-21 21:50:17 +02:00
|
|
|
double * saturation,
|
|
|
|
double * value,
|
|
|
|
ColorTransformValues * threshold,
|
|
|
|
ColorTransformValues * gamma,
|
|
|
|
ColorTransformValues * blacklevel,
|
|
|
|
ColorTransformValues * whitelevel);
|
2013-08-11 21:49:11 +02:00
|
|
|
|
|
|
|
private:
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Send a json command message and receive its reply
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param message The message to send
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @return The returned reply
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-13 20:10:19 +02:00
|
|
|
Json::Value sendMessage(const Json::Value & message);
|
2013-08-11 21:49:11 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Parse a reply message
|
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @param reply The received reply
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-31 14:36:54 +02:00
|
|
|
/// @return true if the reply indicates success
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-13 22:35:50 +02:00
|
|
|
bool parseReply(const Json::Value & reply);
|
|
|
|
|
2013-08-11 21:49:11 +02:00
|
|
|
private:
|
2013-09-09 04:54:13 +02:00
|
|
|
/// Flag for printing all send and received json-messages to the standard out
|
2013-08-13 20:10:19 +02:00
|
|
|
bool _printJson;
|
2013-08-13 19:31:56 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The TCP-Socket with the connection to the server
|
2013-08-13 20:10:19 +02:00
|
|
|
QTcpSocket _socket;
|
2013-08-11 21:49:11 +02:00
|
|
|
};
|