Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
virtual bool enter () override
 Enter the state machine.
 
virtual void actionExit () override
 Exit the state machine.
 
virtual void enterState (const CHSM::state &state, const CHSM::event &event) override
 Action when entering state.
 
bool update (const bool no_wait)
 Update client list with incoming ControlHost message.
 
virtual void actionStart (int, const char *) override
 
virtual void actionStop (int, const char *) override
 
void run ()
 Run driver with user input.
 
void run (std::istream &in)
 Run driver.
 
void update ()
 Update client list with incoming ControlHost messages until the client list is synchronised with the current state or until the timeout.
 
void synchronise ()
 Synchronise clients.
 
void filter (const std::string &target="")
 Filter client list by putting failing clients to sleep.
 
virtual bool filter (const JTag &tag, int length, const char *buffer)
 Filter message.
 
virtual bool enter (const JArgs &args)
 Enter the state machine.
 
virtual bool exit () override
 Exit the state machine.
 
bool isRunning () const
 Check if this client is in runnig state.
 
void replaceEvent (const JTag &oldTag, const JTag &newTag, JDAQEvent_t &event)
 Replace tag of given event in event table.
 
JDAQEvent_tfindEvent (const JTag &tag, const std::string &event_name)
 Find event in event table.
 
void addSubscription (const JSubscription &subscription)
 Add custom subscription.
 
template<class T >
void addParameter (const char option, T &parameter)
 Add parameter to parser used in method enter().
 
template<class T >
void addParameter (const char option, T &parameter, const T &value)
 Add parameter to parser used in method enter().
 
void setSelect ()
 Set the file descriptor mask for the select call.
 
virtual void setSelect (JFileDescriptorMask &mask) const
 Set the file descriptor mask for the select call.
 
virtual void actionSelect (const JFileDescriptorMask &mask)
 Action method following last select call.
 
virtual void actionRunning ()
 This method is repeatedly called when this client machine is in state Running and the clock interval time is non-zero.
 
virtual void actionInput (int length, const char *buffer) override
 This method is called at ev_input.
 
virtual void actionTagged (const JTag &tag, int length, const char *buffer)
 This method is called when a custom tag is encountered.
 
void run (const int port)
 Run for ever.
 
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::string & getName () const
 Get name of state machine.
 
int getDetectorID () const
 Get detector identifier.
 
int getRunNumber () const
 Get run number.
 
virtual void actionEnter ()
 Interface methods for actions corresponding to state transitions.
 
virtual void actionInit (int, const char *)
 
virtual void actionConfigure (int, const char *)
 
virtual void actionPause (int, const char *)
 
virtual void actionContinue (int, const char *)
 
virtual void actionReset (int, const char *)
 
virtual void actionQuit (int, const char *)
 
virtual void actionError ()
 
virtual void actionRecover (int, const char *)
 
const std::string & getHostname () const
 Get hostname.
 
const std::string & getFullName () const
 Get full name of this run control client.
 
const JTaggetUniqueTag () const
 Get unique tag of this run control client.
 
long long int getClockDelay () const
 Get total delay time.
 
long long int getClockInterval () const
 Get interval time.
 
void setClockInterval (const long long int interval_us)
 Set interval time.
 
void resetClock ()
 Reset clock.
 
const std::string & getEventInfo () const
 Get last event information.
 
void setEventInfo (const std::string &info)
 Set last event information.
 

Public Attributes

int timeout_us
 timeout of state transitions [us]
 
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]
 

Protected Types

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

Static Protected Member Functions

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

Protected Attributes

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

Private Member Functions

void configure ()
 Configure client.
 
std::string getMessage (const CHSM::state &state, const CHSM::event &event) const
 Get event message.
 
virtual void actionCheck (int length, const char *buffer) override
 This method is called at ev_check and reports a system check by mimicing an enter state action.
 
void execute (action __action, const CHSM::event &__event) override
 The method to execute the action.
 
const CHSM::state * getState () const
 Get current state.
 

Private Attributes

JSelectReader select
 select call
 
JParser parser
 parser method enter()
 
JSubscriptionList subscription
 custom subscription
 
CHSM_ns_alias::state * state_ [11]
 
CHSM_ns_alias::event const * taken_ [14]
 
CHSM_ns_alias::state * target_ [14]
 

Static Private Attributes

static int const ev_daq_transitions []
 
static int const ev_init_transitions []
 
static int const ev_configure_transitions []
 
static int const ev_start_transitions []
 
static int const ev_pause_transitions []
 
static int const ev_continue_transitions []
 
static int const ev_stop_transitions []
 
static int const ev_reset_transitions []
 
static int const ev_quit_transitions []
 
static int const ev_off_transitions []
 
static int const ev_check_transitions []
 
static int const ev_input_transitions []
 
static int const ev_recover_transitions []
 
static int const ev_error_transitions []
 
static CHSM_ns_alias::transition const transition_ []
 

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 36 of file JDAQDriver.hh.

Member Typedef Documentation

◆ action

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

Type definition of action method.

Definition at line 152 of file JDAQCHSM.hh.

Constructor & Destructor Documentation

◆ JDAQDriver()

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 54 of file JDAQDriver.hh.

58 :
59 JDAQClient(name, server, logger, level),
60 timeout_us(timeout_s * 1000000),
61 is_alive (false)
62 {}
std::string name
Definition JDAQCHSM.hh:165
std::shared_ptr< JControlHost > server
message server
JMessageLogger logger
message logger
JDAQClient(const std::string &name, const std::string &server, JLogger *logger, const int level)
Constructor.
int timeout_us
timeout of state transitions [us]

Member Function Documentation

◆ enter() [1/2]

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 73 of file JDAQDriver.hh.

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

◆ actionExit()

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 156 of file JDAQDriver.hh.

