FairRoot/PandaRoot
runPndTopixSorter.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 <PndMQTopix4Sorter.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  PndMQTopix4Sorter sorter;
36  sorter.CatchSignals();
37 
38  FairMQProgOptions config;
39 
40  try
41  {
42  config.ParseAll(argc, argv);
43 
44  std::string filename = config.GetValue<std::string>("config-json-file");
45  std::string id = config.GetValue<std::string>("id");
46 
47  config.UserParser<FairMQParser::JSON>(filename, id);
48 
49  sorter.fChannels = config.GetFairMQMap();
50 
51  LOG(INFO) << "PID: " << getpid();
52 
53 #ifdef NANOMSG
54  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
55 #else
56  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
57 #endif
58 
59  sorter.SetTransport(transportFactory);
60 
61  sorter.SetProperty(PndMQTopix4Sorter::Id, id);
62 
63  sorter.ChangeState("INIT_DEVICE");
64  sorter.WaitForEndOfState("INIT_DEVICE");
65 
66  sorter.ChangeState("INIT_TASK");
67  sorter.WaitForEndOfState("INIT_TASK");
68 
69  sorter.ChangeState("RUN");
70  sorter.InteractiveStateLoop();
71 
72  }
73  catch (std::exception& e)
74  {
75  LOG(ERROR) << e.what();
76  LOG(INFO) << "Command line options are the following: ";
77  config.PrintHelp();
78  return 1;
79  }
80 
81  return 0;
82 }
int main(int argc, char **argv)
const string filename