diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-22 01:13:17 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-25 10:08:07 +0200 |
commit | 7f15ef65f420179b606f136ed805fae9d320b321 (patch) | |
tree | c4ef2dde841415ce4dedcaaa5f0edf7e258bc356 /plugins/builtin.cpp | |
parent | 3b08cec1ad06f313374bc1fd9cc64e1b28ce798d (diff) |
Improved performance
Before value was translated to a C type variable two times,
at the reception then at the emission. Now it just receives
and sends the signal value without translation nor interpretation
except if you ask for an average, minimum or maximum value. Then in
those cases it interprets the json to return you a value or an
error if there is no numeric values to compute.
Remove unneeded log message at event reception.
Improved signal search engine, will search in source's signals map
by the signal ID not the event name which lead to a more direct map
match.
Bugs-AGL: SPEC-1612
Depends-On: I43e79ed73a507ac2ca7ed4cdc3f16ec009392194
Change-Id: Ie253c3fe1e8cde42dabe8832da74e9f9bf442c14
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'plugins/builtin.cpp')
-rw-r--r-- | plugins/builtin.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/plugins/builtin.cpp b/plugins/builtin.cpp index e56d413..28bcba7 100644 --- a/plugins/builtin.cpp +++ b/plugins/builtin.cpp @@ -32,27 +32,23 @@ CTLP_LUA_REGISTER("builtin"); CTLP_LUA2C (setSignalValueWrap, source, argsJ, responseJ) { const char* name = nullptr; - double resultNum; + json_object* resultNumJ; uint64_t timestamp; struct signalCBT* ctx = (struct signalCBT*)source->context; - if(! wrap_json_unpack(argsJ, "{ss, sF, sI? !}", + if(! wrap_json_unpack(argsJ, "{ss, so, sI? !}", "name", &name, - "value", &resultNum, + "value", &resultNumJ, "timestamp", ×tamp)) { - *responseJ = json_object_new_string("Fail to unpack JSON arguments value"); return -1; } - *responseJ = json_object_new_string(json_object_to_json_string(argsJ)); - - struct signalValue result = resultNum; if(ctx->aSignal) - {ctx->setSignalValue(ctx->aSignal, timestamp*NANO, result);} + ctx->setSignalValue(ctx->aSignal, timestamp*NANO, resultNumJ); else - {ctx->searchNsetSignalValue(name, timestamp*NANO, result);} + ctx->searchNsetSignalValue(name, timestamp*NANO, resultNumJ); return 0; } |