Doxygen comments added

This commit is contained in:
johan 2013-08-31 14:36:54 +02:00
parent 1a2dd19a7b
commit 3187fc84a6
8 changed files with 195 additions and 28 deletions

View File

@ -12,25 +12,48 @@
class JsonClientConnection;
///
/// This class creates a TCP server which accepts connections wich can then send
/// in JSON encoded commands. This interface to Hyperion is used by hyperion-remote
/// to control the leds
///
class JsonServer : public QObject
{
Q_OBJECT
public:
///
/// \brief 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
///
uint16_t getPort() const;
private slots:
///
/// \brief 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
///
void closedConnection(JsonClientConnection * connection);
private:
/// Hyperion instance
Hyperion * _hyperion;
/// The TCP server object
QTcpServer _server;
/// List with open connections
QSet<JsonClientConnection *> _openConnections;
};

View File

@ -15,29 +15,53 @@
class ColorTransform
{
public:
/// @brief Default constructor
ColorTransform();
/// @brief Constructor
/// @param threshold
/// @param gamma
/// @param blacklevel
/// @param whitelevel
ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel);
/// @brief Destructor
~ColorTransform();
/// @return The current threshold value
double getThreshold() const;
/// @param threshold New threshold value
void setThreshold(double threshold);
/// @return The current gamma value
double getGamma() const;
/// @param gamma New gamma value
void setGamma(double gamma);
/// @return The current blacklevel value
double getBlacklevel() const;
/// @param blacklevel New blacklevel value
void setBlacklevel(double blacklevel);
/// @return The current whitelevel value
double getWhitelevel() const;
/// @param whitelevel New whitelevel value
void setWhitelevel(double whitelevel);
/// get the transformed value for the given byte value
/// @brief Transform the given byte value
/// @param input The input color byte
/// @return The transformed byte value
uint8_t transform(uint8_t input) const
{
return _mapping[input];
}
private:
/// @brief (re)-initilize the color mapping
void initializeMapping();
private:

View File

@ -3,19 +3,40 @@
// STL includes
#include <cstdint>
///
/// \brief 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
HsvTransform(double saturationGain, double valueGain);
/// Destructor
~HsvTransform();
/// @param saturationGain New saturationGain
void setSaturationGain(double saturationGain);
/// @return The current Saturation gain
double getSaturationGain() const;
/// @param valueGain New Value gain
void setValueGain(double valueGain);
/// @return The current value gain
double getValueGain() const;
/// @brief 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

View File

@ -7,30 +7,47 @@
// jsoncpp includes
#include <json/json.h>
/**
* JsonSchemaChecker is a very basic implementation of json schema.
* The json schema definition draft can be found at
* http://tools.ietf.org/html/draft-zyp-json-schema-03
*
* The following keywords are supported:
* - type
* - required
* - properties
* - items
* - enum
* - minimum
* - maximum
*/
/// JsonSchemaChecker is a very basic implementation of json schema.
/// The json schema definition draft can be found at
/// http://tools.ietf.org/html/draft-zyp-json-schema-03
///
/// The following keywords are supported:
/// - type
/// - required
/// - properties
/// - items
/// - enum
/// - minimum
/// - maximum
/// - addtionalProperties
/// - minItems
/// - maxItems
///
/// And the non-standard:
/// - dependencies
class JsonSchemaChecker
{
public:
JsonSchemaChecker();
virtual ~JsonSchemaChecker();
///
/// @param The schema to use
/// @return true upon succes
///
bool setSchema(const Json::Value & schema);
///
/// @brief Validate a JSON structure
/// @param The JSON value to check
/// @return true when the arguments is valid according to the schema
///
bool validate(const Json::Value & value);
///
/// @return A list of error messages
///
const std::list<std::string> & getMessages() const;
private:

View File

@ -14,8 +14,8 @@
// Hyperion includes
#include <hyperion/Hyperion.h>
/// Check if XBMC is playing something. When it does not, this class will send all black data Hyperion to
/// override (grabbed) data with a lower priority
/// 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
@ -23,13 +23,22 @@ class XBMCVideoChecker : public QObject
Q_OBJECT
public:
/// @Constructor
/// @param address Netwrok 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
void start();
private slots:
/// \brief Send a request to XBMC
void sendRequest();
/// @brief receive a reply from XBMC
void receiveReply();
private:

View File

@ -18,36 +18,83 @@
class ImageProcessor;
/// @brief The Connection object created by \a JsonServer when a new connection is establshed
///
class JsonClientConnection : public QObject
{
Q_OBJECT
public:
/// @brief Constructor
/// @param socket The Socket object for this connection
/// @param hyperion The Hyperion server
JsonClientConnection(QTcpSocket * socket, Hyperion * hyperion);
/// @brief Destructor
~JsonClientConnection();
signals:
/// @brief 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
void readData();
/// @brief Slot called when this connection is being closed
void socketClosed();
private:
/// @brief 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
/// @param message the incoming message
void handleColorCommand(const Json::Value & message);
/// @brief 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
/// @param message the incoming message
void handleServerInfoCommand(const Json::Value & message);
/// @brief Handle an incoming JSON Clear message
/// @param message the incoming message
void handleClearCommand(const Json::Value & message);
/// @brief Handle an incoming JSON Clearall message
/// @param message the incoming message
void handleClearallCommand(const Json::Value & message);
/// @brief 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
/// @param message the incoming message
void handleNotImplemented();
/// @brief 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
void sendSuccessReply();
/// @brief 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
/// @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:

View File

@ -10,11 +10,14 @@
// hyperion-remote includes
#include "ColorTransformValues.h"
/// Data parameter for a color
typedef vlofgren::PODParameter<QColor> ColorParameter;
typedef vlofgren::PODParameter<QImage> ImageParameter;
typedef vlofgren::PODParameter<ColorTransformValues> TransformParameter;
/// Data parameter for an image
typedef vlofgren::PODParameter<QImage> ImageParameter;
/// Data parameter for color transform values (list of three values)
typedef vlofgren::PODParameter<ColorTransformValues> TransformParameter;
namespace vlofgren {
template<>

View File

@ -19,26 +19,44 @@
class JsonConnection
{
public:
/// @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
JsonConnection(const std::string & address, bool printJson);
/// @brief Destructor
~JsonConnection();
/// Set all leds to the specified color
/// @brief 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);
/// Set the leds according to the given image (assume the image is stretched to the display size)
/// @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
void setImage(QImage image, int priority, int duration);
/// Retrieve a list of all occupied priority channels
/// @brief Retrieve a list of all occupied priority channels
/// @return String with the server info
QString getServerInfo();
/// Clear the given priority channel
/// @brief Clear the given priority channel
/// @param priority The priority
void clear(int priority);
/// Clear all priority channels
/// @brief Clear all priority channels
void clearAll();
/// Set the color transform of the leds
/// Note that providing a NULL will leave the settings on the server unchanged
/// @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,
@ -48,9 +66,14 @@ public:
ColorTransformValues * whitelevel);
private:
/// Send a json command message and receive its reply
/// @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);
/// @brief Parse a reply message
/// @param reply The received reply
/// @return true if the reply indicates success
bool parseReply(const Json::Value & reply);
private: