FairRoot/PandaRoot
runExample1Sink.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 <PndMQExample1Sink.h>
16 #include <iostream>
17 
18 #include "boost/program_options.hpp"
19 
20 #include "FairMQLogger.h"
21 #include "FairMQParser.h"
22 #include "FairMQProgOptions.h"
23 
24 #ifdef NANOMSG
25 #include "FairMQTransportFactoryNN.h"
26 #else
27 #include "FairMQTransportFactoryZMQ.h"
28 #endif
29 
30 using namespace boost::program_options;
31 
32 int main(int argc, char** argv)
33 {
34  PndMQExample1Sink sink;
35  sink.CatchSignals();
36 
37  FairMQProgOptions config;
38 
39  try
40  {
41  if (config.ParseAll(argc, argv))
42  {
43  return 0;
44  }
45 
46  std::string filename = config.GetValue<std::string>("config-json-file");
47  std::string id = config.GetValue<std::string>("id");
48 
49  config.UserParser<FairMQParser::JSON>(filename, id);
50 
51  sink.fChannels = config.GetFairMQMap();
52 
53  LOG(INFO) << "PID: " << getpid();
54 
55 #ifdef NANOMSG
56  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
57 #else
58  FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
59 #endif
60 
61  sink.SetTransport(transportFactory);
62 
63  sink.SetProperty(PndMQExample1Sink::Id, id);
64 
65  sink.ChangeState("INIT_DEVICE");
66  sink.WaitForEndOfState("INIT_DEVICE");
67 
68  sink.ChangeState("INIT_TASK");
69  sink.WaitForEndOfState("INIT_TASK");
70 
71  sink.ChangeState("RUN");
72  sink.InteractiveStateLoop();
73  }
74  catch (std::exception& e)
75  {
76  LOG(ERROR) << e.what();
77  LOG(INFO) << "Command line options are the following: ";
78  config.PrintHelp();
79  return 1;
80  }
81 
82  return 0;
83 }
int main(int argc, char **argv)
const string filename