Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Static Protected Member Functions | Protected Attributes | List of all members
KM3NETDAQ::JDAQDriver Class Reference

Simple driver for run control clients. More...

#include <JDAQDriver.hh>

Inheritance diagram for KM3NETDAQ::JDAQDriver:
KM3NETDAQ::JDAQClient JDAQStateMachine KM3NETDAQ::JDAQClient_t JDAQCHSM

Public Member Functions

 JDAQDriver (const std::string &name, const std::string &server, JLogger *logger, const int level, const int timeout_s)
 Constructor. More...
 
virtual bool enter () override
 Enter the state machine. More...
 
virtual void actionExit () override
 Exit the state machine. More...
 
virtual void enterState (const CHSM::state &state, const CHSM::event &event) override
 Action when entering state. More...
 
bool update (const bool no_wait)
 Update client list with incoming ControlHost message. More...
 
virtual void actionStart (int, const char *) override
 
virtual void actionStop (int, const char *) override
 
void run ()
 Run driver with user input. More...
 
void run (std::istream &in)
 Run driver. More...
 
void update ()
 Update client list with incoming ControlHost messages until the client list is synchronised with the current state or until the timeout. More...
 
void synchronise ()
 Synchronise clients. More...
 
void filter (const std::string &target="")
 Filter client list by putting failing clients to sleep. More...
 
virtual bool enter (const JArgs &args)
 Enter the state machine. More...
 
virtual bool exit () override
 Exit the state machine. More...
 
bool isRunning () const
 Check if this client is in runnig state. More...
 
void replaceEvent (const JTag &oldTag, const JTag &newTag, JDAQEvent_t &event)
 Replace tag of given event in event table. More...
 
JDAQEvent_tfindEvent (const JTag &tag, const std::string &event_name)
 Find event in event table. More...
 
void addSubscription (const JSubscription &subscription)
 Add custom subscription. More...
 
template<class T >
void addParameter (const char option, T &parameter)
 Add parameter to parser used in method enter(). More...
 
template<class T >
void addParameter (const char option, T &parameter, const T &value)
 Add parameter to parser used in method enter(). More...
 
void setSelect ()
 Set the file descriptor mask for the select call. More...
 
virtual void setSelect (JFileDescriptorMask &mask) const
 Set the file descriptor mask for the select call. More...
 
virtual void actionSelect (const JFileDescriptorMask &mask)
 Action method following last select call. More...
 
virtual void actionRunning ()
 This method is repeatedly called when this client machine is in state Running and the clock interval time is non-zero. More...
 
virtual void actionInput (int length, const char *buffer) override
 This method is called at ev_input. More...
 
virtual bool filter (const JTag &tag, int length, const char *buffer)
 Filter message. More...
 
virtual void actionTagged (const JTag &tag, int length, const char *buffer)
 This method is called when a custom tag is encountered. More...
 
void run (const int port)
 Run for ever. More...
 
void A1 (CHSM_ns_alias::event const &)
 
void A2 (CHSM_ns_alias::event const &)
 
void A3 (CHSM_ns_alias::event const &)
 
void A4 (CHSM_ns_alias::event const &)
 
void A5 (CHSM_ns_alias::event const &)
 
void A6 (CHSM_ns_alias::event const &)
 
void A7 (CHSM_ns_alias::event const &)
 
void A8 (CHSM_ns_alias::event const &)
 
void A9 (CHSM_ns_alias::event const &)
 
void A10 (CHSM_ns_alias::event const &)
 
void A11 (CHSM_ns_alias::event const &)
 
void A12 (CHSM_ns_alias::event const &)
 
void A13 (CHSM_ns_alias::event const &)
 
void A14 (CHSM_ns_alias::event const &)
 
void EAM4root (CHSM_ns_alias::state const &, CHSM_ns_alias::event const &)
 
void XAM4root (CHSM_ns_alias::state const &, CHSM_ns_alias::event const &)
 
const std::stringgetName () const
 Get name of state machine. More...
 
const std::stringgetName () const
 Get name of state machine. More...
 
int getDetectorID () const
 Get detector identifier. More...
 
int getDetectorID () const
 Get detector identifier. More...
 
int getRunNumber () const
 Get run number. More...
 
int getRunNumber () const
 Get run number. More...
 
virtual void actionEnter ()
 Interface methods for actions corresponding to state transitions. More...
 
virtual void actionEnter ()
 Interface methods for actions corresponding to state transitions. More...
 
virtual void actionInit (int, const char *)
 
virtual void actionInit (int, const char *)
 
virtual void actionConfigure (int, const char *)
 
virtual void actionConfigure (int, const char *)
 
virtual void actionPause (int, const char *)
 
virtual void actionPause (int, const char *)
 
virtual void actionContinue (int, const char *)
 
virtual void actionContinue (int, const char *)
 
virtual void actionReset (int, const char *)
 
virtual void actionReset (int, const char *)
 
virtual void actionQuit (int, const char *)
 
virtual void actionQuit (int, const char *)
 
virtual void actionError ()
 
virtual void actionError ()
 
virtual void actionRecover (int, const char *)
 
virtual void actionRecover (int, const char *)
 
const std::stringgetHostname () const
 Get hostname. More...
 
const std::stringgetFullName () const
 Get full name of this run control client. More...
 
const JTaggetUniqueTag () const
 Get unique tag of this run control client. More...
 
long long int getClockDelay () const
 Get total delay time. More...
 
long long int getClockInterval () const
 Get interval time. More...
 
void setClockInterval (const long long int interval_us)
 Set interval time. More...
 
void resetClock ()
 Reset clock. More...
 
const std::stringgetEventInfo () const
 Get last event information. More...
 
void setEventInfo (const std::string &info)
 Set last event information. More...
 

Public Attributes

int timeout_us
 timeout of state transitions [us] More...
 
JDAQStateMachine::state_root root
 
JDAQStateMachine::state_Main Main
 
JDAQStateMachine::ev_daq_event ev_daq
 
char ev_daq_param_block [sizeof(ev_daq_event::param_block)]
 
JDAQStateMachine::ev_init_event ev_init
 
char ev_init_param_block [sizeof(ev_init_event::param_block)]
 
JDAQStateMachine::ev_configure_event ev_configure
 
char ev_configure_param_block [sizeof(ev_configure_event::param_block)]
 
JDAQStateMachine::ev_start_event ev_start
 
char ev_start_param_block [sizeof(ev_start_event::param_block)]
 
JDAQStateMachine::ev_pause_event ev_pause
 
char ev_pause_param_block [sizeof(ev_pause_event::param_block)]
 
JDAQStateMachine::ev_continue_event ev_continue
 
char ev_continue_param_block [sizeof(ev_continue_event::param_block)]
 
JDAQStateMachine::ev_stop_event ev_stop
 
char ev_stop_param_block [sizeof(ev_stop_event::param_block)]
 
JDAQStateMachine::ev_reset_event ev_reset
 
char ev_reset_param_block [sizeof(ev_reset_event::param_block)]
 
JDAQStateMachine::ev_quit_event ev_quit
 
char ev_quit_param_block [sizeof(ev_quit_event::param_block)]
 
JDAQStateMachine::ev_off_event ev_off
 
char ev_off_param_block [sizeof(ev_off_event::param_block)]
 
JDAQStateMachine::ev_check_event ev_check
 
char ev_check_param_block [sizeof(ev_check_event::param_block)]
 
JDAQStateMachine::ev_input_event ev_input
 
char ev_input_param_block [sizeof(ev_input_event::param_block)]
 
JDAQStateMachine::ev_recover_event ev_recover
 
