mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Added/Updated/Fixed doxygen comments
This commit is contained in:
parent
d2d7265f02
commit
8441dd51cc
@ -23,27 +23,27 @@ class JsonServer : public QObject
|
||||
|
||||
public:
|
||||
///
|
||||
/// \brief JsonServer constructor
|
||||
/// \param hyperion Hyperion instance
|
||||
/// \param port port number on which to start listening for connections
|
||||
/// JsonServer constructor
|
||||
/// @param hyperion Hyperion instance
|
||||
/// @param port port number on which to start listening for connections
|
||||
///
|
||||
JsonServer(Hyperion * hyperion, uint16_t port = 19444);
|
||||
~JsonServer();
|
||||
|
||||
///
|
||||
/// \return the port number on which this TCP listens for incoming connections
|
||||
/// @return the port number on which this TCP listens for incoming connections
|
||||
///
|
||||
uint16_t getPort() const;
|
||||
|
||||
private slots:
|
||||
///
|
||||
/// \brief Slot which is called when a client tries to create a new connection
|
||||
/// Slot which is called when a client tries to create a new connection
|
||||
///
|
||||
void newConnection();
|
||||
|
||||
///
|
||||
/// \brief Slot which is called when a client closes a connection
|
||||
/// \param The Connection object which is being closed
|
||||
/// Slot which is called when a client closes a connection
|
||||
/// @param The Connection object which is being closed
|
||||
///
|
||||
void closedConnection(JsonClientConnection * connection);
|
||||
|
||||
|
@ -15,17 +15,17 @@
|
||||
class ColorTransform
|
||||
{
|
||||
public:
|
||||
/// @brief Default constructor
|
||||
/// Default constructor
|
||||
ColorTransform();
|
||||
|
||||
/// @brief Constructor
|
||||
/// Constructor
|
||||
/// @param threshold
|
||||
/// @param gamma
|
||||
/// @param blacklevel
|
||||
/// @param whitelevel
|
||||
ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel);
|
||||
|
||||
/// @brief Destructor
|
||||
/// Destructor
|
||||
~ColorTransform();
|
||||
|
||||
/// @return The current threshold value
|
||||
@ -52,7 +52,7 @@ public:
|
||||
/// @param whitelevel New whitelevel value
|
||||
void setWhitelevel(double whitelevel);
|
||||
|
||||
/// @brief Transform the given byte value
|
||||
/// Transform the given byte value
|
||||
/// @param input The input color byte
|
||||
/// @return The transformed byte value
|
||||
uint8_t transform(uint8_t input) const
|
||||
@ -61,14 +61,19 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
/// @brief (re)-initilize the color mapping
|
||||
/// (re)-initilize the color mapping
|
||||
void initializeMapping();
|
||||
|
||||
private:
|
||||
/// The threshold value
|
||||
double _threshold;
|
||||
/// The gamma value
|
||||
double _gamma;
|
||||
/// The blacklevel
|
||||
double _blacklevel;
|
||||
/// The whitelevel
|
||||
double _whitelevel;
|
||||
|
||||
/// The mapping from input color to output color
|
||||
uint8_t _mapping[256];
|
||||
};
|
||||
|
@ -4,48 +4,79 @@
|
||||
#include <cstdint>
|
||||
|
||||
///
|
||||
/// \brief Color transformation to adjust the saturation and value of a RGB color value
|
||||
/// Color transformation to adjust the saturation and value of a RGB color value
|
||||
///
|
||||
class HsvTransform
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Default constructor
|
||||
///
|
||||
HsvTransform();
|
||||
|
||||
/// @brief Constructor
|
||||
/// @param saturationGain
|
||||
/// @param valueGain
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
/// @param saturationGain The used saturation gain
|
||||
/// @param valueGain The used value gain
|
||||
///
|
||||
HsvTransform(double saturationGain, double valueGain);
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~HsvTransform();
|
||||
|
||||
///
|
||||
/// Updates the saturation gain
|
||||
///
|
||||
/// @param saturationGain New saturationGain
|
||||
///
|
||||
void setSaturationGain(double saturationGain);
|
||||
|
||||
///
|
||||
/// Returns the saturation gain
|
||||
///
|
||||
/// @return The current Saturation gain
|
||||
///
|
||||
double getSaturationGain() const;
|
||||
|
||||
/// @param valueGain New Value gain
|
||||
///
|
||||
/// Updates the value gain
|
||||
///
|
||||
/// @param valueGain New value gain
|
||||
///
|
||||
void setValueGain(double valueGain);
|
||||
|
||||
///
|
||||
/// Returns the value gain
|
||||
///
|
||||
/// @return The current value gain
|
||||
///
|
||||
double getValueGain() const;
|
||||
|
||||
/// @brief Apply the transform the the given RGB values.
|
||||
///
|
||||
/// Apply the transform the the given RGB values.
|
||||
///
|
||||
/// @param red The red color component
|
||||
/// @param green The green color component
|
||||
/// @param blue The blue color component
|
||||
///
|
||||
/// @note The values are updated in place.
|
||||
///
|
||||
void transform(uint8_t & red, uint8_t & green, uint8_t & blue) const;
|
||||
|
||||
///
|
||||
/// integer version of the conversion are faster, but a little less accurate
|
||||
/// all values are unsigned 8 bit values and scaled between 0 and 255 except
|
||||
/// for the hue which is a 16 bit number and scaled between 0 and 360
|
||||
///
|
||||
static void rgb2hsv(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, uint8_t & saturation, uint8_t & value);
|
||||
static void hsv2rgb(uint16_t hue, uint8_t saturation, uint8_t value, uint8_t & red, uint8_t & green, uint8_t & blue);
|
||||
|
||||
private:
|
||||
/// The saturation gain
|
||||
double _saturationGain;
|
||||
/// The value gain
|
||||
double _valueGain;
|
||||
};
|
||||
|
@ -8,31 +8,57 @@
|
||||
// Forward class declaration
|
||||
struct RgbColor;
|
||||
|
||||
///
|
||||
/// Plain-Old-Data structure containing the red-green-blue color specification. Size of the
|
||||
/// structure is exactly 3-bytes for easy writing to led-device
|
||||
///
|
||||
struct RgbColor
|
||||
{
|
||||
/// The red color channel
|
||||
uint8_t red;
|
||||
/// The green color channel
|
||||
uint8_t green;
|
||||
/// The blue color channel
|
||||
uint8_t blue;
|
||||
|
||||
/// 'Black' RgbColor (0, 0, 0)
|
||||
static RgbColor BLACK;
|
||||
/// 'Red' RgbColor (255, 0, 0)
|
||||
static RgbColor RED;
|
||||
/// 'Green' RgbColor (0, 255, 0)
|
||||
static RgbColor GREEN;
|
||||
/// 'Blue' RgbColor (0, 0, 255)
|
||||
static RgbColor BLUE;
|
||||
/// 'Yellow' RgbColor (255, 255, 0)
|
||||
static RgbColor YELLOW;
|
||||
/// 'White' RgbColor (255, 255, 255)
|
||||
static RgbColor WHITE;
|
||||
|
||||
///
|
||||
/// Checks is this exactly matches another color
|
||||
///
|
||||
/// @param other The other color
|
||||
///
|
||||
/// @return True if the colors are identical
|
||||
///
|
||||
inline bool operator==(const RgbColor& other) const
|
||||
{
|
||||
return red == other.red && green == other.green && blue == other.blue;
|
||||
}
|
||||
};
|
||||
|
||||
/// Assert to ensure that the size of the structure is 'only' 3 bytes
|
||||
static_assert(sizeof(RgbColor) == 3, "Incorrect size of RgbColor");
|
||||
|
||||
|
||||
///
|
||||
/// Stream operator to write RgbColor to an outputstream (format "'{'[red]','[green]','[blue]'}'")
|
||||
///
|
||||
/// @param os The output stream
|
||||
/// @param color The color to write
|
||||
/// @return The output stream (with the color written to it)
|
||||
///
|
||||
inline std::ostream& operator<<(std::ostream& os, const RgbColor& color)
|
||||
{
|
||||
os << "{" << unsigned(color.red) << "," << unsigned(color.green) << "," << unsigned(color.blue) << "}";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -8,57 +8,127 @@
|
||||
// Local includes
|
||||
#include "RgbColor.h"
|
||||
|
||||
///
|
||||
/// The RgbImage holds a 2D matrix of RgbColors's (or image). Width and height of the image are
|
||||
/// fixed at construction.
|
||||
///
|
||||
class RgbImage
|
||||
{
|
||||
public:
|
||||
|
||||
///
|
||||
/// Constructor for an image with specified width and height
|
||||
///
|
||||
/// @param width The width of the image
|
||||
/// @param height The height of the image
|
||||
/// @param background The color of the image (default = BLACK)
|
||||
///
|
||||
RgbImage(const unsigned width, const unsigned height, const RgbColor background = RgbColor::BLACK);
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~RgbImage();
|
||||
|
||||
///
|
||||
/// Returns the width of the image
|
||||
///
|
||||
/// @return The width of the image
|
||||
///
|
||||
inline unsigned width() const
|
||||
{
|
||||
return mWidth;
|
||||
return _width;
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the height of the image
|
||||
///
|
||||
/// @return The height of the image
|
||||
///
|
||||
inline unsigned height() const
|
||||
{
|
||||
return mHeight;
|
||||
return _height;
|
||||
}
|
||||
|
||||
///
|
||||
/// Sets the color of a specific pixel in the image
|
||||
///
|
||||
/// @param x The x index
|
||||
/// @param y The y index
|
||||
/// @param color The new color
|
||||
///
|
||||
void setPixel(const unsigned x, const unsigned y, const RgbColor color);
|
||||
|
||||
///
|
||||
/// Returns a const reference to a specified pixel in the image
|
||||
///
|
||||
/// @param x The x index
|
||||
/// @param y The y index
|
||||
///
|
||||
/// @return const reference to specified pixel
|
||||
///
|
||||
const RgbColor& operator()(const unsigned x, const unsigned y) const;
|
||||
|
||||
///
|
||||
/// Returns a reference to a specified pixel in the image
|
||||
///
|
||||
/// @param x The x index
|
||||
/// @param y The y index
|
||||
///
|
||||
/// @return reference to specified pixel
|
||||
///
|
||||
RgbColor& operator()(const unsigned x, const unsigned y);
|
||||
|
||||
///
|
||||
/// Copies another image into this image. The images should have exactly the same size.
|
||||
///
|
||||
/// @param other The image to copy into this
|
||||
///
|
||||
inline void copy(const RgbImage& other)
|
||||
{
|
||||
assert(other.mWidth == mWidth);
|
||||
assert(other.mHeight == mHeight);
|
||||
assert(other._width == _width);
|
||||
assert(other._height == _height);
|
||||
|
||||
memcpy(mColors, other.mColors, mWidth*mHeight*sizeof(RgbColor));
|
||||
memcpy(mColors, other.mColors, _width*_height*sizeof(RgbColor));
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a memory pointer to the first pixel in the image
|
||||
/// @return The memory pointer to the first pixel
|
||||
///
|
||||
RgbColor* memptr()
|
||||
{
|
||||
return mColors;
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a const memory pointer to the first pixel in the image
|
||||
/// @return The const memory pointer to the first pixel
|
||||
///
|
||||
const RgbColor* memptr() const
|
||||
{
|
||||
return mColors;
|
||||
}
|
||||
private:
|
||||
|
||||
///
|
||||
/// Translate x and y coordinate to index of the underlying vector
|
||||
///
|
||||
/// @param x The x index
|
||||
/// @param y The y index
|
||||
///
|
||||
/// @return The index into the underlying data-vector
|
||||
///
|
||||
inline unsigned toIndex(const unsigned x, const unsigned y) const
|
||||
{
|
||||
return y*mWidth + x;
|
||||
return y*_width + x;
|
||||
}
|
||||
|
||||
private:
|
||||
const unsigned mWidth;
|
||||
const unsigned mHeight;
|
||||
/// The width of the image
|
||||
const unsigned _width;
|
||||
/// The height of the image
|
||||
const unsigned _height;
|
||||
|
||||
/** The colors of the image */
|
||||
RgbColor* mColors;
|
||||
|
@ -14,46 +14,63 @@
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
///
|
||||
/// This class will check if XBMC is playing something. When it does not, this class will send all black data to Hyperion.
|
||||
/// This allows grabbed screen data to be overriden while in the XBMC menus.
|
||||
///
|
||||
/// Note: The json TCP server needs to be enabled manually in XBMC in System/Settings/Network/Services
|
||||
///
|
||||
class XBMCVideoChecker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/// @Constructor
|
||||
/// @param address Netwrok address of the XBMC instance
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
/// @param address Network address of the XBMC instance
|
||||
/// @param port Port number to use (XBMC default = 9090)
|
||||
/// @param interval The interval at which XBMC is polled
|
||||
/// @param hyperion The Hyperion instance
|
||||
/// @param priority The priority at which to send the all black data
|
||||
///
|
||||
XBMCVideoChecker(const std::string & address, uint16_t port, uint64_t interval, Hyperion * hyperion, int priority);
|
||||
|
||||
/// \brief Start polling XBMC
|
||||
///
|
||||
/// Start polling XBMC
|
||||
///
|
||||
void start();
|
||||
|
||||
private slots:
|
||||
/// \brief Send a request to XBMC
|
||||
///
|
||||
/// Send a request to XBMC
|
||||
///
|
||||
void sendRequest();
|
||||
|
||||
/// @brief receive a reply from XBMC
|
||||
///
|
||||
/// Receive a reply from XBMC
|
||||
///
|
||||
void receiveReply();
|
||||
|
||||
private:
|
||||
/// The network address of the XBMC instance
|
||||
const QString _address;
|
||||
|
||||
/// The port number of XBMC
|
||||
const uint16_t _port;
|
||||
|
||||
/// The JSON-RPC request message
|
||||
const QByteArray _request;
|
||||
|
||||
/// The timer that schedules XBMC queries
|
||||
QTimer _timer;
|
||||
|
||||
/// The QT TCP Socket with connection to XBMC
|
||||
QTcpSocket _socket;
|
||||
|
||||
/// The Hyperion instance to switch leds to black if in XBMC menu
|
||||
Hyperion * _hyperion;
|
||||
|
||||
/// The priority of the BLACK led value when in XBMC menu
|
||||
const int _priority;
|
||||
};
|
||||
|
||||
|
@ -6,32 +6,65 @@
|
||||
|
||||
namespace hyperion
|
||||
{
|
||||
///
|
||||
/// The BlackBorder processor is a wrapper around the black-border detector for keeping track of
|
||||
/// detected borders and count of the type and size of detected borders.
|
||||
///
|
||||
class BlackBorderProcessor
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructor for the BlackBorderProcessor
|
||||
/// @param unknownFrameCnt The number of frames(images) that need to contain an unknown
|
||||
/// border before the current border is set to unknown
|
||||
/// @param borderFrameCnt The number of frames(images) that need to contain a vertical or
|
||||
/// horizontal border becomes the current border
|
||||
/// @param blurRemoveCnt The size to add to a horizontal or vertical border (because the
|
||||
/// outer pixels is blurred (black and color combined))
|
||||
///
|
||||
BlackBorderProcessor(
|
||||
const unsigned unknownFrameCnt,
|
||||
const unsigned borderFrameCnt,
|
||||
const unsigned blurRemoveCnt);
|
||||
|
||||
///
|
||||
/// Return the current (detected) border
|
||||
/// @return The current border
|
||||
///
|
||||
BlackBorder getCurrentBorder() const;
|
||||
|
||||
///
|
||||
/// Processes the image. This performs detecion of black-border on the given image and
|
||||
/// updates the current border accordingly. If the current border is updated the method call
|
||||
/// will return true else false
|
||||
///
|
||||
/// @param image The image to process
|
||||
///
|
||||
/// @return True if a different border was detected than the current else false
|
||||
///
|
||||
bool process(const RgbImage& image);
|
||||
|
||||
private:
|
||||
|
||||
/// The number of unknown-borders detected before it becomes the current border
|
||||
const unsigned _unknownSwitchCnt;
|
||||
|
||||
/// The number of horizontal/vertical borders detected before it becomes the current border
|
||||
const unsigned _borderSwitchCnt;
|
||||
|
||||
/// The number of pixels to increase a detected border for removing blury pixels
|
||||
unsigned _blurRemoveCnt;
|
||||
|
||||
/// The blackborder detector
|
||||
BlackBorderDetector _detector;
|
||||
|
||||
/// The current detected border
|
||||
BlackBorder _currentBorder;
|
||||
|
||||
/// The border detected in the previous frame
|
||||
BlackBorder _previousDetectedBorder;
|
||||
|
||||
/// The number of frame the previous detected border matched the incomming border
|
||||
unsigned _consistentCnt;
|
||||
};
|
||||
} // end namespace hyperion
|
||||
|
@ -6,14 +6,33 @@
|
||||
// Hyperion includes
|
||||
#include <hyperion/LedDevice.h>
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice that write the led-colors to an
|
||||
/// ASCII-textfile('/home/pi/LedDevice.out')
|
||||
///
|
||||
class LedDeviceTest : public LedDevice
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the test-device, which opens an output stream to the file
|
||||
///
|
||||
LedDeviceTest();
|
||||
|
||||
///
|
||||
/// Destructor of this test-device
|
||||
///
|
||||
virtual ~LedDeviceTest();
|
||||
|
||||
///
|
||||
/// Writes the given led-color values to the output stream
|
||||
///
|
||||
/// @param ledValues The color-value per led
|
||||
///
|
||||
/// @return Zero on success else negative
|
||||
///
|
||||
virtual int write(const std::vector<RgbColor> & ledValues);
|
||||
|
||||
private:
|
||||
/// The outputstream
|
||||
std::ofstream _ofs;
|
||||
};
|
||||
|
@ -11,9 +11,7 @@
|
||||
// hyperion local includes
|
||||
#include "LedDeviceWs2801.h"
|
||||
|
||||
LedDeviceWs2801::LedDeviceWs2801(const std::string& name,
|
||||
const std::string& outputDevice,
|
||||
const unsigned interval,
|
||||
LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice,
|
||||
const unsigned baudrate) :
|
||||
mDeviceName(outputDevice),
|
||||
mBaudRate_Hz(baudrate),
|
||||
|
@ -9,25 +9,51 @@
|
||||
// hyperion incluse
|
||||
#include <hyperion/LedDevice.h>
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice interface for writing to Ws2801 led device.
|
||||
///
|
||||
class LedDeviceWs2801 : public LedDevice
|
||||
{
|
||||
public:
|
||||
LedDeviceWs2801(const std::string& name,
|
||||
const std::string& outputDevice,
|
||||
const unsigned interval,
|
||||
///
|
||||
/// Constructs the LedDevice for a string containing leds of the type Ws2801
|
||||
///
|
||||
/// @param outputDevice The name of the output device (eg '/etc/SpiDev.0.0')
|
||||
/// @param baudrate The used baudrate for writing to the output device
|
||||
///
|
||||
LedDeviceWs2801(const std::string& outputDevice,
|
||||
const unsigned baudrate);
|
||||
|
||||
///
|
||||
/// Destructor of the LedDevice; closes the output device if it is open
|
||||
///
|
||||
virtual ~LedDeviceWs2801();
|
||||
|
||||
///
|
||||
/// Opens and configures the output device
|
||||
///
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
int open();
|
||||
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
///
|
||||
/// @param ledValues The color-value per led
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
virtual int write(const std::vector<RgbColor> &ledValues);
|
||||
|
||||
private:
|
||||
/// The name of the output device
|
||||
const std::string mDeviceName;
|
||||
/// The used baudrate of the output device
|
||||
const int mBaudRate_Hz;
|
||||
|
||||
/// The File Identifier of the opened output device (or -1 if not opened)
|
||||
int mFid;
|
||||
/// The transfer structure for writing to the spi-device
|
||||
spi_ioc_transfer spi;
|
||||
/// The 'latch' time for latching the shifted-value into the leds
|
||||
timespec latchTime;
|
||||
};
|
||||
|
@ -18,91 +18,142 @@
|
||||
|
||||
class ImageProcessor;
|
||||
|
||||
/// @brief The Connection object created by \a JsonServer when a new connection is establshed
|
||||
///
|
||||
/// The Connection object created by \a JsonServer when a new connection is establshed
|
||||
///
|
||||
class JsonClientConnection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/// @brief Constructor
|
||||
///
|
||||
/// Constructor
|
||||
/// @param socket The Socket object for this connection
|
||||
/// @param hyperion The Hyperion server
|
||||
///
|
||||
JsonClientConnection(QTcpSocket * socket, Hyperion * hyperion);
|
||||
|
||||
/// @brief Destructor
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~JsonClientConnection();
|
||||
|
||||
signals:
|
||||
/// @brief Signal which is emitted when the connection is being closed
|
||||
///
|
||||
/// Signal which is emitted when the connection is being closed
|
||||
/// @param connection This connection object
|
||||
///
|
||||
void connectionClosed(JsonClientConnection * connection);
|
||||
|
||||
private slots:
|
||||
/// @brief Slot called when new data has arrived
|
||||
///
|
||||
/// Slot called when new data has arrived
|
||||
///
|
||||
void readData();
|
||||
|
||||
/// @brief Slot called when this connection is being closed
|
||||
///
|
||||
/// Slot called when this connection is being closed
|
||||
///
|
||||
void socketClosed();
|
||||
|
||||
private:
|
||||
/// @brief Handle an incoming JSON message
|
||||
///
|
||||
/// Handle an incoming JSON message
|
||||
///
|
||||
/// @param message the incoming message as string
|
||||
///
|
||||
void handleMessage(const std::string & message);
|
||||
|
||||
/// @brief Handle an incoming JSON Color message
|
||||
///
|
||||
/// Handle an incoming JSON Color message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleColorCommand(const Json::Value & message);
|
||||
|
||||
/// @brief Handle an incoming JSON Image message
|
||||
///
|
||||
/// Handle an incoming JSON Image message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleImageCommand(const Json::Value & message);
|
||||
|
||||
/// @brief Handle an incoming JSON Server info message
|
||||
///
|
||||
/// Handle an incoming JSON Server info message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleServerInfoCommand(const Json::Value & message);
|
||||
|
||||
/// @brief Handle an incoming JSON Clear message
|
||||
///
|
||||
/// Handle an incoming JSON Clear message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleClearCommand(const Json::Value & message);
|
||||
|
||||
/// @brief Handle an incoming JSON Clearall message
|
||||
///
|
||||
/// Handle an incoming JSON Clearall message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleClearallCommand(const Json::Value & message);
|
||||
|
||||
/// @brief Handle an incoming JSON Transform message
|
||||
///
|
||||
/// Handle an incoming JSON Transform message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleTransformCommand(const Json::Value & message);
|
||||
|
||||
/// @brief Handle an incoming JSON message of unknown type
|
||||
///
|
||||
/// Handle an incoming JSON message of unknown type
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleNotImplemented();
|
||||
|
||||
/// @brief Send a message to the connected client
|
||||
///
|
||||
/// Send a message to the connected client
|
||||
///
|
||||
/// @param message The JSON message to send
|
||||
///
|
||||
void sendMessage(const Json::Value & message);
|
||||
|
||||
/// @brief Send a standard reply indicating success
|
||||
///
|
||||
/// Send a standard reply indicating success
|
||||
///
|
||||
void sendSuccessReply();
|
||||
|
||||
/// @brief Send an error message back to the client
|
||||
///
|
||||
/// Send an error message back to the client
|
||||
///
|
||||
/// @param error String describing the error
|
||||
///
|
||||
void sendErrorReply(const std::string & error);
|
||||
|
||||
private:
|
||||
/// @brief Check if a JSON messag is valid according to a given JSON schema
|
||||
///
|
||||
/// Check if a JSON messag is valid according to a given JSON schema
|
||||
///
|
||||
/// @param message JSON message which need to be checked
|
||||
/// @param schemaResource Qt esource identifier with the JSON schema
|
||||
/// @param errors Output error message
|
||||
///
|
||||
/// @return true if message conforms the given JSON schema
|
||||
///
|
||||
bool checkJson(const Json::Value & message, const QString &schemaResource, std::string & errors);
|
||||
|
||||
private:
|
||||
/// The TCP-Socket that is connected tot the Json-client
|
||||
QTcpSocket * _socket;
|
||||
|
||||
/// The processor for translating images to led-values
|
||||
ImageProcessor * _imageProcessor;
|
||||
|
||||
/// Link to Hyperion for writing led-values to a priority channel
|
||||
Hyperion * _hyperion;
|
||||
|
||||
/// The buffer used for reading data from the socket
|
||||
QByteArray _receiveBuffer;
|
||||
};
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
|
||||
RgbImage::RgbImage(const unsigned width, const unsigned height, const RgbColor background) :
|
||||
mWidth(width),
|
||||
mHeight(height),
|
||||
_width(width),
|
||||
_height(height),
|
||||
mColors(new RgbColor[width*height])
|
||||
{
|
||||
for (unsigned i=0; i<width*height; ++i)
|
||||
@ -32,8 +32,8 @@ void RgbImage::setPixel(const unsigned x, const unsigned y, const RgbColor color
|
||||
const RgbColor& RgbImage::operator()(const unsigned x, const unsigned y) const
|
||||
{
|
||||
// Debug-mode sanity check on given index
|
||||
assert(x < mWidth);
|
||||
assert(y < mHeight);
|
||||
assert(x < _width);
|
||||
assert(y < _height);
|
||||
|
||||
const unsigned index = toIndex(x, y);
|
||||
return mColors[index];
|
||||
@ -42,8 +42,8 @@ const RgbColor& RgbImage::operator()(const unsigned x, const unsigned y) const
|
||||
RgbColor& RgbImage::operator()(const unsigned x, const unsigned y)
|
||||
{
|
||||
// Debug-mode sanity check on given index
|
||||
assert(x < mWidth);
|
||||
assert(y < mHeight);
|
||||
assert(x < _width);
|
||||
assert(y < _height);
|
||||
|
||||
const unsigned index = toIndex(x, y);
|
||||
return mColors[index];
|
||||
|
@ -15,48 +15,73 @@
|
||||
// hyperion-remote includes
|
||||
#include "ColorTransformValues.h"
|
||||
|
||||
///
|
||||
/// Connection class to setup an connection to the hyperion server and execute commands
|
||||
///
|
||||
class JsonConnection
|
||||
{
|
||||
public:
|
||||
/// @brief COnstructor
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
JsonConnection(const std::string & address, bool printJson);
|
||||
|
||||
/// @brief Destructor
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~JsonConnection();
|
||||
|
||||
/// @brief Set all leds to the specified color
|
||||
///
|
||||
/// Set all leds to the specified color
|
||||
///
|
||||
/// @param color The color
|
||||
/// @param priority The priority
|
||||
/// @param duration The duration in milliseconds
|
||||
///
|
||||
void setColor(QColor color, int priority, int duration);
|
||||
|
||||
/// @brief Set the leds according to the given image (assume the image is stretched to the display size)
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
void setImage(QImage image, int priority, int duration);
|
||||
|
||||
/// @brief Retrieve a list of all occupied priority channels
|
||||
///
|
||||
/// Retrieve a list of all occupied priority channels
|
||||
///
|
||||
/// @return String with the server info
|
||||
///
|
||||
QString getServerInfo();
|
||||
|
||||
/// @brief Clear the given priority channel
|
||||
///
|
||||
/// Clear the given priority channel
|
||||
///
|
||||
/// @param priority The priority
|
||||
///
|
||||
void clear(int priority);
|
||||
|
||||
/// @brief Clear all priority channels
|
||||
///
|
||||
/// Clear all priority channels
|
||||
///
|
||||
void clearAll();
|
||||
|
||||
/// @brief Set the color transform of the leds
|
||||
///
|
||||
/// 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,
|
||||
@ -66,18 +91,28 @@ public:
|
||||
ColorTransformValues * whitelevel);
|
||||
|
||||
private:
|
||||
/// @brief Send a json command message and receive its reply
|
||||
///
|
||||
/// 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);
|
||||
|
||||
/// @brief Parse a reply message
|
||||
///
|
||||
/// Parse a reply message
|
||||
///
|
||||
/// @param reply The received reply
|
||||
///
|
||||
/// @return true if the reply indicates success
|
||||
///
|
||||
bool parseReply(const Json::Value & reply);
|
||||
|
||||
private:
|
||||
/// Flag for printing all send and received json-messages to the standard out
|
||||
bool _printJson;
|
||||
|
||||
/// The TCP-Socket with the connection to the server
|
||||
QTcpSocket _socket;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user