157 {
158 using namespace std;
159 using namespace JLANG;
160
161 for (int i = 0; i != timeout_us; i += SLEEP_TIME_US) {
162
163 while (update(true)) {}
164
165 if (clientList.count() == 0)
166 break;
167 else
168 usleep(SLEEP_TIME_US);
169 }
170
171 if (clientList.count() != 0) {
172 JWarningStream(logger) << "Timeout at transition " << "exit(); forced stop.";
173 }
174
175 clientList.stop();
176 }
Auxiliary classes and methods for language specific functionality.

◆ enterState()

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 187 of file JDAQDriver.hh.

188 {
189 for (int i = 0; i != timeout_us && clientList.count(state) < clientList.count(JClient::ACTIVE) && clientList.count() != 0; ) {
190 if (!update(true)) {
191 usleep(SLEEP_TIME_US);
192 i += SLEEP_TIME_US;
193 }
194 }
195
196 if (clientList.count(state) < clientList.count(JClient::ACTIVE)) {
197 JWarningStream(logger) << "Timeout at transition " << event.name() << " to state " << state.name();
198 }
199 }

◆ update() [1/2]

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 213 of file JDAQDriver.hh.

214 {
215 using namespace std;
216 using namespace JNET;
218
219 try {
220
221 string tag;
222 long long int length = 0;
223
224 if ( no_wait && server->CheckHead(tag, length) <= 0) { return false; }
225 if (!no_wait && server->WaitHead (tag, length) < 0) { return false; }
226
227 char* data= new char[length];
228
229 server->GetFullData(data, length);
230
231 const string buffer(data, length);
232
233 delete [] data;
234
235 JDebugStream(logger) << "Got message " << tag << ' ' << buffer;
236
237 if (tag == RC_LOG) {
238
239 rc_log = buffer;
240
241 } else if (buffer.find(getFullName()) != string::npos) {
242
243 if (tag == DISPTAG_Born)
244 is_alive = true;
245 else if (tag == DISPTAG_Died)
246 is_alive = false;
247
248 } else {
249
250 JClientList::iterator i = clientList.find(buffer);
251
252 if (i != clientList.end()) {
253
254 i->update(tag, buffer);
255
256 } else {
257
258 JErrorStream(logger) << "Message fom illegal client " << buffer;
259
260 try {
261
262 if (tag == DISPTAG_Born ||
263 tag == DISPTAG_Died ||
264 tag == RC_REPLY) {
265
266 string key, hostname, name;
267
268 istringstream is(buffer);
269
270 const locale loc(is.getloc(), new JWhiteSpacesFacet(is.getloc(), TOKEN_DELIMETER));
271
272 is.imbue(loc);
273
274 if (is >> key >> hostname >> name && key == RUN_CONTROL_CLIENT) {
275
276 JClient client(name, hostname);
277
278 client.update(tag, buffer);
279 client.setMode(JClient::ILLEGAL);
280
281 clientList.insert(client);
282
283 JWarningStream(logger) << "Added illegal client " << client.getFullName();
284
285 } else {
286 THROW(JIOException, "JClient: Error reading " << buffer);
287 }
288 }
289 }
290 catch(const JException& error) {
291 JErrorStream(logger) << error;
292 }
293 }
294 }
295
296 return true;
297 }
298 catch(const JControlHostException& error) {
299 JErrorStream(logger) << error;
300 }
301
302 return false;
303 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
General exception.
Definition JException.hh:25
Exception for I/O.
Auxiliary class to specify white space character(s) in currect locale.
ControlHost client manager.
Definition JLigier.cc:245
char * loc(char *orig)
static const std::string RUN_CONTROL_CLIENT
Definition JDAQTags.hh:44
static const std::string TOKEN_DELIMETER
Definition JDAQTags.hh:58
Level specific message streamers.

◆ actionStart()

virtual void KM3NETDAQ::JDAQDriver::actionStart ( int ,
const char *  )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 305 of file JDAQDriver.hh.

306 {
307 rc_log = "";
308 }

◆ actionStop()

virtual void KM3NETDAQ::JDAQDriver::actionStop ( int ,
const char *  )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 310 of file JDAQDriver.hh.

311 {
312 if (rc_log != "")
313 JNoticeStream(logger) << rc_log;
314 else
315 JErrorStream (logger) << "Missing message from JDataWriter with tag " << RC_LOG;
316 }

◆ run() [1/3]

void KM3NETDAQ::JDAQDriver::run ( )
inline

Run driver with user input.

Definition at line 321 of file JDAQDriver.hh.

322 {
323 run(std::cin);
324 }
void run()
Run driver with user input.

◆ run() [2/3]

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 365 of file JDAQDriver.hh.

366 {
367 using namespace std;
368
369 for (string key; in >> key; ) {
370
371 if (key[0] == '#') {
372
373 in.ignore(numeric_limits<streamsize>::max(), '\n');
374
375 } else if (key == "enter") {
376
377 enter();
378
379 if (!active()) {
380 cerr << "State machine not entered; abort." << endl;
381 return;
382 }
383
384 } else if (key == "exit") {
385
386 timeout_us = 0;
387 exit();
388
389 } else if (key == "quit") {
390
391 break;
392
393 } else if (key == "sleep") {
394
395 int sec;
396
397 if (in >> sec) {
398 sleep(sec);
399 }
400
401 } else if (key == "process") {
402
403 string buffer;
404
405 getline(in, buffer, ';');
406
407 istringstream is(buffer);
408
409 JClient client;
410
411 if (is >> client) {
412
413 client.setMode(JClient::ACTIVE);
414
415 if (!clientList.insert(client).second) {
416 JWarningStream(logger) << "Process already exists " << client;
417 }
418
419 } else {
420 JErrorStream(logger) << "Error reading key word process.";
421 }
422
423 } else if (key == "event" || key == "event*") {
424
425 JEvent_t event;
426 char c;
427 string buffer;
428 const char eol = '\n';
429
430 if (in >> event >> c && c == '{' && getline(in, buffer, '}')) {
431
432 if (clientList.count() != 0) {
433
434 JDAQEvent_t* pev = findEvent(RC_CMD, event.getName());
435
436 if (pev != NULL) {
437
438 if (pev->active() || key == "event*") {
439
440 istringstream is(buffer);
441
442 for (string tag; is >> tag; ) {
443
444 ostringstream os;
445
446 os << event << getTokenDelimeter();
447
448 copy(is, os, eol);
449
450 JNoticeStream(logger) << key << ' ' << tag << ' ' << event;
451
452 server->PutFullString(tag, os.str());
453 }
454
455 if (key != "event*") {
456 (*pev)(0, NULL); // trigger driver
457 }
458
459 } else {
460 JErrorStream(logger) << "Inactive event " << event;
461 }
462
463 } else {
464 JErrorStream(logger) << "Unknown event " << event;
465 }
466
467 } else {
468 JErrorStream(logger) << "No active client to trigger event.";
469 }
470
471 } else {
472 JErrorStream(logger) << "Error reading key word event.";
473 }
474
475 } else if (key == "message") {
476
477 string tag;
478 string buffer;
479
480 if (in >> tag && getline(in, buffer, ';'))
481 server->PutFullString(tag, buffer);
482 else
483 JErrorStream(logger) << "Invalid message: <" << tag << "> \"" << buffer << "\"";
484
485 } else if (key == "print") {
486
487 for (JClientList::const_iterator i = clientList.begin(); i != clientList.end(); ++i) {
488 JNoticeStream(logger) << i->getFullName() << ' '
489 << i->getStartCommand() << ' '
490 << i->getAlive() << ' '
491 << i->getStatename();
492 }
493
494 } else if (key == "filter") {
495
496 string client;
497 string buffer;
498
499 getline(in, buffer, ';');
500
501 for (istringstream is(buffer); is >> client; ) {
502 filter(client);
503 }
504
505 } else if (key == "sync") {
506
507 synchronise();
508
509 } else {
510
511 JErrorStream(logger) << "Unknown key: " << key;
512
513 in.ignore(numeric_limits<streamsize>::max(), '\n');
514 }
515 }
516 }
virtual bool exit() override
Exit the state machine.
JDAQEvent_t * findEvent(const JTag &tag, const std::string &event_name)
Find event in event table.
virtual bool enter() override
Enter the state machine.
Definition JDAQDriver.hh:73
void filter(const std::string &target="")
Filter client list by putting failing clients to sleep.
void synchronise()
Synchronise clients.
static void copy(std::istream &in, std::ostream &out, const char eol='\n')
Copy data from input to output stream.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478
static const JNET::JTag RC_CMD
Definition JDAQTags.hh:66
JDAQStateMachine::ev_daq_event JDAQEvent_t
Type definition of a DAQ event.
char getTokenDelimeter()
Get the token delimeter for command messages.

◆ update() [2/2]

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 523 of file JDAQDriver.hh.

524 {
525 using namespace std;
526
527 const CHSM::parent& parent = static_cast<const CHSM::parent&>(Main.RunControl);
528
529 for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
530
531 if (state->active()) {
532 for (int i = 0; i != timeout_us && clientList.count(*state) < clientList.count(JClient::ACTIVE); ) {
533 if (!update(true)) {
534 usleep(SLEEP_TIME_US);
535 i += SLEEP_TIME_US;
536 }
537 }
538 }
539 }
540 }
JDAQStateMachine::state_Main::state_RunControl RunControl
JDAQStateMachine::state_Main Main