char ev_recover_param_block [sizeof(ev_recover_event::param_block)]
 
JDAQStateMachine::ev_error_event ev_error
 
char ev_error_param_block [sizeof(ev_error_event::param_block)]
 

Static Public Attributes

static const int SLEEP_TIME_US = 500000
 
static const int TIMEOUT_S = 1
 time out of update [s] More...
 

Protected Types

typedef void(JDAQCHSM::* action )(int, const char *)
 Type definition of action method. More...
 
typedef void(JDAQCHSM::* action )(int, const char *)
 Type definition of action method. More...
 

Static Protected Member Functions

static void copy (std::istream &in, std::ostream &out, const char eol= '\n')
 Copy data from input to output stream. More...
 

Protected Attributes

JClientList clientList
 
bool is_alive
 
std::string rc_log
 
JSharedPointer< JControlHostserver
 message server More...
 
JMessageLogger logger
 message logger More...
 
std::string name
 
int detector_id
 
int run_number
 
JEventTable eventTable
 event table More...
 
std::string hostname
 
std::string fullname
 
JTag unique_tag
 
JTimekeeper clock
 central clock More...
 
std::string event_info
 event information More...
 

Detailed Description

Simple driver for run control clients.

This class can be used to start a set of run control clients, trigger events and eventually stop the clients.

Definition at line 35 of file JDAQDriver.hh.

Member Typedef Documentation

typedef void(JDAQCHSM::* JDAQCHSM::action)(int, const char *)
protectedinherited

Type definition of action method.

Definition at line 141 of file JDAQCHSM.chsm.

typedef void(JDAQCHSM::* JDAQCHSM::action)(int, const char *)
protectedinherited

Type definition of action method.

Definition at line 152 of file JDAQCHSM.hh.

Constructor & Destructor Documentation

KM3NETDAQ::JDAQDriver::JDAQDriver ( const std::string name,
const std::string server,
JLogger logger,
const int  level,
const int  timeout_s 
)
inline

Constructor.

Parameters
namename of driver
servername of command message server
loggerlogger
leveldebug level
timeout_stimeout_s [s]

Definition at line 53 of file JDAQDriver.hh.

57  :
58  JDAQClient(name, server, logger, level),
59  timeout_us(timeout_s * 1000000),
60  is_alive (false)
61  {}
std::string name
Definition: JDAQCHSM.chsm:154
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
int timeout_us
timeout of state transitions [us]
Definition: JDAQDriver.hh:636
JDAQClient(const std::string &name, const std::string &server, JLogger *logger, const int level)
Constructor.
Definition: JDAQClient.hh:319
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835

Member Function Documentation

virtual bool KM3NETDAQ::JDAQDriver::enter ( )
inlineoverridevirtual

Enter the state machine.

The driver will subscribe to the ControlHost tags corresponding to born, died and reply messages of the clients instead of the standard tags for run control commands. The clients are started after the driver is ready to receive ControlHost messages. In case of an error, a message is printed on the terminal and the state machine is not entered.

Reimplemented from KM3NETDAQ::JDAQClient.

Definition at line 72 of file JDAQDriver.hh.

73  {
74  using namespace std;
75  using namespace JPP;
76 
77  if (server.is_valid() && logger.is_valid()) {
78 
79  try {
80 
81  server->Subscribe(JSubscriptionAll(RC_REPLY) +
85  server->SendMeAlways();
86  server->MyId(getFullName());
87 
88  // check alive of this driver
89 
90  for (int i = 0; i != timeout_us && !is_alive; ) {
91  if (!update(true)) {
92  usleep(SLEEP_TIME_US);
93  i += SLEEP_TIME_US;
94  }
95  }
96 
97  if (is_alive) {
98 
99  {
100  //clientList.start();
101 
102  for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
103  if (i->isActive()) {
104 
105  JNoticeStream(logger) << "Start process " << *i;
106 
107  i->start();
108  }
109  }
110 
111  for (int i = 0; i != timeout_us; i += SLEEP_TIME_US) {
112 
113  while (update(true)) {
114  }
115 
116  if (clientList.count() >= clientList.count(JClient::ACTIVE))
117  break;
118  else
119  usleep(SLEEP_TIME_US);
120  }
121  }
122 
123  if (clientList.count() != clientList.count(JClient::ACTIVE)) {
124  for (JClientList::const_iterator i = clientList.begin(); i != clientList.end(); ++i) {
125  if (i->isActive() && i->getBorn() <= i->getDied()) {
126  JWarningStream(logger) << "client " << i->getFullName() << " did not start.";
127  }
128  }
129  }
130 
131  return CHSM::machine::enter();
132 
133  } else {
134  cerr << "Timeout at subscription." << endl;
135  }
136  }
137  catch(const JControlHostException& error) {
138  cerr << error << endl;
139  }
140 
141  } else {
142  cerr << "Message server or logger not properly initialised." << endl;
143  }
144 
145  return false;
146  }
static const JTag DISPTAG_Died("Died")
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
static const int SLEEP_TIME_US
Definition: JDAQDriver.hh:42
static const JNET::JTag RC_LOG
Definition: JDAQTags.hh:66
static const JNET::JTag RC_REPLY
Definition: JDAQTags.hh:61
Exception for ControlHost.
Definition: JException.hh:484
Auxiliary class for all subscription.
Definition: JControlHost.hh:97
JClientList clientList
Definition: JDAQDriver.hh:640
static const JTag DISPTAG_Born("Born")
int timeout_us
timeout of state transitions [us]
Definition: JDAQDriver.hh:636
bool is_valid() const
Check validity of logger object.
const std::string & getFullName() const
Get full name of this run control client.
Definition: JDAQClient.hh:120
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
void update()
Update client list with incoming ControlHost messages until the client list is synchronised with the ...
Definition: JDAQDriver.hh:522
virtual void KM3NETDAQ::JDAQDriver::actionExit ( )
inlineoverridevirtual

Exit the state machine.

This method waits for the clients to terminate using the died message generated by ControlHost. In case of a timeout, the process is terminated by calling the method stop() of the corresponding client.

Reimplemented from JDAQCHSM.

Definition at line 155 of file JDAQDriver.hh.

156  {
157  using namespace std;
158  using namespace JLANG;
159 
160  for (int i = 0; i != timeout_us; i += SLEEP_TIME_US) {
161 
162  while (update(true)) {}
163 
164  if (clientList.count() == 0)
165  break;
166  else
167  usleep(SLEEP_TIME_US);
168  }
169 
170  if (clientList.count() != 0) {
171  JWarningStream(logger) << "Timeout at transition " << "exit(); forced stop.";
172  }
173 
174  clientList.stop();
175  }
static const int SLEEP_TIME_US
Definition: JDAQDriver.hh:42
JClientList clientList
Definition: JDAQDriver.hh:640
int timeout_us
timeout of state transitions [us]
Definition: JDAQDriver.hh:636
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
void update()
Update client list with incoming ControlHost messages until the client list is synchronised with the ...
Definition: JDAQDriver.hh:522
virtual void KM3NETDAQ::JDAQDriver::enterState ( const CHSM::state &  state,
const CHSM::event &  event 
)
inlineoverridevirtual

Action when entering state.

This method waits for all clients to produce the enter state message. In case of a timeout, no specific action is taken but an error message is logged.

Parameters
stateentered state
eventevent that triggered transition

Reimplemented from KM3NETDAQ::JDAQClient.

Definition at line 186 of file JDAQDriver.hh.

