diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index e6a1df63..0b80e6af 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -6,13 +6,18 @@ # copied verbatim in the file "LICENSE" # ################################################################################ -configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/ProgOptionTest/macro/bsampler-sink.json ${CMAKE_BINARY_DIR}/bin/bsampler-sink.json) +configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/ProgOptionTest/macro/bsampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/example-bsampler-sink.json) +configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink/sampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex1-sampler-sink.json) +configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink/sampler-processor-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex2-sampler-processor-sink.json) Set(INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/fairmq ${CMAKE_SOURCE_DIR}/fairmq/devices ${CMAKE_SOURCE_DIR}/fairmq/tools ${CMAKE_SOURCE_DIR}/fairmq/options + ${CMAKE_SOURCE_DIR}/fairmq/examples/1-sampler-sink + ${CMAKE_SOURCE_DIR}/fairmq/examples/2-sampler-processor-sink + ${CMAKE_SOURCE_DIR}/fairmq/examples/req-rep ) Set(SYSTEM_INCLUDE_DIRECTORIES @@ -22,7 +27,6 @@ Set(SYSTEM_INCLUDE_DIRECTORIES If(PROTOBUF_FOUND) Set(INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/fairmq/examples/req-rep # # following directory is only for protobuf tests and is not essential part of FairMQ #${CMAKE_SOURCE_DIR}/fairmq/prototest ) @@ -71,15 +75,25 @@ set(SRCS "FairMQChannel.cxx" "FairMQDevice.cxx" "FairMQPoller.cxx" + "devices/FairMQBenchmarkSampler.cxx" "devices/FairMQSink.cxx" "devices/FairMQBuffer.cxx" "devices/FairMQProxy.cxx" "devices/FairMQSplitter.cxx" "devices/FairMQMerger.cxx" + "options/FairProgOptions.cxx" "options/FairMQProgOptions.cxx" "options/FairMQParser.cxx" + + "examples/1-sampler-sink/FairMQExample1Sampler.cxx" + "examples/1-sampler-sink/FairMQExample1Sink.cxx" + + "examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx" + "examples/2-sampler-processor-sink/FairMQExample2Processor.cxx" + "examples/2-sampler-processor-sink/FairMQExample2Sink.cxx" + "examples/req-rep/FairMQExampleClient.cxx" "examples/req-rep/FairMQExampleServer.cxx" ) @@ -155,8 +169,13 @@ set(Exe_Names splitter merger proxy - example_client - example_server + ex1-sampler + ex1-sink + ex2-sampler + ex2-processor + ex2-sink + example-client + example-server ) # following executables are only for protobuf tests and are not essential part of FairMQ @@ -177,6 +196,11 @@ set(Exe_Source run/runSplitter.cxx run/runMerger.cxx run/runProxy.cxx + examples/1-sampler-sink/runExample1Sampler.cxx + examples/1-sampler-sink/runExample1Sink.cxx + examples/2-sampler-processor-sink/runExample2Sampler.cxx + examples/2-sampler-processor-sink/runExample2Processor.cxx + examples/2-sampler-processor-sink/runExample2Sink.cxx examples/req-rep/runExampleClient.cxx examples/req-rep/runExampleServer.cxx ) diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.cxx b/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.cxx new file mode 100644 index 00000000..30f605c0 --- /dev/null +++ b/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.cxx @@ -0,0 +1,93 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample1Sampler.cpp + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#include +#include + +#include "FairMQExample1Sampler.h" +#include "FairMQLogger.h" + +FairMQExample1Sampler::FairMQExample1Sampler() + : fText() +{ +} + +void FairMQExample1Sampler::CustomCleanup(void *data, void *object) +{ + delete (std::string*)object; +} + +void FairMQExample1Sampler::Run() +{ + while (GetCurrentState() == RUNNING) + { + boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); + + std::string* text = new std::string(fText); + + FairMQMessage* msg = fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text); + + LOG(INFO) << "Sending \"" << fText << "\""; + + fChannels["data-out"].at(0).Send(msg); + } +} + +FairMQExample1Sampler::~FairMQExample1Sampler() +{ +} + +void FairMQExample1Sampler::SetProperty(const int key, const std::string& value) +{ + switch (key) + { + case Text: + fText = value; + break; + default: + FairMQDevice::SetProperty(key, value); + break; + } +} + +std::string FairMQExample1Sampler::GetProperty(const int key, const std::string& default_ /*= ""*/) +{ + switch (key) + { + case Text: + return fText; + break; + default: + return FairMQDevice::GetProperty(key, default_); + } +} + +void FairMQExample1Sampler::SetProperty(const int key, const int value) +{ + switch (key) + { + default: + FairMQDevice::SetProperty(key, value); + break; + } +} + +int FairMQExample1Sampler::GetProperty(const int key, const int default_ /*= 0*/) +{ + switch (key) + { + default: + return FairMQDevice::GetProperty(key, default_); + } +} diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.h b/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.h new file mode 100644 index 00000000..1569cce5 --- /dev/null +++ b/fairmq/examples/1-sampler-sink/FairMQExample1Sampler.h @@ -0,0 +1,46 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample1Sampler.h + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#ifndef FAIRMQEXAMPLESAMPLER_H_ +#define FAIRMQEXAMPLESAMPLER_H_ + +#include + +#include "FairMQDevice.h" + +class FairMQExample1Sampler : public FairMQDevice +{ + public: + enum + { + Text = FairMQDevice::Last, + Last + }; + FairMQExample1Sampler(); + virtual ~FairMQExample1Sampler(); + + static void CustomCleanup(void* data, void* hint); + + virtual void SetProperty(const int key, const std::string& value); + virtual std::string GetProperty(const int key, const std::string& default_ = ""); + virtual void SetProperty(const int key, const int value); + virtual int GetProperty(const int key, const int default_ = 0); + + protected: + std::string fText; + + virtual void Run(); +}; + +#endif /* FAIRMQEXAMPLE1SAMPLER_H_ */ diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sink.cxx b/fairmq/examples/1-sampler-sink/FairMQExample1Sink.cxx new file mode 100644 index 00000000..1a3799a8 --- /dev/null +++ b/fairmq/examples/1-sampler-sink/FairMQExample1Sink.cxx @@ -0,0 +1,45 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample1Sink.cxx + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#include +#include + +#include "FairMQExample1Sink.h" +#include "FairMQLogger.h" + +using namespace std; + +FairMQExample1Sink::FairMQExample1Sink() +{ +} + +void FairMQExample1Sink::Run() +{ + while (GetCurrentState() == RUNNING) + { + FairMQMessage* msg = fTransportFactory->CreateMessage(); + + fChannels["data-in"].at(0).Receive(msg); + + LOG(INFO) << "Received message: \"" + << string(static_cast(msg->GetData()), msg->GetSize()) + << "\""; + + delete msg; + } +} + +FairMQExample1Sink::~FairMQExample1Sink() +{ +} diff --git a/fairmq/examples/1-sampler-sink/FairMQExample1Sink.h b/fairmq/examples/1-sampler-sink/FairMQExample1Sink.h new file mode 100644 index 00000000..34847903 --- /dev/null +++ b/fairmq/examples/1-sampler-sink/FairMQExample1Sink.h @@ -0,0 +1,30 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample1Sink.h + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#ifndef FAIRMQEXAMPLE1SINK_H_ +#define FAIRMQEXAMPLE1SINK_H_ + +#include "FairMQDevice.h" + +class FairMQExample1Sink : public FairMQDevice +{ + public: + FairMQExample1Sink(); + virtual ~FairMQExample1Sink(); + + protected: + virtual void Run(); +}; + +#endif /* FAIRMQEXAMPLE1SINK_H_ */ diff --git a/fairmq/examples/1-sampler-sink/runExample1Sampler.cxx b/fairmq/examples/1-sampler-sink/runExample1Sampler.cxx new file mode 100644 index 00000000..3e07087a --- /dev/null +++ b/fairmq/examples/1-sampler-sink/runExample1Sampler.cxx @@ -0,0 +1,125 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * runExampleSampler.cxx + * + * @since 2013-04-23 + * @author D. Klein, A. Rybalchenko + */ + +#include +#include + +#include "boost/program_options.hpp" + +#include "FairMQLogger.h" +#include "FairMQParser.h" +#include "FairMQProgOptions.h" +#include "FairMQExample1Sampler.h" + +#ifdef NANOMSG +#include "FairMQTransportFactoryNN.h" +#else +#include "FairMQTransportFactoryZMQ.h" +#endif + +using namespace boost::program_options; + +FairMQExample1Sampler sampler; + +static void s_signal_handler(int signal) +{ + LOG(INFO) << "Caught signal " << signal; + + sampler.ChangeState("END"); + + LOG(INFO) << "Shutdown complete."; + exit(1); +} + +static void s_catch_signals(void) +{ + struct sigaction action; + action.sa_handler = s_signal_handler; + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); +} + +int main(int argc, char** argv) +{ + s_catch_signals(); + + FairMQProgOptions config; + + try + { + std::string text; + + options_description samplerOptions("Sampler options"); + samplerOptions.add_options() + ("text", value(&text)->default_value("Hello"), "Text to send out"); + + config.AddToCmdLineOptions(samplerOptions); + + if (config.ParseAll(argc, argv)) + { + return 0; + } + + std::string filename = config.GetValue("config-json-file"); + std::string id = config.GetValue("id"); + + config.UserParser(filename, id); + + sampler.fChannels = config.GetFairMQMap(); + + LOG(INFO) << "PID: " << getpid(); + +#ifdef NANOMSG + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); +#else + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); +#endif + + sampler.SetTransport(transportFactory); + + sampler.SetProperty(FairMQExample1Sampler::Id, id); + sampler.SetProperty(FairMQExample1Sampler::Text, text); + + sampler.ChangeState("INIT_DEVICE"); + sampler.WaitForEndOfState("INIT_DEVICE"); + + sampler.ChangeState("INIT_TASK"); + sampler.WaitForEndOfState("INIT_TASK"); + + sampler.ChangeState("RUN"); + sampler.WaitForEndOfState("RUN"); + + sampler.ChangeState("STOP"); + + sampler.ChangeState("RESET_TASK"); + sampler.WaitForEndOfState("RESET_TASK"); + + sampler.ChangeState("RESET_DEVICE"); + sampler.WaitForEndOfState("RESET_DEVICE"); + + sampler.ChangeState("END"); + + } + catch (std::exception& e) + { + LOG(ERROR) << e.what(); + LOG(INFO) << "Command line options are the following: "; + config.PrintHelp(); + return 1; + } + + return 0; +} diff --git a/fairmq/examples/1-sampler-sink/runExample1Sink.cxx b/fairmq/examples/1-sampler-sink/runExample1Sink.cxx new file mode 100644 index 00000000..4da79658 --- /dev/null +++ b/fairmq/examples/1-sampler-sink/runExample1Sink.cxx @@ -0,0 +1,116 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * runExampleSink.cxx + * + * @since 2013-04-23 + * @author D. Klein, A. Rybalchenko + */ + +#include +#include + +#include "boost/program_options.hpp" + +#include "FairMQLogger.h" +#include "FairMQParser.h" +#include "FairMQProgOptions.h" +#include "FairMQExample1Sink.h" + +#ifdef NANOMSG +#include "FairMQTransportFactoryNN.h" +#else +#include "FairMQTransportFactoryZMQ.h" +#endif + +using namespace boost::program_options; + +FairMQExample1Sink sink; + +static void s_signal_handler(int signal) +{ + LOG(INFO) << "Caught signal " << signal; + + sink.ChangeState(FairMQExample1Sink::END); + + LOG(INFO) << "Shutdown complete."; + exit(1); +} + +static void s_catch_signals(void) +{ + struct sigaction action; + action.sa_handler = s_signal_handler; + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); +} + +int main(int argc, char** argv) +{ + s_catch_signals(); + + FairMQProgOptions config; + + try + { + if (config.ParseAll(argc, argv)) + { + return 0; + } + + std::string filename = config.GetValue("config-json-file"); + std::string id = config.GetValue("id"); + + config.UserParser(filename, id); + + sink.fChannels = config.GetFairMQMap(); + + LOG(INFO) << "PID: " << getpid(); + +#ifdef NANOMSG + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); +#else + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); +#endif + + sink.SetTransport(transportFactory); + + sink.SetProperty(FairMQExample1Sink::Id, id); + + sink.ChangeState("INIT_DEVICE"); + sink.WaitForEndOfState("INIT_DEVICE"); + + sink.ChangeState("INIT_TASK"); + sink.WaitForEndOfState("INIT_TASK"); + + sink.ChangeState("RUN"); + sink.WaitForEndOfState("RUN"); + + sink.ChangeState("STOP"); + + sink.ChangeState("RESET_TASK"); + sink.WaitForEndOfState("RESET_TASK"); + + sink.ChangeState("RESET_DEVICE"); + sink.WaitForEndOfState("RESET_DEVICE"); + + sink.ChangeState("END"); + + } + catch (std::exception& e) + { + LOG(ERROR) << e.what(); + LOG(INFO) << "Command line options are the following: "; + config.PrintHelp(); + return 1; + } + + return 0; +} diff --git a/fairmq/examples/1-sampler-sink/sampler-sink.json b/fairmq/examples/1-sampler-sink/sampler-sink.json new file mode 100644 index 00000000..c5b3e82e --- /dev/null +++ b/fairmq/examples/1-sampler-sink/sampler-sink.json @@ -0,0 +1,41 @@ +{ + "fairMQOptions": + { + "device": + { + "id": "sampler1", + "channel": + { + "name": "data-out", + "socket": + { + "type": "push", + "method": "bind", + "address": "tcp://*:5555", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + } + }, + + "device": + { + "id": "sink1", + "channel": + { + "name": "data-in", + "socket": + { + "type": "pull", + "method": "connect", + "address": "tcp://localhost:5556", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + } + } + } +} + diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.cxx b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.cxx new file mode 100644 index 00000000..57b6a4fd --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.cxx @@ -0,0 +1,52 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample2Processor.cpp + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#include +#include + +#include "FairMQExample2Processor.h" +#include "FairMQLogger.h" + +FairMQExample2Processor::FairMQExample2Processor() + : fText() +{ +} + +void FairMQExample2Processor::CustomCleanup(void *data, void *object) +{ + delete (std::string*)object; +} + +void FairMQExample2Processor::Run() +{ + while (GetCurrentState() == RUNNING) + { + FairMQMessage* input = fTransportFactory->CreateMessage(); + fChannels["data-in"].at(0).Receive(input); + + LOG(INFO) << "Received data, processing..."; + + std::string* text = new std::string(static_cast(input->GetData()), input->GetSize()); + *text += " (modified by " + fId + ")"; + + delete input; + + FairMQMessage* msg = fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text); + fChannels["data-out"].at(0).Send(msg); + } +} + +FairMQExample2Processor::~FairMQExample2Processor() +{ +} diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.h b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.h new file mode 100644 index 00000000..9f0f1157 --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Processor.h @@ -0,0 +1,41 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample2Processor.h + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#ifndef FAIRMQEXAMPLE2PROCESSOR_H_ +#define FAIRMQEXAMPLE2PROCESSOR_H_ + +#include + +#include "FairMQDevice.h" + +class FairMQExample2Processor : public FairMQDevice +{ + public: + enum + { + Text = FairMQDevice::Last, + Last + }; + FairMQExample2Processor(); + virtual ~FairMQExample2Processor(); + + static void CustomCleanup(void* data, void* hint); + + protected: + std::string fText; + + virtual void Run(); +}; + +#endif /* FAIRMQEXAMPLE2PROCESSOR_H_ */ diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx new file mode 100644 index 00000000..03215b48 --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.cxx @@ -0,0 +1,93 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample2Sampler.cpp + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#include +#include + +#include "FairMQExample2Sampler.h" +#include "FairMQLogger.h" + +FairMQExample2Sampler::FairMQExample2Sampler() + : fText() +{ +} + +void FairMQExample2Sampler::CustomCleanup(void *data, void *object) +{ + delete (std::string*)object; +} + +void FairMQExample2Sampler::Run() +{ + while (GetCurrentState() == RUNNING) + { + boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); + + std::string* text = new std::string(fText); + + FairMQMessage* msg = fTransportFactory->CreateMessage(const_cast(text->c_str()), text->length(), CustomCleanup, text); + + LOG(INFO) << "Sending \"" << fText << "\""; + + fChannels["data-out"].at(0).Send(msg); + } +} + +FairMQExample2Sampler::~FairMQExample2Sampler() +{ +} + +void FairMQExample2Sampler::SetProperty(const int key, const std::string& value) +{ + switch (key) + { + case Text: + fText = value; + break; + default: + FairMQDevice::SetProperty(key, value); + break; + } +} + +std::string FairMQExample2Sampler::GetProperty(const int key, const std::string& default_ /*= ""*/) +{ + switch (key) + { + case Text: + return fText; + break; + default: + return FairMQDevice::GetProperty(key, default_); + } +} + +void FairMQExample2Sampler::SetProperty(const int key, const int value) +{ + switch (key) + { + default: + FairMQDevice::SetProperty(key, value); + break; + } +} + +int FairMQExample2Sampler::GetProperty(const int key, const int default_ /*= 0*/) +{ + switch (key) + { + default: + return FairMQDevice::GetProperty(key, default_); + } +} diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.h b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.h new file mode 100644 index 00000000..71dc3fca --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sampler.h @@ -0,0 +1,46 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample2Sampler.h + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#ifndef FAIRMQEXAMPLE2SAMPLER_H_ +#define FAIRMQEXAMPLE2SAMPLER_H_ + +#include + +#include "FairMQDevice.h" + +class FairMQExample2Sampler : public FairMQDevice +{ + public: + enum + { + Text = FairMQDevice::Last, + Last + }; + FairMQExample2Sampler(); + virtual ~FairMQExample2Sampler(); + + static void CustomCleanup(void* data, void* hint); + + virtual void SetProperty(const int key, const std::string& value); + virtual std::string GetProperty(const int key, const std::string& default_ = ""); + virtual void SetProperty(const int key, const int value); + virtual int GetProperty(const int key, const int default_ = 0); + + protected: + std::string fText; + + virtual void Run(); +}; + +#endif /* FAIRMQEXAMPLE2SAMPLER_H_ */ diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.cxx b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.cxx new file mode 100644 index 00000000..96953b28 --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.cxx @@ -0,0 +1,45 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample2Sink.cxx + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#include +#include + +#include "FairMQExample2Sink.h" +#include "FairMQLogger.h" + +using namespace std; + +FairMQExample2Sink::FairMQExample2Sink() +{ +} + +void FairMQExample2Sink::Run() +{ + while (GetCurrentState() == RUNNING) + { + FairMQMessage* msg = fTransportFactory->CreateMessage(); + + fChannels["data-in"].at(0).Receive(msg); + + LOG(INFO) << "Received message: \"" + << string(static_cast(msg->GetData()), msg->GetSize()) + << "\""; + + delete msg; + } +} + +FairMQExample2Sink::~FairMQExample2Sink() +{ +} diff --git a/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.h b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.h new file mode 100644 index 00000000..228501a0 --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/FairMQExample2Sink.h @@ -0,0 +1,30 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * FairMQExample2Sink.h + * + * @since 2014-10-10 + * @author A. Rybalchenko + */ + +#ifndef FAIRMQEXAMPLE2SINK_H_ +#define FAIRMQEXAMPLE2SINK_H_ + +#include "FairMQDevice.h" + +class FairMQExample2Sink : public FairMQDevice +{ + public: + FairMQExample2Sink(); + virtual ~FairMQExample2Sink(); + + protected: + virtual void Run(); +}; + +#endif /* FAIRMQEXAMPLE2SINK_H_ */ diff --git a/fairmq/examples/2-sampler-processor-sink/runExample2Processor.cxx b/fairmq/examples/2-sampler-processor-sink/runExample2Processor.cxx new file mode 100644 index 00000000..1b9c180b --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/runExample2Processor.cxx @@ -0,0 +1,116 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * runExample2Processor.cxx + * + * @since 2013-04-23 + * @author D. Klein, A. Rybalchenko + */ + +#include +#include + +#include "boost/program_options.hpp" + +#include "FairMQLogger.h" +#include "FairMQParser.h" +#include "FairMQProgOptions.h" +#include "FairMQExample2Processor.h" + +#ifdef NANOMSG +#include "FairMQTransportFactoryNN.h" +#else +#include "FairMQTransportFactoryZMQ.h" +#endif + +using namespace boost::program_options; + +FairMQExample2Processor processor; + +static void s_signal_handler(int signal) +{ + LOG(INFO) << "Caught signal " << signal; + + processor.ChangeState("END"); + + LOG(INFO) << "Shutdown complete."; + exit(1); +} + +static void s_catch_signals(void) +{ + struct sigaction action; + action.sa_handler = s_signal_handler; + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); +} + +int main(int argc, char** argv) +{ + s_catch_signals(); + + FairMQProgOptions config; + + try + { + if (config.ParseAll(argc, argv)) + { + return 0; + } + + std::string filename = config.GetValue("config-json-file"); + std::string id = config.GetValue("id"); + + config.UserParser(filename, id); + + processor.fChannels = config.GetFairMQMap(); + + LOG(INFO) << "PID: " << getpid(); + +#ifdef NANOMSG + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); +#else + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); +#endif + + processor.SetTransport(transportFactory); + + processor.SetProperty(FairMQExample2Processor::Id, id); + + processor.ChangeState("INIT_DEVICE"); + processor.WaitForEndOfState("INIT_DEVICE"); + + processor.ChangeState("INIT_TASK"); + processor.WaitForEndOfState("INIT_TASK"); + + processor.ChangeState("RUN"); + processor.WaitForEndOfState("RUN"); + + processor.ChangeState("STOP"); + + processor.ChangeState("RESET_TASK"); + processor.WaitForEndOfState("RESET_TASK"); + + processor.ChangeState("RESET_DEVICE"); + processor.WaitForEndOfState("RESET_DEVICE"); + + processor.ChangeState("END"); + + } + catch (std::exception& e) + { + LOG(ERROR) << e.what(); + LOG(INFO) << "Command line options are the following: "; + config.PrintHelp(); + return 1; + } + + return 0; +} diff --git a/fairmq/examples/2-sampler-processor-sink/runExample2Sampler.cxx b/fairmq/examples/2-sampler-processor-sink/runExample2Sampler.cxx new file mode 100644 index 00000000..72e9507f --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/runExample2Sampler.cxx @@ -0,0 +1,125 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * runExample2Sampler.cxx + * + * @since 2013-04-23 + * @author D. Klein, A. Rybalchenko + */ + +#include +#include + +#include "boost/program_options.hpp" + +#include "FairMQLogger.h" +#include "FairMQParser.h" +#include "FairMQProgOptions.h" +#include "FairMQExample2Sampler.h" + +#ifdef NANOMSG +#include "FairMQTransportFactoryNN.h" +#else +#include "FairMQTransportFactoryZMQ.h" +#endif + +using namespace boost::program_options; + +FairMQExample2Sampler sampler; + +static void s_signal_handler(int signal) +{ + LOG(INFO) << "Caught signal " << signal; + + sampler.ChangeState("END"); + + LOG(INFO) << "Shutdown complete."; + exit(1); +} + +static void s_catch_signals(void) +{ + struct sigaction action; + action.sa_handler = s_signal_handler; + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); +} + +int main(int argc, char** argv) +{ + s_catch_signals(); + + FairMQProgOptions config; + + try + { + std::string text; + + options_description samplerOptions("Sampler options"); + samplerOptions.add_options() + ("text", value(&text)->default_value("Hello"), "Text to send out"); + + config.AddToCmdLineOptions(samplerOptions); + + if (config.ParseAll(argc, argv)) + { + return 0; + } + + std::string filename = config.GetValue("config-json-file"); + std::string id = config.GetValue("id"); + + config.UserParser(filename, id); + + sampler.fChannels = config.GetFairMQMap(); + + LOG(INFO) << "PID: " << getpid(); + +#ifdef NANOMSG + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); +#else + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); +#endif + + sampler.SetTransport(transportFactory); + + sampler.SetProperty(FairMQExample2Sampler::Id, id); + sampler.SetProperty(FairMQExample2Sampler::Text, text); + + sampler.ChangeState("INIT_DEVICE"); + sampler.WaitForEndOfState("INIT_DEVICE"); + + sampler.ChangeState("INIT_TASK"); + sampler.WaitForEndOfState("INIT_TASK"); + + sampler.ChangeState("RUN"); + sampler.WaitForEndOfState("RUN"); + + sampler.ChangeState("STOP"); + + sampler.ChangeState("RESET_TASK"); + sampler.WaitForEndOfState("RESET_TASK"); + + sampler.ChangeState("RESET_DEVICE"); + sampler.WaitForEndOfState("RESET_DEVICE"); + + sampler.ChangeState("END"); + + } + catch (std::exception& e) + { + LOG(ERROR) << e.what(); + LOG(INFO) << "Command line options are the following: "; + config.PrintHelp(); + return 1; + } + + return 0; +} diff --git a/fairmq/examples/2-sampler-processor-sink/runExample2Sink.cxx b/fairmq/examples/2-sampler-processor-sink/runExample2Sink.cxx new file mode 100644 index 00000000..9d1c39e8 --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/runExample2Sink.cxx @@ -0,0 +1,116 @@ +/******************************************************************************** + * 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" * + ********************************************************************************/ +/** + * runExample2Sink.cxx + * + * @since 2013-04-23 + * @author D. Klein, A. Rybalchenko + */ + +#include +#include + +#include "boost/program_options.hpp" + +#include "FairMQLogger.h" +#include "FairMQParser.h" +#include "FairMQProgOptions.h" +#include "FairMQExample2Sink.h" + +#ifdef NANOMSG +#include "FairMQTransportFactoryNN.h" +#else +#include "FairMQTransportFactoryZMQ.h" +#endif + +using namespace boost::program_options; + +FairMQExample2Sink sink; + +static void s_signal_handler(int signal) +{ + LOG(INFO) << "Caught signal " << signal; + + sink.ChangeState(FairMQExample2Sink::END); + + LOG(INFO) << "Shutdown complete."; + exit(1); +} + +static void s_catch_signals(void) +{ + struct sigaction action; + action.sa_handler = s_signal_handler; + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); +} + +int main(int argc, char** argv) +{ + s_catch_signals(); + + FairMQProgOptions config; + + try + { + if (config.ParseAll(argc, argv)) + { + return 0; + } + + std::string filename = config.GetValue("config-json-file"); + std::string id = config.GetValue("id"); + + config.UserParser(filename, id); + + sink.fChannels = config.GetFairMQMap(); + + LOG(INFO) << "PID: " << getpid(); + +#ifdef NANOMSG + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN(); +#else + FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ(); +#endif + + sink.SetTransport(transportFactory); + + sink.SetProperty(FairMQExample2Sink::Id, id); + + sink.ChangeState("INIT_DEVICE"); + sink.WaitForEndOfState("INIT_DEVICE"); + + sink.ChangeState("INIT_TASK"); + sink.WaitForEndOfState("INIT_TASK"); + + sink.ChangeState("RUN"); + sink.WaitForEndOfState("RUN"); + + sink.ChangeState("STOP"); + + sink.ChangeState("RESET_TASK"); + sink.WaitForEndOfState("RESET_TASK"); + + sink.ChangeState("RESET_DEVICE"); + sink.WaitForEndOfState("RESET_DEVICE"); + + sink.ChangeState("END"); + + } + catch (std::exception& e) + { + LOG(ERROR) << e.what(); + LOG(INFO) << "Command line options are the following: "; + config.PrintHelp(); + return 1; + } + + return 0; +} diff --git a/fairmq/examples/2-sampler-processor-sink/sampler-processor-sink.json b/fairmq/examples/2-sampler-processor-sink/sampler-processor-sink.json new file mode 100644 index 00000000..216b9f09 --- /dev/null +++ b/fairmq/examples/2-sampler-processor-sink/sampler-processor-sink.json @@ -0,0 +1,102 @@ +{ + "fairMQOptions": + { + "device": + { + "id": "sampler1", + "channel": + { + "name": "data-out", + "socket": + { + "type": "push", + "method": "bind", + "address": "tcp://*:5555", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + } + }, + + "device": + { + "id": "processor1", + "channel": + { + "name": "data-in", + "socket": + { + "type": "pull", + "method": "connect", + "address": "tcp://localhost:5555", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + }, + "channel": + { + "name": "data-out", + "socket": + { + "type": "push", + "method": "connect", + "address": "tcp://localhost:5556", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + } + }, + + "device": + { + "id": "processor2", + "channel": + { + "name": "data-in", + "socket": + { + "type": "pull", + "method": "connect", + "address": "tcp://localhost:5555", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + }, + "channel": + { + "name": "data-out", + "socket": + { + "type": "push", + "method": "connect", + "address": "tcp://localhost:5556", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + } + }, + + "device": + { + "id": "sink1", + "channel": + { + "name": "data-in", + "socket": + { + "type": "pull", + "method": "bind", + "address": "tcp://*:5556", + "sndBufSize": "1000", + "rcvBufSize": "1000", + "rateLogging": "0" + } + } + } + } +} diff --git a/fairmq/options/FairMQProgOptions.cxx b/fairmq/options/FairMQProgOptions.cxx index 11b3ac25..98b39ce4 100644 --- a/fairmq/options/FairMQProgOptions.cxx +++ b/fairmq/options/FairMQProgOptions.cxx @@ -41,18 +41,18 @@ int FairMQProgOptions::ParseAll(const int argc, char** argv, bool AllowUnregiste if (fUseConfigFile) { fCmdline_options.add_options() - ("device-id", po::value< std::string >(), "Device ID"); + ("id", po::value< std::string >(), "Device ID"); fConfig_file_options.add_options() - ("device-id", po::value< std::string >()->required(), "Device ID"); + ("id", po::value< std::string >()->required(), "Device ID"); } else { fCmdline_options.add_options() - ("device-id", po::value< std::string >()->required(), "Device ID"); + ("id", po::value< std::string >()->required(), "Device ID"); } fVisible_options.add_options() - ("device-id", po::value< std::string >()->required(), "Device ID (required value)"); + ("id", po::value< std::string >()->required(), "Device ID (required value)"); // parse command line if (ParseCmdLine(argc,argv,fCmdline_options,fvarmap,AllowUnregistered)) @@ -101,12 +101,12 @@ int FairMQProgOptions::NotifySwitchOption() void FairMQProgOptions::InitOptionDescription() { fMQParserOptions.add_options() - ("config-xml-string", po::value< std::vector >()->multitoken(), "XML input as command line string.") - ("config-xml-filename", po::value< std::string >(), "XML input as file.") - ("config-json-string", po::value< std::vector >()->multitoken(), "JSON input as command line string.") - ("config-json-filename", po::value< std::string >(), "JSON input as file.") + ("config-xml-string", po::value< std::vector >()->multitoken(), "XML input as command line string.") + ("config-xml-file", po::value< std::string >(), "XML input as file.") + ("config-json-string", po::value< std::vector >()->multitoken(), "JSON input as command line string.") + ("config-json-file", po::value< std::string >(), "JSON input as file.") - // ("ini.config.string", po::value< std::vector >()->multitoken(), "INI input as command line string.") - // ("ini.config.filename", po::value< std::string >(), "INI input as file.") + // ("ini.config.string", po::value< std::vector >()->multitoken(), "INI input as command line string.") + // ("ini.config.file", po::value< std::string >(), "INI input as file.") ; } \ No newline at end of file diff --git a/fairmq/options/FairMQProgOptions.h b/fairmq/options/FairMQProgOptions.h index 55547c52..970dbe2d 100644 --- a/fairmq/options/FairMQProgOptions.h +++ b/fairmq/options/FairMQProgOptions.h @@ -30,6 +30,7 @@ protected: public: FairMQProgOptions(); virtual ~FairMQProgOptions(); + virtual int ParseAll(const int argc, char** argv, bool AllowUnregistered = false); // external parser, store function diff --git a/fairmq/options/ProgOptionTest/macro/ConfigFileTest.cfg.in b/fairmq/options/ProgOptionTest/macro/ConfigFileTest.cfg.in index 160ce842..e8ede13d 100644 --- a/fairmq/options/ProgOptionTest/macro/ConfigFileTest.cfg.in +++ b/fairmq/options/ProgOptionTest/macro/ConfigFileTest.cfg.in @@ -9,8 +9,8 @@ # xml.config.node.root = fairMQOptions #---------------------------------------------------- -config-json-filename = @CMAKE_BINARY_DIR@/bin/testJSON.json -config-xml-filename = @CMAKE_BINARY_DIR@/bin/testXML.xml +config-json-file = @CMAKE_BINARY_DIR@/bin/testJSON.json +config-xml-file = @CMAKE_BINARY_DIR@/bin/testXML.xml # device-id = merger diff --git a/fairmq/options/ProgOptionTest/macro/start-bsampler-sink.sh.in b/fairmq/options/ProgOptionTest/macro/start-bsampler-sink.sh.in index fcbae77b..f1330d71 100644 --- a/fairmq/options/ProgOptionTest/macro/start-bsampler-sink.sh.in +++ b/fairmq/options/ProgOptionTest/macro/start-bsampler-sink.sh.in @@ -5,14 +5,14 @@ JSONFILE="@CMAKE_BINARY_DIR@/bin/bsampler-sink.json" # Note: device-id value must correspond to the device id given in the json file BSAMPLER="runOptTestSampler" -BSAMPLER+=" --config-sjson-filename $JSONFILE" -BSAMPLER+=" --device-id bsampler1" +BSAMPLER+=" --config-json-file $JSONFILE" +BSAMPLER+=" --id bsampler1" xterm -geometry 150x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/$BSAMPLER & SINK="runOptTestSink" -SINK+=" --config-json-filename $JSONFILE" -SINK+=" --device-id sink1" +SINK+=" --config-json-file $JSONFILE" +SINK+=" --id sink1" xterm -geometry 150x23+0+350 -hold -e @CMAKE_BINARY_DIR@/bin/$SINK & diff --git a/fairmq/options/ProgOptionTest/macro/testMQOptions1.sh.in b/fairmq/options/ProgOptionTest/macro/testMQOptions1.sh.in index 1e3fff99..06f6d6be 100644 --- a/fairmq/options/ProgOptionTest/macro/testMQOptions1.sh.in +++ b/fairmq/options/ProgOptionTest/macro/testMQOptions1.sh.in @@ -6,6 +6,6 @@ if [ "$#" -gt 0 ]; then RUN_TEST+=" $*" fi -RUN_TEST+=" --config-xml-filename @CMAKE_BINARY_DIR@/bin/testXML.xml" +RUN_TEST+=" --config-xml-file @CMAKE_BINARY_DIR@/bin/testXML.xml" @CMAKE_BINARY_DIR@/bin/$RUN_TEST \ No newline at end of file diff --git a/fairmq/options/ProgOptionTest/macro/testMQOptions4.sh.in b/fairmq/options/ProgOptionTest/macro/testMQOptions4.sh.in index c3cf03ee..cf7c0dd8 100644 --- a/fairmq/options/ProgOptionTest/macro/testMQOptions4.sh.in +++ b/fairmq/options/ProgOptionTest/macro/testMQOptions4.sh.in @@ -6,6 +6,6 @@ if [ "$#" -gt 0 ]; then RUN_TEST+=" $*" fi -RUN_TEST+=" --config-json-filename @CMAKE_BINARY_DIR@/bin/testJSON.json" +RUN_TEST+=" --config-json-file @CMAKE_BINARY_DIR@/bin/testJSON.json" @CMAKE_BINARY_DIR@/bin/$RUN_TEST \ No newline at end of file diff --git a/fairmq/options/ProgOptionTest/run/runOptTestSampler.cxx b/fairmq/options/ProgOptionTest/run/runOptTestSampler.cxx index be46b4e0..04b7c0f8 100644 --- a/fairmq/options/ProgOptionTest/run/runOptTestSampler.cxx +++ b/fairmq/options/ProgOptionTest/run/runOptTestSampler.cxx @@ -55,8 +55,8 @@ int main(int argc, char** argv) return 0; // keys defined in FairMQProgOptions - string filename=config.GetValue("config-json-filename"); - string deviceID=config.GetValue("device-id"); + string filename=config.GetValue("config-json-file"); + string deviceID=config.GetValue("id"); // ////////////////////////////////////////////////////////////// // User defined parsing method. diff --git a/fairmq/options/ProgOptionTest/run/runOptTestSink.cxx b/fairmq/options/ProgOptionTest/run/runOptTestSink.cxx index 6b687b92..1270f5f9 100644 --- a/fairmq/options/ProgOptionTest/run/runOptTestSink.cxx +++ b/fairmq/options/ProgOptionTest/run/runOptTestSink.cxx @@ -49,8 +49,8 @@ int main(int argc, char** argv) return 0; // keys defined in FairMQProgOptions - string filename=config.GetValue("config-json-filename"); - string deviceID=config.GetValue("device-id"); + string filename=config.GetValue("config-json-file"); + string deviceID=config.GetValue("id"); // ////////////////////////////////////////////////////////////// // User defined parsing method. diff --git a/fairmq/options/ProgOptionTest/run/testMQoptions1.cxx b/fairmq/options/ProgOptionTest/run/testMQoptions1.cxx index 2423de01..536eab9a 100644 --- a/fairmq/options/ProgOptionTest/run/testMQoptions1.cxx +++ b/fairmq/options/ProgOptionTest/run/testMQoptions1.cxx @@ -23,9 +23,9 @@ int testXML1(FairMQProgOptions* config) std::string filename; std::string XMLrootNode; - filename=config->GetValue("config-xml-filename"); + filename=config->GetValue("config-xml-file"); XMLrootNode=config->GetValue("xml.config.node.root"); - std::string id=config->GetValue("device-id"); + std::string id=config->GetValue("id"); config->UserParser(filename,id,XMLrootNode); // other xml parser test config->UserParser(filename); @@ -42,7 +42,7 @@ int testXML2(FairMQProgOptions* config) LOG(INFO)<<"--------- test XML2 ---------\n"; std::string XML; std::string XMLrootNode; - std::string id=config->GetValue("device-id"); + std::string id=config->GetValue("id"); XMLrootNode=config->GetValue("xml.config.node.root"); // Note: convert the vector into one string with GetStringValue(key) @@ -62,9 +62,9 @@ int testJSON1(FairMQProgOptions* config) LOG(INFO)<<"--------- test JSON1 ---------\n"; std::string filename; std::string JSONrootNode; - std::string id=config->GetValue("device-id"); + std::string id=config->GetValue("id"); - filename=config->GetValue("config-json-filename"); + filename=config->GetValue("config-json-file"); JSONrootNode=config->GetValue("json.config.node.root"); config->UserParser(filename,id,JSONrootNode); @@ -79,7 +79,7 @@ int testJSON2(FairMQProgOptions* config) LOG(INFO)<<"--------- test JSON2 ---------\n"; std::string JSON; std::string JSONrootNode; - std::string id=config->GetValue("device-id"); + std::string id=config->GetValue("id"); JSONrootNode=config->GetValue("json.config.node.root"); // Note: convert the vector into one string with GetStringValue(key) @@ -122,13 +122,13 @@ int main(int argc, char** argv) // Parse xml or json from cmd line or file - if(config->GetVarMap().count("config-xml-filename")) + if(config->GetVarMap().count("config-xml-file")) testXML1(config); if(config->GetVarMap().count("config-xml-string")) testXML2(config); - if(config->GetVarMap().count("config-json-filename")) + if(config->GetVarMap().count("config-json-file")) testJSON1(config); if(config->GetVarMap().count("config-json-string")) diff --git a/fairmq/options/ProgOptionTest/run/testMQoptions2.cxx b/fairmq/options/ProgOptionTest/run/testMQoptions2.cxx index c29a7110..51838245 100644 --- a/fairmq/options/ProgOptionTest/run/testMQoptions2.cxx +++ b/fairmq/options/ProgOptionTest/run/testMQoptions2.cxx @@ -57,9 +57,9 @@ int main(int argc, char** argv) std::string filename; std::string XMLrootNode; - filename=config.GetValue("config-xml-filename"); + filename=config.GetValue("config-xml-file"); XMLrootNode=config.GetValue("xml.config.node.root"); - std::string id=config.GetValue("device-id"); + std::string id=config.GetValue("id"); config.UserParser(filename,id,XMLrootNode); diff --git a/fairmq/run/runBenchmarkSampler.cxx b/fairmq/run/runBenchmarkSampler.cxx index a30a4f07..59022ec2 100644 --- a/fairmq/run/runBenchmarkSampler.cxx +++ b/fairmq/run/runBenchmarkSampler.cxx @@ -9,7 +9,7 @@ * runBenchmarkSampler.cxx * * @since 2013-04-23 - * @author: D. Klein, A. Rybalchenko + * @author D. Klein, A. Rybalchenko */ #include @@ -80,7 +80,7 @@ int main(int argc, char** argv) } string filename = config.GetValue("config-json-filename"); - string id = config.GetValue("device-id"); + string id = config.GetValue("id"); config.UserParser(filename, id); diff --git a/fairmq/run/runSink.cxx b/fairmq/run/runSink.cxx index 3494d72f..587a0035 100644 --- a/fairmq/run/runSink.cxx +++ b/fairmq/run/runSink.cxx @@ -76,7 +76,7 @@ int main(int argc, char** argv) } string filename = config.GetValue("config-json-filename"); - string id = config.GetValue("device-id"); + string id = config.GetValue("id"); config.UserParser(filename, id);