mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Refactor DDS example and tools to be able to run with/without DDS
This commit is contained in:
parent
af971c6ab1
commit
a05dc80402
|
@ -12,10 +12,6 @@ configure_file(${CMAKE_SOURCE_DIR}/fairmq/run/benchmark.json ${CMAKE_BINARY_DIR}
|
||||||
add_subdirectory(logger)
|
add_subdirectory(logger)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
||||||
If(DDS_FOUND)
|
|
||||||
add_subdirectory(deployment)
|
|
||||||
EndIf(DDS_FOUND)
|
|
||||||
|
|
||||||
Set(INCLUDE_DIRECTORIES
|
Set(INCLUDE_DIRECTORIES
|
||||||
${CMAKE_SOURCE_DIR}/fairmq
|
${CMAKE_SOURCE_DIR}/fairmq
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/devices
|
${CMAKE_SOURCE_DIR}/fairmq/devices
|
||||||
|
@ -31,6 +27,14 @@ Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||||
${ZMQ_INCLUDE_DIR}
|
${ZMQ_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
If(DDS_FOUND)
|
||||||
|
add_definitions(-DDDS_FOUND)
|
||||||
|
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||||
|
${SYSTEM_INCLUDE_DIRECTORIES}
|
||||||
|
${DDS_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
EndIf(DDS_FOUND)
|
||||||
|
|
||||||
If(NANOMSG_FOUND)
|
If(NANOMSG_FOUND)
|
||||||
add_definitions(-DNANOMSG_FOUND)
|
add_definitions(-DNANOMSG_FOUND)
|
||||||
Set(INCLUDE_DIRECTORIES
|
Set(INCLUDE_DIRECTORIES
|
||||||
|
@ -57,6 +61,13 @@ Set(LINK_DIRECTORIES
|
||||||
${Boost_LIBRARY_DIRS}
|
${Boost_LIBRARY_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
If(DDS_FOUND)
|
||||||
|
Set(LINK_DIRECTORIES
|
||||||
|
${LINK_DIRECTORIES}
|
||||||
|
DDS_LIBRARY_DIR
|
||||||
|
)
|
||||||
|
EndIf(DDS_FOUND)
|
||||||
|
|
||||||
Link_Directories(${LINK_DIRECTORIES})
|
Link_Directories(${LINK_DIRECTORIES})
|
||||||
|
|
||||||
Set(SRCS
|
Set(SRCS
|
||||||
|
@ -113,6 +124,7 @@ Set(FAIRMQHEADERS
|
||||||
devices/BaseSourcePolicy.h
|
devices/BaseSourcePolicy.h
|
||||||
options/FairProgOptionsHelper.h
|
options/FairProgOptionsHelper.h
|
||||||
tools/FairMQTools.h
|
tools/FairMQTools.h
|
||||||
|
tools/FairMQDDSTools.h
|
||||||
tools/runSimpleMQStateMachine.h
|
tools/runSimpleMQStateMachine.h
|
||||||
)
|
)
|
||||||
Install(FILES ${FAIRMQHEADERS} DESTINATION include)
|
Install(FILES ${FAIRMQHEADERS} DESTINATION include)
|
||||||
|
@ -139,6 +151,15 @@ If(NANOMSG_FOUND)
|
||||||
)
|
)
|
||||||
EndIf(NANOMSG_FOUND)
|
EndIf(NANOMSG_FOUND)
|
||||||
|
|
||||||
|
If(DDS_FOUND)
|
||||||
|
Set(DEPENDENCIES
|
||||||
|
${DEPENDENCIES}
|
||||||
|
${DDS_INTERCOM_LIBRARY_SHARED}
|
||||||
|
${DDS_PROTOCOL_LIBRARY_SHARED} # also link the two DDS dependency libraries to avoid linking issues on some osx systems
|
||||||
|
${DDS_USER_DEFAULTS_LIBRARY_SHARED}
|
||||||
|
)
|
||||||
|
EndIf(DDS_FOUND)
|
||||||
|
|
||||||
Set(LIBRARY_NAME FairMQ)
|
Set(LIBRARY_NAME FairMQ)
|
||||||
|
|
||||||
GENERATE_LIBRARY()
|
GENERATE_LIBRARY()
|
||||||
|
@ -151,6 +172,13 @@ Set(Exe_Names
|
||||||
proxy
|
proxy
|
||||||
)
|
)
|
||||||
|
|
||||||
|
If(DDS_FOUND)
|
||||||
|
Set(Exe_Names
|
||||||
|
${Exe_Names}
|
||||||
|
fairmq-dds-command-ui
|
||||||
|
)
|
||||||
|
EndIf(DDS_FOUND)
|
||||||
|
|
||||||
Set(Exe_Source
|
Set(Exe_Source
|
||||||
run/runBenchmarkSampler.cxx
|
run/runBenchmarkSampler.cxx
|
||||||
run/runSink.cxx
|
run/runSink.cxx
|
||||||
|
@ -159,6 +187,13 @@ Set(Exe_Source
|
||||||
run/runProxy.cxx
|
run/runProxy.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
|
If(DDS_FOUND)
|
||||||
|
Set(Exe_Source
|
||||||
|
${Exe_Source}
|
||||||
|
run/runDDSCommandUI.cxx
|
||||||
|
)
|
||||||
|
EndIf(DDS_FOUND)
|
||||||
|
|
||||||
list(LENGTH Exe_Names _length)
|
list(LENGTH Exe_Names _length)
|
||||||
math(EXPR _length ${_length}-1)
|
math(EXPR _length ${_length}-1)
|
||||||
|
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
################################################################################
|
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
|
||||||
# #
|
|
||||||
# This software is distributed under the terms of the #
|
|
||||||
# GNU Lesser General Public Licence version 3 (LGPL) version 3, #
|
|
||||||
# copied verbatim in the file "LICENSE" #
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
Set(INCLUDE_DIRECTORIES
|
|
||||||
${CMAKE_SOURCE_DIR}/fairmq
|
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/zeromq
|
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/nanomsg
|
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/devices
|
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/tools
|
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/options
|
|
||||||
${CMAKE_SOURCE_DIR}/fairmq/deployment
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
|
||||||
${SYSTEM_INCLUDE_DIRECTORIES}
|
|
||||||
${Boost_INCLUDE_DIR}
|
|
||||||
${DDS_INCLUDE_DIR}
|
|
||||||
${ZMQ_INCLUDE_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
|
||||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
|
||||||
|
|
||||||
Set(LINK_DIRECTORIES
|
|
||||||
${LINK_DIRECTORIES}
|
|
||||||
${Boost_LIBRARY_DIRS}
|
|
||||||
${DDS_LIBRARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
Link_Directories(${LINK_DIRECTORIES})
|
|
||||||
|
|
||||||
Install(FILES FairMQDDSTools.h DESTINATION include)
|
|
||||||
|
|
||||||
Set(Exe_Names
|
|
||||||
${Exe_Names}
|
|
||||||
fairmq-dds-command-ui
|
|
||||||
)
|
|
||||||
|
|
||||||
Set(Exe_Source
|
|
||||||
${Exe_Source}
|
|
||||||
runDDSCommandUI.cxx
|
|
||||||
)
|
|
||||||
|
|
||||||
list(LENGTH Exe_Names _length)
|
|
||||||
math(EXPR _length ${_length}-1)
|
|
||||||
|
|
||||||
ForEach(_file RANGE 0 ${_length})
|
|
||||||
list(GET Exe_Names ${_file} _name)
|
|
||||||
list(GET Exe_Source ${_file} _src)
|
|
||||||
set(EXE_NAME ${_name})
|
|
||||||
set(SRCS ${_src})
|
|
||||||
set(DEPENDENCIES FairMQ dds_intercom_lib)
|
|
||||||
GENERATE_EXECUTABLE()
|
|
||||||
EndForEach(_file RANGE 0 ${_length})
|
|
|
@ -8,28 +8,34 @@
|
||||||
#ifndef RUNSIMPLEMQSTATEMACHINE_H
|
#ifndef RUNSIMPLEMQSTATEMACHINE_H
|
||||||
#define RUNSIMPLEMQSTATEMACHINE_H
|
#define RUNSIMPLEMQSTATEMACHINE_H
|
||||||
|
|
||||||
/// std
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <type_traits>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/// boost
|
#ifdef DDS_FOUND
|
||||||
#include "boost/program_options.hpp"
|
#include "FairMQDDSTools.h"
|
||||||
|
#endif /*DDS_FOUND*/
|
||||||
|
|
||||||
/// FairRoot - FairMQ
|
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
#include "FairMQParser.h"
|
#include "FairMQParser.h"
|
||||||
#include "FairMQProgOptions.h"
|
#include "FairMQProgOptions.h"
|
||||||
|
|
||||||
// template function that takes any device
|
// template function that takes any device
|
||||||
// and runs a simple MQ state machine configured from a JSON file
|
// and runs a simple MQ state machine configured from a JSON file and/or (optionally) DDS.
|
||||||
template<typename TMQDevice>
|
template<typename TMQDevice>
|
||||||
inline int runStateMachine(TMQDevice& device, FairMQProgOptions& config)
|
inline int runStateMachine(TMQDevice& device, FairMQProgOptions& config)
|
||||||
{
|
{
|
||||||
device.CatchSignals();
|
device.CatchSignals();
|
||||||
|
|
||||||
device.SetConfig(config);
|
device.SetConfig(config);
|
||||||
|
std::string control = config.GetValue<std::string>("control");
|
||||||
|
|
||||||
device.ChangeState(TMQDevice::INIT_DEVICE);
|
device.ChangeState(TMQDevice::INIT_DEVICE);
|
||||||
|
#ifdef DDS_FOUND
|
||||||
|
if (control == "dds")
|
||||||
|
{
|
||||||
|
HandleConfigViaDDS(device);
|
||||||
|
}
|
||||||
|
#endif /*DDS_FOUND*/
|
||||||
device.WaitForEndOfState(TMQDevice::INIT_DEVICE);
|
device.WaitForEndOfState(TMQDevice::INIT_DEVICE);
|
||||||
|
|
||||||
device.ChangeState(TMQDevice::INIT_TASK);
|
device.ChangeState(TMQDevice::INIT_TASK);
|
||||||
|
@ -37,9 +43,6 @@ inline int runStateMachine(TMQDevice& device, FairMQProgOptions& config)
|
||||||
|
|
||||||
device.ChangeState(TMQDevice::RUN);
|
device.ChangeState(TMQDevice::RUN);
|
||||||
|
|
||||||
std::string control = config.GetValue<std::string>("control");
|
|
||||||
|
|
||||||
// TODO: Extend this with DDS (requires optional dependency?)?
|
|
||||||
if (control == "interactive")
|
if (control == "interactive")
|
||||||
{
|
{
|
||||||
device.InteractiveStateLoop();
|
device.InteractiveStateLoop();
|
||||||
|
@ -59,12 +62,21 @@ inline int runStateMachine(TMQDevice& device, FairMQProgOptions& config)
|
||||||
device.ChangeState(TMQDevice::END);
|
device.ChangeState(TMQDevice::END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DDS_FOUND
|
||||||
|
else if (control == "dds")
|
||||||
|
{
|
||||||
|
runDDSStateHandler(device);
|
||||||
|
}
|
||||||
|
#endif /*DDS_FOUND*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "Requested control mechanism '" << control << "' is not available.";
|
LOG(ERROR) << "Requested control mechanism '" << control << "' is not available.";
|
||||||
LOG(ERROR) << "Currently available are:"
|
LOG(ERROR) << "Currently available are:"
|
||||||
<< " 'interactive'"
|
<< " 'interactive'"
|
||||||
<< ", 'static'"
|
<< ", 'static'"
|
||||||
|
#ifdef DDS_FOUND
|
||||||
|
<< ", 'dds'"
|
||||||
|
#endif /*DDS_FOUND*/
|
||||||
<< ". Exiting.";
|
<< ". Exiting.";
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user