187  {
188  for (int i = 0; i != timeout_us && clientList.count(state) < clientList.count(JClient::ACTIVE) && clientList.count() != 0; ) {
189  if (!update(true)) {
190  usleep(SLEEP_TIME_US);
191  i += SLEEP_TIME_US;
192  }
193  }
194 
195  if (clientList.count(state) < clientList.count(JClient::ACTIVE)) {
196  JWarningStream(logger) << "Timeout at transition " << event.name() << " to state " << state.name();
197  }
198  }
static const int SLEEP_TIME_US
Definition: JDAQDriver.hh:42
JClientList clientList
Definition: JDAQDriver.hh:640
int timeout_us
timeout of state transitions [us]
Definition: JDAQDriver.hh:636
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
void update()
Update client list with incoming ControlHost messages until the client list is synchronised with the ...
Definition: JDAQDriver.hh:522
bool KM3NETDAQ::JDAQDriver::update ( const bool  no_wait)
inline

Update client list with incoming ControlHost message.

This method receives and processes a message. The client list is updated accordingly. If the no-wait option is set to true, it returns in the absence of a pending message immediately. The return value is then false. If the no-wait option is set to false, it waits until the next message is received.

Parameters
no_waitwait option
Returns
true if message received; else false

Definition at line 212 of file JDAQDriver.hh.

