2013-08-11 21:49:11 +02:00
|
|
|
#pragma once
|
|
|
|
|
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>
|
2016-10-11 19:51:20 +02:00
|
|
|
#include <QJsonObject>
|
2013-08-13 19:31:56 +02:00
|
|
|
|
2017-10-12 11:55:03 +02:00
|
|
|
//forward class decl
|
|
|
|
class Logger;
|
|
|
|
|
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
|
|
|
///
|
2016-08-28 15:10:43 +02:00
|
|
|
JsonConnection(const QString & 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
|
|
|
///
|
2016-08-28 15:10:43 +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
|
|
|
|
///
|
2016-10-11 19:51:20 +02:00
|
|
|
/// @param effectName 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
|
|
|
|
///
|
2016-08-28 15:10:43 +02:00
|
|
|
void setEffect(const QString & effectName, const QString &effectArgs, int priority, int duration);
|
2013-11-24 16:10:48 +01:00
|
|
|
|
2016-10-24 23:52:53 +02:00
|
|
|
///
|
|
|
|
/// Create a effect configuration file (.json)
|
|
|
|
///
|
|
|
|
/// @param effectName The name of the effect
|
|
|
|
/// @param effectScript The name of the Python effect file
|
|
|
|
/// @param effectArgs The arguments of the effect
|
|
|
|
///
|
|
|
|
void createEffect(const QString &effectName, const QString &effectScript, const QString & effectArgs);
|
2017-10-12 11:55:03 +02:00
|
|
|
|
2016-11-18 18:39:21 +01:00
|
|
|
///
|
|
|
|
/// Delete a effect configuration file (.json)
|
|
|
|
///
|
|
|
|
/// @param effectName The name of the effect
|
|
|
|
///
|
|
|
|
void deleteEffect(const QString &effectName);
|
2016-10-24 23:52:53 +02: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
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
///
|
|
|
|
/// Retrieve system info
|
|
|
|
///
|
|
|
|
/// @return String with the sys info
|
|
|
|
///
|
|
|
|
QString getSysInfo();
|
|
|
|
|
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();
|
2016-12-19 23:59:50 +01:00
|
|
|
|
2016-08-04 13:10:53 +02:00
|
|
|
///
|
|
|
|
/// Enable/Disable components during runtime
|
|
|
|
///
|
2017-11-22 00:52:55 +01:00
|
|
|
/// @param component The component [SMOOTHING, BLACKBORDER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER]
|
2016-08-04 13:10:53 +02:00
|
|
|
/// @param state The state of the component [true | false]
|
|
|
|
///
|
2016-08-28 15:10:43 +02:00
|
|
|
void setComponentState(const QString & component, const bool state);
|
2013-08-13 20:10:19 +02:00
|
|
|
|
2016-07-31 22:21:35 +02:00
|
|
|
///
|
2016-08-03 22:03:19 +02:00
|
|
|
/// Set current active priority channel and deactivate auto source switching
|
2016-07-31 22:21:35 +02:00
|
|
|
///
|
|
|
|
/// @param priority The priority
|
|
|
|
///
|
|
|
|
void setSource(int priority);
|
2016-12-19 23:59:50 +01:00
|
|
|
|
2016-08-03 22:03:19 +02:00
|
|
|
///
|
|
|
|
/// Enables auto source, if disabled prio by manual selecting input source
|
|
|
|
///
|
2016-07-31 22:21:35 +02:00
|
|
|
void setSourceAutoSelect();
|
2016-12-19 23:59:50 +01:00
|
|
|
|
2016-08-03 22:03:19 +02:00
|
|
|
///
|
2017-10-12 11:55:03 +02:00
|
|
|
/// Print the current loaded Hyperion configuration file
|
2016-08-03 22:03:19 +02:00
|
|
|
///
|
2016-08-15 22:32:01 +02:00
|
|
|
QString getConfig(std::string type);
|
2016-07-31 22:21:35 +02:00
|
|
|
|
2016-08-14 20:17:12 +02:00
|
|
|
///
|
|
|
|
/// Write JSON Value(s) to the actual loaded configuration file
|
|
|
|
///
|
|
|
|
/// @param jsonString The JSON String(s) to write
|
|
|
|
/// @param create Specifies whether the nonexistent json string to be created
|
|
|
|
///
|
2016-10-09 22:22:17 +02:00
|
|
|
void setConfig(const QString &jsonString);
|
2016-08-14 20:17:12 +02:00
|
|
|
|
2016-04-02 00:04:11 +02:00
|
|
|
///
|
|
|
|
/// Set the color adjustment of the leds
|
|
|
|
///
|
|
|
|
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
|
|
|
///
|
|
|
|
/// @param adjustmentId The identifier of the correction to set
|
|
|
|
/// @param redAdjustment The red channel adjustment values
|
|
|
|
/// @param greenAdjustment The green channel adjustment values
|
|
|
|
/// @param blueAdjustment The blue channel adjustment values
|
2017-01-06 14:25:55 +01:00
|
|
|
/// @param gamma The gamma value
|
2017-02-11 22:52:47 +01:00
|
|
|
/// @param backlightThreshold The threshold aka backlight
|
2017-01-06 14:25:55 +01:00
|
|
|
/// @param brightness The threshold aka upper brightness limit
|
|
|
|
|
2016-04-02 00:04:11 +02:00
|
|
|
void setAdjustment(
|
2016-08-28 15:10:43 +02:00
|
|
|
const QString & adjustmentId,
|
|
|
|
const QColor & redAdjustment,
|
|
|
|
const QColor & greenAdjustment,
|
2017-01-06 14:25:55 +01:00
|
|
|
const QColor & blueAdjustment,
|
|
|
|
const QColor & cyanAdjustment,
|
|
|
|
const QColor & magentaAdjustment,
|
|
|
|
const QColor & yellowAdjustment,
|
|
|
|
const QColor & blackAdjustment,
|
|
|
|
const QColor & whiteAdjustment,
|
|
|
|
double *gammaR,
|
|
|
|
double *gammaG,
|
|
|
|
double *gammaB,
|
2017-04-03 05:19:05 +02:00
|
|
|
int *backlightThreshold,
|
2017-02-11 22:52:47 +01:00
|
|
|
int *backlightColored,
|
2017-04-03 05:19:05 +02:00
|
|
|
int *brightness,
|
|
|
|
int *brightnessC);
|
2016-04-02 00:04:11 +02:00
|
|
|
|
2016-12-19 23:59:50 +01:00
|
|
|
///
|
|
|
|
/// sets the image to leds mapping type
|
|
|
|
///
|
|
|
|
/// @param mappingType led mapping type
|
|
|
|
void setLedMapping(QString mappingType);
|
|
|
|
|
2017-08-04 23:08:15 +02:00
|
|
|
// sets video mode 3D/2D
|
|
|
|
void setVideoMode(QString videoMode);
|
|
|
|
|
|
|
|
|
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
|
|
|
///
|
2016-10-11 19:51:20 +02:00
|
|
|
QJsonObject sendMessage(const QJsonObject & 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
|
|
|
///
|
2016-10-11 19:51:20 +02:00
|
|
|
bool parseReply(const QJsonObject & reply);
|
2013-08-13 22:35:50 +02:00
|
|
|
|
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
|
|
|
|
2017-10-12 11:55:03 +02:00
|
|
|
// Logger class
|
|
|
|
Logger* _log;
|
|
|
|
|
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;
|
2017-10-12 11:55:03 +02:00
|
|
|
|
2013-08-11 21:49:11 +02:00
|
|
|
};
|