◆ synchronise()

void KM3NETDAQ::JDAQDriver::synchronise ( )
inline

Synchronise clients.

Definition at line 546 of file JDAQDriver.hh.

547 {
548 using namespace std;
549
550 const CHSM::parent& parent = static_cast<const CHSM::parent&>(Main.RunControl);
551
552 for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
553
554 if (state->active()) {
555
556 if (clientList.count(*state) < clientList.count(JClient::ACTIVE)) {
557
558 JDebugStream(logger) << "Synchronising " << state->name();
559
560 for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
561
562 if (i->getMode() == JClient::ACTIVE) {
563
564 if (!i->getAlive()) {
565
566 try {
567
568 string buffer;
569
570 if (JControlHost::WhereIs(JClient::SERVER, i->getFullName(), buffer) > 0) {
571
572 i->setAlive(true);
573
574 if (buffer.find(i->getHostname()) == string::npos) {
575 JErrorStream(logger) << i->getFullName() << " running on " << buffer << " but not alive.";
576 }
577 }
578 }
579 catch(const JControlHostException& error) {
580 JErrorStream(logger) << error;
581 }
582 }
583
584 if (i->getAlive() && i->getStatename() != state->name()) {
585 server->PutFullString(KM3NETDAQ::getUniqueTag(i->getHostname(), i->getName()), ev_check.name());
586 }
587 }
588 }
589
590
591 for (int i = 0; i != timeout_us && clientList.count(*state) < clientList.count(JClient::ACTIVE); ) {
592 if (!update(true)) {
593 usleep(SLEEP_TIME_US);
594 i += SLEEP_TIME_US;
595 }
596 }
597
598 if (clientList.count(*state) < clientList.count(JClient::ACTIVE)) {
599 JWarningStream(logger) << "Timeout at synchronisation.";
600 }
601 }
602 }
603 }
604 }
JDAQStateMachine::ev_check_event ev_check
static int WhereIs(const std::string &host_name, const std::string &nick_name, std::string &answer)
Locate ControlHost client(s).
static std::string SERVER
host name of message server
Definition JClient.hh:32
JTag getUniqueTag(const std::string &hostname, const std::string &name)
Get unique tag of run control client.