213  {
214  using namespace std;
215  using namespace JNET;
217 
218  try {
219 
220  string tag;
221  long long int length = 0;
222 
223  if ( no_wait && server->CheckHead(tag, length) <= 0) { return false; }
224  if (!no_wait && server->WaitHead (tag, length) < 0) { return false; }
225 
226  char* data= new char[length];
227 
228  server->GetFullData(data, length);
229 
230  const string buffer(data, length);
231 
232  delete [] data;
233 
234  JDebugStream(logger) << "Got message " << tag << ' ' << buffer;
235 
236  if (tag == RC_LOG) {
237 
238  rc_log = buffer;
239 
240  } else if (buffer.find(getFullName()) != string::npos) {
241 
242  if (tag == DISPTAG_Born)
243  is_alive = true;
244  else if (tag == DISPTAG_Died)
245  is_alive = false;
246 
247  } else {
248 
249  JClientList::iterator i = clientList.find(buffer);
250 
251  if (i != clientList.end()) {
252 
253  i->update(tag, buffer);
254 
255  } else {
256 
257  JErrorStream(logger) << "Message fom illegal client " << buffer;
258 
259  try {
260 
261  if (tag == DISPTAG_Born ||
262  tag == DISPTAG_Died ||
263  tag == RC_REPLY) {
264 
265  string key, hostname, name;
266 
267  istringstream is(buffer);
268 
269  const locale loc(is.getloc(), new JWhiteSpacesFacet(is.getloc(), TOKEN_DELIMETER));
270 
271  is.imbue(loc);
272 
273  if (is >> key >> hostname >> name && key == RUN_CONTROL_CLIENT) {
274 
275  JClient client(name, hostname);
276 
277  client.update(tag, buffer);
278  client.setMode(JClient::ILLEGAL);
279 
280  clientList.insert(client);
281 
282  JWarningStream(logger) << "Added illegal client " << client.getFullName();
283 
284  } else {
285  THROW(JIOException, "JClient: Error reading " << buffer);
286  }
287  }
288  }
289  catch(const JException& error) {
290  JErrorStream(logger) << error;
291  }
292  }
293  }
294 
295  return true;
296  }
297  catch(const JControlHostException& error) {
298  JErrorStream(logger) << error;
299  }
300 
301  return false;
302  }
General exception.
Definition: JException.hh:24
static const JTag DISPTAG_Died("Died")
ControlHost client manager.
Definition: JLigier.cc:243
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
std::string name
Definition: JDAQCHSM.chsm:154
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
static const std::string TOKEN_DELIMETER
Definition: JDAQTags.hh:52
is
Definition: JDAQCHSM.chsm:167
static const std::string RUN_CONTROL_CLIENT
Definition: JDAQTags.hh:38
static const JNET::JTag RC_LOG
Definition: JDAQTags.hh:66
static const JNET::JTag RC_REPLY
Definition: JDAQTags.hh:61
then echo Test string reversed by client(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho-r" -C fi if (( 1 ))
Exception for ControlHost.
Definition: JException.hh:484
JClientList clientList
Definition: JDAQDriver.hh:640
static const JTag DISPTAG_Born("Born")
Auxiliary class to specify white space character(s) in currect locale.
const std::string & getFullName() const
Get full name of this run control client.
Definition: JDAQClient.hh:120
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
char * loc(char *orig)
Exception for I/O.
Definition: JException.hh:340
virtual void KM3NETDAQ::JDAQDriver::actionStart ( int  ,
const char *   
)
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 304 of file JDAQDriver.hh.

305  {
306  rc_log = "";
307  }
virtual void KM3NETDAQ::JDAQDriver::actionStop ( int  ,
const char *   
)
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 309 of file JDAQDriver.hh.

310  {
311  if (rc_log != "")
312  JNoticeStream(logger) << rc_log;
313  else
314  JErrorStream (logger) << "Missing message from JDataWriter with tag " << RC_LOG;
315  }
static const JNET::JTag RC_LOG
Definition: JDAQTags.hh:66
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
void KM3NETDAQ::JDAQDriver::run ( )
inline

Run driver with user input.

Definition at line 320 of file JDAQDriver.hh.

321  {
322  run(std::cin);
323  }
void run()
Run driver with user input.
Definition: JDAQDriver.hh:320
void KM3NETDAQ::JDAQDriver::run ( std::istream &  in)
inline

Run driver.

Example input format:

# comment line.
process <process name> <host name> [<start command>];
# The following tokens in <start command> will be substituted: 
#   $HOST$    by  <host name>;
#   $NAME$    by  <process name>;
#   $SERVER$  by  JClient::SERVER;
#   $LOGGER$  by  JClient::LOGGER;
#   $ARGS$    by  part following '/' in <process name>;
# enter state machine.
enter
# trigger event
# data can be provided online and mixed with data from a separate file (optional).
# multiple tags should be separated by a new line.
event <event name> {
  [<tag 1> [data]]
  [<tag 2> [data][%<file name>%][data]]
}
# optionally quit before end of input
[quit]
# optionally kill processes that did not properly terminate.
[exit]
Parameters
ininput stream

Definition at line 364 of file JDAQDriver.hh.

365  {
366  using namespace std;
367 
368  for (string key; in >> key; ) {
369 
370  if (key[0] == '#') {
371 
372  in.ignore(numeric_limits<streamsize>::max(), '\n');
373 
374  } else if (key == "enter") {
375 
376  enter();
377 
378  if (!active()) {
379  cerr << "State machine not entered; abort." << endl;
380  return;
381  }
382 
383  } else if (key == "exit") {
384 
385  timeout_us = 0;
386  exit();
387 
388  } else if (key == "quit") {
389 
390  break;
391 
392  } else if (key == "sleep") {
393 
394  int sec;
395 
396  if (in >> sec) {
397  sleep(sec);
398  }
399 
400  } else if (key == "process") {
401 
402  string buffer;
403 
404  getline(in, buffer, ';');
405 
406  istringstream is(buffer);
407 
408  JClient client;
409 
410  if (is >> client) {
411 
412  client.setMode(JClient::ACTIVE);
413 
414  if (!clientList.insert(client).second) {
415  JWarningStream(logger) << "Process already exists " << client;
416  }
417 
418  } else {
419  JErrorStream(logger) << "Error reading key word process.";
420  }
421 
422  } else if (key == "event" || key == "event*") {
423 
424  JEvent_t event;
425  char c;
426  string buffer;
427  const char eol = '\n';
428 
429  if (in >> event >> c && c == '{' && getline(in, buffer, '}')) {
430 
431  if (clientList.count() != 0) {
432 
433  JDAQEvent_t* pev = findEvent(RC_CMD, event.getName());
434 
435  if (pev != NULL) {
436 
437  if (pev->active() || key == "event*") {
438 
439  istringstream is(buffer);
440 
441  for (string tag; is >> tag; ) {
442 
443  ostringstream os;
444 
445  os << event << getTokenDelimeter();
446 
447  copy(is, os, eol);
448 
449  JNoticeStream(logger) << key << ' ' << tag << ' ' << event;
450 
451  server->PutFullString(tag, os.str());
452  }
453 
454  if (key != "event*") {
455  (*pev)(0, NULL); // trigger driver
456  }
457 
458  } else {
459  JErrorStream(logger) << "Inactive event " << event;
460  }
461 
462  } else {
463  JErrorStream(logger) << "Unknown event " << event;
464  }
465 
466  } else {
467  JErrorStream(logger) << "No active client to trigger event.";
468  }
469 
470  } else {
471  JErrorStream(logger) << "Error reading key word event.";
472  }
473 
474  } else if (key == "message") {
475 
476  string tag;
477  string buffer;
478 
479  if (in >> tag && getline(in, buffer, ';'))
480  server->PutFullString(tag, buffer);
481  else
482  JErrorStream(logger) << "Invalid message: <" << tag << "> \"" << buffer << "\"";
483 
484  } else if (key == "print") {
485 
486  for (JClientList::const_iterator i = clientList.begin(); i != clientList.end(); ++i) {
487  JNoticeStream(logger) << i->getFullName() << ' '
488  << i->getStartCommand() << ' '
489  << i->getAlive() << ' '
490  << i->getStatename();
491  }
492 
493  } else if (key == "filter") {
494 
495  string client;
496  string buffer;
497 
498  getline(in, buffer, ';');
499 
500  for (istringstream is(buffer); is >> client; ) {
501  filter(client);
502  }
503 
504  } else if (key == "sync") {
505 
506  synchronise();
507 
508  } else {
509 
510  JErrorStream(logger) << "Unknown key: " << key;
511 
512  in.ignore(numeric_limits<streamsize>::max(), '\n');
513  }
514  }
515  }
JDAQEvent_t * findEvent(const JTag &tag, const std::string &event_name)
Find event in event table.
Definition: JDAQClient.hh:536
ControlHost client manager.
Definition: JLigier.cc:243
static void copy(std::istream &in, std::ostream &out, const char eol= '\n')
Copy data from input to output stream.
Definition: JDAQDriver.hh:652
virtual bool exit() override
Exit the state machine.
Definition: JDAQClient.hh:485
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
is
Definition: JDAQCHSM.chsm:167
void synchronise()
Synchronise clients.
Definition: JDAQDriver.hh:545
then echo Test string reversed by client(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho-r" -C fi if (( 1 ))
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
char getTokenDelimeter()
Get the token delimeter for command messages.
JClientList clientList
Definition: JDAQDriver.hh:640
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
int timeout_us
timeout of state transitions [us]
Definition: JDAQDriver.hh:636
void filter(const std::string &target="")
Filter client list by putting failing clients to sleep.
Definition: JDAQDriver.hh:612
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
static const JNET::JTag RC_CMD
Definition: JDAQTags.hh:60
JDAQStateMachine::ev_daq_event JDAQEvent_t
Type definition of a DAQ event.
Definition: JEventTable.hh:25
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
virtual bool enter() override
Enter the state machine.
Definition: JDAQDriver.hh:72
void KM3NETDAQ::JDAQDriver::update ( )
inline

Update client list with incoming ControlHost messages until the client list is synchronised with the current state or until the timeout.

Definition at line 522 of file JDAQDriver.hh.

523  {
524  using namespace std;
525 
526  const CHSM::parent& parent = static_cast<const CHSM::parent&>(Main.RunControl);
527 
528  for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
529 
530  if (state->active()) {
531  for (int i = 0; i != timeout_us && clientList.count(*state) < clientList.count(JClient::ACTIVE); ) {
532  if (!update(true)) {
533  usleep(SLEEP_TIME_US);
534  i += SLEEP_TIME_US;
535  }
536  }
537  }
538  }
539  }
JDAQStateMachine::state_Main Main
static const int SLEEP_TIME_US
Definition: JDAQDriver.hh:42
JClientList clientList
Definition: JDAQDriver.hh:640
int timeout_us
timeout of state transitions [us]
Definition: JDAQDriver.hh:636
JDAQStateMachine::state_Main::state_RunControl RunControl
void update()
Update client list with incoming ControlHost messages until the client list is synchronised with the ...
Definition: JDAQDriver.hh:522
void KM3NETDAQ::JDAQDriver::synchronise ( )
inline

Synchronise clients.

Definition at line 545 of file JDAQDriver.hh.

546  {
547  using namespace std;
548 
549  const CHSM::parent& parent = static_cast<const CHSM::parent&>(Main.RunControl);
550 
551  for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
552 
553  if (state->active()) {
554 
555  if (clientList.count(*state) < clientList.count(JClient::ACTIVE)) {
556 
557  JDebugStream(logger) << "Synchronising " << state->name();
558 
559  for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
560 
561  if (i->getMode() == JClient::ACTIVE) {
562 
563  if (!i->getAlive()) {
564 
565  try {
566 
567  string buffer;
568 
569  if (JControlHost::WhereIs(JClient::SERVER, i->getFullName(), buffer) > 0) {
570 
571  i->setAlive(true);
572 
573  if (buffer.find(i->getHostname()) == string::npos) {
574  JErrorStream(logger) << i->getFullName() << " running on " << buffer << " but not alive.";
575  }
576  }
577  }
578  catch(const JControlHostException& error) {
579  JErrorStream(logger) << error;
580  }
581  }
582 
583  if (i->getAlive() && i->getStatename() != state->name()) {
584  server->PutFullString(KM3NETDAQ::getUniqueTag(i->getHostname(), i->getName()), ev_check.name());
585  }
586  }
587  }
588 
589 
590  for (int i = 0; i != timeout_us && clientList.count(*state) < clientList.count(JClient::ACTIVE); ) {
591  if (!update(true)) {
592  usleep(SLEEP_TIME_US);
593  i += SLEEP_TIME_US;
594  }
595  }
596 
597  if (clientList.count(*state) < clientList.count(JClient::ACTIVE)) {
598  JWarningStream(logger) << "Timeout at synchronisation.";
599  }
600  }
601  }
602  }
603  }
JDAQStateMachine::state_Main Main
JTag getUniqueTag(const std::string &hostname, const std::string &name)
Get unique tag of run control client.
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
static const int SLEEP_TIME_US
Definition: JDAQDriver.hh:42
Exception for ControlHost.
Definition: JException.hh:484
JClientList clientList
Definition: JDAQDriver.hh:640
JDAQStateMachine::ev_check_event ev_check
int timeout_us
timeout of state transitions [us]
Definition: JDAQDriver.hh:636
&set_variable SERVER
Definition: JStopDAQ.sh:29
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
static int WhereIs(const std::string &host_name, const std::string &nick_name, std::string &answer)
Locate ControlHost client(s).
JDAQStateMachine::state_Main::state_RunControl RunControl
void update()
Update client list with incoming ControlHost messages until the client list is synchronised with the ...
Definition: JDAQDriver.hh:522
void KM3NETDAQ::JDAQDriver::filter ( const std::string target = "")
inline

Filter client list by putting failing clients to sleep.

In this, only clients with names that contain the given character sequence are considered.

Parameters
targettarget name of client(s)

