aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf.d/cmake/config.cmake3
-rw-r--r--conf.d/project/data/signal-composer-daemon-04-oncall.lua2
-rw-r--r--conf.d/project/etc/control-basic-conf.json (renamed from conf.d/project/etc/control-txc-demo.json)8
-rw-r--r--conf.d/project/etc/control-signal-composer.json9
-rw-r--r--conf.d/project/etc/sig-demoboard.json5
-rw-r--r--conf.d/project/etc/sig-doors.json39
-rw-r--r--conf.d/project/etc/sig-geoloc.json9
-rw-r--r--conf.d/project/etc/sig-txc.json11
-rw-r--r--conf.d/project/etc/sources-txc.json6
-rw-r--r--conf.d/project/etc/sources.json6
m---------ctl-utilities0
-rw-r--r--plugins/CMakeLists.txt22
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp3
-rw-r--r--signal-composer-binding/signal-composer.cpp64
-rw-r--r--signal-composer-binding/signal-composer.hpp2
-rw-r--r--signal-composer-binding/signal.cpp3
16 files changed, 89 insertions, 103 deletions
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index adc3122..82e252a 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -129,9 +129,8 @@ list(APPEND link_libraries afb-helpers)
# CACHE STRING "Compilation flags for RELEASE build type.")
set(CONTROL_SUPPORT_LUA 1)
-add_definitions(-DCONTROL_PLUGIN_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib/plugins:${CMAKE_BINARY_DIR}/package/lib/plugins")
+add_definitions(-DCONTROL_PLUGIN_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib/plugins:${CMAKE_BINARY_DIR}/package/lib/plugins:${CMAKE_BINARY_DIR}/package/var")
add_definitions(-DCONTROL_CONFIG_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/etc:${CMAKE_BINARY_DIR}/package/etc")
-add_definitions(-DCONTROL_LUA_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/var:${CMAKE_BINARY_DIR}/package/var")
add_definitions(-DCTL_PLUGIN_MAGIC=1286576532)
# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable]
diff --git a/conf.d/project/data/signal-composer-daemon-04-oncall.lua b/conf.d/project/data/signal-composer-daemon-04-oncall.lua
index 9d31f25..a66d71f 100644
--- a/conf.d/project/data/signal-composer-daemon-04-oncall.lua
+++ b/conf.d/project/data/signal-composer-daemon-04-oncall.lua
@@ -64,7 +64,7 @@ function _Unit_Converter(source, args, event)
print('Converted value is: '.. event['value'] .. args["to"])
- _lua2c['setSignalValueWrap'](source, event)
+ composer:setSignalValueWrap(source, event)
end
-- Display receive arguments and echo them to caller
diff --git a/conf.d/project/etc/control-txc-demo.json b/conf.d/project/etc/control-basic-conf.json
index d44a8fe..dd7255f 100644
--- a/conf.d/project/etc/control-txc-demo.json
+++ b/conf.d/project/etc/control-basic-conf.json
@@ -19,10 +19,10 @@
"basename": "gps"
},
{
- "uid": "builtin",
- "info": "Builtin routine for onReceived or getSignals routines",
- "basename": "builtin",
- "lua2c": "setSignalValueWrap"
+ "uid": "convert",
+ "info": "LUA fonctions used to convert standard unit.",
+ "spath": "/tmp",
+ "file": "unit-conversion.lua"
}
],
"signals": {
diff --git a/conf.d/project/etc/control-signal-composer.json b/conf.d/project/etc/control-signal-composer.json
index da100e1..1ea7198 100644
--- a/conf.d/project/etc/control-signal-composer.json
+++ b/conf.d/project/etc/control-signal-composer.json
@@ -9,15 +9,20 @@
},
"plugins": [
{
+ "uid": "convert",
+ "info": "LUA fonctions used to convert standard unit.",
+ "libs": "unit-conversion.lua"
+ },
+ {
"uid": "gps-callbacks",
"info": "Manage interaction with gps service",
- "basename": "gps"
+ "libs": "gps.ctlso"
}
],
"signals": {
"files": ["sig-txc" ]
},
"sources": {
- "files": "sources"
+ "files": "sources-txc"
}
}
diff --git a/conf.d/project/etc/sig-demoboard.json b/conf.d/project/etc/sig-demoboard.json
index da64a26..2d9493f 100644
--- a/conf.d/project/etc/sig-demoboard.json
+++ b/conf.d/project/etc/sig-demoboard.json
@@ -24,10 +24,7 @@
"event": "low-can/diagnostic_messages.engine.speed",
"retention": 30,
"unit": "rpm",
- "frequency": 1,
- "onReceived": {
- "function": "plugin://defaultOnReceived"
- }
+ "frequency": 1
},
{
"uid": "fuel_level",
diff --git a/conf.d/project/etc/sig-doors.json b/conf.d/project/etc/sig-doors.json
index 98cec4e..35f617e 100644
--- a/conf.d/project/etc/sig-doors.json
+++ b/conf.d/project/etc/sig-doors.json
@@ -5,56 +5,64 @@
"uid": "rear_left_window",
"event": "low-can/messages.windows.rear_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
"uid": "rear_left_door",
"event": "low-can/messages.doors.rear_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
"uid": "rear_right_window",
"event": "low-can/messages.windows.rear_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
"uid": "rear_right_door",
"event": "low-can/messages.doors.rear_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
"uid": "front_left_window",
"event": "low-can/messages.windows.front_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
"uid": "front_left_door",
"event": "low-can/messages.doors.front_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
"uid": "front_right_window",
"event": "low-can/messages.windows.front_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
"uid": "front_right_door",
"event": "low-can/messages.doors.front_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
@@ -64,7 +72,8 @@
"rear_left_door"
],
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen"
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen"
}
},
{
@@ -74,7 +83,8 @@
"rear_right_window"
],
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen",
"args": {}
}
},
@@ -85,7 +95,8 @@
"front_left_window"
],
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen",
"args": {}
}
},
@@ -96,7 +107,8 @@
"front_right_window"
],
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen",
"args": {}
}
},
@@ -113,7 +125,8 @@
"rear_right_window"
],
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
+ "uri": "plugin://low-can-callbacks",
+ "function": "isOpen",
"args": {
"evtname": "doors.open"
}
diff --git a/conf.d/project/etc/sig-geoloc.json b/conf.d/project/etc/sig-geoloc.json
index 09ec6f3..0922b18 100644
--- a/conf.d/project/etc/sig-geoloc.json
+++ b/conf.d/project/etc/sig-geoloc.json
@@ -7,7 +7,8 @@
"unit": "degree",
"frequency": 1,
"onReceived": {
- "function": "plugin://gps-callbacks/getLatitude"
+ "uri": "plugin://gps-callbacks",
+ "function": "getLatitude"
}
},
{
@@ -16,7 +17,8 @@
"unit": "degree",
"frequency": 1,
"onReceived": {
- "function": "plugin://gps-callbacks/getSignal",
+ "uri": "plugin://gps-callbacks",
+ "function": "getSignal",
"args": {
"what": "longitude"
}
@@ -38,7 +40,8 @@
"unit": "degree",
"frequency": 1,
"onReceived": {
- "function": "lua://_Heading"
+ "uri": "plugin://gps-callbacks",
+ "function": "getHeading"
}
},
{
diff --git a/conf.d/project/etc/sig-txc.json b/conf.d/project/etc/sig-txc.json
index 275eea6..abe8a73 100644
--- a/conf.d/project/etc/sig-txc.json
+++ b/conf.d/project/etc/sig-txc.json
@@ -8,6 +8,14 @@
"unit": "km/h",
"getSignalsArgs": {
"event": "vehicle_speed"
+ },
+ "onReceived": {
+ "uri": "lua://convert/",
+ "function": "_Unit_Converter",
+ "args": {
+ "from": "km/h",
+ "to": "mi/h"
+ }
}
},
{
@@ -96,7 +104,8 @@
"retention": 30,
"unit": "degrees",
"onReceived": {
- "function": "plugin://gps-callbacks/getHeading"
+ "uri": "plugin://gps-callbacks",
+ "function": "getHeading"
}
}
]
diff --git a/conf.d/project/etc/sources-txc.json b/conf.d/project/etc/sources-txc.json
index 4404d60..77bc99b 100644
--- a/conf.d/project/etc/sources-txc.json
+++ b/conf.d/project/etc/sources-txc.json
@@ -6,11 +6,13 @@
"api": "txc",
"info": "Use TXC demo binding as signals provider",
"init": {
- "function": "api://txc/start",
+ "uri": "api://txc",
+ "function": "start",
"args": {"filename": "var/nyc-downtown-crosstown.json"}
},
"getSignals": {
- "function": "api://txc/subscribe"
+ "uri": "api://txc",
+ "function": "subscribe"
}
}
]
diff --git a/conf.d/project/etc/sources.json b/conf.d/project/etc/sources.json
index c01ebd1..35d62a8 100644
--- a/conf.d/project/etc/sources.json
+++ b/conf.d/project/etc/sources.json
@@ -6,7 +6,8 @@
"api": "low-can",
"info": "Low level binding to handle CAN bus communications",
"getSignals": {
- "function": "plugin://low-can-callbacks/subscribeToLow"
+ "uri": "plugin://low-can-callbacks",
+ "function": "subscribeToLow"
}
},
{
@@ -14,7 +15,8 @@
"api": "gps",
"info": "Low level binding which retrieve Satellite positionning values",
"init": {
- "function": "api://gps/subscribe",
+ "uri": "api://gps",
+ "function": "subscribe",
"args": {
"value": "location"
}
diff --git a/ctl-utilities b/ctl-utilities
-Subproject 364a6151777806640b2e208288328e76ef93340
+Subproject 01295105d39eb96fafa20fea9ef131d0fb8dcab
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 0d437d5..fc24fbd 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -16,28 +16,6 @@
# limitations under the License.
###########################################################################
-PROJECT_TARGET_ADD(builtin)
-
- # Define targets
- ADD_LIBRARY(${TARGET_NAME} MODULE ${TARGET_NAME}.cpp)
-
- # Alsa Plugin properties
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- LABELS "PLUGIN"
- PREFIX ""
- SUFFIX ".ctlso"
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- ${link_libraries}
- )
-
- target_include_directories(${TARGET_NAME}
- PRIVATE "../ctl-utilities/ctl-lib"
- PRIVATE "../signal-composer-binding")
-
PROJECT_TARGET_ADD(low-can)
# Define targets
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index 7cdda91..0d9c8e3 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -279,9 +279,6 @@ int execConf()
int err = 0;
CtlConfigExec(nullptr, composer.ctlConfig());
- composer.initSourcesAPI();
- composer.initSignals();
-
AFB_DEBUG("Signal Composer Control configuration Done.");
return err;
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index 3b11a70..ce4fe47 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -37,6 +37,22 @@ extern "C" void setSignalValueHandle(void* aSignal, uint64_t timestamp, struct s
sig->set(timestamp, value);
}
+bool startsWith(const std::string& str, const std::string& pattern)
+{
+ size_t sep;
+ if( (sep = str.find(pattern)) != std::string::npos && !sep)
+ {return true;}
+ return false;
+}
+
+void extractString(void* closure, json_object* object)
+{
+ std::vector<std::string> *files = (std::vector<std::string>*) closure;
+ const char *oneFile = json_object_get_string(object);
+
+ files->push_back(oneFile);
+}
+
// aSignal member value will be initialized in sourceAPI->addSignal()
static struct signalCBT pluginHandle = {
.searchNsetSignalValue = searchNsetSignalValueHandle,
@@ -47,7 +63,7 @@ static struct signalCBT pluginHandle = {
CtlSectionT Composer::ctlSections_[] = {
[0]={.key="plugins" , .uid="plugins", .info=nullptr,
- .loadCB=pluginsLoad,
+ .loadCB=PluginConfig,
.handle=&pluginHandle,
.actions=nullptr},
[1]={.key="sources" , .uid="sources", .info=nullptr,
@@ -89,25 +105,13 @@ CtlActionT* Composer::convert2Action(const std::string& name, json_object* actio
CtlActionT *ctlAction = new CtlActionT;
json_object_object_add(actionJ, "uid", json_object_new_string(name.c_str()));
+
if(! ActionLoadOne(nullptr, ctlAction, actionJ, 0))
{return ctlAction;}
-
delete(ctlAction);
return nullptr;
}
-/// @brief Load controller plugins
-///
-/// @param[in] section - Control Section structure
-/// @param[in] pluginsJ - JSON object containing all plugins definition made in
-/// JSON configuration file.
-///
-/// @return 0 if OK, other if not.
-int Composer::pluginsLoad(AFB_ApiT apiHandle, CtlSectionT *section, json_object *pluginsJ)
-{
- return PluginConfig(nullptr, section, pluginsJ);
-}
-
int Composer::loadOneSourceAPI(json_object* sourceJ)
{
json_object *initJ = nullptr,
@@ -158,7 +162,9 @@ int Composer::loadOneSourceAPI(json_object* sourceJ)
if(!getSignalsJ)
{
getSignalsJ = json_object_new_object();
- std::string function = "api://" + std::string(api) + "/subscribe";
+ std::string uri = "api://" + std::string(api);
+ std::string function = "subscribe";
+ json_object_object_add(getSignalsJ, "uri", json_object_new_string(uri.c_str()));
json_object_object_add(getSignalsJ, "function", json_object_new_string(function.c_str()));
}
getSignalsCtl = convert2Action("getSignals", getSignalsJ);
@@ -259,11 +265,6 @@ int Composer::loadOneSignal(json_object* signalJ)
}
std::string api = eventStr.substr(0, sep);
src = getSourceAPI(api);
- if(!src)
- {
- AFB_ERROR("This signal'source isn't registered. Check your configuration.");
- return -1;
- }
}
else
{
@@ -362,6 +363,8 @@ int Composer::loadSignals(AFB_ApiT apihandle, CtlSectionT* section, json_object
{err = composer.loadOneSignal(signalsJ);}
AFB_NOTICE("%ld new signals added to service", count);
}
+ else
+ {Composer::instance().initSignals();}
return err;
}
@@ -452,27 +455,6 @@ void Composer::destroyContext(void* ctx)
delete(reinterpret_cast<clientAppCtx*>(ctx));
}
-std::vector<std::string> Composer::parseURI(const std::string& uri)
-{
- std::vector<std::string> uriV;
- std::string delimiters = "/";
-
- std::string::size_type start = 0;
- auto pos = uri.find_first_of(delimiters, start);
- while(pos != std::string::npos)
- {
- if(pos != start) // ignore empty tokens
- uriV.emplace_back(uri, start, pos - start);
- start = pos + 1;
- pos = uri.find_first_of(delimiters, start);
- }
-
- if(start < uri.length()) // ignore trailing delimiter
- uriV.emplace_back(uri, start, uri.length() - start); // add what's left of the string
-
- return uriV;
-}
-
int Composer::loadConfig(std::string& filepath)
{
const char *dirList= getenv("CONTROL_CONFIG_PATH");
diff --git a/signal-composer-binding/signal-composer.hpp b/signal-composer-binding/signal-composer.hpp
index db45189..7139a72 100644
--- a/signal-composer-binding/signal-composer.hpp
+++ b/signal-composer-binding/signal-composer.hpp
@@ -35,7 +35,6 @@ private:
~Composer();
CtlActionT* convert2Action(const std::string& name, json_object* action);
- static int pluginsLoad(AFB_ApiT apiHandle, CtlSectionT *section, json_object *pluginsJ);
int loadOneSourceAPI(json_object* sourcesJ);
static int loadSourcesAPI(AFB_ApiT apihandle, CtlSectionT* section, json_object *signalsJ);
@@ -50,7 +49,6 @@ public:
static Composer& instance();
static void* createContext(void* ctx);
static void destroyContext(void* ctx);
- static std::vector<std::string> parseURI(const std::string& uri);
int loadConfig(std::string& filepath);
int loadSources(json_object* sourcesJ);
int loadSignals(json_object* signalsJ);
diff --git a/signal-composer-binding/signal.cpp b/signal-composer-binding/signal.cpp
index 577d94c..63bc0a8 100644
--- a/signal-composer-binding/signal.cpp
+++ b/signal-composer-binding/signal.cpp
@@ -189,7 +189,8 @@ struct signalCBT* Signal::get_context()
signalCtx_.aSignal = (void*)this;
- signalCtx_.pluginCtx = onReceived_ && onReceived_->type == CTL_TYPE_CB ?
+ signalCtx_.pluginCtx = onReceived_ && onReceived_->type == CTL_TYPE_CB
+ && onReceived_->exec.cb.plugin ?
onReceived_->exec.cb.plugin->context:
nullptr;
}