◆ filter() [1/2]

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 613 of file JDAQDriver.hh.

614 {
615 const CHSM::parent& parent = static_cast<const CHSM::parent&>(Main.RunControl);
616
617 for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
618
619 if (state->active()) {
620
621 for (JClientList::iterator i = clientList.begin(); i != clientList.end(); ++i) {
622
623 if (target == "" || i->getName().find(target) != std::string::npos) {
624
625 if (!i->getAlive() || i->getStatename() != state->name()) {
626
627 JNoticeStream(logger) << "Put to sleep " << i->getFullName();
628
629 i->setMode(JClient::SLEEP);
630 }
631 }
632 }
633 }
634 }
635 }

◆ copy()

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 653 of file JDAQDriver.hh.

654 {
655 using namespace std;
656 using namespace JPP;
657
658 const JEquationParameters parameters("=", ";", "", "");
659
660 string buffer;
661
662 if (getline(in, buffer, eol)) {
663
664 for (string::size_type pos = 0; pos < buffer.length(); ) {
665
666 string::size_type lpos = buffer.substr(pos).find(FILENAME_PREFIX);
667 string::size_type rpos = buffer.substr(pos).find(FILENAME_POSTFIX);
668
669 if (lpos != string::npos &&
670 rpos != string::npos) {
671
672 out << buffer.substr(pos, lpos);
673
674 lpos += FILENAME_PREFIX.length();
675 pos += lpos;
676
677 ifstream file(buffer.substr(pos, rpos - lpos).c_str());
678
679 copy(file, out, '\0');
680
681 rpos += FILENAME_POSTFIX.length();
682 pos += rpos - lpos;
683
684 } else {
685
686 out << buffer.substr(pos);
687
688 pos += buffer.substr(pos).length();
689 }
690 }
691 }
692 }
Simple data structure to support I/O of equations (see class JLANG::JEquation).
static const std::string FILENAME_PREFIX
Definition JDAQTags.hh:60
static const std::string FILENAME_POSTFIX
Definition JDAQTags.hh:61

◆ filter() [2/2]

virtual bool KM3NETDAQ::JDAQClient::filter ( const JTag & tag,
int length,
const char * buffer )
inlinevirtual

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

Reimplemented from KM3NETDAQ::JDAQClient.

Definition at line 661 of file JDAQClient.hh.

662 {
663 return false;
664 }

◆ enter() [2/2]

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 391 of file JDAQClient.hh.

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

◆ exit()

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 484 of file JDAQClient.hh.

485 {
486 try {
487 if (server) { server.reset(); }
488 }
489 catch(const std::exception& error) {
490 }
491
492 try {
493 if (logger) { logger.reset(); }
494 }
495 catch(const std::exception& error) {
496 }
497
498 return CHSM::machine::exit();
499 }
void reset(JLogger *__logger=NULL)
Reset logger.

◆ isRunning()

bool KM3NETDAQ::JDAQClient::isRunning ( ) const
inlineinherited

Check if this client is in runnig state.

Returns
true if running; else false

Definition at line 507 of file JDAQClient.hh.

508 {
509 return Main.RunControl.Operational.Running.active();
510 }
JDAQStateMachine::state_Main::state_RunControl::state_Operational Operational

◆ replaceEvent()

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 520 of file JDAQClient.hh.

523 {
524 eventTable.replace(oldTag, newTag, event);
525 }
void replace(const JTag &oldTag, const JTag &newTag, JDAQEvent_t &event)
Replace entry in table.
JEventTable eventTable
event table

◆ findEvent()

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 535 of file JDAQClient.hh.

536 {
537 JEventTable::const_iterator i = eventTable.find(tag, event_name);
538
539 if (i != eventTable.end())
540 return i->second;
541 else
542 return NULL;
543 }
const_iterator find(const JTag &tag, const std::string &event_name) const
Find entry.

◆ addSubscription()

void KM3NETDAQ::JDAQClient::addSubscription ( const JSubscription & subscription)
inlineinherited

Add custom subscription.

Parameters
subscriptionsubscription

Definition at line 551 of file JDAQClient.hh.

552 {
554 }
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
JSubscriptionList subscription
custom subscription

◆ addParameter() [1/2]

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 564 of file JDAQClient.hh.

565 {
566 parser[option] = make_field(parameter);
567 }

◆ addParameter() [2/2]

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 578 of file JDAQClient.hh.

579 {
580 parser[option] = make_field(parameter) = value;
581 }

◆ setSelect() [1/2]

void KM3NETDAQ::JDAQClient::setSelect ( )
inlineinherited

Set the file descriptor mask for the select call.

Definition at line 587 of file JDAQClient.hh.

588 {
589 select.reset();
590
592
594 }
void setReaderMask(const JAbstractFile &file)
Set reader mask.
JFileDescriptorMask & getReaderMask()
Get reader mask.
JSelectReader select
select call
void setSelect()
Set the file descriptor mask for the select call.

◆ setSelect() [2/2]

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 603 of file JDAQClient.hh.

604 {}

◆ actionSelect()

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::DataQueue, KM3NETDAQ::JDataFilter, KM3NETDAQ::JDataWriter, and KM3NETDAQ::MonitorRouter.

Definition at line 613 of file JDAQClient.hh.

614 {}

◆ actionRunning()

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 AcousticDataFilter, KM3NETDAQ::DataQueue, KM3NETDAQ::JDataFilter, KM3NETDAQ::JDataWriter, KM3NETDAQ::JDQSimulator, KM3NETDAQ::JEventGenerator, and KM3NETDAQ::MonitorRouter.

Definition at line 624 of file JDAQClient.hh.

625 {}

