-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from RI-SE/feature_emptyScenarioModule
Created empty ScenarioControl module
- Loading branch information
Showing
5 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule util
updated
from 32d9e9 to ea2939