Definition at line 612 of file JDAQDriver.hh.

613  {
614  const CHSM::parent& parent = static_cast<const CHSM::parent&>(Main.RunControl);
615 
616  for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
617 
618  if (state->active()) {
619 
620  for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
621 
622  if (target == "" || i->getName().find(target) != std::string::npos) {
623 
624  if (!i->getAlive() || i->getStatename() != state->name()) {
625 
626  JNoticeStream(logger) << "Put to sleep " << i->getFullName();
627 
628  i->setMode(JClient::SLEEP);
629  }
630  }
631  }
632  }
633  }
634  }
JDAQStateMachine::state_Main Main
JClientList clientList
Definition: JDAQDriver.hh:640
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
JDAQStateMachine::state_Main::state_RunControl RunControl
static void KM3NETDAQ::JDAQDriver::copy ( std::istream &  in,
std::ostream &  out,
const char  eol = '\n' 
)
inlinestaticprotected

Copy data from input to output stream.

Tagged file names are recursively expanded.

Parameters
ininput stream
outoutput stream
eolend of line

Definition at line 652 of file JDAQDriver.hh.

653  {
654  using namespace std;
655 
656  string buffer;
657 
658  if (getline(in, buffer, eol)) {
659 
660  for (string::size_type pos = 0; pos < buffer.length(); ) {
661 
662  string::size_type lpos = buffer.substr(pos).find(FILENAME_PREFIX);
663  string::size_type rpos = buffer.substr(pos).find(FILENAME_POSTFIX);
664 
665  if (lpos != string::npos &&
666  rpos != string::npos) {
667 
668  out << buffer.substr(pos, lpos);
669 
670  lpos += FILENAME_PREFIX.length();
671  pos += lpos;
672 
673  ifstream file(buffer.substr(pos, rpos - lpos).c_str());
674 
675  copy(file, out, '\0');
676 
677  rpos += FILENAME_POSTFIX.length();
678  pos += rpos - lpos;
679 
680  } else {
681 
682  out << buffer.substr(pos);
683 
684  pos += buffer.substr(pos).length();
685  }
686  }
687  }
688  }
static const std::string FILENAME_PREFIX
Definition: JDAQTags.hh:54
static const std::string FILENAME_POSTFIX
Definition: JDAQTags.hh:55
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
Definition: JDataQuality.sh:19
static void copy(std::istream &in, std::ostream &out, const char eol= '\n')
Copy data from input to output stream.
Definition: JDAQDriver.hh:652
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
virtual bool KM3NETDAQ::JDAQClient::enter ( const JArgs args)
inlinevirtualinherited

Enter the state machine.

This overloaded method enter reproduces the constructor. All necessary input is parsed from the list of arguments. In case of an error, the state machine is not entered.

Parameters
argsarray of command line arguments
Returns
true if okay; else false

Definition at line 392 of file JDAQClient.hh.

393  {
394  using namespace std;
395 
396  string server;
397  string logger;
398  int level;
399  bool use_cout;
400 
401  try {
402 
403  parser['H'] = make_field(server) = "localhost";
404  parser['M'] = make_field(logger) = "localhost";
405  parser['d'] = make_field(level) = 0;
406  parser['c'] = make_field(use_cout);
407 
408  if (parser.read(args) != 0) {
409  return false;
410  }
411  }
412  catch(const std::exception &error) {
413  cerr << error.what() << endl;
414  return false;
415  }
416 
417  try {
418 
419  JLogger* out = NULL;
420 
421  if (use_cout)
422  out = new JStreamLogger(cout);
423  else
424  out = new JControlHostLogger(logger);
425 
426  this->logger = JMessageLogger(out, getName(), level);
427 
428  this->server.reset(new JControlHost(server));
429 
430  return enter();
431  }
432  catch(const std::exception& error) {
433  cerr << error.what() << endl;
434  return false;
435  }
436  }
JParser parser
parser method enter()
Definition: JDAQClient.hh:1065
Message logging based on std::ostream.
Interface for logging messages.
Definition: JLogger.hh:22
Message logging based on ControlHost.
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
virtual bool enter() override
Enter the state machine.
Definition: JDAQClient.hh:447
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1811
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
const std::string & getName() const
Get name of state machine.
Definition: JDAQCHSM.chsm:78
virtual bool KM3NETDAQ::JDAQClient::exit ( )
inlineoverridevirtualinherited

Exit the state machine.

This method releases the various resources.

Returns
true if okay; else false

Definition at line 485 of file JDAQClient.hh.

486  {
487  try {
488  if (server.is_valid()) { server.reset(NULL); }
489  }
490  catch(const std::exception& error) {
491  }
492 
493  try {
494  if (logger.is_valid()) { logger.reset(NULL); }
495  }
496  catch(const std::exception& error) {
497  }
498 
499  return CHSM::machine::exit();
500  }
void reset(JLogger *__logger=NULL)
Reset logger.
exit
Definition: JPizza.sh:36
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
bool is_valid() const
Check validity of logger object.
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
bool KM3NETDAQ::JDAQClient::isRunning ( ) const
inlineinherited

Check if this client is in runnig state.

Returns
true if running; else false

Definition at line 508 of file JDAQClient.hh.

509  {
510  return Main.RunControl.Operational.Running.active();
511  }
JDAQStateMachine::state_Main Main
JDAQStateMachine::state_Main::state_RunControl::state_Operational Operational
JDAQStateMachine::state_Main::state_RunControl RunControl
void KM3NETDAQ::JDAQClient::replaceEvent ( const JTag oldTag,
const JTag newTag,
JDAQEvent_t event 
)
inlineinherited

Replace tag of given event in event table.

Parameters
oldTagold tag
newTagnew tag
eventevent

Definition at line 521 of file JDAQClient.hh.

524  {
525  eventTable.replace(oldTag, newTag, event);
526  }
void replace(const JTag &oldTag, const JTag &newTag, JDAQEvent_t &event)
Replace entry in table.
Definition: JEventTable.hh:96
JEventTable eventTable
event table
Definition: JDAQClient.hh:203
JDAQEvent_t* KM3NETDAQ::JDAQClient::findEvent ( const JTag tag,
const std::string event_name 
)
inlineinherited

Find event in event table.

Parameters
tagtag
event_nameevent name
Returns
pointer to event or NULL

Definition at line 536 of file JDAQClient.hh.

537  {
538  JEventTable::const_iterator i = eventTable.find(tag, event_name);
539 
540  if (i != eventTable.end())
541  return i->second;
542  else
543  return NULL;
544  }
JEventTable eventTable
event table
Definition: JDAQClient.hh:203
const_iterator find(const JTag &tag, const std::string &event_name) const
Find entry.
Definition: JEventTable.hh:116
void KM3NETDAQ::JDAQClient::addSubscription ( const JSubscription subscription)
inlineinherited

Add custom subscription.

Parameters
subscriptionsubscription

Definition at line 552 of file JDAQClient.hh.

553  {
555  }
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
JSubscriptionList subscription
custom subscription
Definition: JDAQClient.hh:1066
template<class T >
void KM3NETDAQ::JDAQClient::addParameter ( const char  option,
T parameter 
)
inlineinherited

Add parameter to parser used in method enter().

Parameters
optionoption
parameterparameter

Definition at line 565 of file JDAQClient.hh.

566  {
567  parser[option] = make_field(parameter);
568  }
JParser parser
parser method enter()
Definition: JDAQClient.hh:1065
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
template<class T >
void KM3NETDAQ::JDAQClient::addParameter ( const char  option,
T parameter,
const T value 
)
inlineinherited

Add parameter to parser used in method enter().