◆ actionInput()

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 634 of file JDAQClient.hh.

635 {
636 using namespace std;
637
638 JProperties properties(JEquationParameters("=", ";", "", ""), 1);
639
640 int level = this->logger.getLevel();
641
642 properties["debug"] = level;
643
644 properties.read(string(buffer, length));
645
646 this->logger.setLevel(level);
647 }
Utility class to parse parameter values.
JLevel_t getLevel()
Get debug level.
void setLevel(const int __level)
Set debug level.

◆ actionTagged()

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 674 of file JDAQClient.hh.

675 {
676 }

◆ run() [3/3]

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 774 of file JDAQClient.hh.

775 {
776 JControlHostServer local_server(port);
777
778 for ( ; ; ) {
779
780 JControlHost* ps = local_server.AcceptClient();
781
782 ps->Connected();
783
784 JNET::JPrefix prefix;
785
786 ps->WaitHead(prefix);
787
788 const int length = prefix.getSize();
789
790 char* buffer = new char[length];
791
792 ps->GetFullData(buffer, length);
793 ps->PutFullData(prefix.toString(), buffer, length);
794
795 delete ps;
796
797 enter(JArgs(std::string(buffer, length)));
798
799 delete [] buffer;
800
801 run();
802
803 exit();
804 }
805 }
Data structure to store command line arguments.
Definition JArgs.hh:26
ControlHost prefix.
Definition JPrefix.hh:33
int getSize() const
Get size.
Definition JPrefix.hh:62
std::string toString() const
Convert tag to string.
Definition JTag.hh:171
void run()
Run as run control client following command messages via JNET::JControlHost.

◆ configure()

void KM3NETDAQ::JDAQClient::configure ( )
inlineprivateinherited

Configure client.

This method is used to setup the event table.

Definition at line 950 of file JDAQClient.hh.

951 {
952 }

◆ getMessage()

std::string KM3NETDAQ::JDAQClient::getMessage ( const CHSM::state & state,
const CHSM::event & event ) const
inlineprivateinherited

Get event message.

Parameters
statestate
eventevent
Returns
message

Definition at line 962 of file JDAQClient.hh.

963 {
964 std::ostringstream os;
965
966 os << getFullName()
968 << (getEventInfo() != "" ?
969 JEvent_t(event.name(), getEventInfo()) :
970 JEvent_t(event.name()))
972 << getStateName(state.name());
973
974 return os.str();
975 }
std::string getStateName(const std::string &name)
Get name of state.
const std::string & getEventInfo() const
Get last event information.

◆ actionCheck()

virtual void KM3NETDAQ::JDAQClient::actionCheck ( int length,
const char * buffer )
inlineoverrideprivatevirtualinherited

This method is called at ev_check and reports a system check by mimicing an enter state action.

Parameters
lengthnumber of characters
buffermessage

Reimplemented from JDAQCHSM.

Definition at line 999 of file JDAQClient.hh.

1000 {
1001 if (Main.RunControl.Error.active()) {
1002
1004
1005 } else {
1006
1007 for (CHSM::parent::iterator state = Main.RunControl.Operational.begin(); state != Main.RunControl.Operational.end(); ++state) {
1008
1009 if (state->active()) {
1010
1011 // mimic enter state
1012
1013 enterState(*state, ev_check);
1014 }
1015 }
1016 }
1017 }
virtual void enterState(const CHSM::state &state, const CHSM::event &event) override
Action when entering state.

◆ execute()

void KM3NETDAQ::JDAQClient::execute ( action __action,
const CHSM::event & __event )
inlineoverrideprivatevirtualinherited

The method to execute the action.

Parameters
__actionpointer to action method
__eventevent that triggered the action

Implements JDAQCHSM.

Definition at line 1026 of file JDAQClient.hh.

1027 {
1028 try {
1029
1030 const JDAQStateMachine::ev_daq_event& event = dynamic_cast<const JDAQStateMachine::ev_daq_event&>(__event);
1031
1032 (this->*__action)(event->length, event->buffer);
1033 }
1034 catch(const std::exception& error) {
1035 JErrorStream(logger) << "Error at event " << __event.name() << " \"" << error.what() << "\"; trigger ev_error.";
1036 ev_error();
1037 }
1038 }
JDAQStateMachine::ev_error_event ev_error

◆ getState()

const CHSM::state * KM3NETDAQ::JDAQClient::getState ( ) const
inlineprivateinherited

Get current state.

Returns
state

Definition at line 1046 of file JDAQClient.hh.

1047 {
1048 for (CHSM::parent::const_iterator state = Main.RunControl.Operational.begin(); state != Main.RunControl.Operational.end(); ++state) {
1049 if (state->active()) {
1050 return &(*state);
1051 }
1052 }
1053
1054 if (Main.RunControl.Error.active()) {
1055 return &Main.RunControl.Error;
1056 }
1057
1058 return NULL;
1059 }

◆ A1()

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.hh:135

◆ A2()

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.hh:123
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.

◆ A3()

void JDAQStateMachine::A3 ( CHSM_ns_alias::event const & event)
inherited

Definition at line 348 of file JDAQCHSM.cc.

348{ JDAQCHSM::exit(); }

◆ A4()

void JDAQStateMachine::A4 ( CHSM_ns_alias::event const & event)
inherited

Definition at line 350 of file JDAQCHSM.cc.

virtual void actionConfigure(int, const char *)
Definition JDAQCHSM.hh:124

◆ A5()

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.hh:129

◆ A6()

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 }
int run_number
Definition JDAQCHSM.hh:167
virtual void actionStart(int, const char *)
Definition JDAQCHSM.hh:125
int detector_id
Definition JDAQCHSM.hh:166
JDAQStateMachine::ev_start_event ev_start

◆ A7()

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.hh:130

◆ A8()

