mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
Refactor the examples after move from FairRoot
This commit is contained in:
parent
31cba0515e
commit
bab7e13737
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
|||
build
|
||||
|
||||
.DS_Store
|
||||
|
|
|
@ -29,6 +29,7 @@ include(CTest)
|
|||
option(BUILD_NANOMSG_TRANSPORT "Build nanomsg transport." OFF)
|
||||
option(BUILD_OFI_TRANSPORT "Build experimental OFI transport." OFF)
|
||||
option(BUILD_DDS_PLUGIN "Build DDS plugin." OFF)
|
||||
option(BUILD_EXAMPLES "Build FairMQ examples." ON)
|
||||
################################################################################
|
||||
|
||||
|
||||
|
@ -71,6 +72,10 @@ add_subdirectory(fairmq)
|
|||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
################################################################################
|
||||
|
||||
|
||||
|
@ -178,5 +183,11 @@ else()
|
|||
set(dds_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_DDS_PLUGIN=ON${CR})")
|
||||
endif()
|
||||
message(STATUS " ${BWhite}dds_plugin${CR} ${dds_summary}")
|
||||
if(BUILD_EXAMPLES)
|
||||
set(examples_summary "${BGreen}YES${CR} (default, disable with ${BMagenta}-DBUILD_EXAMPLES=OFF${CR})")
|
||||
else()
|
||||
set(examples_summary "${BRed} NO${CR} (enable with ${BMagenta}-DBUILD_EXAMPLES=ON${CR})")
|
||||
endif()
|
||||
message(STATUS " ${BWhite}examples${CR} ${examples_summary}")
|
||||
message(STATUS " ")
|
||||
################################################################################
|
||||
|
|
|
@ -92,6 +92,7 @@ On command line:
|
|||
|
||||
* `-DDISABLE_COLOR=ON` disables coloured console output.
|
||||
* `-DBUILD_TESTING=OFF` disables building of tests.
|
||||
* `-DBUILD_ESXAMPLES=OFF` disables building of examples.
|
||||
* `-DBUILD_NANOMSG_TRANSPORT=ON` enables building of nanomsg transport.
|
||||
* `-DBUILD_OFI_TRANSPORT=ON` enables building of the experimental OFI transport.
|
||||
* `-DBUILD_DDS_PLUGIN=ON` enables building of the DDS plugin.
|
||||
|
|
50
examples/1-1/CMakeLists.txt
Normal file
50
examples/1-1/CMakeLists.txt
Normal file
|
@ -0,0 +1,50 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
add_library(Example11Lib STATIC
|
||||
"Sampler.cxx"
|
||||
"Sampler.h"
|
||||
"Sink.cxx"
|
||||
"Sink.h"
|
||||
)
|
||||
|
||||
target_link_libraries(Example11Lib PUBLIC FairMQ)
|
||||
|
||||
add_executable(fairmq-ex-1-1-sampler runSampler.cxx)
|
||||
target_link_libraries(fairmq-ex-1-1-sampler PRIVATE Example11Lib)
|
||||
|
||||
add_executable(fairmq-ex-1-1-sink runSink.cxx)
|
||||
target_link_libraries(fairmq-ex-1-1-sink PRIVATE Example11Lib)
|
||||
|
||||
add_custom_target(Example11 DEPENDS fairmq-ex-1-1-sampler fairmq-ex-1-1-sink)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
fairmq-ex-1-1-sampler
|
||||
fairmq-ex-1-1-sink
|
||||
|
||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# configure run script with different executable paths for build and for install directories
|
||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh)
|
||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh_install)
|
||||
|
||||
install(
|
||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh_install
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
RENAME fairmq-start-ex-1-1.sh
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh)
|
||||
|
||||
add_test(NAME Example-1-1 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh)
|
||||
set_tests_properties(Example-1-1 PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
@ -6,7 +6,7 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample1Sampler.cpp
|
||||
* Sampler.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
|
@ -15,27 +15,28 @@
|
|||
#include <thread> // this_thread::sleep_for
|
||||
#include <chrono>
|
||||
|
||||
#include "FairMQExample1Sampler.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
#include "Sampler.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample1Sampler::FairMQExample1Sampler()
|
||||
namespace example_1_1
|
||||
{
|
||||
|
||||
Sampler::Sampler()
|
||||
: fText()
|
||||
, fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQExample1Sampler::InitTask()
|
||||
void Sampler::InitTask()
|
||||
{
|
||||
// Get the fText and fMaxIterations values from the command line options (via fConfig)
|
||||
fText = fConfig->GetValue<string>("text");
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
bool FairMQExample1Sampler::ConditionalRun()
|
||||
bool Sampler::ConditionalRun()
|
||||
{
|
||||
// create a copy of the data with new(), that will be deleted after the transfer is complete
|
||||
string* text = new string(fText);
|
||||
|
@ -68,6 +69,8 @@ bool FairMQExample1Sampler::ConditionalRun()
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample1Sampler::~FairMQExample1Sampler()
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_1_1
|
|
@ -1,37 +1,42 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample2Sampler.h
|
||||
* Sampler.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE2SAMPLER_H_
|
||||
#define FAIRMQEXAMPLE2SAMPLER_H_
|
||||
#ifndef FAIRMQEXAMPLE11SAMPLER_H
|
||||
#define FAIRMQEXAMPLE11SAMPLER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample2Sampler : public FairMQDevice
|
||||
namespace example_1_1
|
||||
{
|
||||
|
||||
class Sampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample2Sampler();
|
||||
virtual ~FairMQExample2Sampler();
|
||||
Sampler();
|
||||
virtual ~Sampler();
|
||||
|
||||
protected:
|
||||
std::string fText;
|
||||
uint64_t fMaxIterations;
|
||||
uint64_t fNumIterations;
|
||||
|
||||
virtual void InitTask();
|
||||
virtual bool ConditionalRun();
|
||||
void InitTask() override;
|
||||
bool ConditionalRun() override;
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE2SAMPLER_H_ */
|
||||
} // namespace example_1_1
|
||||
|
||||
#endif /* FAIRMQEXAMPLE11SAMPLER_H */
|
|
@ -1,39 +1,40 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample1Sink.cxx
|
||||
* Sink.cxx
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQExample1Sink.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
#include "Sink.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample1Sink::FairMQExample1Sink()
|
||||
namespace example_1_1
|
||||
{
|
||||
|
||||
Sink::Sink()
|
||||
: fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
// register a handler for data arriving on "data" channel
|
||||
OnData("data", &FairMQExample1Sink::HandleData);
|
||||
OnData("data", &Sink::HandleData);
|
||||
}
|
||||
|
||||
void FairMQExample1Sink::InitTask()
|
||||
void Sink::InitTask()
|
||||
{
|
||||
// Get the fMaxIterations value from the command line options (via fConfig)
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
|
||||
bool FairMQExample1Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received: \"" << string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||
|
||||
|
@ -47,6 +48,8 @@ bool FairMQExample1Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample1Sink::~FairMQExample1Sink()
|
||||
Sink::~Sink()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_1_1
|
|
@ -1,27 +1,30 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample1Sink.h
|
||||
* Sink.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE1SINK_H_
|
||||
#define FAIRMQEXAMPLE1SINK_H_
|
||||
#ifndef FAIRMQEXAMPLE11SINK_H
|
||||
#define FAIRMQEXAMPLE11SINK_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample1Sink : public FairMQDevice
|
||||
namespace example_1_1
|
||||
{
|
||||
|
||||
class Sink : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample1Sink();
|
||||
virtual ~FairMQExample1Sink();
|
||||
Sink();
|
||||
virtual ~Sink();
|
||||
|
||||
protected:
|
||||
virtual void InitTask();
|
||||
|
@ -32,4 +35,6 @@ class FairMQExample1Sink : public FairMQDevice
|
|||
uint64_t fNumIterations;
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE1SINK_H_ */
|
||||
} // namespace example_1_1
|
||||
|
||||
#endif /* FAIRMQEXAMPLE11SINK_H */
|
11
examples/1-1/fairmq-start-ex-1-1.sh.in
Executable file
11
examples/1-1/fairmq-start-ex-1-1.sh.in
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
SAMPLER="fairmq-ex-1-1-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0"
|
||||
xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||
|
||||
SINK="fairmq-ex-1-1-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://localhost:5555,rateLogging=0"
|
||||
xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK &
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample5Client.h"
|
||||
#include "Sampler.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -20,5 +20,5 @@ void addCustomOptions(bpo::options_description& options)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample5Client();
|
||||
return new example_1_1::Sampler();
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample6Sink.h"
|
||||
#include "Sink.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample6Sink();
|
||||
return new example_1_1::Sink();
|
||||
}
|
|
@ -1,26 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
ex1config="@CMAKE_BINARY_DIR@/bin/config/ex1-sampler-sink.json"
|
||||
|
||||
# setup a trap to kill everything if the test fails/timeouts
|
||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID;' TERM
|
||||
|
||||
SAMPLER="ex1-sampler"
|
||||
SAMPLER="fairmq-ex-1-1-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --verbosity veryhigh"
|
||||
SAMPLER+=" --control static --color false"
|
||||
SAMPLER+=" --max-iterations 1"
|
||||
SAMPLER+=" --mq-config $ex1config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SAMPLER &
|
||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0"
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||
SAMPLER_PID=$!
|
||||
|
||||
SINK="ex1-sink"
|
||||
SINK="fairmq-ex-1-1-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --verbosity veryhigh"
|
||||
SINK+=" --control static --color false"
|
||||
SINK+=" --max-iterations 1"
|
||||
SINK+=" --mq-config $ex1config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SINK &
|
||||
SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://localhost:5555,rateLogging=0"
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||
SINK_PID=$!
|
||||
|
||||
# wait for sampler and sink to finish
|
62
examples/1-n-1/CMakeLists.txt
Normal file
62
examples/1-n-1/CMakeLists.txt
Normal file
|
@ -0,0 +1,62 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
add_library(Example1N1Lib STATIC
|
||||
"Sampler.cxx"
|
||||
"Sampler.h"
|
||||
"Processor.cxx"
|
||||
"Processor.h"
|
||||
"Sink.cxx"
|
||||
"Sink.h"
|
||||
)
|
||||
|
||||
target_link_libraries(Example1N1Lib PUBLIC FairMQ)
|
||||
|
||||
add_executable(fairmq-ex-1-n-1-sampler runSampler.cxx)
|
||||
target_link_libraries(fairmq-ex-1-n-1-sampler PRIVATE Example1N1Lib)
|
||||
|
||||
add_executable(fairmq-ex-1-n-1-processor runProcessor.cxx)
|
||||
target_link_libraries(fairmq-ex-1-n-1-processor PRIVATE Example1N1Lib)
|
||||
|
||||
add_executable(fairmq-ex-1-n-1-sink runSink.cxx)
|
||||
target_link_libraries(fairmq-ex-1-n-1-sink PRIVATE Example1N1Lib)
|
||||
|
||||
add_custom_target(Example1N1 DEPENDS fairmq-ex-1-n-1-sampler fairmq-ex-1-n-1-processor fairmq-ex-1-n-1-sink)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
fairmq-ex-1-n-1-sampler
|
||||
fairmq-ex-1-n-1-processor
|
||||
fairmq-ex-1-n-1-sink
|
||||
|
||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# configure run script with different executable paths for build and for install directories
|
||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh)
|
||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh_install)
|
||||
|
||||
install(
|
||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh_install
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
RENAME fairmq-start-ex-1-n-1.sh
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-1-n-1.json ${CMAKE_CURRENT_BINARY_DIR}/ex-1-n-1.json)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-1-n-1.json
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR} # TODO: install this in a more appropriate directory
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh)
|
||||
|
||||
add_test(NAME Example-1-n-1 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh)
|
||||
set_tests_properties(Example-1-n-1 PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
@ -1,24 +1,26 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "FairMQExample2Processor.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "Processor.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample2Processor::FairMQExample2Processor()
|
||||
namespace example_1_n_1
|
||||
{
|
||||
OnData("data1", &FairMQExample2Processor::HandleData);
|
||||
|
||||
Processor::Processor()
|
||||
{
|
||||
OnData("data1", &Processor::HandleData);
|
||||
}
|
||||
|
||||
bool FairMQExample2Processor::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Processor::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received data, processing...";
|
||||
|
||||
|
@ -44,6 +46,8 @@ bool FairMQExample2Processor::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample2Processor::~FairMQExample2Processor()
|
||||
Processor::~Processor()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_1_n_1
|
|
@ -1,24 +1,29 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE2PROCESSOR_H_
|
||||
#define FAIRMQEXAMPLE2PROCESSOR_H_
|
||||
#ifndef FAIRMQEXAMPLE1N1PROCESSOR_H_
|
||||
#define FAIRMQEXAMPLE1N1PROCESSOR_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample2Processor : public FairMQDevice
|
||||
namespace example_1_n_1
|
||||
{
|
||||
|
||||
class Processor : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample2Processor();
|
||||
virtual ~FairMQExample2Processor();
|
||||
Processor();
|
||||
virtual ~Processor();
|
||||
|
||||
protected:
|
||||
bool HandleData(FairMQMessagePtr&, int);
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE2PROCESSOR_H_ */
|
||||
} // namespace example_1_n_1
|
||||
|
||||
#endif /* FAIRMQEXAMPLE1N1PROCESSOR_H_ */
|
|
@ -1,12 +1,12 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample2Sampler.cpp
|
||||
* Sampler.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
|
@ -15,27 +15,28 @@
|
|||
#include <thread> // this_thread::sleep_for
|
||||
#include <chrono>
|
||||
|
||||
#include "FairMQExample2Sampler.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
#include "Sampler.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample2Sampler::FairMQExample2Sampler()
|
||||
namespace example_1_n_1
|
||||
{
|
||||
|
||||
Sampler::Sampler()
|
||||
: fText()
|
||||
, fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQExample2Sampler::InitTask()
|
||||
void Sampler::InitTask()
|
||||
{
|
||||
// Get the fText and fMaxIterations values from the command line options (via fConfig)
|
||||
fText = fConfig->GetValue<string>("text");
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
bool FairMQExample2Sampler::ConditionalRun()
|
||||
bool Sampler::ConditionalRun()
|
||||
{
|
||||
// Initializing message with NewStaticMessage will avoid copy
|
||||
// but won't delete the data after the sending is completed.
|
||||
|
@ -60,6 +61,8 @@ bool FairMQExample2Sampler::ConditionalRun()
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample2Sampler::~FairMQExample2Sampler()
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_1_n_1
|
|
@ -6,24 +6,27 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample1Sampler.h
|
||||
* Sampler.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE1SAMPLER_H_
|
||||
#define FAIRMQEXAMPLE1SAMPLER_H_
|
||||
#ifndef FAIRMQEXAMPLE1N1SAMPLER_H_
|
||||
#define FAIRMQEXAMPLE1N1SAMPLER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample1Sampler : public FairMQDevice
|
||||
namespace example_1_n_1
|
||||
{
|
||||
|
||||
class Sampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample1Sampler();
|
||||
virtual ~FairMQExample1Sampler();
|
||||
Sampler();
|
||||
virtual ~Sampler();
|
||||
|
||||
protected:
|
||||
std::string fText;
|
||||
|
@ -34,4 +37,6 @@ class FairMQExample1Sampler : public FairMQDevice
|
|||
virtual bool ConditionalRun();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE1SAMPLER_H_ */
|
||||
} // namespace example_1_n_1
|
||||
|
||||
#endif /* FAIRMQEXAMPLE1N1SAMPLER_H_ */
|
|
@ -1,39 +1,40 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample2Sink.cxx
|
||||
* Sink.cxx
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQExample2Sink.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
#include "Sink.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample2Sink::FairMQExample2Sink()
|
||||
namespace example_1_n_1
|
||||
{
|
||||
|
||||
Sink::Sink()
|
||||
: fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
// register a handler for data arriving on "data2" channel
|
||||
OnData("data2", &FairMQExample2Sink::HandleData);
|
||||
OnData("data2", &Sink::HandleData);
|
||||
}
|
||||
|
||||
void FairMQExample2Sink::InitTask()
|
||||
void Sink::InitTask()
|
||||
{
|
||||
// Get the fMaxIterations value from the command line options (via fConfig)
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
// handler is called whenever a message arrives on "data2", with a reference to the message and a sub-channel index (here 0)
|
||||
bool FairMQExample2Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received: \"" << string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||
|
||||
|
@ -47,6 +48,8 @@ bool FairMQExample2Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample2Sink::~FairMQExample2Sink()
|
||||
Sink::~Sink()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_1_n_1
|
|
@ -1,27 +1,30 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample2Sink.h
|
||||
* Sink.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE2SINK_H_
|
||||
#define FAIRMQEXAMPLE2SINK_H_
|
||||
#ifndef FAIRMQEXAMPLE1N1SINK_H
|
||||
#define FAIRMQEXAMPLE1N1SINK_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample2Sink : public FairMQDevice
|
||||
namespace example_1_n_1
|
||||
{
|
||||
|
||||
class Sink : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample2Sink();
|
||||
virtual ~FairMQExample2Sink();
|
||||
Sink();
|
||||
virtual ~Sink();
|
||||
|
||||
protected:
|
||||
virtual void InitTask();
|
||||
|
@ -32,4 +35,6 @@ class FairMQExample2Sink : public FairMQDevice
|
|||
uint64_t fNumIterations;
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE2SINK_H_ */
|
||||
} // namespace example_1_n_1
|
||||
|
||||
#endif /* FAIRMQEXAMPLE1N1SINK_H */
|
25
examples/1-n-1/fairmq-start-ex-1-n-1.sh.in
Executable file
25
examples/1-n-1/fairmq-start-ex-1-n-1.sh.in
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
ex2config="@EX_BIN_DIR@/ex-1-n-1.json"
|
||||
|
||||
SAMPLER="fairmq-ex-1-n-1-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --mq-config $ex2config"
|
||||
xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||
|
||||
PROCESSOR1="fairmq-ex-1-n-1-processor"
|
||||
PROCESSOR1+=" --id processor1"
|
||||
PROCESSOR1+=" --mq-config $ex2config"
|
||||
PROCESSOR1+=" --config-key processor"
|
||||
xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$PROCESSOR1 &
|
||||
|
||||
PROCESSOR2="fairmq-ex-1-n-1-processor"
|
||||
PROCESSOR2+=" --id processor2"
|
||||
PROCESSOR2+=" --mq-config $ex2config"
|
||||
PROCESSOR2+=" --config-key processor"
|
||||
xterm -geometry 80x23+500+330 -hold -e @EX_BIN_DIR@/$PROCESSOR2 &
|
||||
|
||||
SINK="fairmq-ex-1-n-1-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --mq-config $ex2config"
|
||||
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SINK &
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample3Sink.h"
|
||||
#include "Processor.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample3Sink();
|
||||
return new example_1_n_1::Processor();
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample1Sampler.h"
|
||||
#include "Sampler.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -20,5 +20,5 @@ void addCustomOptions(bpo::options_description& options)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample1Sampler();
|
||||
return new example_1_n_1::Sampler();
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample4Sink.h"
|
||||
#include "Sink.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample4Sink();
|
||||
return new example_1_n_1::Sink();
|
||||
}
|
|
@ -1,44 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
ex2config="@CMAKE_BINARY_DIR@/bin/config/ex2-sampler-processor-sink.json"
|
||||
ex2config="@CMAKE_CURRENT_BINARY_DIR@/ex-1-n-1.json"
|
||||
|
||||
# setup a trap to kill everything if the test fails/timeouts
|
||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; kill -TERM $PROCESSOR1_PID; kill -TERM $PROCESSOR2_PID; wait $SAMPLER_PID; wait $SINK_PID; wait $PROCESSOR1_PID; wait $PROCESSOR2_PID;' TERM
|
||||
|
||||
SAMPLER="ex2-sampler"
|
||||
SAMPLER="fairmq-ex-1-n-1-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --verbosity veryhigh"
|
||||
SAMPLER+=" --control static --color false"
|
||||
SAMPLER+=" --max-iterations 2"
|
||||
SAMPLER+=" --mq-config $ex2config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SAMPLER &
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||
SAMPLER_PID=$!
|
||||
|
||||
PROCESSOR1="ex2-processor"
|
||||
PROCESSOR1="fairmq-ex-1-n-1-processor"
|
||||
PROCESSOR1+=" --id processor1"
|
||||
PROCESSOR1+=" --verbosity veryhigh"
|
||||
PROCESSOR1+=" --control static --color false"
|
||||
PROCESSOR1+=" --mq-config $ex2config"
|
||||
PROCESSOR1+=" --config-key processor"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR1 &
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 &
|
||||
PROCESSOR1_PID=$!
|
||||
|
||||
PROCESSOR2="ex2-processor"
|
||||
PROCESSOR2="fairmq-ex-1-n-1-processor"
|
||||
PROCESSOR2+=" --id processor2"
|
||||
PROCESSOR2+=" --verbosity veryhigh"
|
||||
PROCESSOR2+=" --control static --color false"
|
||||
PROCESSOR2+=" --mq-config $ex2config"
|
||||
PROCESSOR2+=" --config-key processor"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR2 &
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 &
|
||||
PROCESSOR2_PID=$!
|
||||
|
||||
SINK="ex2-sink"
|
||||
SINK="fairmq-ex-1-n-1-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --verbosity veryhigh"
|
||||
SINK+=" --control static --color false"
|
||||
SINK+=" --max-iterations 2"
|
||||
SINK+=" --mq-config $ex2config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SINK &
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||
SINK_PID=$!
|
||||
|
||||
# wait for sampler and sink to finish
|
17
examples/CMakeLists.txt
Normal file
17
examples/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
add_subdirectory(1-1)
|
||||
add_subdirectory(1-n-1)
|
||||
add_subdirectory(copypush)
|
||||
add_subdirectory(dds)
|
||||
add_subdirectory(multipart)
|
||||
add_subdirectory(multiple-channels)
|
||||
add_subdirectory(multiple-transports)
|
||||
add_subdirectory(region)
|
||||
add_subdirectory(req-rep)
|
|
@ -1,83 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/1-sampler-sink/ex1-sampler-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex1-sampler-sink.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/1-sampler-sink/startMQEx1.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/1-sampler-sink/startMQEx1.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/1-sampler-sink/testMQEx1.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/1-sampler-sink/testMQEx1.sh)
|
||||
|
||||
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}/examples/MQ/1-sampler-sink
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
include_directories(${INCLUDE_DIRECTORIES})
|
||||
include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${LINK_DIRECTORIES})
|
||||
|
||||
set(SRCS
|
||||
"FairMQExample1Sampler.cxx"
|
||||
"FairMQExample1Sink.cxx"
|
||||
)
|
||||
|
||||
set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
set(LIBRARY_NAME FairMQExample1)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
set(Exe_Names
|
||||
ex1-sampler
|
||||
ex1-sink
|
||||
)
|
||||
|
||||
set(Exe_Source
|
||||
runExample1Sampler.cxx
|
||||
runExample1Sink.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/1-sampler-sink/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/1-sampler-sink")
|
||||
|
||||
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 FairMQExample1)
|
||||
GENERATE_EXECUTABLE()
|
||||
endforeach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex1-sampler-sink COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/1-sampler-sink/testMQEx1.sh)
|
||||
set_tests_properties(MQ.ex1-sampler-sink PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex1-sampler-sink PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex1-sampler-sink PROPERTIES PASS_REGULAR_EXPRESSION " Received: \"Hello\"")
|
||||
|
||||
install(
|
||||
FILES ex1-sampler-sink.json
|
||||
DESTINATION share/fairbase/examples/MQ/1-sampler-sink/config/
|
||||
)
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"fairMQOptions": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "sampler1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "push",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sink1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/bash
|
||||
ex1config="@CMAKE_BINARY_DIR@/bin/config/ex1-sampler-sink.json"
|
||||
|
||||
SAMPLER="ex1-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --mq-config $ex1config"
|
||||
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SAMPLER &
|
||||
|
||||
SINK="ex1-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --mq-config $ex1config"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/1-sampler-sink/$SINK &
|
|
@ -1,86 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/2-sampler-processor-sink/ex2-sampler-processor-sink.json ${CMAKE_BINARY_DIR}/bin/config/ex2-sampler-processor-sink.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/2-sampler-processor-sink/startMQEx2.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/2-sampler-processor-sink/startMQEx2.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/2-sampler-processor-sink/testMQEx2.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/2-sampler-processor-sink/testMQEx2.sh)
|
||||
|
||||
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}/examples/MQ/2-sampler-processor-sink
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
include_directories(${INCLUDE_DIRECTORIES})
|
||||
include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${LINK_DIRECTORIES})
|
||||
|
||||
set(SRCS
|
||||
"FairMQExample2Sampler.cxx"
|
||||
"FairMQExample2Processor.cxx"
|
||||
"FairMQExample2Sink.cxx"
|
||||
)
|
||||
|
||||
set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
set(LIBRARY_NAME FairMQExample2)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
set(Exe_Names
|
||||
ex2-sampler
|
||||
ex2-processor
|
||||
ex2-sink
|
||||
)
|
||||
|
||||
set(Exe_Source
|
||||
runExample2Sampler.cxx
|
||||
runExample2Processor.cxx
|
||||
runExample2Sink.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/2-sampler-processor-sink/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/2-sampler-processor-sink")
|
||||
|
||||
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 FairMQExample2)
|
||||
GENERATE_EXECUTABLE()
|
||||
endforeach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex2-sampler-processor-sink COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/2-sampler-processor-sink/testMQEx2.sh)
|
||||
set_tests_properties(MQ.ex2-sampler-processor-sink PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex2-sampler-processor-sink PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex2-sampler-processor-sink PROPERTIES PASS_REGULAR_EXPRESSION "Received: ")
|
||||
|
||||
install(
|
||||
FILES ex2-sampler-processor-sink.json
|
||||
DESTINATION share/fairbase/examples/MQ/2-sampler-processor-sink/config/
|
||||
)
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/bash
|
||||
ex2config="@CMAKE_BINARY_DIR@/bin/config/ex2-sampler-processor-sink.json"
|
||||
|
||||
SAMPLER="ex2-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --mq-config $ex2config"
|
||||
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SAMPLER &
|
||||
|
||||
PROCESSOR1="ex2-processor"
|
||||
PROCESSOR1+=" --id processor1"
|
||||
PROCESSOR1+=" --mq-config $ex2config"
|
||||
PROCESSOR1+=" --config-key processor"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR1 &
|
||||
|
||||
PROCESSOR2="ex2-processor"
|
||||
PROCESSOR2+=" --id processor2"
|
||||
PROCESSOR2+=" --mq-config $ex2config"
|
||||
PROCESSOR2+=" --config-key processor"
|
||||
xterm -geometry 80x23+500+330 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$PROCESSOR2 &
|
||||
|
||||
SINK="ex2-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --mq-config $ex2config"
|
||||
xterm -geometry 80x23+1000+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/2-sampler-processor-sink/$SINK &
|
|
@ -1,87 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/3-dds/ex3-dds-topology.xml
|
||||
${CMAKE_BINARY_DIR}/bin/config/ex3-dds-topology.xml @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/3-dds/ex3-dds-hosts.cfg
|
||||
${CMAKE_BINARY_DIR}/bin/config/ex3-dds-hosts.cfg COPYONLY)
|
||||
|
||||
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}/examples/MQ/3-dds
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${SYSTEM_INCLUDE_DIRECTORIES}
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
Set(LINK_DIRECTORIES
|
||||
${LINK_DIRECTORIES}
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
Link_Directories(${LINK_DIRECTORIES})
|
||||
|
||||
Set(SRCS
|
||||
${SRCS}
|
||||
"FairMQExample3Sampler.cxx"
|
||||
"FairMQExample3Processor.cxx"
|
||||
"FairMQExample3Sink.cxx"
|
||||
)
|
||||
|
||||
Set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
set(LIBRARY_NAME FairMQExample3)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
Set(Exe_Names
|
||||
${Exe_Names}
|
||||
ex3-sampler
|
||||
ex3-processor
|
||||
ex3-sink
|
||||
)
|
||||
|
||||
Set(Exe_Source
|
||||
${Exe_Source}
|
||||
runExample3Sampler.cxx
|
||||
runExample3Processor.cxx
|
||||
runExample3Sink.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/3-dds/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/3-dds")
|
||||
|
||||
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 FairMQExample3)
|
||||
GENERATE_EXECUTABLE()
|
||||
EndForEach(_file RANGE 0 ${_length})
|
||||
|
||||
Install(
|
||||
FILES ex3-dds-hosts.cfg ex3-dds-topology.xml
|
||||
DESTINATION share/fairbase/examples/MQ/3-dds/config/
|
||||
)
|
|
@ -1,83 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/4-copypush/ex4-copypush.json ${CMAKE_BINARY_DIR}/bin/config/ex4-copypush.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/4-copypush/startMQEx4.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/4-copypush/startMQEx4.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/4-copypush/testMQEx4.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/4-copypush/testMQEx4.sh)
|
||||
|
||||
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}/examples/MQ/4-copypush
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
Set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
Link_Directories(${LINK_DIRECTORIES})
|
||||
|
||||
Set(SRCS
|
||||
"FairMQExample4Sampler.cxx"
|
||||
"FairMQExample4Sink.cxx"
|
||||
)
|
||||
|
||||
Set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
Set(LIBRARY_NAME FairMQExample4)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
Set(Exe_Names
|
||||
ex4-sampler
|
||||
ex4-sink
|
||||
)
|
||||
|
||||
Set(Exe_Source
|
||||
runExample4Sampler.cxx
|
||||
runExample4Sink.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/4-copypush/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/4-copypush")
|
||||
|
||||
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 FairMQExample4)
|
||||
GENERATE_EXECUTABLE()
|
||||
EndForEach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex4-copypush COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/4-copypush/testMQEx4.sh)
|
||||
set_tests_properties(MQ.ex4-copypush PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex4-copypush PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex4-copypush PROPERTIES PASS_REGULAR_EXPRESSION "Received message: ")
|
||||
|
||||
Install(
|
||||
FILES ex4-copypush.json
|
||||
DESTINATION share/fairbase/examples/MQ/4-copypush/config/
|
||||
)
|
|
@ -1,68 +0,0 @@
|
|||
{
|
||||
"fairMQOptions": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "sampler1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "push",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
},
|
||||
{
|
||||
"type": "push",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5556",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sink1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sink2",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5556",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
ex4config="@CMAKE_BINARY_DIR@/bin/config/ex4-copypush.json"
|
||||
|
||||
SAMPLER="ex4-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --mq-config $ex4config"
|
||||
xterm -geometry 80x23+0+165 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SAMPLER &
|
||||
|
||||
SINK1="ex4-sink"
|
||||
SINK1+=" --id sink1"
|
||||
SINK1+=" --mq-config $ex4config"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK1 &
|
||||
|
||||
SINK2="ex4-sink"
|
||||
SINK2+=" --id sink2"
|
||||
SINK2+=" --mq-config $ex4config"
|
||||
xterm -geometry 80x23+500+330 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK2 &
|
|
@ -1,83 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/5-req-rep/ex5-req-rep.json ${CMAKE_BINARY_DIR}/bin/config/ex5-req-rep.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/5-req-rep/startMQEx5.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/5-req-rep/startMQEx5.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/5-req-rep/testMQEx5.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/5-req-rep/testMQEx5.sh)
|
||||
|
||||
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}/examples/MQ/5-req-rep
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
include_directories(${INCLUDE_DIRECTORIES})
|
||||
include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${LINK_DIRECTORIES})
|
||||
|
||||
set(SRCS
|
||||
"FairMQExample5Client.cxx"
|
||||
"FairMQExample5Server.cxx"
|
||||
)
|
||||
|
||||
set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
set(LIBRARY_NAME FairMQExample5)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
set(Exe_Names
|
||||
ex5-client
|
||||
ex5-server
|
||||
)
|
||||
|
||||
set(Exe_Source
|
||||
runExample5Client.cxx
|
||||
runExample5Server.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/5-req-rep/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/5-req-rep")
|
||||
|
||||
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 FairMQExample5)
|
||||
GENERATE_EXECUTABLE()
|
||||
endforeach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex5-req-rep COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/5-req-rep/testMQEx5.sh)
|
||||
set_tests_properties(MQ.ex5-req-rep PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex5-req-rep PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex5-req-rep PROPERTIES PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
||||
|
||||
install(
|
||||
FILES ex5-req-rep.json
|
||||
DESTINATION share/fairbase/examples/MQ/5-req-rep/config/
|
||||
)
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"fairMQOptions": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "client",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "req",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5005",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "server",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "rep",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5005",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample5Server.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& options)
|
||||
{
|
||||
options.add_options()
|
||||
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample5Server();
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/bash
|
||||
ex5config="@CMAKE_BINARY_DIR@/bin/config/ex5-req-rep.json"
|
||||
|
||||
CLIENT="ex5-client"
|
||||
CLIENT+=" --id client"
|
||||
CLIENT+=" --mq-config $ex5config"
|
||||
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/5-req-rep/$CLIENT &
|
||||
|
||||
SERVER="ex5-server"
|
||||
SERVER+=" --id server"
|
||||
SERVER+=" --mq-config $ex5config"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/5-req-rep/$SERVER &
|
|
@ -1,86 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/6-multiple-channels/ex6-multiple-channels.json ${CMAKE_BINARY_DIR}/bin/config/ex6-multiple-channels.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/6-multiple-channels/startMQEx6.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/6-multiple-channels/startMQEx6.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/6-multiple-channels/testMQEx6.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/6-multiple-channels/testMQEx6.sh)
|
||||
|
||||
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}/examples/MQ/6-multiple-channels
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
include_directories(${INCLUDE_DIRECTORIES})
|
||||
include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${LINK_DIRECTORIES})
|
||||
|
||||
set(SRCS
|
||||
"FairMQExample6Sampler.cxx"
|
||||
"FairMQExample6Sink.cxx"
|
||||
"FairMQExample6Broadcaster.cxx"
|
||||
)
|
||||
|
||||
set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
set(LIBRARY_NAME FairMQExample6)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
set(Exe_Names
|
||||
ex6-sampler
|
||||
ex6-sink
|
||||
ex6-broadcaster
|
||||
)
|
||||
|
||||
set(Exe_Source
|
||||
runExample6Sampler.cxx
|
||||
runExample6Sink.cxx
|
||||
runExample6Broadcaster.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/6-multiple-channels/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/6-multiple-channels")
|
||||
|
||||
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 FairMQExample6)
|
||||
GENERATE_EXECUTABLE()
|
||||
endforeach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex6-multiple-channels COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/6-multiple-channels/testMQEx6.sh)
|
||||
set_tests_properties(MQ.ex6-multiple-channels PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex6-multiple-channels PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex6-multiple-channels PROPERTIES PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
||||
|
||||
install(
|
||||
FILES ex6-multiple-channels.json
|
||||
DESTINATION share/fairbase/examples/MQ/6-multiple-channels/config/
|
||||
)
|
|
@ -1,86 +0,0 @@
|
|||
{
|
||||
"fairMQOptions": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "sampler1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "push",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "broadcast",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "sub",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5005",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sink1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "broadcast",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "sub",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5005",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "broadcaster1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "broadcast",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pub",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5005",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample6Broadcaster.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& /*options*/)
|
||||
{
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample6Broadcaster();
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
ex6config="@CMAKE_BINARY_DIR@/bin/config/ex6-multiple-channels.json"
|
||||
|
||||
SAMPLER="ex6-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --mq-config $ex6config"
|
||||
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$SAMPLER &
|
||||
|
||||
SINK="ex6-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --mq-config $ex6config"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$SINK &
|
||||
|
||||
BROADCASTER="ex6-broadcaster"
|
||||
BROADCASTER+=" --id broadcaster1"
|
||||
BROADCASTER+=" --mq-config $ex6config"
|
||||
xterm -geometry 80x23+250+330 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/6-multiple-channels/$BROADCASTER &
|
|
@ -1,83 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/8-multipart/ex8-multipart.json ${CMAKE_BINARY_DIR}/bin/config/ex8-multipart.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/8-multipart/startMQEx8.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/8-multipart/startMQEx8.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/8-multipart/testMQEx8.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/8-multipart/testMQEx8.sh)
|
||||
|
||||
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}/examples/MQ/8-multipart
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
Set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
Link_Directories(${LINK_DIRECTORIES})
|
||||
|
||||
Set(SRCS
|
||||
"FairMQExample8Sampler.cxx"
|
||||
"FairMQExample8Sink.cxx"
|
||||
)
|
||||
|
||||
Set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
Set(LIBRARY_NAME FairMQExample8)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
Set(Exe_Names
|
||||
ex8-sampler
|
||||
ex8-sink
|
||||
)
|
||||
|
||||
Set(Exe_Source
|
||||
runExample8Sampler.cxx
|
||||
runExample8Sink.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/8-multipart/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/8-multipart")
|
||||
|
||||
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 FairMQExample8)
|
||||
GENERATE_EXECUTABLE()
|
||||
EndForEach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex8-multipart COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/8-multipart/testMQEx8.sh)
|
||||
set_tests_properties(MQ.ex8-multipart PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex8-multipart PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex8-multipart PROPERTIES PASS_REGULAR_EXPRESSION "Received message with 2 parts")
|
||||
|
||||
Install(
|
||||
FILES ex8-multipart.json
|
||||
DESTINATION share/fairbase/examples/MQ/8-multipart/config/
|
||||
)
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"fairMQOptions": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "sampler1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data-out",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "push",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sink1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data-in",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample8Sampler.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& options)
|
||||
{
|
||||
options.add_options()
|
||||
("max-iterations", bpo::value<uint64_t>()->default_value(5), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample8Sampler();
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/bash
|
||||
ex8config="@CMAKE_BINARY_DIR@/bin/config/ex8-multipart.json"
|
||||
|
||||
SAMPLER="ex8-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --mq-config $ex8config"
|
||||
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SAMPLER &
|
||||
|
||||
SINK="ex8-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --mq-config $ex8config"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SINK &
|
|
@ -1,86 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/multiple-transports/ex-multiple-transports.json ${CMAKE_BINARY_DIR}/bin/config/ex-multiple-transports.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/multiple-transports/startMTEx.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/multiple-transports/startMTEx.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/MQ/multiple-transports/testMTEx.sh.in ${CMAKE_BINARY_DIR}/bin/examples/MQ/multiple-transports/testMTEx.sh)
|
||||
|
||||
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}/examples/MQ/multiple-transports
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
Set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
Link_Directories(${LINK_DIRECTORIES})
|
||||
|
||||
Set(SRCS
|
||||
"FairMQExampleMTSampler1.cxx"
|
||||
"FairMQExampleMTSampler2.cxx"
|
||||
"FairMQExampleMTSink.cxx"
|
||||
)
|
||||
|
||||
Set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
Set(LIBRARY_NAME FairMQExampleMT)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
Set(Exe_Names
|
||||
ex-mt-sampler1
|
||||
ex-mt-sampler2
|
||||
ex-mt-sink
|
||||
)
|
||||
|
||||
Set(Exe_Source
|
||||
runExampleMTSampler1.cxx
|
||||
runExampleMTSampler2.cxx
|
||||
runExampleMTSink.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/MQ/multiple-transports/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/MQ/multiple-transports")
|
||||
|
||||
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 FairMQExampleMT)
|
||||
GENERATE_EXECUTABLE()
|
||||
EndForEach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex-multiple-transports COMMAND ${CMAKE_BINARY_DIR}/bin/examples/MQ/multiple-transports/testMTEx.sh)
|
||||
set_tests_properties(MQ.ex-multiple-transports PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex-multiple-transports PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex-multiple-transports PROPERTIES PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
||||
|
||||
Install(
|
||||
FILES ex-multiple-transports.json
|
||||
DESTINATION share/fairbase/examples/MQ/multiple-transports/config/
|
||||
)
|
|
@ -1,23 +0,0 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExampleMTSampler1.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& options)
|
||||
{
|
||||
options.add_options()
|
||||
("max-iterations", bpo::value<uint64_t>()->default_value(5), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExampleMTSampler1();
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExampleMTSampler2.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& options)
|
||||
{
|
||||
options.add_options()
|
||||
("max-iterations", bpo::value<uint64_t>()->default_value(5), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExampleMTSampler2();
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
#!/bin/bash
|
||||
config="@CMAKE_BINARY_DIR@/bin/config/ex-multiple-transports.json"
|
||||
|
||||
SAMPLER1="ex-mt-sampler1"
|
||||
SAMPLER1+=" --id sampler1"
|
||||
SAMPLER1+=" --severity debug"
|
||||
SAMPLER1+=" --transport shmem"
|
||||
SAMPLER1+=" --mq-config $config"
|
||||
xterm -geometry 80x30+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER1 &
|
||||
|
||||
SAMPLER2="ex-mt-sampler2"
|
||||
SAMPLER2+=" --id sampler2"
|
||||
SAMPLER2+=" --severity debug"
|
||||
SAMPLER2+=" --transport nanomsg"
|
||||
SAMPLER2+=" --mq-config $config"
|
||||
xterm -geometry 80x30+0+450 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER2 &
|
||||
|
||||
SINK="ex-mt-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --severity debug"
|
||||
SINK+=" --transport shmem"
|
||||
SINK+=" --mq-config $config"
|
||||
xterm -geometry 80x30+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SINK &
|
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash
|
||||
config="@CMAKE_BINARY_DIR@/bin/config/ex-multiple-transports.json"
|
||||
SESSION="$(@CMAKE_BINARY_DIR@/bin/uuidGen -h)"
|
||||
|
||||
trap 'kill -TERM $SAMPLER1_PID; kill -TERM $SAMPLER2_PID; kill -TERM $SINK_PID; wait $SAMPLER1_PID; wait $SAMPLER2_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/bin/shmmonitor --cleanup --session $SESSION;' TERM
|
||||
|
||||
SINK="ex-mt-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --verbosity veryhigh"
|
||||
SINK+=" --session $SESSION"
|
||||
SINK+=" --max-iterations 1"
|
||||
SINK+=" --control static --color false"
|
||||
SINK+=" --transport shmem"
|
||||
SINK+=" --mq-config $config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SINK &
|
||||
SINK_PID=$!
|
||||
|
||||
SAMPLER1="ex-mt-sampler1"
|
||||
SAMPLER1+=" --id sampler1"
|
||||
SAMPLER1+=" --session $SESSION"
|
||||
SAMPLER1+=" --verbosity veryhigh"
|
||||
SAMPLER1+=" --max-iterations 1"
|
||||
SAMPLER1+=" --control static --color false"
|
||||
SAMPLER1+=" --transport shmem"
|
||||
SAMPLER1+=" --mq-config $config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER1 &
|
||||
SAMPLER1_PID=$!
|
||||
|
||||
SAMPLER2="ex-mt-sampler2"
|
||||
SAMPLER2+=" --id sampler2"
|
||||
SAMPLER2+=" --session $SESSION"
|
||||
SAMPLER2+=" --verbosity veryhigh"
|
||||
SAMPLER2+=" --max-iterations 1"
|
||||
SAMPLER2+=" --control static --color false"
|
||||
SAMPLER2+=" --transport nanomsg"
|
||||
SAMPLER2+=" --mq-config $config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/multiple-transports/$SAMPLER2 &
|
||||
SAMPLER2_PID=$!
|
||||
|
||||
wait $SAMPLER1_PID
|
||||
wait $SAMPLER2_PID
|
||||
wait $SINK_PID
|
|
@ -1,83 +0,0 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/advanced/Region/ex-region.json ${CMAKE_BINARY_DIR}/bin/config/ex-region.json)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/advanced/Region/startMQExRegion.sh.in ${CMAKE_BINARY_DIR}/bin/examples/advanced/Region/startMQExRegion.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/examples/advanced/Region/testMQExRegion.sh.in ${CMAKE_BINARY_DIR}/bin/examples/advanced/Region/testMQExRegion.sh)
|
||||
|
||||
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}/examples/advanced/Region
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
Set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
Link_Directories(${LINK_DIRECTORIES})
|
||||
|
||||
Set(SRCS
|
||||
"FairMQExampleRegionSampler.cxx"
|
||||
"FairMQExampleRegionSink.cxx"
|
||||
)
|
||||
|
||||
Set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
FairMQ
|
||||
)
|
||||
|
||||
Set(LIBRARY_NAME FairMQExampleRegion)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
Set(Exe_Names
|
||||
ex-region-sampler
|
||||
ex-region-sink
|
||||
)
|
||||
|
||||
Set(Exe_Source
|
||||
runExampleRegionSampler.cxx
|
||||
runExampleRegionSink.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
set(BIN_DESTINATION share/fairbase/examples/advanced/Region/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/examples/advanced/Region")
|
||||
|
||||
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 FairMQExampleRegion)
|
||||
GENERATE_EXECUTABLE()
|
||||
EndForEach(_file RANGE 0 ${_length})
|
||||
|
||||
add_test(NAME MQ.ex-advanced-region COMMAND ${CMAKE_BINARY_DIR}/bin/examples/advanced/Region/testMQExRegion.sh)
|
||||
set_tests_properties(MQ.ex-advanced-region PROPERTIES TIMEOUT "30")
|
||||
set_tests_properties(MQ.ex-advanced-region PROPERTIES RUN_SERIAL true)
|
||||
set_tests_properties(MQ.ex-advanced-region PROPERTIES PASS_REGULAR_EXPRESSION "Received ack")
|
||||
|
||||
Install(
|
||||
FILES ex-region.json
|
||||
DESTINATION share/fairbase/examples/advanced/Region/config/
|
||||
)
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"fairMQOptions": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "sampler1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "push",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:7777",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sink1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:7777",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"rateLogging": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExampleRegionSink.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& options)
|
||||
{
|
||||
options.add_options()
|
||||
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExampleRegionSink();
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/bash
|
||||
exRegionConfig="@CMAKE_BINARY_DIR@/bin/config/ex-region.json"
|
||||
|
||||
msgSize="1000000"
|
||||
|
||||
if [[ $1 =~ ^[0-9]+$ ]]; then
|
||||
msgSize=$1
|
||||
fi
|
||||
|
||||
SAMPLER="ex-region-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --severity debug"
|
||||
SAMPLER+=" --msg-size $msgSize"
|
||||
# SAMPLER+=" --rate 10"
|
||||
SAMPLER+=" --transport shmem"
|
||||
SAMPLER+=" --mq-config $exRegionConfig"
|
||||
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/advanced/Region/$SAMPLER &
|
||||
|
||||
SINK="ex-region-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --severity debug"
|
||||
SINK+=" --transport shmem"
|
||||
SINK+=" --mq-config $exRegionConfig"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/advanced/Region/$SINK &
|
51
examples/copypush/CMakeLists.txt
Normal file
51
examples/copypush/CMakeLists.txt
Normal file
|
@ -0,0 +1,51 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
add_library(ExampleCopyPushLib STATIC
|
||||
"Sampler.cxx"
|
||||
"Sampler.h"
|
||||
"Sink.cxx"
|
||||
"Sink.h"
|
||||
)
|
||||
|
||||
target_link_libraries(ExampleCopyPushLib PUBLIC FairMQ)
|
||||
|
||||
add_executable(fairmq-ex-copypush-sampler runSampler.cxx)
|
||||
target_link_libraries(fairmq-ex-copypush-sampler PRIVATE ExampleCopyPushLib)
|
||||
|
||||
|
||||
add_executable(fairmq-ex-copypush-sink runSink.cxx)
|
||||
target_link_libraries(fairmq-ex-copypush-sink PRIVATE ExampleCopyPushLib)
|
||||
|
||||
add_custom_target(ExampleCopyPush DEPENDS fairmq-ex-copypush-sampler fairmq-ex-copypush-sink)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
fairmq-ex-copypush-sampler
|
||||
fairmq-ex-copypush-sink
|
||||
|
||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# configure run script with different executable paths for build and for install directories
|
||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh)
|
||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh_install)
|
||||
|
||||
install(
|
||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh_install
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
RENAME fairmq-start-ex-copypush.sh
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh)
|
||||
|
||||
add_test(NAME Example-CopyPush COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh)
|
||||
set_tests_properties(Example-CopyPush PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
|
@ -6,7 +6,7 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample4Sampler.cpp
|
||||
* Sampler.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
|
@ -15,13 +15,14 @@
|
|||
#include <thread> // this_thread::sleep_for
|
||||
#include <chrono>
|
||||
|
||||
#include "FairMQExample4Sampler.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
#include "Sampler.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample4Sampler::FairMQExample4Sampler()
|
||||
namespace example_copypush
|
||||
{
|
||||
|
||||
Sampler::Sampler()
|
||||
: fNumDataChannels(0)
|
||||
, fCounter(0)
|
||||
, fMaxIterations(0)
|
||||
|
@ -29,13 +30,13 @@ FairMQExample4Sampler::FairMQExample4Sampler()
|
|||
{
|
||||
}
|
||||
|
||||
void FairMQExample4Sampler::InitTask()
|
||||
void Sampler::InitTask()
|
||||
{
|
||||
fNumDataChannels = fChannels.at("data").size();
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
bool FairMQExample4Sampler::ConditionalRun()
|
||||
bool Sampler::ConditionalRun()
|
||||
{
|
||||
|
||||
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
||||
|
@ -61,6 +62,8 @@ bool FairMQExample4Sampler::ConditionalRun()
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample4Sampler::~FairMQExample4Sampler()
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_copypush
|
|
@ -6,24 +6,27 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample4Sampler.h
|
||||
* Sampler.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE4SAMPLER_H_
|
||||
#define FAIRMQEXAMPLE4SAMPLER_H_
|
||||
#ifndef FAIRMQEXAMPLECOPYPUSHSAMPLER_H
|
||||
#define FAIRMQEXAMPLECOPYPUSHSAMPLER_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
#include <stdint.h> // uint64_t
|
||||
|
||||
class FairMQExample4Sampler : public FairMQDevice
|
||||
namespace example_copypush
|
||||
{
|
||||
|
||||
class Sampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample4Sampler();
|
||||
virtual ~FairMQExample4Sampler();
|
||||
Sampler();
|
||||
virtual ~Sampler();
|
||||
|
||||
protected:
|
||||
virtual void InitTask();
|
||||
|
@ -35,4 +38,6 @@ class FairMQExample4Sampler : public FairMQDevice
|
|||
uint64_t fNumIterations;
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE4SAMPLER_H_ */
|
||||
} // namespace example_copypush
|
||||
|
||||
#endif /* FAIRMQEXAMPLECOPYPUSHSAMPLER_H */
|
|
@ -1,37 +1,36 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample4Sink.cxx
|
||||
* Sink.cxx
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQExample4Sink.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
#include "Sink.h"
|
||||
|
||||
#include <stdint.h> // uint64_t
|
||||
namespace example_copypush
|
||||
{
|
||||
|
||||
FairMQExample4Sink::FairMQExample4Sink()
|
||||
Sink::Sink()
|
||||
: fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
OnData("data", &FairMQExample4Sink::HandleData);
|
||||
OnData("data", &Sink::HandleData);
|
||||
}
|
||||
|
||||
void FairMQExample4Sink::InitTask()
|
||||
void Sink::InitTask()
|
||||
{
|
||||
// Get the fMaxIterations value from the command line options (via fConfig)
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
bool FairMQExample4Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received message: \"" << *(static_cast<uint64_t*>(msg->GetData())) << "\"";
|
||||
|
||||
|
@ -45,6 +44,8 @@ bool FairMQExample4Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample4Sink::~FairMQExample4Sink()
|
||||
Sink::~Sink()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_copypush
|
|
@ -1,27 +1,32 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample4Sink.h
|
||||
* Sink.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE4SINK_H_
|
||||
#define FAIRMQEXAMPLE4SINK_H_
|
||||
#ifndef FAIRMQEXAMPLECOPYPUSHSINK_H
|
||||
#define FAIRMQEXAMPLECOPYPUSHSINK_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample4Sink : public FairMQDevice
|
||||
#include <stdint.h> // uint64_t
|
||||
|
||||
namespace example_copypush
|
||||
{
|
||||
|
||||
class Sink : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample4Sink();
|
||||
virtual ~FairMQExample4Sink();
|
||||
Sink();
|
||||
virtual ~Sink();
|
||||
|
||||
protected:
|
||||
virtual void InitTask();
|
||||
|
@ -32,4 +37,6 @@ class FairMQExample4Sink : public FairMQDevice
|
|||
uint64_t fNumIterations;
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE4SINK_H_ */
|
||||
} // namespace example_copypush
|
||||
|
||||
#endif /* FAIRMQEXAMPLECOPYPUSHSINK_H */
|
16
examples/copypush/fairmq-start-ex-copypush.sh.in
Executable file
16
examples/copypush/fairmq-start-ex-copypush.sh.in
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
SAMPLER="fairmq-ex-copypush-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555,address=tcp://*:5556"
|
||||
xterm -geometry 80x23+0+165 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||
|
||||
SINK1="fairmq-ex-copypush-sink"
|
||||
SINK1+=" --id sink1"
|
||||
SINK1+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555"
|
||||
xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK1 &
|
||||
|
||||
SINK2="fairmq-ex-copypush-sink"
|
||||
SINK2+=" --id sink2"
|
||||
SINK2+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5556"
|
||||
xterm -geometry 80x23+500+330 -hold -e @EX_BIN_DIR@/$SINK2 &
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample2Sink.h"
|
||||
#include "Sampler.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample2Sink();
|
||||
return new example_copypush::Sampler();
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample1Sink.h"
|
||||
#include "Sink.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample1Sink();
|
||||
return new example_copypush::Sink();
|
||||
}
|
|
@ -1,35 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
ex4config="@CMAKE_BINARY_DIR@/bin/config/ex4-copypush.json"
|
||||
|
||||
# setup a trap to kill everything if the test fails/timeouts
|
||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK1_PID; kill -TERM $SINK2_PID; wait $SAMPLER_PID; wait $SINK1_PID; wait $SINK2_PID;' TERM
|
||||
|
||||
SAMPLER="ex4-sampler"
|
||||
SAMPLER="fairmq-ex-copypush-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --verbosity veryhigh"
|
||||
SAMPLER+=" --control static --color false"
|
||||
SAMPLER+=" --max-iterations 1"
|
||||
SAMPLER+=" --mq-config $ex4config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SAMPLER &
|
||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555,address=tcp://*:5556"
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||
SAMPLER_PID=$!
|
||||
|
||||
SINK1="ex4-sink"
|
||||
SINK1="fairmq-ex-copypush-sink"
|
||||
SINK1+=" --id sink1"
|
||||
SINK1+=" --verbosity veryhigh"
|
||||
SINK1+=" --control static --color false"
|
||||
SINK1+=" --max-iterations 1"
|
||||
SINK1+=" --mq-config $ex4config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK1 &
|
||||
SINK1+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555"
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK1 &
|
||||
SINK1_PID=$!
|
||||
|
||||
SINK2="ex4-sink"
|
||||
SINK2="fairmq-ex-copypush-sink"
|
||||
SINK2+=" --id sink2"
|
||||
SINK2+=" --verbosity veryhigh"
|
||||
SINK2+=" --control static --color false"
|
||||
SINK2+=" --max-iterations 1"
|
||||
SINK2+=" --mq-config $ex4config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/4-copypush/$SINK2 &
|
||||
SINK2+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5556"
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK2 &
|
||||
SINK2_PID=$!
|
||||
|
||||
# wait for everything to finish
|
60
examples/dds/CMakeLists.txt
Normal file
60
examples/dds/CMakeLists.txt
Normal file
|
@ -0,0 +1,60 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
add_library(ExampleDDSLib STATIC
|
||||
"Sampler.cxx"
|
||||
"Sampler.h"
|
||||
"Processor.cxx"
|
||||
"Processor.h"
|
||||
"Sink.cxx"
|
||||
"Sink.h"
|
||||
)
|
||||
|
||||
target_link_libraries(ExampleDDSLib PUBLIC FairMQ)
|
||||
|
||||
add_executable(fairmq-ex-dds-sampler runSampler.cxx)
|
||||
target_link_libraries(fairmq-ex-dds-sampler PRIVATE ExampleDDSLib)
|
||||
|
||||
add_executable(fairmq-ex-dds-processor runProcessor.cxx)
|
||||
target_link_libraries(fairmq-ex-dds-processor PRIVATE ExampleDDSLib)
|
||||
|
||||
add_executable(fairmq-ex-dds-sink runSink.cxx)
|
||||
target_link_libraries(fairmq-ex-dds-sink PRIVATE ExampleDDSLib)
|
||||
|
||||
add_custom_target(ExampleDDS DEPENDS fairmq-ex-dds-sampler fairmq-ex-dds-processor fairmq-ex-dds-sink)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
fairmq-ex-dds-sampler
|
||||
fairmq-ex-dds-processor
|
||||
fairmq-ex-dds-sink
|
||||
|
||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# configure run script with different executable paths for build and for install directories
|
||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(DDS_PLUGIN_LIB_DIR ${CMAKE_BINARY_DIR}/fairmq/plugins/DDS)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml @ONLY)
|
||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||
set(DDS_PLUGIN_LIB_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_LIBDIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-topology.xml ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml_install @ONLY)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-dds-hosts.cfg ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-hosts.cfg COPYONLY)
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-topology.xml_install
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
RENAME ex-dds-topology.xml
|
||||
)
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-dds-hosts.cfg
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
)
|
|
@ -1,22 +1,25 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "FairMQExample3Processor.h"
|
||||
#include "Processor.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample3Processor::FairMQExample3Processor()
|
||||
namespace example_dds
|
||||
{
|
||||
OnData("data1", &FairMQExample3Processor::HandleData);
|
||||
|
||||
Processor::Processor()
|
||||
{
|
||||
OnData("data1", &Processor::HandleData);
|
||||
}
|
||||
|
||||
bool FairMQExample3Processor::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Processor::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received data, processing...";
|
||||
|
||||
|
@ -42,6 +45,8 @@ bool FairMQExample3Processor::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample3Processor::~FairMQExample3Processor()
|
||||
Processor::~Processor()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_dds
|
|
@ -6,19 +6,24 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE2PROCESSOR_H_
|
||||
#define FAIRMQEXAMPLE2PROCESSOR_H_
|
||||
#ifndef FAIRMQEXAMPLEDDSPROCESSOR_H
|
||||
#define FAIRMQEXAMPLEDDSPROCESSOR_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample3Processor : public FairMQDevice
|
||||
namespace example_dds
|
||||
{
|
||||
|
||||
class Processor : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample3Processor();
|
||||
virtual ~FairMQExample3Processor();
|
||||
Processor();
|
||||
virtual ~Processor();
|
||||
|
||||
protected:
|
||||
bool HandleData(FairMQMessagePtr&, int);
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE3PROCESSOR_H_ */
|
||||
}
|
||||
|
||||
#endif /* FAIRMQEXAMPLEDDSPROCESSOR_H */
|
|
@ -6,7 +6,7 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample3Sampler.cpp
|
||||
* Sampler.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
|
@ -15,17 +15,18 @@
|
|||
#include <thread> // this_thread::sleep_for
|
||||
#include <chrono>
|
||||
|
||||
#include "FairMQExample3Sampler.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
#include "Sampler.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample3Sampler::FairMQExample3Sampler()
|
||||
namespace example_dds
|
||||
{
|
||||
|
||||
Sampler::Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
bool FairMQExample3Sampler::ConditionalRun()
|
||||
bool Sampler::ConditionalRun()
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
|
||||
|
@ -45,6 +46,8 @@ bool FairMQExample3Sampler::ConditionalRun()
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample3Sampler::~FairMQExample3Sampler()
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -6,25 +6,30 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample6Broadcaster.h
|
||||
* Sampler.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE6BROADCASTER_H_
|
||||
#define FAIRMQEXAMPLE6BROADCASTER_H_
|
||||
#ifndef FAIRMQEXAMPLEDDSSAMPLER_H
|
||||
#define FAIRMQEXAMPLEDDSSAMPLER_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample6Broadcaster : public FairMQDevice
|
||||
namespace example_dds
|
||||
{
|
||||
|
||||
class Sampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample6Broadcaster();
|
||||
virtual ~FairMQExample6Broadcaster();
|
||||
Sampler();
|
||||
virtual ~Sampler();
|
||||
|
||||
protected:
|
||||
virtual bool ConditionalRun();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE6BROADCASTER_H_ */
|
||||
} // namespace example_dds
|
||||
|
||||
#endif /* FAIRMQEXAMPLEDDSSAMPLER_H */
|
|
@ -6,25 +6,27 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample3Sink.cxx
|
||||
* Sink.cxx
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQExample3Sink.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "Sink.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample3Sink::FairMQExample3Sink()
|
||||
namespace example_dds
|
||||
{
|
||||
|
||||
Sink::Sink()
|
||||
{
|
||||
// register a handler for data arriving on "data2" channel
|
||||
OnData("data2", &FairMQExample3Sink::HandleData);
|
||||
OnData("data2", &Sink::HandleData);
|
||||
}
|
||||
|
||||
// handler is called whenever a message arrives on "data2", with a reference to the message and a sub-channel index (here 0)
|
||||
bool FairMQExample3Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received: \"" << string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||
|
||||
|
@ -32,6 +34,8 @@ bool FairMQExample3Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample3Sink::~FairMQExample3Sink()
|
||||
Sink::~Sink()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_dds
|
|
@ -1,30 +1,35 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample3Sink.h
|
||||
* Sink.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE3SINK_H_
|
||||
#define FAIRMQEXAMPLE3SINK_H_
|
||||
#ifndef FAIRMQEXAMPLEDDSSINK_H
|
||||
#define FAIRMQEXAMPLEDDSSINK_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample3Sink : public FairMQDevice
|
||||
namespace example_dds
|
||||
{
|
||||
|
||||
class Sink : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample3Sink();
|
||||
virtual ~FairMQExample3Sink();
|
||||
Sink();
|
||||
virtual ~Sink();
|
||||
|
||||
protected:
|
||||
bool HandleData(FairMQMessagePtr&, int);
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE3SINK_H_ */
|
||||
} // namespace example_dds
|
||||
|
||||
#endif /* FAIRMQEXAMPLEDDSSINK_H */
|
|
@ -8,7 +8,7 @@
|
|||
<declrequirement id="SinkWorker" type="wnname" value="sink"/>
|
||||
|
||||
<decltask id="Sampler">
|
||||
<exe reachable="true">@CMAKE_BINARY_DIR@/bin/examples/MQ/3-dds/ex3-sampler --id sampler --color false --channel-config name=data1,type=push,method=bind -S "<@CMAKE_BINARY_DIR@/lib" -P dds</exe>
|
||||
<exe reachable="true">@EX_BIN_DIR@/fairmq-ex-dds-sampler --id sampler --color false --channel-config name=data1,type=push,method=bind -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds</exe>
|
||||
<requirements>
|
||||
<id>SamplerWorker</id>
|
||||
</requirements>
|
||||
|
@ -18,7 +18,7 @@
|
|||
</decltask>
|
||||
|
||||
<decltask id="Processor">
|
||||
<exe reachable="true">@CMAKE_BINARY_DIR@/bin/examples/MQ/3-dds/ex3-processor --id processor_%taskIndex% --config-key processor --color false --channel-config name=data1,type=pull,method=connect name=data2,type=push,method=connect -S "<@CMAKE_BINARY_DIR@/lib" -P dds</exe>
|
||||
<exe reachable="true">@EX_BIN_DIR@/fairmq-ex-dds-processor --id processor_%taskIndex% --config-key processor --color false --channel-config name=data1,type=pull,method=connect name=data2,type=push,method=connect -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds</exe>
|
||||
<requirements>
|
||||
<id>ProcessorWorker</id>
|
||||
</requirements>
|
||||
|
@ -29,7 +29,7 @@
|
|||
</decltask>
|
||||
|
||||
<decltask id="Sink">
|
||||
<exe reachable="true">@CMAKE_BINARY_DIR@/bin/examples/MQ/3-dds/ex3-sink --id sink --color false --channel-config name=data2,type=pull,method=bind -S "<@CMAKE_BINARY_DIR@/lib" -P dds</exe>
|
||||
<exe reachable="true">@EX_BIN_DIR@/fairmq-ex-dds-sink --id sink --color false --channel-config name=data2,type=pull,method=bind -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds</exe>
|
||||
<requirements>
|
||||
<id>SinkWorker</id>
|
||||
</requirements>
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample8Sink.h"
|
||||
#include "Processor.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample8Sink();
|
||||
return new example_dds::Processor();
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample3Sampler.h"
|
||||
#include "Sampler.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample3Sampler();
|
||||
return new example_dds::Sampler();
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExample3Processor.h"
|
||||
#include "Sink.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -17,5 +17,5 @@ void addCustomOptions(bpo::options_description& /*options*/)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExample3Processor();
|
||||
return new example_dds::Sink();
|
||||
}
|
50
examples/multipart/CMakeLists.txt
Normal file
50
examples/multipart/CMakeLists.txt
Normal file
|
@ -0,0 +1,50 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
add_library(ExampleMultipartLib STATIC
|
||||
"Sampler.cxx"
|
||||
"Sampler.h"
|
||||
"Sink.cxx"
|
||||
"Sink.h"
|
||||
)
|
||||
|
||||
target_link_libraries(ExampleMultipartLib PUBLIC FairMQ)
|
||||
|
||||
add_executable(fairmq-ex-multipart-sampler runSampler.cxx)
|
||||
target_link_libraries(fairmq-ex-multipart-sampler PRIVATE ExampleMultipartLib)
|
||||
|
||||
add_executable(fairmq-ex-multipart-sink runSink.cxx)
|
||||
target_link_libraries(fairmq-ex-multipart-sink PRIVATE ExampleMultipartLib)
|
||||
|
||||
add_custom_target(ExampleMultipart DEPENDS fairmq-ex-multipart-sampler fairmq-ex-multipart-sink)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
fairmq-ex-multipart-sampler
|
||||
fairmq-ex-multipart-sink
|
||||
|
||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# configure run script with different executable paths for build and for install directories
|
||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh)
|
||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh_install)
|
||||
|
||||
install(
|
||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh_install
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
RENAME fairmq-start-ex-multipart.sh
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh)
|
||||
|
||||
add_test(NAME Example-Multipart COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh)
|
||||
set_tests_properties(Example-Multipart PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 2 parts")
|
|
@ -1,17 +1,22 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef FAIRMQEX8HEADER_H_
|
||||
#define FAIRMQEX8HEADER_H_
|
||||
#ifndef FAIRMQEXAMPLEMULTIPARTHEADER_H
|
||||
#define FAIRMQEXAMPLEMULTIPARTHEADER_H
|
||||
|
||||
struct Ex8Header
|
||||
namespace example_multipart
|
||||
{
|
||||
|
||||
struct Header
|
||||
{
|
||||
int32_t stopFlag;
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEX8HEADER_H_ */
|
||||
}
|
||||
|
||||
#endif /* FAIRMQEXAMPLEMULTIPARTHEADER_H */
|
|
@ -1,12 +1,12 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample8Sampler.cpp
|
||||
* Sampler.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
|
@ -15,27 +15,28 @@
|
|||
#include <thread> // this_thread::sleep_for
|
||||
#include <chrono>
|
||||
|
||||
#include "FairMQExample8Sampler.h"
|
||||
#include "FairMQEx8Header.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h"
|
||||
#include "Sampler.h"
|
||||
#include "Header.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample8Sampler::FairMQExample8Sampler()
|
||||
namespace example_multipart
|
||||
{
|
||||
|
||||
Sampler::Sampler()
|
||||
: fMaxIterations(5)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQExample8Sampler::InitTask()
|
||||
void Sampler::InitTask()
|
||||
{
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
bool FairMQExample8Sampler::ConditionalRun()
|
||||
bool Sampler::ConditionalRun()
|
||||
{
|
||||
Ex8Header header;
|
||||
Header header;
|
||||
header.stopFlag = 0;
|
||||
|
||||
// Set stopFlag to 1 for last message.
|
||||
|
@ -54,7 +55,7 @@ bool FairMQExample8Sampler::ConditionalRun()
|
|||
|
||||
LOG(info) << "Sending body of size: " << parts.At(1)->GetSize();
|
||||
|
||||
Send(parts, "data-out");
|
||||
Send(parts, "data");
|
||||
|
||||
// Go out of the sending loop if the stopFlag was sent.
|
||||
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations)
|
||||
|
@ -69,6 +70,8 @@ bool FairMQExample8Sampler::ConditionalRun()
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample8Sampler::~FairMQExample8Sampler()
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace example_multipart
|
|
@ -1,27 +1,30 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample8Sampler.h
|
||||
* Sampler.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE8SAMPLER_H_
|
||||
#define FAIRMQEXAMPLE8SAMPLER_H_
|
||||
#ifndef FAIRMQEXAMPLEDDSSAMPLER_H
|
||||
#define FAIRMQEXAMPLEDDSSAMPLER_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample8Sampler : public FairMQDevice
|
||||
namespace example_multipart
|
||||
{
|
||||
|
||||
class Sampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample8Sampler();
|
||||
virtual ~FairMQExample8Sampler();
|
||||
Sampler();
|
||||
virtual ~Sampler();
|
||||
|
||||
protected:
|
||||
virtual void InitTask();
|
||||
|
@ -32,4 +35,6 @@ class FairMQExample8Sampler : public FairMQDevice
|
|||
uint64_t fNumIterations;
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE8SAMPLER_H_ */
|
||||
} // namespace example_multipart
|
||||
|
||||
#endif /* FAIRMQEXAMPLEDDSSAMPLER_H */
|
|
@ -6,27 +6,29 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample8Sink.cxx
|
||||
* Sink.cxx
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQExample8Sink.h"
|
||||
#include "FairMQEx8Header.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "Sink.h"
|
||||
#include "Header.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample8Sink::FairMQExample8Sink()
|
||||
namespace example_multipart
|
||||
{
|
||||
OnData("data-in", &FairMQExample8Sink::HandleData);
|
||||
|
||||
Sink::Sink()
|
||||
{
|
||||
OnData("data", &Sink::HandleData);
|
||||
}
|
||||
|
||||
bool FairMQExample8Sink::HandleData(FairMQParts& parts, int /*index*/)
|
||||
bool Sink::HandleData(FairMQParts& parts, int /*index*/)
|
||||
{
|
||||
Ex8Header header;
|
||||
header.stopFlag = (static_cast<Ex8Header*>(parts.At(0)->GetData()))->stopFlag;
|
||||
Header header;
|
||||
header.stopFlag = (static_cast<Header*>(parts.At(0)->GetData()))->stopFlag;
|
||||
|
||||
LOG(info) << "Received message with " << parts.Size() << " parts";
|
||||
|
||||
|
@ -42,6 +44,8 @@ bool FairMQExample8Sink::HandleData(FairMQParts& parts, int /*index*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample8Sink::~FairMQExample8Sink()
|
||||
Sink::~Sink()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +1,34 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample8Sink.h
|
||||
* Sink.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE8SINK_H_
|
||||
#define FAIRMQEXAMPLE8SINK_H_
|
||||
#ifndef FAIRMQEXAMPLEMULTIPARTSINK_H
|
||||
#define FAIRMQEXAMPLEMULTIPARTSINK_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample8Sink : public FairMQDevice
|
||||
namespace example_multipart
|
||||
{
|
||||
|
||||
class Sink : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample8Sink();
|
||||
virtual ~FairMQExample8Sink();
|
||||
Sink();
|
||||
virtual ~Sink();
|
||||
|
||||
protected:
|
||||
bool HandleData(FairMQParts&, int);
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE8SINK_H_ */
|
||||
}
|
||||
#endif /* FAIRMQEXAMPLEMULTIPARTSINK_H */
|
|
@ -5,7 +5,7 @@
|
|||
"id": "sampler1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data-out",
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "push",
|
||||
|
@ -23,7 +23,7 @@
|
|||
"id": "sink1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data-in",
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
|
@ -41,7 +41,7 @@
|
|||
"id": "sink2",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data-in",
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
11
examples/multipart/fairmq-start-ex-multipart.sh.in
Executable file
11
examples/multipart/fairmq-start-ex-multipart.sh.in
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
SAMPLER="fairmq-ex-multipart-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --channel-config name=data,type=push,method=connect,rateLogging=0,address=tcp://127.0.0.1:5555"
|
||||
xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||
|
||||
SINK="fairmq-ex-multipart-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --channel-config name=data,type=pull,method=bind,rateLogging=0,address=tcp://127.0.0.1:5555"
|
||||
xterm -geometry 80x23+500+0 -hold -e @EX_BIN_DIR@/$SINK &
|
|
@ -1,13 +1,13 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExampleMTSink.h"
|
||||
#include "Sampler.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
|
@ -19,5 +19,5 @@ void addCustomOptions(bpo::options_description& options)
|
|||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExampleMTSink();
|
||||
return new example_multipart::Sampler();
|
||||
}
|
21
examples/multipart/runSink.cxx
Normal file
21
examples/multipart/runSink.cxx
Normal file
|
@ -0,0 +1,21 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "Sink.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& /*options*/)
|
||||
{
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new example_multipart::Sink();
|
||||
}
|
|
@ -1,24 +1,23 @@
|
|||
#!/bin/bash
|
||||
ex8config="@CMAKE_BINARY_DIR@/bin/config/ex8-multipart.json"
|
||||
|
||||
# setup a trap to kill everything if the test fails/timeouts
|
||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID;' TERM
|
||||
|
||||
SAMPLER="ex8-sampler"
|
||||
SAMPLER="fairmq-ex-multipart-sampler"
|
||||
SAMPLER+=" --id sampler1"
|
||||
SAMPLER+=" --verbosity veryhigh"
|
||||
SAMPLER+=" --max-iterations 1"
|
||||
SAMPLER+=" --control static --color false"
|
||||
SAMPLER+=" --mq-config $ex8config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SAMPLER &
|
||||
SAMPLER+=" --channel-config name=data,type=push,method=connect,rateLogging=0,address=tcp://127.0.0.1:5555"
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||
SAMPLER_PID=$!
|
||||
|
||||
SINK="ex8-sink"
|
||||
SINK="fairmq-ex-multipart-sink"
|
||||
SINK+=" --id sink1"
|
||||
SINK+=" --verbosity veryhigh"
|
||||
SINK+=" --control static --color false"
|
||||
SINK+=" --mq-config $ex8config"
|
||||
@CMAKE_BINARY_DIR@/bin/examples/MQ/8-multipart/$SINK &
|
||||
SINK+=" --channel-config name=data,type=pull,method=bind,rateLogging=0,address=tcp://127.0.0.1:5555"
|
||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||
SINK_PID=$!
|
||||
|
||||
wait $SAMPLER_PID
|
|
@ -6,7 +6,7 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample6Broadcaster.cpp
|
||||
* Broadcaster.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
|
@ -15,16 +15,18 @@
|
|||
#include <thread> // this_thread::sleep_for
|
||||
#include <chrono>
|
||||
|
||||
#include "FairMQExample6Broadcaster.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "Broadcaster.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample6Broadcaster::FairMQExample6Broadcaster()
|
||||
namespace example_multiple_channels
|
||||
{
|
||||
|
||||
Broadcaster::Broadcaster()
|
||||
{
|
||||
}
|
||||
|
||||
bool FairMQExample6Broadcaster::ConditionalRun()
|
||||
bool Broadcaster::ConditionalRun()
|
||||
{
|
||||
this_thread::sleep_for(chrono::seconds(1));
|
||||
|
||||
|
@ -39,6 +41,8 @@ bool FairMQExample6Broadcaster::ConditionalRun()
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample6Broadcaster::~FairMQExample6Broadcaster()
|
||||
Broadcaster::~Broadcaster()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +1,35 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample3Sampler.h
|
||||
* Broadcaster.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE3SAMPLER_H_
|
||||
#define FAIRMQEXAMPLE3SAMPLER_H_
|
||||
#ifndef FAIRMQEXAMPLEMULTIPLECHANNELSBROADCASTER_H
|
||||
#define FAIRMQEXAMPLEMULTIPLECHANNELSBROADCASTER_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample3Sampler : public FairMQDevice
|
||||
namespace example_multiple_channels
|
||||
{
|
||||
|
||||
class Broadcaster : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample3Sampler();
|
||||
virtual ~FairMQExample3Sampler();
|
||||
Broadcaster();
|
||||
virtual ~Broadcaster();
|
||||
|
||||
protected:
|
||||
virtual bool ConditionalRun();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE3SAMPLER_H_ */
|
||||
}
|
||||
|
||||
#endif /* FAIRMQEXAMPLEMULTIPLECHANNELSBROADCASTER_H */
|
56
examples/multiple-channels/CMakeLists.txt
Normal file
56
examples/multiple-channels/CMakeLists.txt
Normal file
|
@ -0,0 +1,56 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
add_library(ExampleMultipleChannelsLib STATIC
|
||||
"Sampler.cxx"
|
||||
"Sampler.h"
|
||||
"Broadcaster.cxx"
|
||||
"Broadcaster.h"
|
||||
"Sink.cxx"
|
||||
"Sink.h"
|
||||
)
|
||||
|
||||
target_link_libraries(ExampleMultipleChannelsLib PUBLIC FairMQ)
|
||||
|
||||
add_executable(fairmq-ex-multiple-channels-sampler runSampler.cxx)
|
||||
target_link_libraries(fairmq-ex-multiple-channels-sampler PRIVATE ExampleMultipleChannelsLib)
|
||||
|
||||
add_executable(fairmq-ex-multiple-channels-broadcaster runBroadcaster.cxx)
|
||||
target_link_libraries(fairmq-ex-multiple-channels-broadcaster PRIVATE ExampleMultipleChannelsLib)
|
||||
|
||||
add_executable(fairmq-ex-multiple-channels-sink runSink.cxx)
|
||||
target_link_libraries(fairmq-ex-multiple-channels-sink PRIVATE ExampleMultipleChannelsLib)
|
||||
|
||||
add_custom_target(ExampleMultipleChannels DEPENDS fairmq-ex-multiple-channels-sampler fairmq-ex-multiple-channels-broadcaster fairmq-ex-multiple-channels-sink)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
fairmq-ex-multiple-channels-sampler
|
||||
fairmq-ex-multiple-channels-broadcaster
|
||||
fairmq-ex-multiple-channels-sink
|
||||
|
||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# configure run script with different executable paths for build and for install directories
|
||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh)
|
||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh_install)
|
||||
|
||||
install(
|
||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh_install
|
||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||
RENAME fairmq-start-ex-multiple-channels.sh
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh)
|
||||
|
||||
add_test(NAME Example-Multiple-Channels COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh)
|
||||
set_tests_properties(Example-Multiple-Channels PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
|
@ -6,7 +6,7 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample6Sampler.cpp
|
||||
* Sampler.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
|
@ -16,27 +16,28 @@
|
|||
#include <thread> // this_thread::sleep_for
|
||||
#include <chrono>
|
||||
|
||||
#include "FairMQExample6Sampler.h"
|
||||
#include "Sampler.h"
|
||||
#include "FairMQPoller.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample6Sampler::FairMQExample6Sampler()
|
||||
namespace example_multiple_channels
|
||||
{
|
||||
|
||||
Sampler::Sampler()
|
||||
: fText()
|
||||
, fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQExample6Sampler::InitTask()
|
||||
void Sampler::InitTask()
|
||||
{
|
||||
fText = fConfig->GetValue<string>("text");
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
void FairMQExample6Sampler::Run()
|
||||
void Sampler::Run()
|
||||
{
|
||||
FairMQPollerPtr poller(NewPoller("data", "broadcast"));
|
||||
|
||||
|
@ -74,6 +75,8 @@ void FairMQExample6Sampler::Run()
|
|||
}
|
||||
}
|
||||
|
||||
FairMQExample6Sampler::~FairMQExample6Sampler()
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -6,24 +6,27 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample6Sampler.h
|
||||
* Sampler.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLE6SAMPLER_H_
|
||||
#define FAIRMQEXAMPLE6SAMPLER_H_
|
||||
#ifndef FAIRMQEXAMPLEMULTIPLECHANNELSSAMPLER_H
|
||||
#define FAIRMQEXAMPLEMULTIPLECHANNELSSAMPLER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExample6Sampler : public FairMQDevice
|
||||
namespace example_multiple_channels
|
||||
{
|
||||
|
||||
class Sampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExample6Sampler();
|
||||
virtual ~FairMQExample6Sampler();
|
||||
Sampler();
|
||||
virtual ~Sampler();
|
||||
|
||||
protected:
|
||||
std::string fText;
|
||||
|
@ -34,4 +37,6 @@ class FairMQExample6Sampler : public FairMQDevice
|
|||
virtual void InitTask();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLE6SAMPLER_H_ */
|
||||
}
|
||||
|
||||
#endif /* FAIRMQEXAMPLEMULTIPLECHANNELSSAMPLER_H */
|
|
@ -1,41 +1,40 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExample6Sink.cxx
|
||||
* Sink.cxx
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "FairMQExample6Sink.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h"
|
||||
#include "Sink.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample6Sink::FairMQExample6Sink()
|
||||
namespace example_multiple_channels
|
||||
{
|
||||
|
||||
Sink::Sink()
|
||||
: fReceivedData(false)
|
||||
, fReceivedBroadcast(false)
|
||||
, fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
OnData("broadcast", &FairMQExample6Sink::HandleBroadcast);
|
||||
OnData("data", &FairMQExample6Sink::HandleData);
|
||||
OnData("broadcast", &Sink::HandleBroadcast);
|
||||
OnData("data", &Sink::HandleData);
|
||||
}
|
||||
|
||||
void FairMQExample6Sink::InitTask()
|
||||
void Sink::InitTask()
|
||||
{
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
bool FairMQExample6Sink::HandleBroadcast(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Sink::HandleBroadcast(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received broadcast: \"" << string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||
fReceivedBroadcast = true;
|
||||
|
@ -43,7 +42,7 @@ bool FairMQExample6Sink::HandleBroadcast(FairMQMessagePtr& msg, int /*index*/)
|
|||
return CheckIterations();
|
||||
}
|
||||
|
||||
bool FairMQExample6Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
bool Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
||||
{
|
||||
LOG(info) << "Received message: \"" << string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||
fReceivedData = true;
|
||||
|
@ -51,7 +50,7 @@ bool FairMQExample6Sink::HandleData(FairMQMessagePtr& msg, int /*index*/)
|
|||
return CheckIterations();
|
||||
}
|
||||
|
||||
bool FairMQExample6Sink::CheckIterations()
|
||||
bool Sink::CheckIterations()
|
||||
{
|
||||
if (fMaxIterations > 0)
|
||||
{
|
||||
|
@ -65,6 +64,8 @@ bool FairMQExample6Sink::CheckIterations()
|
|||
return true;
|
||||
}
|
||||
|
||||
FairMQExample6Sink::~FairMQExample6Sink()
|
||||
Sink::~Sink()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user