diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-09-26 18:38:44 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-14 11:00:25 +0100 |
commit | 6b492d666ed1faeeec5f761105f473956b426cc9 (patch) | |
tree | 35b292414e134f280d9616be0e0dcc6b3e7f6bd4 /signal-composer-binding/signal-composer.cpp | |
parent | c22ad857bcd2f567d22f3239d91fa65720718713 (diff) |
Introduce retention setting in place of class
Be able to tweak retention value for each signal in seconds
Change-Id: I1cabe48a2660cdeb2e9b32b277e7c819c6b49bd9
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer.cpp')
-rw-r--r-- | signal-composer-binding/signal-composer.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp index 89d442d..2247ba9 100644 --- a/signal-composer-binding/signal-composer.cpp +++ b/signal-composer-binding/signal-composer.cpp @@ -214,30 +214,30 @@ int Composer::loadOneSignal(json_object* signalJ) CtlActionT* onReceivedCtl; const char *id = nullptr, *event = nullptr, - *sClass = nullptr, *unit = nullptr; + int retention; double frequency=0.0; std::string api; std::vector<std::string> dependsV; ssize_t sep; - int err = wrap_json_unpack(signalJ, "{ss,s?s,s?o,s?o,s?s,s?s,s?F,s?o !}", + int err = wrap_json_unpack(signalJ, "{ss,s?s,s?o,s?o,s?F,s?s,s?F,s?o !}", "id", &id, "event", &event, "depends", &dependsJ, "getSignalsArgs", &getSignalsArgs, - "class", &sClass, + "retention", &retention, "unit", &unit, "frequency", &frequency, "onReceived", &onReceivedJ); if (err) { - AFB_ERROR("Missing something id|[event|depends]|[getSignalsArgs]|[class]|[unit]|[frequency]|[onReceived] in %s", json_object_get_string(signalJ)); + AFB_ERROR("Missing something id|[event|depends]|[getSignalsArgs]|[retention]|[unit]|[frequency]|[onReceived] in %s", json_object_get_string(signalJ)); return err; } - // Set default sClass is not specified - sClass = !sClass ? "state" : sClass; + // Set default retention is not specified + retention = !retention ? 30 : retention; unit = !unit ? "" : unit; // Get an action handler @@ -246,7 +246,7 @@ int Composer::loadOneSignal(json_object* signalJ) // event or depends field manadatory if( (!event && !dependsJ) || (event && dependsJ) ) { - AFB_ERROR("Missing something id|[event|depends]|[getSignalsArgs]|[class]|[unit]|[frequency]|[onReceived] in %s. Or you declare event AND depends, only one of them is needed.", json_object_get_string(signalJ)); + AFB_ERROR("Missing something id|[event|depends]|[getSignalsArgs]|[retention]|[unit]|[frequency]|[onReceived] in %s. Or you declare event AND depends, only one of them is needed.", json_object_get_string(signalJ)); return -1; } @@ -299,7 +299,7 @@ int Composer::loadOneSignal(json_object* signalJ) SourceAPI* src = getSourceAPI(api) ? getSourceAPI(api):getSourceAPI("signal-composer"); if(src != nullptr) - {src->addSignal(id, event, dependsV, sClass, unit, frequency, onReceivedCtl, getSignalsArgs);} + {src->addSignal(id, event, dependsV, retention, unit, frequency, onReceivedCtl, getSignalsArgs);} else {err = -1;} |