void JDAQStateMachine::A8 ( CHSM_ns_alias::event const & event)
inherited

Definition at line 366 of file JDAQCHSM.cc.

virtual void actionContinue(int, const char *)
Definition JDAQCHSM.hh:127

◆ A9()

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.hh:128

◆ A10()

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.hh:126

◆ A11()

void JDAQStateMachine::A11 ( CHSM_ns_alias::event const & event)
inherited

Definition at line 372 of file JDAQCHSM.cc.

virtual void actionRecover(int, const char *)
Definition JDAQCHSM.hh:136

◆ A12()

void JDAQStateMachine::A12 ( CHSM_ns_alias::event const & event)
inherited

Definition at line 374 of file JDAQCHSM.cc.

374{ JDAQCHSM::exit(); }

◆ A13()

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.hh:132

◆ A14()

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.hh:133

◆ EAM4root()

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.hh:120

◆ XAM4root()

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.hh:121

◆ getName()

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 }

◆ getDetectorID()

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 }

◆ getRunNumber()

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 }

◆ actionEnter()

virtual void JDAQCHSM::actionEnter ( )
inlinevirtualinherited

Interface methods for actions corresponding to state transitions.

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

Definition at line 120 of file JDAQCHSM.hh.

120{}

◆ actionInit()

virtual void JDAQCHSM::actionInit ( int ,
const char *  )
inlinevirtualinherited

◆ actionConfigure()

virtual void JDAQCHSM::actionConfigure ( int ,
const char *  )
inlinevirtualinherited

◆ actionPause()

virtual void JDAQCHSM::actionPause ( int ,
const char *  )
inlinevirtualinherited

◆ actionContinue()

virtual void JDAQCHSM::actionContinue ( int ,
const char *  )
inlinevirtualinherited

◆ actionReset()

virtual void JDAQCHSM::actionReset ( int ,
const char *  )
inlinevirtualinherited

◆ actionQuit()

virtual void JDAQCHSM::actionQuit ( int ,
const char *  )
inlinevirtualinherited

◆ actionError()

virtual void JDAQCHSM::actionError ( )
inlinevirtualinherited

Definition at line 135 of file JDAQCHSM.hh.

135{}

◆ actionRecover()

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

Definition at line 136 of file JDAQCHSM.hh.

136{}

◆ getHostname()

const std::string & KM3NETDAQ::JDAQClient_t::getHostname ( ) const
inlineinherited

Get hostname.

Returns
host name

Definition at line 108 of file JDAQClient.hh.

109 {
110 return hostname;
111 }

◆ getFullName()

const std::string & KM3NETDAQ::JDAQClient_t::getFullName ( ) const
inlineinherited

Get full name of this run control client.

Returns
full name

Definition at line 119 of file JDAQClient.hh.

120 {
121 return fullname;
122 }

◆ getUniqueTag()

const JTag & KM3NETDAQ::JDAQClient_t::getUniqueTag ( ) const
inlineinherited

Get unique tag of this run control client.

Returns
unique tag

Definition at line 130 of file JDAQClient.hh.

131 {
132 return unique_tag;
133 }

◆ getClockDelay()

long long int KM3NETDAQ::JDAQClient_t::getClockDelay ( ) const
inlineinherited

Get total delay time.

Returns
delay time [us]

Definition at line 141 of file JDAQClient.hh.

142 {
143 return clock.getDelay();
144 }
long long int getDelay() const
Get total delay time.
JTimekeeper clock
central clock

◆ getClockInterval()

long long int KM3NETDAQ::JDAQClient_t::getClockInterval ( ) const
inlineinherited

Get interval time.

Returns
interval time [us]

Definition at line 153 of file JDAQClient.hh.

154 {
155 return clock.getInterval();
156 }
long long int getInterval() const
Get interval time.

◆ setClockInterval()

void KM3NETDAQ::JDAQClient_t::setClockInterval ( const long long int interval_us)
inlineinherited

Set interval time.

Parameters
interval_usinterval time [us]

Definition at line 164 of file JDAQClient.hh.

165 {
166 clock.setInterval(interval_us);
167 }
void setInterval(const long long int interval_us)
Set interval time.

◆ resetClock()

void KM3NETDAQ::JDAQClient_t::resetClock ( )
inlineinherited

Reset clock.

Definition at line 173 of file JDAQClient.hh.

174 {
175 clock.reset();
176 }
void reset(const long long int t0)
Reset time.

◆ getEventInfo()

const std::string & KM3NETDAQ::JDAQClient_t::getEventInfo ( ) const
inlineinherited

Get last event information.

Returns
event information

Definition at line 184 of file JDAQClient.hh.

185 {
186 return event_info;
187 }
std::string event_info
event information

◆ setEventInfo()

void KM3NETDAQ::JDAQClient_t::setEventInfo ( const std::string & info)
inlineinherited

Set last event information.

Parameters
infoevent information

Definition at line 195 of file JDAQClient.hh.

196 {
197 this->event_info = info;
198 }

Member Data Documentation

◆ SLEEP_TIME_US

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

Definition at line 43 of file JDAQDriver.hh.

◆ timeout_us

int KM3NETDAQ::JDAQDriver::timeout_us

timeout of state transitions [us]

Definition at line 637 of file JDAQDriver.hh.

◆ clientList

JClientList KM3NETDAQ::JDAQDriver::clientList
protected

Definition at line 641 of file JDAQDriver.hh.

◆ is_alive

bool KM3NETDAQ::JDAQDriver::is_alive
protected

Definition at line 642 of file JDAQDriver.hh.

◆ rc_log

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

Definition at line 643 of file JDAQDriver.hh.

◆ server

std::shared_ptr<JControlHost> KM3NETDAQ::JDAQClient::server
protectedinherited

message server

Definition at line 832 of file JDAQClient.hh.

