FairRoot/PandaRoot
runPndTopixSorterMerger.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
15 #include <PndMQSorterMerger.h>
16 #include <iostream>
17 #include <TApplication.h>
18 
19 #include "boost/program_options.hpp"
20 
21 #include "FairMQLogger.h"
22 #include "FairMQParser.h"
23 #include "FairMQProgOptions.h"
24 
25 #ifdef NANOMSG
26 #include "FairMQTransportFactoryNN.h"
27 #else
28 #include "FairMQTransportFactoryZMQ.h"
29 #endif
30 
31 using namespace boost::program_options;
32 
33 int main(int argc, char** argv)
34 {
35  PndMQSorterMerger sorter;
36  sorter.CatchSignals();
37 
38  FairMQProgOptions config;
39 
40  try
41  {
42  config.ParseAll(argc, argv);
43  std::string filename = config.GetValue<std::string>("config-json-file");
44  std::string id = config.GetValue<std::string>("id");
45 
46  config.UserParser<FairMQParser::JSON>(filename, id);
47 
48  sorter.fChannels = config.GetFairMQMap();
49 
50  LOG(INFO) << "PID: " << getpid();
51 
52 #ifdef NANOMSG
53  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
54 #else
55  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
56 #endif
57 
58  sorter.SetTransport(transportFactory);
59 
60  sorter.SetProperty(PndMQSorterMerger::Id, id);
61 
62  sorter.ChangeState("INIT_DEVICE");
63  sorter.WaitForEndOfState("INIT_DEVICE");
64 
65  sorter.ChangeState("INIT_TASK");
66  sorter.WaitForEndOfState("INIT_TASK");
67 
68  sorter.ChangeState("RUN");
69  sorter.InteractiveStateLoop();
70 
71  }
72  catch (std::exception& e)
73  {
74  LOG(ERROR) << e.what();
75  LOG(INFO) << "Command line options are the following: ";
76  config.PrintHelp();
77  return 1;
78  }
79 
80  return 0;
81 }
int main(int argc, char **argv)
const string filename