Skip to content

Commit 40f4012

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 85292e0 + ef51031 commit 40f4012

File tree

9 files changed

+243
-147
lines changed

9 files changed

+243
-147
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,15 @@ include_directories(
6767
${Boost_INCLUDE_DIRS}
6868
${Monitoring_INCLUDE_DIRS}
6969
${FAIRROOT_INCLUDE_DIR}
70-
${FAIRROOT_INCLUDE_DIR}/fairmq
70+
${_fairmq_incdir}
71+
${_fairlogger_incdir}
7172
${ZeroMQ_INCLUDE_DIR}
7273
${Common_INCLUDE_DIRS}
7374
${Configuration_INCLUDE_DIRS}
7475
${InfoLogger_INCLUDE_DIRS}
7576
${ReadoutCard_INCLUDE_DIRS}
7677
${DataSampling_INCLUDE_DIRS}
77-
${Numa_INCLUDE_DIRS}
78+
${Numa_INCLUDE_DIRS}
7879
)
7980

8081
add_library(

cmake/FindFairMQInFairRoot.cmake

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# DEPRECATED: Remove this file, once we require FairMQ 1.2+
2+
#
3+
# Simple check for availability of FairMQ
4+
#
5+
# The FairMQ module of FairRoot might be disabled in the built of FairRoot
6+
# due to missing dependencies, e.g ZeroMQ and boost. Those dependencies
7+
# also have to be available in the required (minimal) version.
8+
#
9+
10+
if(FairRoot_DIR)
11+
set(FAIRROOTPATH ${FairRoot_DIR})
12+
else()
13+
set(FAIRROOTPATH $ENV{FAIRROOTPATH})
14+
endif(FairRoot_DIR)
15+
16+
if(FAIRROOTPATH)
17+
if(NOT FairMQInFairRoot_FIND_QUIETLY)
18+
MESSAGE(STATUS "FairRoot ... - found ${FAIRROOTPATH}")
19+
endif(NOT FairMQInFairRoot_FIND_QUIETLY)
20+
else()
21+
if(NOT FairMQInFairRoot_FIND_QUIETLY)
22+
MESSAGE(FATAL_ERROR "FairRoot installation not found")
23+
endif(NOT FairMQInFairRoot_FIND_QUIETLY)
24+
endif(FAIRROOTPATH)
25+
26+
set(FAIRMQ_REQUIRED_HEADERS FairMQDevice.h)
27+
if(NOT FairMQInFairRoot_FIND_QUIETLY)
28+
message(STATUS "Looking for FairMQ functionality in FairRoot ...")
29+
endif(NOT FairMQInFairRoot_FIND_QUIETLY)
30+
31+
find_path(FAIRMQ_INCLUDE_DIR NAMES ${FAIRMQ_REQUIRED_HEADERS}
32+
PATHS ${FAIRROOTPATH}/include/fairmq
33+
NO_DEFAULT_PATH
34+
)
35+
36+
# search once more in the system if not yet found
37+
find_path(FAIRMQ_INCLUDE_DIR NAMES ${FAIRMQ_REQUIRED_HEADERS}
38+
)
39+
40+
if(FAIRMQ_INCLUDE_DIR)
41+
if(NOT FairMQInFairRoot_FIND_QUIETLY)
42+
message(STATUS "Looking for FairMQ functionality in FairRoot: yes")
43+
endif(NOT FairMQInFairRoot_FIND_QUIETLY)
44+
set(FAIRMQ_FOUND TRUE)
45+
set(FairMQInFairRoot_FOUND TRUE)
46+
else(FAIRMQ_INCLUDE_DIR)
47+
if(FairMQInFairRoot_FIND_REQUIRED)
48+
message(FATAL_ERROR "FairRoot is not built with FairMQ support")
49+
else(FairMQInFairRoot_FIND_REQUIRED)
50+
if(NOT FairMQInFairRoot_FIND_QUIETLY)
51+
message(STATUS "Looking for FairMQ functionality in FairRoot: no")
52+
endif(NOT FairMQInFairRoot_FIND_QUIETLY)
53+
endif(FairMQInFairRoot_FIND_REQUIRED)
54+
endif(FAIRMQ_INCLUDE_DIR)

cmake/FindMonitoring.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ include(FindPackageHandleStandardArgs)
2121

2222
# find includes
2323
find_path(MONITORING_INCLUDE_DIR Monitoring.h
24-
HINTS ${Monitoring_ROOT}/include ENV LD_LIBRARY_PATH PATH_SUFFIXES "../include/Monitoring" "../../include/Monitoring" )
24+
HINTS ${Monitoring_ROOT}/include ENV LD_LIBRARY_PATH PATH_SUFFIXES "../include/Monitoring" "../../include/Monitoring" )
2525