◆ logger

JMessageLogger KM3NETDAQ::JDAQClient::logger
protectedinherited

message logger

Definition at line 833 of file JDAQClient.hh.

◆ select

JSelectReader KM3NETDAQ::JDAQClient::select
privateinherited

select call

Definition at line 1062 of file JDAQClient.hh.

◆ parser

JParser KM3NETDAQ::JDAQClient::parser
privateinherited

parser method enter()

Definition at line 1063 of file JDAQClient.hh.

◆ subscription

JSubscriptionList KM3NETDAQ::JDAQClient::subscription
privateinherited

custom subscription

Definition at line 1064 of file JDAQClient.hh.

◆ root

JDAQStateMachine::state_root JDAQStateMachine::root
inherited

◆ Main

JDAQStateMachine::state_Main JDAQStateMachine::Main
inherited

◆ ev_daq_transitions

int const JDAQStateMachine::ev_daq_transitions
staticprivateinherited
Initial value:
= {
-1
}

Definition at line 52 of file JDAQCHSM.hh.

◆ ev_daq

JDAQStateMachine::ev_daq_event JDAQStateMachine::ev_daq
inherited

◆ ev_daq_param_block

char JDAQStateMachine::ev_daq_param_block[sizeof(ev_daq_event::param_block)]
inherited

Definition at line 238 of file JDAQCHSM.hh.

◆ ev_init_transitions

int const JDAQStateMachine::ev_init_transitions
staticprivateinherited
Initial value:
= {
1, -1
}

Definition at line 69 of file JDAQCHSM.hh.

◆ ev_init

JDAQStateMachine::ev_init_event JDAQStateMachine::ev_init
inherited

◆ ev_init_param_block

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

Definition at line 258 of file JDAQCHSM.hh.

◆ ev_configure_transitions

int const JDAQStateMachine::ev_configure_transitions
staticprivateinherited
Initial value:
= {
3, -1
}

Definition at line 86 of file JDAQCHSM.hh.

◆ ev_configure

JDAQStateMachine::ev_configure_event JDAQStateMachine::ev_configure
inherited

◆ ev_configure_param_block

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

Definition at line 278 of file JDAQCHSM.hh.

◆ ev_start_transitions

int const JDAQStateMachine::ev_start_transitions
staticprivateinherited
Initial value:
= {
5, -1
}

Definition at line 103 of file JDAQCHSM.hh.

◆ ev_start

JDAQStateMachine::ev_start_event JDAQStateMachine::ev_start
inherited

◆ ev_start_param_block

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

Definition at line 298 of file JDAQCHSM.hh.

◆ ev_pause_transitions

int const JDAQStateMachine::ev_pause_transitions
staticprivateinherited
Initial value:
= {
9, -1
}

Definition at line 120 of file JDAQCHSM.hh.

120 {}
121 virtual void actionExit() {}
122

◆ ev_pause

JDAQStateMachine::ev_pause_event JDAQStateMachine::ev_pause
inherited

◆ ev_pause_param_block

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

Definition at line 318 of file JDAQCHSM.hh.

◆ ev_continue_transitions

int const JDAQStateMachine::ev_continue_transitions
staticprivateinherited
Initial value:
= {
7, -1
}

Definition at line 137 of file JDAQCHSM.hh.

139 :
140

◆ ev_continue

JDAQStateMachine::ev_continue_event JDAQStateMachine::ev_continue
inherited

◆ ev_continue_param_block

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

Definition at line 338 of file JDAQCHSM.hh.

◆ ev_stop_transitions

int const JDAQStateMachine::ev_stop_transitions
staticprivateinherited
Initial value:
= {
8, -1
}

Definition at line 154 of file JDAQCHSM.hh.

◆ ev_stop

JDAQStateMachine::ev_stop_event JDAQStateMachine::ev_stop
inherited

◆ ev_stop_param_block

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

Definition at line 358 of file JDAQCHSM.hh.

◆ ev_reset_transitions

int const JDAQStateMachine::ev_reset_transitions
staticprivateinherited
Initial value:
= {
4, -1
}

Definition at line 171 of file JDAQCHSM.hh.

