From e7ad0d6c34ff5eeeced055f44b78411b5f5bad31 Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Thu, 19 May 2016 10:22:02 +0200 Subject: [PATCH] Refactor DDS example and tools to be able to run with/without DDS --- examples/MQ/3-dds/CMakeLists.txt | 10 +++++++--- examples/MQ/3-dds/ex3-dds-topology.xml | 6 +++--- examples/MQ/3-dds/runExample3Processor.cxx | 14 ++------------ examples/MQ/3-dds/runExample3Sampler.cxx | 14 ++------------ examples/MQ/3-dds/runExample3Sink.cxx | 14 ++------------ 5 files changed, 16 insertions(+), 42 deletions(-) diff --git a/examples/MQ/3-dds/CMakeLists.txt b/examples/MQ/3-dds/CMakeLists.txt index 8efc2a2d..b236e04e 100644 --- a/examples/MQ/3-dds/CMakeLists.txt +++ b/examples/MQ/3-dds/CMakeLists.txt @@ -10,6 +10,10 @@ configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/3-dds/ex3-dds-topology.xml ${CMAK configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/3-dds/ex3-dds-hosts.cfg ${CMAKE_BINARY_DIR}/bin/config/ex3-dds-hosts.cfg COPYONLY) configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/3-dds/ex3-dds.json ${CMAKE_BINARY_DIR}/bin/config/ex3-dds.json COPYONLY) +If(DDS_FOUND) + add_definitions(-DDDS_FOUND) +EndIf(DDS_FOUND) + Set(INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/fairmq ${CMAKE_SOURCE_DIR}/fairmq/zeromq @@ -17,7 +21,6 @@ Set(INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/fairmq/devices ${CMAKE_SOURCE_DIR}/fairmq/tools ${CMAKE_SOURCE_DIR}/fairmq/options - ${CMAKE_SOURCE_DIR}/fairmq/deployment ${CMAKE_SOURCE_DIR}/examples/MQ/3-dds ${CMAKE_CURRENT_BINARY_DIR} ) @@ -35,7 +38,6 @@ Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) Set(LINK_DIRECTORIES ${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS} - ${DDS_LIBRARY_DIR} ) Link_Directories(${LINK_DIRECTORIES}) @@ -50,7 +52,9 @@ Set(SRCS Set(DEPENDENCIES ${DEPENDENCIES} FairMQ - dds_intercom_lib + ${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} ) set(LIBRARY_NAME FairMQExample3) diff --git a/examples/MQ/3-dds/ex3-dds-topology.xml b/examples/MQ/3-dds/ex3-dds-topology.xml index a7ed143d..c1dcbd61 100644 --- a/examples/MQ/3-dds/ex3-dds-topology.xml +++ b/examples/MQ/3-dds/ex3-dds-topology.xml @@ -16,7 +16,7 @@ - @CMAKE_BINARY_DIR@/bin/ex3-sampler --id sampler --log-color false --mq-config @CMAKE_BINARY_DIR@/bin/config/ex3-dds.json + @CMAKE_BINARY_DIR@/bin/ex3-sampler --id sampler --log-color false --control dds --mq-config @CMAKE_BINARY_DIR@/bin/config/ex3-dds.json SamplerWorker samplerAddr @@ -24,7 +24,7 @@ - @CMAKE_BINARY_DIR@/bin/ex3-processor --id processor_%taskIndex% --config-key processor --log-color false --mq-config @CMAKE_BINARY_DIR@/bin/config/ex3-dds.json + @CMAKE_BINARY_DIR@/bin/ex3-processor --id processor_%taskIndex% --config-key processor --log-color false --control dds --mq-config @CMAKE_BINARY_DIR@/bin/config/ex3-dds.json ProcessorWorker samplerAddr @@ -33,7 +33,7 @@ - @CMAKE_BINARY_DIR@/bin/ex3-sink --id sink --log-color false --mq-config @CMAKE_BINARY_DIR@/bin/config/ex3-dds.json + @CMAKE_BINARY_DIR@/bin/ex3-sink --id sink --log-color false --control dds --mq-config @CMAKE_BINARY_DIR@/bin/config/ex3-dds.json SinkWorker sinkAddr diff --git a/examples/MQ/3-dds/runExample3Processor.cxx b/examples/MQ/3-dds/runExample3Processor.cxx index 406d711f..98b2b891 100644 --- a/examples/MQ/3-dds/runExample3Processor.cxx +++ b/examples/MQ/3-dds/runExample3Processor.cxx @@ -13,9 +13,9 @@ */ #include "FairMQLogger.h" -#include "FairMQDDSTools.h" #include "FairMQProgOptions.h" #include "FairMQExample3Processor.h" +#include "runSimpleMQStateMachine.h" int main(int argc, char** argv) { @@ -25,17 +25,7 @@ int main(int argc, char** argv) config.ParseAll(argc, argv); FairMQExample3Processor processor; - processor.CatchSignals(); - processor.SetConfig(config); - - processor.ChangeState("INIT_DEVICE"); - HandleConfigViaDDS(processor); - processor.WaitForEndOfState("INIT_DEVICE"); - - processor.ChangeState("INIT_TASK"); - processor.WaitForEndOfState("INIT_TASK"); - - runDDSStateHandler(processor); + runStateMachine(processor, config); } catch (std::exception& e) { diff --git a/examples/MQ/3-dds/runExample3Sampler.cxx b/examples/MQ/3-dds/runExample3Sampler.cxx index 337526a4..c301de7a 100644 --- a/examples/MQ/3-dds/runExample3Sampler.cxx +++ b/examples/MQ/3-dds/runExample3Sampler.cxx @@ -13,9 +13,9 @@ */ #include "FairMQLogger.h" -#include "FairMQDDSTools.h" #include "FairMQProgOptions.h" #include "FairMQExample3Sampler.h" +#include "runSimpleMQStateMachine.h" int main(int argc, char** argv) { @@ -25,17 +25,7 @@ int main(int argc, char** argv) config.ParseAll(argc, argv); FairMQExample3Sampler sampler; - sampler.CatchSignals(); - sampler.SetConfig(config); - - sampler.ChangeState("INIT_DEVICE"); - HandleConfigViaDDS(sampler); - sampler.WaitForEndOfState("INIT_DEVICE"); - - sampler.ChangeState("INIT_TASK"); - sampler.WaitForEndOfState("INIT_TASK"); - - runDDSStateHandler(sampler); + runStateMachine(sampler, config); } catch (std::exception& e) { diff --git a/examples/MQ/3-dds/runExample3Sink.cxx b/examples/MQ/3-dds/runExample3Sink.cxx index c1793a29..041605e6 100644 --- a/examples/MQ/3-dds/runExample3Sink.cxx +++ b/examples/MQ/3-dds/runExample3Sink.cxx @@ -13,9 +13,9 @@ */ #include "FairMQLogger.h" -#include "FairMQDDSTools.h" #include "FairMQProgOptions.h" #include "FairMQExample3Sink.h" +#include "runSimpleMQStateMachine.h" int main(int argc, char** argv) { @@ -25,17 +25,7 @@ int main(int argc, char** argv) config.ParseAll(argc, argv); FairMQExample3Sink sink; - sink.CatchSignals(); - sink.SetConfig(config); - - sink.ChangeState("INIT_DEVICE"); - HandleConfigViaDDS(sink); - sink.WaitForEndOfState("INIT_DEVICE"); - - sink.ChangeState("INIT_TASK"); - sink.WaitForEndOfState("INIT_TASK"); - - runDDSStateHandler(sink); + runStateMachine(sink, config); } catch (std::exception& e) {