2626
# Remove the final "Monitoring"
2727
get_filename_component(MONITORING_INCLUDE_DIR ${MONITORING_INCLUDE_DIR} DIRECTORY)
@@ -34,7 +34,7 @@ set(Monitoring_LIBRARIES ${MONITORING_LIBRARY})
3434
# handle the QUIETLY and REQUIRED arguments and set Monitoring_FOUND to TRUE
3535
# if all listed variables are TRUE
3636
find_package_handle_standard_args(Monitoring "Monitoring could not be found. Set Monitoring_ROOT as root installation directory."
37-
MONITORING_LIBRARY MONITORING_INCLUDE_DIR)
37+
MONITORING_LIBRARY MONITORING_INCLUDE_DIR)
3838
if(${Monitoring_FOUND})
3939
set(Monitoring_DEFINITIONS "")
4040
message(STATUS "Monitoring found : ${Monitoring_LIBRARIES}")

cmake/ReadoutDependencies.cmake

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
find_package(Boost COMPONENTS unit_test_framework program_options system REQUIRED)
1+
find_package(Boost COMPONENTS unit_test_framework program_options system thread system timer program_options random filesystem regex signals REQUIRED)
22
find_package(Git QUIET)
3-
find_package(FairRoot)
43
find_package(Monitoring REQUIRED)
54
find_package(Configuration REQUIRED)
65
find_package(Common REQUIRED)
@@ -10,17 +9,45 @@ find_package(DataSampling REQUIRED)
109
find_package(ZeroMQ REQUIRED)
1110
find_package(Numa)
1211

12+
find_package(FairRoot)
1313
if (FAIRROOT_FOUND)
14+
find_package(FairMQInFairRoot) # DEPRECATED: This looks for FairMQ embedded in old FairRoot versions,
15+
# before FairMQ and FairLogger have moved to separate repos.
16+
# Remove this line, once we require FairMQ 1.2+.
17+
if(NOT FairMQInFairRoot_FOUND) # DEPRECATED: Remove this condition, once we require FairMQ 1.2+
18+
find_package(FairMQ REQUIRED)
19+
find_package(FairLogger REQUIRED)
20+
endif()
1421
# this should go away when fairrot provides a proper Find script or proper config scripts
1522
# See : http://www.cmake.org/cmake/help/v3.0/command/link_directories.html
1623
link_directories(${FAIRROOT_LIBRARY_DIR})
17-
set(FAIRROOT_LIBRARIES Base FairMQ BaseMQ Logger)
1824
ADD_DEFINITIONS(-DWITH_FAIRMQ)
25+
get_target_property(_boost_incdir Boost::boost INTERFACE_INCLUDE_DIRECTORIES)
26+
27+
if(FairMQInFairRoot_FOUND)
28+
# DEPRECATED: Remove this case, once we require FairMQ 1.2+
29+
get_target_property(_fairmq_incdir FairRoot::FairMQ INTERFACE_INCLUDE_DIRECTORIES)
30+
o2_define_bucket(NAME fairmq_bucket
31+
DEPENDENCIES FairRoot::FairMQ
32+
INCLUDE_DIRECTORIES ${_boost_incdir} ${_fairmq_incdir}
33+
)
34+
else()
35+
get_target_property(_fairmq_incdir FairMQ::FairMQ INTERFACE_INCLUDE_DIRECTORIES)
36+
get_target_property(_fairlogger_incdir FairLogger::FairLogger INTERFACE_INCLUDE_DIRECTORIES)
37+
o2_define_bucket(NAME fairmq_bucket
38+
DEPENDENCIES FairMQ::FairMQ
39+
INCLUDE_DIRECTORIES ${_boost_incdir} ${_fairmq_incdir} ${_fairlogger_incdir}
40+
)
41+
#set(_fairlogger_incdir)
42+
endif()
1943
else (FAIRROOT_FOUND)
2044
message(WARNING "FairRoot not found, corresponding classes will not be compiled.")
45+
o2_define_bucket(NAME fairmq_bucket
46+
INCLUDE_DIRECTORIES ${_boost_incdir}
47+
)
2148
endif (FAIRROOT_FOUND)
2249