173 : public JDAQCHSM {
DAQ state machine interface.
Definition JDAQCHSM.hh:25

◆ ev_reset

JDAQStateMachine::ev_reset_event JDAQStateMachine::ev_reset
inherited

◆ ev_reset_param_block

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

Definition at line 378 of file JDAQCHSM.hh.

◆ ev_quit_transitions

int const JDAQStateMachine::ev_quit_transitions
staticprivateinherited
Initial value:
= {
6, -1
}

Definition at line 188 of file JDAQCHSM.hh.

188 : public CHSM_ns_alias::cluster { // 1
189 public:
190 class state_Operational : public CHSM_ns_alias::cluster { // 2

◆ ev_quit

JDAQStateMachine::ev_quit_event JDAQStateMachine::ev_quit
inherited

◆ ev_quit_param_block

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

Definition at line 398 of file JDAQCHSM.hh.

◆ ev_off_transitions

int const JDAQStateMachine::ev_off_transitions
staticprivateinherited
Initial value:
= {
2, 11, -1
}

Definition at line 205 of file JDAQCHSM.hh.

205 :
206 static int const children_[];
207 } RunControl;

◆ ev_off

JDAQStateMachine::ev_off_event JDAQStateMachine::ev_off
inherited

◆ ev_off_param_block

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

Definition at line 418 of file JDAQCHSM.hh.

◆ ev_check_transitions

int const JDAQStateMachine::ev_check_transitions
staticprivateinherited
Initial value:
= {
12, -1
}

Definition at line 222 of file JDAQCHSM.hh.

◆ ev_check

JDAQStateMachine::ev_check_event JDAQStateMachine::ev_check
inherited

◆ ev_check_param_block

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

Definition at line 438 of file JDAQCHSM.hh.

◆ ev_input_transitions

int const JDAQStateMachine::ev_input_transitions
staticprivateinherited
Initial value:
= {
13, -1
}

Definition at line 239 of file JDAQCHSM.hh.

240 : static int const ev_init_transitions[]; public:
241 class ev_init_event : public JDAQStateMachine::ev_daq_event {
static int const ev_init_transitions[]
Definition JDAQCHSM.hh:69

◆ ev_input

JDAQStateMachine::ev_input_event JDAQStateMachine::ev_input
inherited

◆ ev_input_param_block

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

Definition at line 458 of file JDAQCHSM.hh.

◆ ev_recover_transitions

int const JDAQStateMachine::ev_recover_transitions
staticprivateinherited
Initial value:
= {
10, -1
}

Definition at line 256 of file JDAQCHSM.hh.

◆ ev_recover

JDAQStateMachine::ev_recover_event JDAQStateMachine::ev_recover
inherited

◆ ev_recover_param_block

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

Definition at line 478 of file JDAQCHSM.hh.

◆ ev_error_transitions

int const JDAQStateMachine::ev_error_transitions
staticprivateinherited
Initial value:
= {
0, -1
}

Definition at line 273 of file JDAQCHSM.hh.

273 :
274 ev_configure_event( CHSM_EVENT_ARGS ) :
275 JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { }

◆ ev_error

JDAQStateMachine::ev_error_event JDAQStateMachine::ev_error
inherited

◆ ev_error_param_block

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

Definition at line 495 of file JDAQCHSM.hh.

◆ state_

CHSM_ns_alias::state* JDAQStateMachine::state_[11]
privateinherited

Definition at line 522 of file JDAQCHSM.hh.

◆ transition_

CHSM_ns_alias::transition const JDAQStateMachine::transition_
staticprivateinherited
Initial value:
= {
{ 0, 2, 8, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A1 },
{ 0, 3, 4, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A2 },
{ 0, 3, -1, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A3 },
{ 0, 4, 5, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A4 },
{ 0, 4, 3, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A5 },
{ 0, 5, 7, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A6 },
{ 0, 5, 4, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A7 },
{ 0, 6, 7, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A8 },
{ 0, 6, 4, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A9 },
{ 0, 7, 6, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A10 },
{ 0, 8, 2, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A11 },
{ 0, 8, -1, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A12 },
{ 0, 9, -1, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A13 },
{ 0, 9, -1, 0, (CHSM_ns_alias::transition::action)&JDAQStateMachine::A14 },
0
}
void A1(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:344
void A4(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:350
void A13(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:376
void A11(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:372
void A2(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:346
void A14(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:378
void A7(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:364
void A9(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:368
void A12(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:374
void A3(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:348
void A8(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:366
void A5(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:352
void A10(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:370
void A6(CHSM_ns_alias::event const &)
Definition JDAQCHSM.cc:354

Definition at line 280 of file JDAQCHSM.hh.

280 : static int const ev_start_transitions[]; public:
281 class ev_start_event : public JDAQStateMachine::ev_daq_event {
282 public:
285 param_block( CHSM_ns_alias::event const &, int , const char * );
286 protected:
287 virtual ~param_block();
288 };
289 param_block* operator->() const {
290 return (param_block*)param_block_;
291 }
292 void operator()( int , const char * );
293 protected:
294 ev_start_event( CHSM_EVENT_ARGS ) :
295 JDAQStateMachine::ev_daq_event( CHSM_EVENT_INIT ) { }
296 friend class JDAQStateMachine;
ev_daq_event(CHSM_EVENT_ARGS)
Definition JDAQCHSM.hh:234
param_block * operator->() const
Definition JDAQCHSM.hh:289
JDAQStateMachine::ev_daq_event::param_block base_param_block
Definition JDAQCHSM.hh:283
void operator()(int, const char *)
Definition JDAQCHSM.cc:111
ev_start_event(CHSM_EVENT_ARGS)
Definition JDAQCHSM.hh:294
static int const ev_start_transitions[]
Definition JDAQCHSM.hh:103
param_block(CHSM_ns_alias::event const &, int, const char *)
Definition JDAQCHSM.cc:106

◆ taken_

CHSM_ns_alias::event const* JDAQStateMachine::taken_[14]
privateinherited

Definition at line 524 of file JDAQCHSM.hh.

◆ target_

CHSM_ns_alias::state* JDAQStateMachine::target_[14]
privateinherited

Definition at line 525 of file JDAQCHSM.hh.

◆ name

std::string JDAQCHSM::name
protectedinherited

Definition at line 165 of file JDAQCHSM.hh.

◆ detector_id

int JDAQCHSM::detector_id
protectedinherited

Definition at line 166 of file JDAQCHSM.hh.

◆ run_number

int JDAQCHSM::run_number
protectedinherited

Definition at line 167 of file JDAQCHSM.hh.

◆ TIMEOUT_S

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

time out of update [s]

Definition at line 62 of file JDAQClient.hh.

◆ eventTable

JEventTable KM3NETDAQ::JDAQClient_t::eventTable
protectedinherited

event table

Definition at line 202 of file JDAQClient.hh.

◆ hostname

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

Definition at line 203 of file JDAQClient.hh.

◆ fullname

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

Definition at line 204 of file JDAQClient.hh.

◆ unique_tag

JTag KM3NETDAQ::JDAQClient_t::unique_tag
protectedinherited

Definition at line 205 of file JDAQClient.hh.

◆ clock

JTimekeeper KM3NETDAQ::JDAQClient_t::clock
protectedinherited

central clock

Definition at line 206 of file JDAQClient.hh.

◆ event_info

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

event information

Definition at line 207 of file JDAQClient.hh.


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