aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-12-14 23:20:41 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-15 15:25:46 +0100
commit12cb9d534fca1eb57f93462900f305a148fd3f16 (patch)
tree890f492cf02bf2e05ed006cde1a78c1ddc53dffa
parent9a2be611dfb8fe4d542a67b204e5c61d96db911b (diff)
Get back on track l2c functions
Adjust to the new controller behavior lua2c functions calls Change-Id: I52d385101d5205a2dd2c996810feccb1f00c20c7 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--conf.d/project/lua.d/signal-composer-daemon-00-utils.lua1
-rw-r--r--conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua7
m---------ctl-utilities0
-rw-r--r--plugins/builtin.cpp10
4 files changed, 8 insertions, 10 deletions
diff --git a/conf.d/project/lua.d/signal-composer-daemon-00-utils.lua b/conf.d/project/lua.d/signal-composer-daemon-00-utils.lua
index 29d2c70..943c6c6 100644
--- a/conf.d/project/lua.d/signal-composer-daemon-00-utils.lua
+++ b/conf.d/project/lua.d/signal-composer-daemon-00-utils.lua
@@ -74,7 +74,6 @@ function Dump_Table(o)
end
end
-
-- simulate C prinf function
printf = function(s,...)
io.write(s:format(...))
diff --git a/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua b/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
index 581343e..21f516a 100644
--- a/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
+++ b/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
@@ -42,8 +42,6 @@ function _Unit_Converter(source, args, event)
local sourcei, targeti = _positions[sourceunits], _positions[targetunits]
assert(sourcei and targeti)
- print(event['timestamp'])
-
if sourcei<targeti then
local base=1
@@ -52,8 +50,7 @@ function _Unit_Converter(source, args, event)
end
event["value"] = value/base
-
- lua2c["luaSet"](source, event)
+ _lua2c['setSignalValueWrap'](source, event)
elseif sourcei>targeti then
@@ -64,7 +61,7 @@ function _Unit_Converter(source, args, event)
event["value"] = value/base
- lua2c["luaSet"](source, event)
+ _lua2c["setSignalValueWrap"](source, event)
else
print("No conversion")
diff --git a/ctl-utilities b/ctl-utilities
-Subproject 7eba3c57c97aa4cae102f4f13eaa1cfa939719c
+Subproject e241d7fd03df9f2c8813f3da10a3f3970c601de
diff --git a/plugins/builtin.cpp b/plugins/builtin.cpp
index 0989935..ab85bb7 100644
--- a/plugins/builtin.cpp
+++ b/plugins/builtin.cpp
@@ -31,8 +31,6 @@ extern "C"
{
CTLP_LUA_REGISTER("builtin");
-static struct signalCBT* pluginCtx = NULL;
-
// Call at initialisation time
/*CTLP_ONLOAD(plugin, handle) {
pluginCtx = (struct signalCBT*)calloc (1, sizeof(struct signalCBT));
@@ -72,16 +70,20 @@ CTLP_LUA2C (setSignalValueWrap, source, argsJ, responseJ)
const char* name = nullptr;
double resultNum;
uint64_t timestamp;
+
+ struct signalCBT* ctx = (struct signalCBT*)source->context;
+
if(! wrap_json_unpack(argsJ, "{ss, sF, sI? !}",
"name", &name,
"value", &resultNum,
"timestamp", &timestamp))
{
- AFB_ERROR("Fail to set value for uid: %s, argsJ: %s", source->uid, json_object_to_json_string(argsJ));
+ *responseJ = json_object_new_string("Fail to unpack JSON arguments value");
return -1;
}
+
struct signalValue result = resultNum;
- pluginCtx->searchNsetSignalValue(name, timestamp*MICRO, result);
+ ctx->setSignalValue(ctx->aSignal, timestamp*MICRO, result);
return 0;
}