23-
if (Numa_FOUND)
50+
if (Numa_FOUND)
2451
ADD_DEFINITIONS(-DWITH_NUMA)
2552
else (Numa_FOUND)
2653
message(WARNING "Numa not found, corresponding features will be disabled.")
@@ -65,8 +92,8 @@ o2_define_bucket(
6592

6693
DEPENDENCIES
6794
o2_readout_bucket
68-
${FAIRROOT_LIBRARIES}
6995
${ROOT_LIBRARIES}
96+
fairmq_bucket
7097

7198
SYSTEMINCLUDE_DIRECTORIES
7299
${FAIRROOT_INCLUDE_DIR}

src/ConsumerFMQ.cxx

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <fairmq/FairMQDevice.h>
77
#include <fairmq/FairMQMessage.h>
88
#include <fairmq/FairMQTransportFactory.h>
9-
#include <fairmq/zeromq/FairMQTransportFactoryZMQ.h>
109

1110

1211
class FMQSender : public FairMQDevice
@@ -16,8 +15,8 @@ class FMQSender : public FairMQDevice
1615
FMQSender() { }
1716
~FMQSender() { }
1817

19-
protected:
20-
18+
protected:
19+
2120
void Run() override {
2221
while (CheckCurrentState(RUNNING)) {
2322
//printf("loop Run()\n");
@@ -45,39 +44,39 @@ class ConsumerFMQ: public Consumer {
4544
FMQSender sender;
4645

4746

48-
// todo: check why this type is not public in FMQ interface?
49-
typedef std::unordered_map<std::string, std::vector<FairMQChannel>> FairMQMap;
47+
// todo: check why this type is not public in FMQ interface?
48+
typedef std::unordered_map<std::string, std::vector<FairMQChannel>> FairMQMap;
5049
FairMQMap m;
51-
52-
FairMQTransportFactory *transportFactory;
53-
54-
public:
50+
51+
std::shared_ptr<FairMQTransportFactory> transportFactory;
52+
53+
public:
5554

5655

5756
ConsumerFMQ(ConfigFile &cfg, std::string cfgEntryPoint) : Consumer(cfg,cfgEntryPoint), channels(1) {
58-
57+
5958
channels[0].UpdateType("pair"); // pub or push?
6059
channels[0].UpdateMethod("bind");
6160
channels[0].UpdateAddress("ipc:///tmp/readout-pipe-0");
62-
channels[0].UpdateRateLogging(0);
63-
channels[0].UpdateSndBufSize(10);
61+
channels[0].UpdateRateLogging(0);
62+
channels[0].UpdateSndBufSize(10);
6463
if (!channels[0].ValidateChannel()) {
6564
throw "ConsumerFMQ: channel validation failed";
6665
}
6766

6867

6968
// todo: def "data-out" as const string to name output channel to which we will push
7069
m.emplace(std::string("data-out"),channels);
71-
70+
7271
for (auto it : m) {
7372
std::cout << it.first << " = " << it.second.size() << " channels " << std::endl;
7473
for (auto ch : it.second) {
7574
std::cout << ch.GetAddress() <<std::endl;
7675
}
7776
}
7877

79-
transportFactory = new FairMQTransportFactoryZMQ();
80-
78+
transportFactory = FairMQTransportFactory::CreateTransportFactory("zeromq");
79+
8180
sender.fChannels = m;
8281
sender.SetTransport("zeromq");
8382
sender.ChangeState(FairMQStateMachine::Event::INIT_DEVICE);
@@ -88,18 +87,16 @@ class ConsumerFMQ: public Consumer {
8887

8988
// sender.InteractiveStateLoop();
9089
}
91-
90+
9291
~ConsumerFMQ() {
9392
sender.ChangeState(FairMQStateMachine::Event::STOP);
9493
sender.ChangeState(FairMQStateMachine::Event::RESET_TASK);
9594
sender.WaitForEndOfState(FairMQStateMachine::Event::RESET_TASK);
9695
sender.ChangeState(FairMQStateMachine::Event::RESET_DEVICE);
9796
sender.WaitForEndOfState(FairMQStateMachine::Event::RESET_DEVICE);
9897
sender.ChangeState(FairMQStateMachine::Event::END);
99-
100-
delete transportFactory;
10198
}
102-
99+
103100
int pushData(DataBlockContainerReference &b) {
104101

105102
// we create a copy of the reference, in a newly allocated object, so that reference is kept alive until this new object is destroyed in the cleanupCallback
@@ -109,7 +106,7 @@ class ConsumerFMQ: public Consumer {
109106

110107
sender.fChannels.at("data-out").at(0).Send(msgHeader);
111108
sender.fChannels.at("data-out").at(0).Send(msgBody);
112-
109+
113110

114111

115112
// how to know if it was a success?
@@ -120,7 +117,7 @@ class ConsumerFMQ: public Consumer {
120117

121118
// use multipart?
122119
// channels.at("data-out").at(0).SendPart(msgBody);
123-
120+
124121
return 0;
125122
}
126123
private:

0 commit comments

Comments
 (0)