mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-14 17:16:47 +00:00
FairMQRegion and examples/advanced/Region
This commit is contained in:
parent
ae4e474261
commit
f6ee1cdf57
79
examples/advanced/Region/CMakeLists.txt
Normal file
79
examples/advanced/Region/CMakeLists.txt
Normal file
|
@ -0,0 +1,79 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence version 3 (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
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)
|
||||
|
||||
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})
|
||||
|
||||
Install(
|
||||
FILES ex-region.json
|
||||
DESTINATION share/fairbase/examples/advanced/Region/config/
|
||||
)
|
46
examples/advanced/Region/FairMQExampleRegionSampler.cxx
Normal file
46
examples/advanced/Region/FairMQExampleRegionSampler.cxx
Normal file
|
@ -0,0 +1,46 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExampleRegionSampler.cpp
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQExampleRegionSampler.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExampleRegionSampler::FairMQExampleRegionSampler()
|
||||
: fMsgSize(10000)
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQExampleRegionSampler::InitTask()
|
||||
{
|
||||
fMsgSize = fConfig->GetValue<int>("msg-size");
|
||||
}
|
||||
|
||||
void FairMQExampleRegionSampler::Run()
|
||||
{
|
||||
FairMQChannel& dataOutChannel = fChannels.at("data").at(0);
|
||||
|
||||
FairMQRegionPtr region(NewRegionFor("data", 0, 10000000));
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
FairMQMessagePtr msg(NewMessageFor("data", 0, region, region->GetData(), fMsgSize));
|
||||
dataOutChannel.Send(msg);
|
||||
}
|
||||
}
|
||||
|
||||
FairMQExampleRegionSampler::~FairMQExampleRegionSampler()
|
||||
{
|
||||
}
|
35
examples/advanced/Region/FairMQExampleRegionSampler.h
Normal file
35
examples/advanced/Region/FairMQExampleRegionSampler.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExampleRegionSampler.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLEREGIONSAMPLER_H_
|
||||
#define FAIRMQEXAMPLEREGIONSAMPLER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExampleRegionSampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExampleRegionSampler();
|
||||
virtual ~FairMQExampleRegionSampler();
|
||||
|
||||
protected:
|
||||
int fMsgSize;
|
||||
|
||||
virtual void InitTask();
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLEREGIONSAMPLER_H_ */
|
37
examples/advanced/Region/FairMQExampleRegionSink.cxx
Normal file
37
examples/advanced/Region/FairMQExampleRegionSink.cxx
Normal file
|
@ -0,0 +1,37 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExampleRegionSink.cxx
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQExampleRegionSink.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExampleRegionSink::FairMQExampleRegionSink()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQExampleRegionSink::Run()
|
||||
{
|
||||
FairMQChannel& dataInChannel = fChannels.at("data").at(0);
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
FairMQMessagePtr msg(dataInChannel.Transport()->CreateMessage());
|
||||
dataInChannel.Receive(msg);
|
||||
}
|
||||
}
|
||||
|
||||
FairMQExampleRegionSink::~FairMQExampleRegionSink()
|
||||
{
|
||||
}
|
32
examples/advanced/Region/FairMQExampleRegionSink.h
Normal file
32
examples/advanced/Region/FairMQExampleRegionSink.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQExampleRegionSink.h
|
||||
*
|
||||
* @since 2014-10-10
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQEXAMPLEREGIONSINK_H_
|
||||
#define FAIRMQEXAMPLEREGIONSINK_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQExampleRegionSink : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQExampleRegionSink();
|
||||
virtual ~FairMQExampleRegionSink();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQEXAMPLEREGIONSINK_H_ */
|
42
examples/advanced/Region/ex-region.json
Normal file
42
examples/advanced/Region/ex-region.json
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
23
examples/advanced/Region/runExampleRegionSampler.cxx
Normal file
23
examples/advanced/Region/runExampleRegionSampler.cxx
Normal file
|
@ -0,0 +1,23 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runFairMQDevice.h"
|
||||
#include "FairMQExampleRegionSampler.h"
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
|
||||
void addCustomOptions(bpo::options_description& options)
|
||||
{
|
||||
options.add_options()
|
||||
("msg-size", bpo::value<int>()->default_value(1000), "Message size in bytes");
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExampleRegionSampler();
|
||||
}
|
21
examples/advanced/Region/runExampleRegionSink.cxx
Normal file
21
examples/advanced/Region/runExampleRegionSink.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 version 3 (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)
|
||||
{
|
||||
}
|
||||
|
||||
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/)
|
||||
{
|
||||
return new FairMQExampleRegionSink();
|
||||
}
|
21
examples/advanced/Region/startMQExRegion.sh.in
Executable file
21
examples/advanced/Region/startMQExRegion.sh.in
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/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+=" --msg-size $msgSize"
|
||||
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+=" --transport shmem"
|
||||
SINK+=" --mq-config $exRegionConfig"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/advanced/Region/$SINK &
|
Loading…
Reference in New Issue
Block a user