Jpp
Classes | Functions
JDAQDemoClient.cc File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <sys/types.h>
#include <unistd.h>
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JArgs.hh"
#include "JSystem/JShell.hh"
#include "JRuncontrol/JDAQClient.hh"

Go to the source code of this file.

Classes

class  JDAQDemoClient
 

Functions

int main (int argc, char *argv[])
 Run control demo client. More...
 

Detailed Description

Run control demo client class.

The various action methods could be implemented in this class. Note that non-empty data at event ev_configure will make the process prematurely exit. Note that process with extension /+ will sleep forever during the exit transition.

Author
mdejong

Definition in file JDAQDemoClient.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Run control demo client.

Definition at line 158 of file JDAQDemoClient.cc.

159 {
160  using namespace std;
161  using namespace JPP;
162  using namespace KM3NETDAQ;
163 
164  string server;
165  string logger;
166  string client_name;
167  bool use_cout;
168  int debug;
169 
170  string file_name;
171  int port;
172 
173  try {
174 
175  JParser<> zap("Application for writing real-time data to disk.");
176 
177  zap['H'] = make_field(server) = "localhost";
178  zap['M'] = make_field(logger) = "localhost";
179  zap['u'] = make_field(client_name) = "%";
180  zap['c'] = make_field(use_cout);
181  zap['d'] = make_field(debug) = 3;
182 
183  zap['f'] = make_field(file_name) = "";
184  zap['P'] = make_field(port) = -1;
185 
186  zap(argc, argv);
187  }
188  catch(const exception &error) {
189  FATAL(error.what() << endl);
190  }
191 
192  if (port == -1) {
193 
194  JLogger* out = NULL;
195 
196  if (use_cout)
197  out = new JStreamLogger(cout);
198  else
199  out = new JControlHostLogger(logger);
200 
201  if (file_name == "") {
202 
203  JDAQDemoClient demo(getProcessName(client_name, argv[0]), server, out, debug);
204 
205  demo.enter();
206  demo.run();
207 
208  } else {
209 
210  JDAQDemoClient demo(getProcessName(client_name, argv[0]), out, debug);
211 
212  if (debug >= debug_t && use_cout) {
213  demo.debug(CHSM::machine::D_all);
214  }
215  demo.CHSM::machine::enter();
216 
217  ifstream in(file_name.c_str());
218 
219  demo.run(in);
220 
221  in.close();
222  }
223 
224  } else {
225 
226  JDAQDemoClient demo(getProcessName(client_name, argv[0]));
227 
228  demo.run(port);
229  }
230 }
JLOGGER::JLogger
Interface for logging messages.
Definition: JLogger.hh:22
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JLOGGER::JStreamLogger
Message logging based on std::ostream.
Definition: JStreamLogger.hh:22
JLOGGER::JControlHostLogger
Message logging based on ControlHost.
Definition: JControlHostLogger.hh:26
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
JEEP::debug_t
debug
Definition: JMessage.hh:29
KM3NETDAQ::getProcessName
std::string getProcessName(const std::string &name, const std::string &process)
Get process name of run control client.
Definition: JRuncontrolToolkit.hh:194
JDAQDemoClient
Definition: JDAQDemoClient.cc:28