Parameters
optionoption
parameterparameter
valuedefault value

Definition at line 579 of file JDAQClient.hh.

580  {
581  parser[option] = make_field(parameter) = value;
582  }
JParser parser
parser method enter()
Definition: JDAQClient.hh:1065
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
void KM3NETDAQ::JDAQClient::setSelect ( )
inlineinherited

Set the file descriptor mask for the select call.

Definition at line 588 of file JDAQClient.hh.

589  {
590  select.reset();
591 
593 
595  }
JSelectReader select
select call
Definition: JDAQClient.hh:1064
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:834
JFileDescriptorMask & getReaderMask()
Get reader mask.
void setReaderMask(const JAbstractFile &file)
Set reader mask.
void reset()
Reset.
void setSelect()
Set the file descriptor mask for the select call.
Definition: JDAQClient.hh:588
virtual void KM3NETDAQ::JDAQClient::setSelect ( JFileDescriptorMask mask) const
inlinevirtualinherited

Set the file descriptor mask for the select call.

This implementation does nothing but may be redefined by the derived class.

Parameters
maskfile descriptor mask

Reimplemented in KM3NETDAQ::JDataFilter, KM3NETDAQ::JDataWriter, and KM3NETDAQ::MonitorRouter.

Definition at line 604 of file JDAQClient.hh.

605  {}
virtual void KM3NETDAQ::JDAQClient::actionSelect ( const JFileDescriptorMask mask)
inlinevirtualinherited

Action method following last select call.

This implementation does nothing but may be redefined by the derived class.

Parameters
maskfile descriptor mask

Reimplemented in KM3NETDAQ::JDataFilter, KM3NETDAQ::DataQueue, KM3NETDAQ::JDataWriter, and KM3NETDAQ::MonitorRouter.

Definition at line 614 of file JDAQClient.hh.

615  {}
virtual void KM3NETDAQ::JDAQClient::actionRunning ( )
inlinevirtualinherited

This method is repeatedly called when this client machine is in state Running and the clock interval time is non-zero.

This implementation does nothing but may be redefined by the derived class. Care has to be taken so that the time needed to execute this method should be less than the specified clock interval time (see method setClockInterval()).

Reimplemented in KM3NETDAQ::JDataFilter, KM3NETDAQ::JDataWriter, KM3NETDAQ::JDQSimulator, KM3NETDAQ::DataQueue, KM3NETDAQ::JEventGenerator, KM3NETDAQ::MonitorRouter, and AcousticDataFilter.

Definition at line 625 of file JDAQClient.hh.

626  {}
virtual void KM3NETDAQ::JDAQClient::actionInput ( int  length,
const char *  buffer 
)
inlineoverridevirtualinherited

This method is called at ev_input.

Parameters
lengthlength of data
bufferpointer to data

Reimplemented from JDAQCHSM.

Reimplemented in KM3NETDAQ::DataQueue.

Definition at line 635 of file JDAQClient.hh.

636  {
637  using namespace std;
638 
639  JProperties properties(JEquationParameters("=", ";", "", ""), 1);
640 
641  int level = this->logger.getLevel();
642 
643  properties["debug"] = level;
644 
645  properties.read(string(buffer, length));
646 
647  this->logger.setLevel(level);
648  }
Utility class to parse parameter values.
Definition: JProperties.hh:497
Simple data structure to support I/O of equations (see class JLANG::JEquation).
JMessageLogger logger
message logger
Definition: JDAQClient.hh:835
void setLevel(const int __level)
Set debug level.
JLevel_t getLevel()
Get debug level.
virtual bool KM3NETDAQ::JDAQClient::filter ( const JTag tag,
int  length,
const char *  buffer 
)
inlinevirtualinherited

Filter message.

The filter method can be overwritten so that a specific action is made before the corresponding message is processed by the state machine. The message is ignored if true is returned, else it is normally processed.

Parameters
tagtag
lengthnumber of characters
buffermessage
Returns
skip message or not

Definition at line 662 of file JDAQClient.hh.

663  {
664  return false;
665  }
virtual void KM3NETDAQ::JDAQClient::actionTagged ( const JTag tag,
int  length,
const char *  buffer 
)
inlinevirtualinherited

This method is called when a custom tag is encountered.

Parameters
tagtag
lengthlength of data
bufferpointer to data

Reimplemented in KM3NETDAQ::JDataFilter.

Definition at line 675 of file JDAQClient.hh.

676  {
677  }
void KM3NETDAQ::JDAQClient::run ( const int  port)
inlineinherited

Run for ever.

This method can be used when the run control client is started before the run control (e.g. at boot time of the host processor). This method should be called before the state machine is entered. It launches a server which accepts a JNET::JControlHost connection from a designated application e.g. the JDAQClientStarter.cc program. The state machine is entered using the available data in the JNET::JControlHost message. After the state machine is exited, it accepts a new a JNET::JControlHost connection.

Parameters
portport number

Definition at line 775 of file JDAQClient.hh.

776  {
777  JControlHostServer local_server(port);
778 
779  for ( ; ; ) {
780 
781  JControlHost* ps = local_server.AcceptClient();
782 
783  ps->Connected();
784 
785  JNET::JPrefix prefix;
786 
787  ps->WaitHead(prefix);
788 
789  const int length = prefix.getSize();
790 
791  char* buffer = new char[length];
792 
793  ps->GetFullData(buffer, length);
794  ps->PutFullData(prefix.toString(), buffer, length);
795 
796  delete ps;
797 
798  enter(JArgs(std::string(buffer, length)));
799 
800  delete [] buffer;
801 
802  run();
803 
804  exit();
805  }
806  }
ControlHost prefix.
Definition: JPrefix.hh:31
virtual bool exit() override
Exit the state machine.
Definition: JDAQClient.hh:485
virtual bool enter() override
Enter the state machine.
Definition: JDAQClient.hh:447
void run()
Run as run control client following command messages via JNET::JControlHost.
Definition: JDAQClient.hh:690
int getSize() const
Get size.
Definition: JPrefix.hh:62
then awk string
std::string toString() const
Convert tag to string.
Definition: JTag.hh:171
void JDAQStateMachine::A1 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 344 of file JDAQCHSM.cc.

344 { actionError(); }
virtual void actionError()
Definition: JDAQCHSM.chsm:124
void JDAQStateMachine::A2 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 346 of file JDAQCHSM.cc.

346 { execute(&JDAQCHSM::actionInit, event); }
virtual void actionInit(int, const char *)
Definition: JDAQCHSM.chsm:112
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::A3 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 348 of file JDAQCHSM.cc.

348 { JDAQCHSM::exit(); }
exit
Definition: JPizza.sh:36
void JDAQStateMachine::A4 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 350 of file JDAQCHSM.cc.

virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
virtual void actionConfigure(int, const char *)
Definition: JDAQCHSM.chsm:113
void JDAQStateMachine::A5 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 352 of file JDAQCHSM.cc.

352 { execute(&JDAQCHSM::actionReset, event); }
virtual void actionReset(int, const char *)
Definition: JDAQCHSM.chsm:118
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::A6 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 354 of file JDAQCHSM.cc.

354  {
355 
356  std::istringstream is(std::string(ev_start->buffer, ev_start->length));
357 
358  is >> run_number >> detector_id;
359 
361 
362  }
JDAQStateMachine::ev_start_event ev_start
int run_number
Definition: JDAQCHSM.chsm:156
is
Definition: JDAQCHSM.chsm:167
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
then awk string
virtual void actionStart(int, const char *)
Definition: JDAQCHSM.chsm:114
int detector_id
Definition: JDAQCHSM.chsm:155
void JDAQStateMachine::A7 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 364 of file JDAQCHSM.cc.

