Added skeleton for effect engine development

Former-commit-id: e1fb69fd4de4b8968075660e3ba7f7add021c152
This commit is contained in:
johan
2013-11-24 16:10:48 +01:00
parent 333cecdca8
commit 5454ddb375
19 changed files with 304 additions and 12 deletions

View File

@@ -94,6 +94,8 @@ void JsonClientConnection::handleMessage(const std::string &messageString)
handleColorCommand(message);
else if (command == "image")
handleImageCommand(message);
else if (command == "effect")
handleEffectCommand(message);
else if (command == "serverinfo")
handleServerInfoCommand(message);
else if (command == "clear")
@@ -151,7 +153,22 @@ void JsonClientConnection::handleImageCommand(const Json::Value &message)
sendSuccessReply();
}
void JsonClientConnection::handleServerInfoCommand(const Json::Value &message)
void JsonClientConnection::handleEffectCommand(const Json::Value &message)
{
// extract parameters
int priority = message["priority"].asInt();
int duration = message.get("duration", -1).asInt();
const Json::Value & effect = message["effect"];
const std::string & effectName = effect["name"].asString();
// set output
_hyperion->setEffect(effectName, priority, duration);
// send reply
sendSuccessReply();
}
void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
{
// create result
Json::Value result;
@@ -193,6 +210,17 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &message)
whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::GREEN));
whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::BLUE));
// collect effect info
Json::Value & effects = info["effects"];
std::list<std::string> effectNames = _hyperion->getEffects();
for (const std::string & name : effectNames)
{
Json::Value effect;
effect["name"] = name;
effects.append(effect);
}
// send the result
sendMessage(result);
}

View File

@@ -78,6 +78,13 @@ private:
///
void handleImageCommand(const Json::Value & message);
///
/// Handle an incoming JSON Effect message
///
/// @param message the incoming message
///
void handleEffectCommand(const Json::Value & message);
///
/// Handle an incoming JSON Server info message
///

View File

@@ -1,11 +1,12 @@
<RCC>
<qresource prefix="/">
<file alias="schema">schema/schema.json</file>
<file alias="schema-color">schema/schema-color.json</file>
<file alias="schema-image">schema/schema-image.json</file>
<file alias="schema-serverinfo">schema/schema-serverinfo.json</file>
<file alias="schema-clear">schema/schema-clear.json</file>
<file alias="schema-clearall">schema/schema-clearall.json</file>
<file alias="schema-transform">schema/schema-transform.json</file>
</qresource>
<qresource prefix="/">
<file alias="schema">schema/schema.json</file>
<file alias="schema-color">schema/schema-color.json</file>
<file alias="schema-image">schema/schema-image.json</file>
<file alias="schema-serverinfo">schema/schema-serverinfo.json</file>
<file alias="schema-clear">schema/schema-clear.json</file>
<file alias="schema-clearall">schema/schema-clearall.json</file>
<file alias="schema-transform">schema/schema-transform.json</file>
<file alias="schema-effect">schema/schema-effect.json</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,31 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["effect"]
},
"priority": {
"type": "integer",
"required": true
},
"duration": {
"type": "integer",
"required": false
},
"effect": {
"type": "object",
"required": true,
"properties" :{
"name" : {
"type" : "string",
"required" : true
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}

View File

@@ -5,7 +5,7 @@
"command": {
"type" : "string",
"required" : true,
"enum" : ["color", "image", "serverinfo", "clear", "clearall", "transform"]
"enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform"]
}
}
}