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..4bc11d538 --- /dev/null +++ b/modules/ScenarioControl/src/main.cpp @@ -0,0 +1,42 @@ +#include +#include + +#include "logging.h" +#include "util.h" + +#define MODULE_NAME "ScenarioControl" + +int main() +{ + COMMAND command = COMM_INV; + char mqRecvData[MQ_MSG_SIZE]; + const struct timespec sleepTimePeriod = {0,10000000}; + 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; + default: + LogMessage(LOG_LEVEL_INFO,"Received command %u",command); + } + } + + return 0; +} 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) diff --git a/util b/util index 32d9e9ba1..ea293911d 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit 32d9e9ba1aaa71332d177628a5b87e216158cf48 +Subproject commit ea293911d756e7c109f0c5406556cdd4f97793ea