364 { execute(&JDAQCHSM::actionQuit, event); }
virtual void actionQuit(int, const char *)
Definition: JDAQCHSM.chsm:119
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::A8 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 366 of file JDAQCHSM.cc.

366 { execute(&JDAQCHSM::actionContinue, event); }
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
virtual void actionContinue(int, const char *)
Definition: JDAQCHSM.chsm:116
void JDAQStateMachine::A9 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 368 of file JDAQCHSM.cc.

368 { execute(&JDAQCHSM::actionStop, event); }
virtual void actionStop(int, const char *)
Definition: JDAQCHSM.chsm:117
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::A10 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 370 of file JDAQCHSM.cc.

370 { execute(&JDAQCHSM::actionPause, event); }
virtual void actionPause(int, const char *)
Definition: JDAQCHSM.chsm:115
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::A11 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 372 of file JDAQCHSM.cc.

372 { execute(&JDAQCHSM::actionRecover, event); }
virtual void actionRecover(int, const char *)
Definition: JDAQCHSM.chsm:125
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::A12 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 374 of file JDAQCHSM.cc.

374 { JDAQCHSM::exit(); }
exit
Definition: JPizza.sh:36
void JDAQStateMachine::A13 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 376 of file JDAQCHSM.cc.

376 { execute(&JDAQCHSM::actionCheck, event); }
virtual void actionCheck(int, const char *)
Definition: JDAQCHSM.chsm:121
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::A14 ( CHSM_ns_alias::event const &  event)
inherited

Definition at line 378 of file JDAQCHSM.cc.

378 { execute(&JDAQCHSM::actionInput, event); }
virtual void actionInput(int, const char *)
Definition: JDAQCHSM.chsm:122
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.
void JDAQStateMachine::EAM4root ( CHSM_ns_alias::state const &  chsm_state_,
CHSM_ns_alias::event const &  event 
)
inherited

Definition at line 337 of file JDAQCHSM.cc.

337  {
338 #line 164 "JDAQCHSM.chsm"
339  CHSM_ns_alias::cluster const &state = (CHSM_ns_alias::cluster const&)chsm_state_; actionEnter(); }
virtual void actionEnter()
Interface methods for actions corresponding to state transitions.
Definition: JDAQCHSM.chsm:109
void JDAQStateMachine::XAM4root ( CHSM_ns_alias::state const &  chsm_state_,
CHSM_ns_alias::event const &  event 
)
inherited

Definition at line 340 of file JDAQCHSM.cc.

340  {
341 #line 165 "JDAQCHSM.chsm"
342  CHSM_ns_alias::cluster const &state = (CHSM_ns_alias::cluster const&)chsm_state_; actionExit(); }
virtual void actionExit()
Definition: JDAQCHSM.chsm:110
const std::string& JDAQCHSM::getName ( ) const
inlineinherited

Get name of state machine.

Returns
name

Definition at line 78 of file JDAQCHSM.chsm.

79  {
80  return name;
81  }
std::string name
Definition: JDAQCHSM.chsm:154
const std::string& JDAQCHSM::getName ( ) const
inlineinherited

Get name of state machine.

Returns
name

Definition at line 89 of file JDAQCHSM.hh.

90  {
91  return name;
92  }
std::string name
Definition: JDAQCHSM.chsm:154
int JDAQCHSM::getDetectorID ( ) const
inlineinherited

Get detector identifier.

Returns
detector identifier.

Definition at line 89 of file JDAQCHSM.chsm.

90  {
91  return detector_id;
92  }
int detector_id
Definition: JDAQCHSM.chsm:155
int JDAQCHSM::getDetectorID ( ) const
inlineinherited

Get detector identifier.

Returns
detector identifier.

Definition at line 100 of file JDAQCHSM.hh.

101  {
102  return detector_id;
103  }
int detector_id
Definition: JDAQCHSM.chsm:155
int JDAQCHSM::getRunNumber ( ) const
inlineinherited

Get run number.

Returns
run number

Definition at line 100 of file JDAQCHSM.chsm.

101  {
102  return run_number;
103  }
int run_number
Definition: JDAQCHSM.chsm:156
int JDAQCHSM::getRunNumber ( ) const
inlineinherited

Get run number.

Returns
run number

Definition at line 111 of file JDAQCHSM.hh.

112  {
113  return run_number;
114  }
int run_number
Definition: JDAQCHSM.chsm:156
virtual void JDAQCHSM::actionEnter ( )
inlinevirtualinherited

Interface methods for actions corresponding to state transitions.

Reimplemented in KM3NETDAQ::JDataFilter, KM3NETDAQ::DataQueue, JDAQDemoClient, AcousticDataFilter, and KM3NETDAQ::MonitorRouter.

Definition at line 109 of file JDAQCHSM.chsm.

109 {}
virtual void JDAQCHSM::actionEnter ( )
inlinevirtualinherited

Interface methods for actions corresponding to state transitions.

Reimplemented in KM3NETDAQ::JDataFilter, KM3NETDAQ::DataQueue, JDAQDemoClient, AcousticDataFilter, and KM3NETDAQ::MonitorRouter.

Definition at line 120 of file JDAQCHSM.hh.

120 {}
virtual void JDAQCHSM::actionInit ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionInit ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionConfigure ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionConfigure ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionPause ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionPause ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionContinue ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionContinue ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionReset ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionReset ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionQuit ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionQuit ( int  ,
const char *   
)
inlinevirtualinherited
virtual void JDAQCHSM::actionError ( )
inlinevirtualinherited

Definition at line 124 of file JDAQCHSM.chsm.

124 {}
virtual void JDAQCHSM::actionError ( )
inlinevirtualinherited

Definition at line 135 of file JDAQCHSM.hh.

135 {}
virtual void JDAQCHSM::actionRecover ( int  ,
const char *   
)
inlinevirtualinherited

Definition at line 125 of file JDAQCHSM.chsm.

125 {}
virtual void JDAQCHSM::actionRecover ( int  ,
const char *   
)
inlinevirtualinherited

Definition at line 136 of file JDAQCHSM.hh.

136 {}
const std::string& KM3NETDAQ::JDAQClient_t::getHostname ( ) const
inlineinherited

Get hostname.

Returns
host name

Definition at line 109 of file JDAQClient.hh.

110  {
111  return hostname;
112  }
const std::string& KM3NETDAQ::JDAQClient_t::getFullName ( ) const
inlineinherited

Get full name of this run control client.

Returns
full name

Definition at line 120 of file JDAQClient.hh.

121  {
122  return fullname;
123  }
const JTag& KM3NETDAQ::JDAQClient_t::getUniqueTag ( ) const
inlineinherited

Get unique tag of this run control client.

Returns
unique tag

Definition at line 131 of file JDAQClient.hh.

132  {
133  return unique_tag;
134  }
long long int KM3NETDAQ::JDAQClient_t::getClockDelay ( ) const
inlineinherited

Get total delay time.

Returns
delay time [us]

Definition at line 142 of file JDAQClient.hh.

143  {
144  return clock.getDelay();
145  }
long long int getDelay() const
Get total delay time.
Definition: JTimekeeper.hh:78
JTimekeeper clock
central clock
Definition: JDAQClient.hh:207
long long int KM3NETDAQ::JDAQClient_t::getClockInterval ( ) const
inlineinherited

Get interval time.

Returns
interval time [us]

Definition at line 154 of file JDAQClient.hh.

