From 8c2380fa743856459b4db19e4c5e2203f0af63ac Mon Sep 17 00:00:00 2001 From: Lukas Wikander Date: Mon, 1 Jul 2019 15:38:38 +0200 Subject: [PATCH 1/5] Copied dummy module --- modules/ScenarioControl/CMakeLists.txt | 46 ++++++++++++++++++++++++ modules/ScenarioControl/README.md | 18 ++++++++++ modules/ScenarioControl/src/main.cpp | 50 ++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 modules/ScenarioControl/CMakeLists.txt create mode 100644 modules/ScenarioControl/README.md create mode 100644 modules/ScenarioControl/src/main.cpp diff --git a/modules/ScenarioControl/CMakeLists.txt b/modules/ScenarioControl/CMakeLists.txt new file mode 100644 index 000000000..58b3ae31a --- /dev/null +++ b/modules/ScenarioControl/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 2.8) + +project(ScenarioControl) +# This module is an example of how to set up a new module external to the Maestro executable + + +include_directories(inc) +include_directories(../../util/C/logging) +include_directories(../../util/C/time) +include_directories(../../util/C/MQBus) +include_directories(../../server/inc) +include(GNUInstallDirs) + + +# Create library +add_library(MaestroLogging + ../../util/C/logging/logging.h + ../../util/C/logging/logging.c +) + +add_library(MaestroTime + ../../util/C/time/maestroTime.h + ../../util/C/time/maestroTime.c +) + +add_library(MQBus + ../../util/C/MQBus/mqbus.h + ../../util/C/MQBus/mqbus.c +) + +# Create library +add_library(util + ../../server/src/util.c + ../../server/inc/util.h +) + +add_executable(ScenarioControl src/main.cpp) + +install(TARGETS ScenarioControl DESTINATION bin) + +target_link_libraries(ScenarioControl MaestroTime MaestroLogging util) +target_link_libraries(util MQBus MaestroTime MaestroLogging) +target_link_libraries(MQBus rt m) + + + diff --git a/modules/ScenarioControl/README.md b/modules/ScenarioControl/README.md new file mode 100644 index 000000000..e6bce0e21 --- /dev/null +++ b/modules/ScenarioControl/README.md @@ -0,0 +1,18 @@ +## Dummy module +TODO. + +### Build process +1) Ensure your util repo is up to date +2) Navigate to this README.md file +3) Create the build directory: ```mkdir build``` +4) Enter the build directory: ```cd build``` +5) Generate necessary cmake files: ```cmake ..``` +6) Build the module: ```make``` + +### Run the module +1) Ensure you have built the module +2) Navigate to the build directory +3) Run the module: ```./ScenarioControl``` +4) Run Maestro + +Note: steps 3 and 4 can be replaced with running the runServer.sh script in the top directory of this repository diff --git a/modules/ScenarioControl/src/main.cpp b/modules/ScenarioControl/src/main.cpp new file mode 100644 index 000000000..30ddbbb2b --- /dev/null +++ b/modules/ScenarioControl/src/main.cpp @@ -0,0 +1,50 @@ +#include +#include + +#include "logging.h" +#include "util.h" + +#define MODULE_NAME "Dummy" + +int main() +{ + COMMAND command = COMM_INV; + char mqRecvData[MQ_MSG_SIZE]; + const struct timespec sleepTimePeriod = {0,10000000}; + const struct timespec abortWaitTime = {1,0}; + struct timespec remTime; + + LogInit(MODULE_NAME,LOG_LEVEL_DEBUG); + LogMessage(LOG_LEVEL_INFO, "Task running with PID: %u",getpid()); + + // Initialize message bus connection + while(iCommInit()) + { + nanosleep(&sleepTimePeriod,&remTime); + } + + while(true) + { + if (iCommRecv(&command,mqRecvData,MQ_MSG_SIZE,nullptr) < 0) + { + util_error("Message bus receive error"); + } + + switch (command) { + case COMM_INV: + nanosleep(&sleepTimePeriod,&remTime); + break; + case COMM_OBC_STATE: + break; + case COMM_STRT: + nanosleep(&abortWaitTime,&remTime); + LogMessage(LOG_LEVEL_WARNING,"Sending ABORT"); + iCommSend(COMM_ABORT,nullptr,0); + break; + default: + LogMessage(LOG_LEVEL_INFO,"Received command %u",command); + } + } + + return 0; +} From e27dc35a6a505fb2c1d135a11d21aa14c4f8d7ec Mon Sep 17 00:00:00 2001 From: Lukas Wikander Date: Mon, 1 Jul 2019 15:43:12 +0200 Subject: [PATCH 2/5] Util module reference update --- util | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util b/util index 32d9e9ba1..ea293911d 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit 32d9e9ba1aaa71332d177628a5b87e216158cf48 +Subproject commit ea293911d756e7c109f0c5406556cdd4f97793ea From 81bcbd831403287c74af8f6fc27c98693ff14eb3 Mon Sep 17 00:00:00 2001 From: Lukas Wikander Date: Mon, 1 Jul 2019 15:45:47 +0200 Subject: [PATCH 3/5] Removed dummy module functionality --- modules/ScenarioControl/src/main.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/ScenarioControl/src/main.cpp b/modules/ScenarioControl/src/main.cpp index 30ddbbb2b..f089cdbb8 100644 --- a/modules/ScenarioControl/src/main.cpp +++ b/modules/ScenarioControl/src/main.cpp @@ -4,7 +4,7 @@ #include "logging.h" #include "util.h" -#define MODULE_NAME "Dummy" +#define MODULE_NAME "ScenarioControl" int main() { @@ -34,13 +34,6 @@ int main() case COMM_INV: nanosleep(&sleepTimePeriod,&remTime); break; - case COMM_OBC_STATE: - break; - case COMM_STRT: - nanosleep(&abortWaitTime,&remTime); - LogMessage(LOG_LEVEL_WARNING,"Sending ABORT"); - iCommSend(COMM_ABORT,nullptr,0); - break; default: LogMessage(LOG_LEVEL_INFO,"Received command %u",command); } From 2a590c1ab43514ab0afa5da41ae33108b0286b19 Mon Sep 17 00:00:00 2001 From: Lukas Wikander Date: Mon, 1 Jul 2019 15:47:58 +0200 Subject: [PATCH 4/5] Removed unused variable --- modules/ScenarioControl/src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ScenarioControl/src/main.cpp b/modules/ScenarioControl/src/main.cpp index f089cdbb8..4bc11d538 100644 --- a/modules/ScenarioControl/src/main.cpp +++ b/modules/ScenarioControl/src/main.cpp @@ -11,7 +11,6 @@ int main() COMMAND command = COMM_INV; char mqRecvData[MQ_MSG_SIZE]; const struct timespec sleepTimePeriod = {0,10000000}; - const struct timespec abortWaitTime = {1,0}; struct timespec remTime; LogInit(MODULE_NAME,LOG_LEVEL_DEBUG); From 910c9d3259cb506a064ba4a2a414a72e7372420c Mon Sep 17 00:00:00 2001 From: Lukas Wikander Date: Mon, 1 Jul 2019 15:50:57 +0200 Subject: [PATCH 5/5] updated server run script --- runServer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runServer.sh b/runServer.sh index f6e87f4d0..92d205629 100755 --- a/runServer.sh +++ b/runServer.sh @@ -2,7 +2,7 @@ #### User settings # Modify this array by adding more modules to include them in the execution -MODULES=(dummy) +MODULES=(ScenarioControl)