From 47d9a2667ee860c3dc3199a4e0c4f23a03f47fbc Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 3 Jul 2018 19:07:17 +0200 Subject: Continue Mapis works WIP Beginning work to handle events from a Mapi. Also rename old fapis file to mapis and some format Change-Id: I30bedcbe13cac9568e21cd3a0947516e74dde271 Signed-off-by: Romain Forlot --- conf.d/project/etc/aft-mapis.json | 9 ++++++- conf.d/project/lua.d/fapi_low-can.lua | 43 ----------------------------- conf.d/project/lua.d/fapi_tests.lua | 51 ----------------------------------- conf.d/project/lua.d/mapi_low-can.lua | 43 +++++++++++++++++++++++++++++ conf.d/project/lua.d/mapi_tests.lua | 51 +++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 95 deletions(-) delete mode 100644 conf.d/project/lua.d/fapi_low-can.lua delete mode 100644 conf.d/project/lua.d/fapi_tests.lua create mode 100644 conf.d/project/lua.d/mapi_low-can.lua create mode 100644 conf.d/project/lua.d/mapi_tests.lua (limited to 'conf.d/project') diff --git a/conf.d/project/etc/aft-mapis.json b/conf.d/project/etc/aft-mapis.json index edcfc87..f68e05f 100644 --- a/conf.d/project/etc/aft-mapis.json +++ b/conf.d/project/etc/aft-mapis.json @@ -54,6 +54,13 @@ "info": "Write a CAN messages to the CAN bus.", "action": "lua://low-can#_write" } - ] + ], + "events": [{ + "uid": "low-can/diagnostic_messages", + "action": "lua://AFT#_evt_catcher_" + },{ + "uid": "low-can/messages_engine_speed", + "action": "lua://AFT#_evt_catcher_" + }] }] } diff --git a/conf.d/project/lua.d/fapi_low-can.lua b/conf.d/project/lua.d/fapi_low-can.lua deleted file mode 100644 index f7cd99a..0000000 --- a/conf.d/project/lua.d/fapi_low-can.lua +++ /dev/null @@ -1,43 +0,0 @@ ---[[ - Copyright (C) 2018 "IoT.bzh" - Author Romain Forlot - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - NOTE: strict mode: every global variables should be prefixed by '_' ---]] - -function _subscribe(source, args) - AFB:success(source) -end - -function _unsubscribe(source, args) - AFB:success(source) -end - -function _get(source, args) - AFB:success(source) -end - -function _list(source, args) - AFB:success(source) -end - -function _auth(source, args) - AFB:success(source) -end - -function _write(source, args) - AFB:success(source) -end diff --git a/conf.d/project/lua.d/fapi_tests.lua b/conf.d/project/lua.d/fapi_tests.lua deleted file mode 100644 index 1111a2d..0000000 --- a/conf.d/project/lua.d/fapi_tests.lua +++ /dev/null @@ -1,51 +0,0 @@ ---[[ - Copyright (C) 2018 "IoT.bzh" - Author Romain Forlot - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - NOTE: strict mode: every global variables should be prefixed by '_' ---]] - -_AFT.testVerbStatusSuccess("TestListverb", "low-can", "list", {}) -_AFT.testVerbStatusSuccess("TestGetVerb", "low-can", "get", { event = "engine.speed"}) - -_AFT.testCustom("Test_detection_is_off", function() - local logMsg = "signal: Engine is off, diagnostic_messages.engine.speed won't received responses until it's on" - _AFT.addLogToMonitor("low-can", "warning", logMsg) - - _AFT.assertVerbStatusSuccess("low-can","subscribe", { event = "diagnostic_messages.engine.speed" }) - _AFT.assertLogReceived(logMsg) - _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = "diagnostic_messages.engine.speed" }) -end) - -_AFT.testCustom("Test_turning_on", function() - _AFT.assertVerbStatusSuccess("low-can","subscribe", { event = "diagnostic_messages.engine.speed" }) - - local evt = "low-can/diagnostic_messages" - local logMsg = "signal: Engine is off, diagnostic_messages.engine.speed won't received responses until it's on" - _AFT.addLogToMonitor("low-can", "warning", logMsg) - _AFT.addEventToMonitor(evt) - - local ret = os.execute("./var/replay_launcher.sh ./var/test1.canreplay") - _AFT.assertIsTrue(ret) - - _AFT.assertEvtReceived(evt, function(eventName, data) - _AFT.assertIsTrue(data.name == "diagnostic_messages.engine.speed") - end) - - _AFT.assertLogNotReceived(logMsg) - - _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = "diagnostic_messages.engine.speed" }) -end) diff --git a/conf.d/project/lua.d/mapi_low-can.lua b/conf.d/project/lua.d/mapi_low-can.lua new file mode 100644 index 0000000..f7cd99a --- /dev/null +++ b/conf.d/project/lua.d/mapi_low-can.lua @@ -0,0 +1,43 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Romain Forlot + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +function _subscribe(source, args) + AFB:success(source) +end + +function _unsubscribe(source, args) + AFB:success(source) +end + +function _get(source, args) + AFB:success(source) +end + +function _list(source, args) + AFB:success(source) +end + +function _auth(source, args) + AFB:success(source) +end + +function _write(source, args) + AFB:success(source) +end diff --git a/conf.d/project/lua.d/mapi_tests.lua b/conf.d/project/lua.d/mapi_tests.lua new file mode 100644 index 0000000..1111a2d --- /dev/null +++ b/conf.d/project/lua.d/mapi_tests.lua @@ -0,0 +1,51 @@ +--[[ + Copyright (C) 2018 "IoT.bzh" + Author Romain Forlot + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + NOTE: strict mode: every global variables should be prefixed by '_' +--]] + +_AFT.testVerbStatusSuccess("TestListverb", "low-can", "list", {}) +_AFT.testVerbStatusSuccess("TestGetVerb", "low-can", "get", { event = "engine.speed"}) + +_AFT.testCustom("Test_detection_is_off", function() + local logMsg = "signal: Engine is off, diagnostic_messages.engine.speed won't received responses until it's on" + _AFT.addLogToMonitor("low-can", "warning", logMsg) + + _AFT.assertVerbStatusSuccess("low-can","subscribe", { event = "diagnostic_messages.engine.speed" }) + _AFT.assertLogReceived(logMsg) + _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = "diagnostic_messages.engine.speed" }) +end) + +_AFT.testCustom("Test_turning_on", function() + _AFT.assertVerbStatusSuccess("low-can","subscribe", { event = "diagnostic_messages.engine.speed" }) + + local evt = "low-can/diagnostic_messages" + local logMsg = "signal: Engine is off, diagnostic_messages.engine.speed won't received responses until it's on" + _AFT.addLogToMonitor("low-can", "warning", logMsg) + _AFT.addEventToMonitor(evt) + + local ret = os.execute("./var/replay_launcher.sh ./var/test1.canreplay") + _AFT.assertIsTrue(ret) + + _AFT.assertEvtReceived(evt, function(eventName, data) + _AFT.assertIsTrue(data.name == "diagnostic_messages.engine.speed") + end) + + _AFT.assertLogNotReceived(logMsg) + + _AFT.assertVerbStatusSuccess("low-can","unsubscribe", { event = "diagnostic_messages.engine.speed" }) +end) -- cgit 1.2.3-korg