155  {
156  return clock.getInterval();
157  }
JTimekeeper clock
central clock
Definition: JDAQClient.hh:207
long long int getInterval() const
Get interval time.
Definition: JTimekeeper.hh:67
void KM3NETDAQ::JDAQClient_t::setClockInterval ( const long long int  interval_us)
inlineinherited

Set interval time.

Parameters
interval_usinterval time [us]

Definition at line 165 of file JDAQClient.hh.

166  {
167  clock.setInterval(interval_us);
168  }
JTimekeeper clock
central clock
Definition: JDAQClient.hh:207
void setInterval(const long long int interval_us)
Set interval time.
Definition: JTimekeeper.hh:89
void KM3NETDAQ::JDAQClient_t::resetClock ( )
inlineinherited

Reset clock.

Definition at line 174 of file JDAQClient.hh.

175  {
176  clock.reset();
177  }
JTimekeeper clock
central clock
Definition: JDAQClient.hh:207
void reset(const long long int t0)
Reset time.
Definition: JTimekeeper.hh:100
const std::string& KM3NETDAQ::JDAQClient_t::getEventInfo ( ) const
inlineinherited

Get last event information.

Returns
event information

Definition at line 185 of file JDAQClient.hh.

186  {
187  return event_info;
188  }
std::string event_info
event information
Definition: JDAQClient.hh:208
void KM3NETDAQ::JDAQClient_t::setEventInfo ( const std::string info)
inlineinherited

Set last event information.

Parameters
infoevent information

Definition at line 196 of file JDAQClient.hh.

197  {
198  this->event_info = info;
199  }
std::string event_info
event information
Definition: JDAQClient.hh:208

Member Data Documentation

const int KM3NETDAQ::JDAQDriver::SLEEP_TIME_US = 500000
static

Definition at line 42 of file JDAQDriver.hh.

int KM3NETDAQ::JDAQDriver::timeout_us

timeout of state transitions [us]

Definition at line 636 of file JDAQDriver.hh.

JClientList KM3NETDAQ::JDAQDriver::clientList
protected

Definition at line 640 of file JDAQDriver.hh.

bool KM3NETDAQ::JDAQDriver::is_alive
protected

Definition at line 641 of file JDAQDriver.hh.

std::string KM3NETDAQ::JDAQDriver::rc_log
protected

Definition at line 642 of file JDAQDriver.hh.

JSharedPointer<JControlHost> KM3NETDAQ::JDAQClient::server
protectedinherited

message server

Definition at line 834 of file JDAQClient.hh.

JMessageLogger KM3NETDAQ::JDAQClient::logger
protectedinherited

message logger

Definition at line 835 of file JDAQClient.hh.

JDAQStateMachine::state_root JDAQStateMachine::root
inherited
JDAQStateMachine::state_Main JDAQStateMachine::Main
inherited
JDAQStateMachine::ev_daq_event JDAQStateMachine::ev_daq
inherited
char JDAQStateMachine::ev_daq_param_block[sizeof(ev_daq_event::param_block)]
inherited

Definition at line 238 of file JDAQCHSM.hh.

JDAQStateMachine::ev_init_event JDAQStateMachine::ev_init
inherited
char JDAQStateMachine::ev_init_param_block[sizeof(ev_init_event::param_block)]
inherited

Definition at line 258 of file JDAQCHSM.hh.

JDAQStateMachine::ev_configure_event JDAQStateMachine::ev_configure
inherited
char JDAQStateMachine::ev_configure_param_block[sizeof(ev_configure_event::param_block)]
inherited

Definition at line 278 of file JDAQCHSM.hh.

JDAQStateMachine::ev_start_event JDAQStateMachine::ev_start
inherited
char JDAQStateMachine::ev_start_param_block[sizeof(ev_start_event::param_block)]
inherited

Definition at line 298 of file JDAQCHSM.hh.

JDAQStateMachine::ev_pause_event JDAQStateMachine::ev_pause
inherited
char JDAQStateMachine::ev_pause_param_block[sizeof(ev_pause_event::param_block)]
inherited

Definition at line 318 of file JDAQCHSM.hh.

JDAQStateMachine::ev_continue_event JDAQStateMachine::ev_continue
inherited
char JDAQStateMachine::ev_continue_param_block[sizeof(ev_continue_event::param_block)]
inherited

Definition at line 338 of file JDAQCHSM.hh.

JDAQStateMachine::ev_stop_event JDAQStateMachine::ev_stop
inherited
char JDAQStateMachine::ev_stop_param_block[sizeof(ev_stop_event::param_block)]
inherited

Definition at line 358 of file JDAQCHSM.hh.

JDAQStateMachine::ev_reset_event JDAQStateMachine::ev_reset
inherited
char JDAQStateMachine::ev_reset_param_block[sizeof(ev_reset_event::param_block)]
inherited

Definition at line 378 of file JDAQCHSM.hh.

JDAQStateMachine::ev_quit_event JDAQStateMachine::ev_quit
inherited
char JDAQStateMachine::ev_quit_param_block[sizeof(ev_quit_event::param_block)]
inherited

Definition at line 398 of file JDAQCHSM.hh.

JDAQStateMachine::ev_off_event JDAQStateMachine::ev_off
inherited
char JDAQStateMachine::ev_off_param_block[sizeof(ev_off_event::param_block)]
inherited

Definition at line 418 of file JDAQCHSM.hh.

JDAQStateMachine::ev_check_event JDAQStateMachine::ev_check
inherited
char JDAQStateMachine::ev_check_param_block[sizeof(ev_check_event::param_block)]
inherited

Definition at line 438 of file JDAQCHSM.hh.

JDAQStateMachine::ev_input_event JDAQStateMachine::ev_input
inherited
char JDAQStateMachine::ev_input_param_block[sizeof(ev_input_event::param_block)]
inherited

Definition at line 458 of file JDAQCHSM.hh.

JDAQStateMachine::ev_recover_event JDAQStateMachine::ev_recover
inherited
char JDAQStateMachine::ev_recover_param_block[sizeof(ev_recover_event::param_block)]
inherited

Definition at line 478 of file JDAQCHSM.hh.

JDAQStateMachine::ev_error_event JDAQStateMachine::ev_error
inherited
char JDAQStateMachine::ev_error_param_block[sizeof(ev_error_event::param_block)]
inherited

Definition at line 495 of file JDAQCHSM.hh.

std::string JDAQCHSM::name
protectedinherited

Definition at line 154 of file JDAQCHSM.chsm.

int JDAQCHSM::detector_id
protectedinherited

Definition at line 155 of file JDAQCHSM.chsm.

int JDAQCHSM::run_number
protectedinherited

Definition at line 156 of file JDAQCHSM.chsm.

const int KM3NETDAQ::JDAQClient_t::TIMEOUT_S = 1
staticinherited

time out of update [s]

Definition at line 63 of file JDAQClient.hh.

JEventTable KM3NETDAQ::JDAQClient_t::eventTable
protectedinherited

event table

Definition at line 203 of file JDAQClient.hh.

std::string KM3NETDAQ::JDAQClient_t::hostname
protectedinherited

Definition at line 204 of file JDAQClient.hh.

std::string KM3NETDAQ::JDAQClient_t::fullname
protectedinherited

Definition at line 205 of file JDAQClient.hh.

JTag KM3NETDAQ::JDAQClient_t::unique_tag
protectedinherited

Definition at line 206 of file JDAQClient.hh.

JTimekeeper KM3NETDAQ::JDAQClient_t::clock
protectedinherited

central clock

Definition at line 207 of file JDAQClient.hh.

std::string KM3NETDAQ::JDAQClient_t::event_info
protectedinherited

event information

Definition at line 208 of file JDAQClient.hh.


The documentation for this class was generated from the following file: