Skip to content

Commit

Permalink
Merge pull request #89 from RI-SE/feature_emptyScenarioModule
Browse files Browse the repository at this point in the history
Created empty ScenarioControl module
  • Loading branch information
LukasWikander authored Jul 5, 2019
2 parents 2aa4e10 + 910c9d3 commit 439f50e
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 2 deletions.
46 changes: 46 additions & 0 deletions modules/ScenarioControl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)



18 changes: 18 additions & 0 deletions modules/ScenarioControl/README.md
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions modules/ScenarioControl/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>
#include <unistd.h>

#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;
}
2 changes: 1 addition & 1 deletion runServer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#### User settings
# Modify this array by adding more modules to include them in the execution
MODULES=(dummy)
MODULES=(ScenarioControl)



Expand Down
2 changes: 1 addition & 1 deletion util
Submodule util updated from 32d9e9 to ea2939

0 comments on commit 439f50e

Please sign in to comment.