Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQClient.hh
Go to the documentation of this file.
1 #ifndef __JRUNCONTROL__JDAQCLIENT__
2 #define __JRUNCONTROL__JDAQCLIENT__
3 
4 #include <string>
5 #include <iostream>
6 #include <sstream>
7 #include <iomanip>
8 #include <exception>
9 #include <typeinfo>
10 #include <ctype.h>
11 
12 #include "JSystem/JNetwork.hh"
13 #include "JNet/JControlHost.hh"
15 #include "JNet/JSelectReader.hh"
16 #include "JLang/JString.hh"
17 #include "JLang/JSharedPointer.hh"
18 #include "JLang/JAbstractFile.hh"
20 #include "JLang/JTimeval.hh"
21 #include "JLang/JRedirectStream.hh"
22 #include "JLang/JNullStream.hh"
23 #include "Jeep/JParser.hh"
24 #include "Jeep/JProperties.hh"
25 #include "Jeep/JArgs.hh"
26 #include "Jeep/JTimekeeper.hh"
28 #include "JLogger/JStreamLogger.hh"
31 #include "JDAQ/JDAQTags.hh"
34 #include "JRuncontrol/JDAQCHSM.hh"
35 
36 
37 /**
38  * \author mdejong
39  */
40 
41 namespace KM3NETDAQ {
42 
43  using namespace JLOGGER;
44  using JNET::JControlHost;
46  using JNET::JSelectReader;
51  using JLANG::JTimeval;
54  using JEEP::JArgs;
55  using JEEP::JTimekeeper;
56 
57 
58  /**
59  * Run control client base class.
60  *
61  * This base class implements the protocol for the communication
62  * with the central run control program.
63  * This protocol is based on JNET::JControlHost tags and CHSM event names.
64  * The method run can be used to process JNET::JControlHost messages
65  * and accordingly update the state machine.
66  *
67  * For client specific events with a designated JNET::JControlHost tag,
68  * the corresponding entry in the event table should be replaced.
69  * This should be done in the constructor of the derived class
70  * using method JDAQClient::replaceEvent.
71  *
72  * The method JDAQClient::addParameter can be used to add a parameter of
73  * the derived class to the list that is parsed in method enter.
74  *
75  * The method JDAQClient::filter can be overwritten so that a specific action
76  * is made before the corresponding message is processed by the state machine.
77  * The message is ignored if this method returns true,
78  * else it is normally processed.
79  *
80  * The method JDAQClient::setSelect can be used to set the file descriptor mask
81  * of the select call and the method actionSelect can be used to take
82  * client specific actions following the select call.
83  *
84  * If the clock interval is non-zero, the method JDAQClient::actionRunning is
85  * repeatedly called when this client machine is in state <tt>Running</tt>.
86  * The clock interval can be set using method JDAQClient::setClockInterval.
87  */
88  class JDAQClient :
89  public JDAQStateMachine
90  {
91  public:
92  /**
93  * Constructor.
94  *
95  * \param name name of client
96  */
97  JDAQClient(const std::string& name) :
98  JDAQStateMachine(name),
99  parser(),
100  event_number(-1)
101  {
102  configure();
103  }
104 
105 
106  /**
107  * Constructor.
108  *
109  * \param name name of client
110  * \param server name of command message server
111  * \param logger pointer to logger
112  * \param level debug level
113  */
114  JDAQClient(const std::string& name,
115  const std::string& server,
116  JLogger* logger,
117  const int level) :
118  JDAQStateMachine(name),
119  parser(),
120  event_number(-1)
121  {
122  this->logger = JMessageLogger(logger, name, level);
123 
124  try {
125  this->server.reset(new JControlHost(server));
126  }
127  catch(JControlHostException& error) {
128  JErrorStream(this->logger) << error;
129  }
130 
131  configure();
132  }
133 
134 
135  /**
136  * Enter the state machine.
137  * This overloaded method enter reproduces the constructor.
138  * All necessary input is parsed from the list of arguments.
139  * In case of an error, the state machine is not entered.
140  *
141  * \param args array of command line arguments
142  */
143  virtual bool enter(const JArgs& args)
144  {
145  using namespace std;
146 
147  string server;
148  string logger;
149  int level;
150  bool use_cout;
151 
152  try {
153 
154  parser['H'] = make_field(server) = "localhost";
155  parser['M'] = make_field(logger) = "localhost";
156  parser['d'] = make_field(level) = 0;
157  parser['c'] = make_field(use_cout);
158 
159  if (parser.read(args) != 0) {
160  return false;
161  }
162  }
163  catch(const exception &error) {
164  cerr << error.what() << endl;
165  return false;
166  }
167 
168  try {
169 
170  JLogger* out = NULL;
171 
172  if (use_cout)
173  out = new JStreamLogger(cout);
174  else
175  out = new JControlHostLogger(logger);
176 
177  this->logger = JMessageLogger(out, getName(), level);
178 
179  this->server.reset(new JControlHost(server));
180 
181  return enter();
182  }
183  catch(const JControlHostException& error) {
184  cerr << error << endl;
185  return false;
186  }
187  }
188 
189 
190  /**
191  * Enter the state machine.
192  * This method activates the subscription to JNET::JControlHost messages.
193  * In case of an error, the state machine is not entered.
194  */
195  virtual bool enter()
196  {
197  using namespace std;
198 
199  if (server.is_valid() && logger.is_valid()) {
200 
201  try {
202 
203  server->Subscribe(getSubscription(eventTable));
204  server->SendMeAlways();
205  server->MyId(getFullName());
206 
207  return CHSM::machine::enter();
208  }
209  catch(const JControlHostException& error) {
210  JErrorStream(logger) << error;
211  }
212 
213  } else {
214  cerr << "Message server or logger not properly initialised." << endl;
215  }
216 
217  return false;
218  }
219 
220 
221  /**
222  * Exit the state machine.
223  * This method releases the various resources.
224  */
225  virtual bool exit()
226  {
227  try {
228  if (server.is_valid()) server.reset(NULL);
229  }
230  catch(const JControlHostException& error) {
231  }
232 
233  try {
234  if (logger.is_valid()) logger.reset(NULL);
235  }
236  catch(const JControlHostException& error) {
237  }
238 
239  return CHSM::machine::exit();
240  }
241 
242 
243  /**
244  * Get full name of this run control client.
245  *
246  * \return full name
247  */
248  const std::string& getFullName() const
249  {
250  return full_name;
251  }
252 
253 
254  /**
255  * Get unique tag of this run control client.
256  *
257  * \return unique tag
258  */
259  const JNET::JTag& getUniqueTag() const
260  {
261  return unique_tag;
262  }
263 
264 
265  /**
266  * Get last event number.
267  *
268  * \return event number
269  */
270  int getEventNumber() const
271  {
272  return event_number;
273  }
274 
275 
276  /**
277  * Check if this client is in runnig state.
278  *
279  * \return true if running; else false
280  */
281  bool isRunning() const
282  {
283  return Main.RunControl.Operational.Running.active();
284  }
285 
286 
287  /**
288  * Replace tag of given event in event table.
289  *
290  * \param oldTag old tag
291  * \param newTag new tag
292  * \param event event
293  */
294  void replaceEvent(const JNET::JTag& oldTag,
295  const JNET::JTag& newTag,
296  JDAQEvent_t& event)
297  {
298  eventTable.replace(oldTag, newTag, event);
299  }
300 
301 
302  /**
303  * Find event in event table.
304  *
305  * \param tag tag
306  * \param event_name event name
307  * \return pointer to event or NULL
308  */
309  JDAQEvent_t* findEvent(const JNET::JTag& tag, const std::string& event_name)
310  {
311  JEventTable::const_iterator i = eventTable.find(tag, event_name);
312 
313  if (i != eventTable.end())
314  return i->second;
315  else
316  return NULL;
317  }
318 
319 
320  /**
321  * Add parameter to parser used in method enter().
322  *
323  * \param option option
324  * \param parameter parameter
325  */
326  template<class T>
327  void addParameter(const char option, T& parameter)
328  {
329  parser[option] = make_field(parameter);
330  }
331 
332 
333  /**
334  * Add parameter to parser used in method enter().
335  *
336  * \param option option
337  * \param parameter parameter
338  * \param value default value
339  */
340  template<class T>
341  void addParameter(const char option, T& parameter, const T& value)
342  {
343  parser[option] = make_field(parameter) = value;
344  }
345 
346 
347  /**
348  * Get total delay time.
349  *
350  * \return delay time [us]
351  */
352  long long int getClockDelay() const
353  {
354  return clock.getDelay();
355  }
356 
357 
358  /**
359  * Get hostname.
360  *
361  * \return host name
362  */
363  const std::string& getHostname() const
364  {
365  return hostname;
366  }
367 
368 
369  /**
370  * Get interval time.
371  *
372  * \return interval time [us]
373  */
374  long long int getClockInterval() const
375  {
376  return clock.getInterval();
377  }
378 
379 
380  /**
381  * Set interval time.
382  *
383  * \param interval_us interval time [us]
384  */
385  void setClockInterval(const long long int interval_us)
386  {
387  clock.setInterval(interval_us);
388  }
389 
390 
391  /**
392  * Reset clock.
393  */
394  void resetClock()
395  {
396  clock.reset();
397  }
398 
399 
400  /**
401  * Set the file descriptor mask for the select call.
402  */
403  void setSelect()
404  {
405  select.reset();
406 
407  setSelect(select.getReaderMask());
408 
409  select.setReaderMask(*server);
410  }
411 
412 
413  /**
414  * Set the file descriptor mask for the select call.
415  * This implementation does nothing but may be redefined by the derived class.
416  *
417  * \param mask file descriptor mask
418  */
419  virtual void setSelect(JFileDescriptorMask& mask) const
420  {}
421 
422 
423  /**
424  * Action method following last select call.
425  * This implementation does nothing but may be redefined by the derived class.
426  *
427  * \param mask file descriptor mask
428  */
429  virtual void actionSelect(const JFileDescriptorMask& mask)
430  {}
431 
432 
433  /**
434  * This method is repeatedly called when this client machine is in state Running
435  * and the clock interval time is non-zero.
436  * This implementation does nothing but may be redefined by the derived class.
437  * Care has to be taken so that the time needed to execute this method should be
438  * less than the specified clock interval time (see method setClockInterval()).
439  */
440  virtual void actionRunning()
441  {}
442 
443 
444  /**
445  * This method is called at <tt>ev_input</tt>.
446  *
447  * \param length length of data
448  * \param buffer pointer to data
449  */
450  virtual void actionInput(int length, const char* buffer)
451  {
452  using namespace std;
453 
454  JProperties properties(JEquationParameters("=", ";", "", ""), 1);
455 
456  int level = this->logger.getLevel();
457 
458  properties["debug"] = level;
459 
460  properties.read(string(buffer, length));
461 
462  this->logger.setLevel(level);
463  }
464 
465 
466  /**
467  * Filter message.
468  * The filter method can be overloaded so that a specific action is made
469  * before the corresponding message is processed by the state machine.
470  * The message is ignored if true is returned, else it is normally processed.
471  *
472  * \param tag tag
473  * \param length number of characters
474  * \param buffer message
475  * \return skip message or not
476  */
477  virtual bool filter(const std::string& tag, int length, const char* buffer)
478  {
479  return false;
480  }
481 
482 
483  /**
484  * Run as run control client following command messages via JNET::JControlHost.
485  * This method can be called once the state machine is entered.
486  * It returns when the state machine is exited.
487  * If the clock interval is non-zero, the method actionRunning() is
488  * repeatedly called when this client machine is in state Running.
489  * The file descriptor mask can be set to interrupt the timeout of
490  * the select call and clock method wait() in this calling sequence
491  * (see methods setSelect() and actionSelect()).
492  */
493  void run()
494  {
495  using namespace std;
496 
497  while (active()) {
498 
499  try {
500 
501  setSelect();
502 
503  if (select(JTimeval(TIMEOUT_S,0)) > 0) {
504 
505  if (select.hasReaderMask(*server)) {
506  update();
507  }
508 
509  actionSelect(select.getReaderMask());
510 
511  } else {
512 
513  continue;
514  }
515 
516 
517  if (isRunning() && clock.getInterval() != 0LL) {
518 
519  long long int numberOfCalls = 0;
520 
521  clock.reset();
522 
523  do {
524 
525  ++numberOfCalls;
526 
527  setSelect();
528 
529  if (clock.wait(select.getReaderMask())) {
530 
531  if (select.hasReaderMask(*server)) {
532  update();
533  }
534 
535  actionSelect(select.getReaderMask());
536 
537  } else {
538 
539  try {
540  actionRunning();
541  }
542  catch(const exception& error) {
543  logger.error(error.what());
544  }
545  }
546 
547  } while (isRunning());
548 
549  if (numberOfCalls != 0) {
550  JNoticeStream(logger) << "Delay per call " << clock.getDelay() / numberOfCalls / 1000 << " ms";
551  }
552  }
553  }
554  catch(const exception& error) {
555  JErrorStream(logger) << "method run(): " << error.what();
556  }
557  }
558  }
559 
560 
561  /**
562  * Run for ever.
563  * This method can be used when the run control client is started before the run control
564  * (e.g. at boot time of the host processor).
565  * This method should be called before the state machine is entered.
566  * It launches a server which accepts a JNET::JControlHost connection from
567  * a designated application e.g. the JDAQClientStarter.cc program.
568  * The state machine is entered using the available data in the JNET::JControlHost message.
569  * After the state machine is exited, it accepts a new a JNET::JControlHost connection.
570  *
571  * \param port port number
572  */
573  void run(const int port)
574  {
575  JControlHostServer server(port);
576 
577  for ( ; ; ) {
578 
579  JControlHost* ps = server.AcceptClient();
580 
581  ps->Connected();
582 
583  JNET::JPrefix prefix;
584 
585  ps->WaitHead(prefix);
586 
587  const int length = prefix.getSize();
588 
589  char* buffer = new char[length];
590 
591  ps->GetFullData(buffer, length);
592  ps->PutFullData(prefix.toString(), buffer, length);
593 
594  delete ps;
595 
596  enter(JArgs(std::string(buffer, length)));
597 
598  delete [] buffer;
599 
600  run();
601 
602  exit();
603  }
604  }
605 
606 
607  /**
608  * Run client with commands from input stream (e.g for debugging).
609  *
610  * Example input format:
611  * <pre>
612  * <tag> <event name>[\#data];
613  * <tag> <event name>[\#data];
614  * </pre>
615  *
616  * \param in input stream
617  */
618  void run(std::istream& in)
619  {
620  using std::string;
621 
622  string tag;
623  string buffer;
624 
625  while (in >> tag && getline(in, buffer, ';')) {
626  update(tag, buffer.length(), buffer.data());
627  }
628  }
629 
630 
631  static const int TIMEOUT_S = 1; //!< time out of update [s]
632 
633  protected:
634 
636  JMessageLogger logger; //!< message logger
637 
638  private:
639  /**
640  * Update state machine.
641  * This method waits for a message from JNET::JControlHost server.
642  */
643  void update()
644  {
645  JNET::JPrefix prefix;
646 
647  server->WaitHead(prefix);
648 
649  const int length = prefix.getSize();
650 
651  char* buffer = new char[length];
652 
653  server->GetFullData(buffer, length);
654 
655  if (!filter(prefix.toString(), length, buffer)) {
656  update(prefix.toString(), length, buffer);
657  }
658 
659  delete [] buffer;
660  }
661 
662 
663  /**
664  * Update state machine.
665  *
666  * \param tag tag
667  * \param length number of characters
668  * \param buffer message
669  */
670  void update(const JNET::JTag& tag, int length, const char* buffer)
671  {
672  using namespace std;
673  using namespace JLANG;
674 
675  string::size_type pos = 0;
676 
677  while (pos != (string::size_type) length && TOKEN_DELIMETER.find(*(buffer + pos)) == string::npos) {
678  ++pos;
679  }
680 
681  JEvent_t event = JEvent_t::toValue(string(buffer, pos));
682 
683  JString event_name(event.getName());
684 
685  event_number = event.getNumber();
686  event_name = event_name.trim(); // remove white spaces, if any
687 
688  while (pos != (string::size_type) length && TOKEN_DELIMETER.find(*(buffer + pos)) != string::npos) {
689  ++pos;
690  }
691 
692 
693  JEventTable::const_iterator i = eventTable.find(tag, event_name);
694 
695  if (i != eventTable.end()) {
696 
697  // redirect all I/O
698 
699  JErrorStream error(logger);
700 
701  JRedirectStream redirect[] = { JRedirectStream(cin, JLANG::null),
703  JRedirectStream(cerr, error) };
704 
705  if (redirect[0] &&
706  redirect[1] &&
707  redirect[2]) {
708 
709  (*(i->second))(length - pos, buffer + pos);
710  }
711 
712  } else {
713 
714  JErrorStream(logger) << "Unknown key <" << JEventTable::getKey(tag,event_name) << ">";
715  }
716  }
717 
718 
719  /**
720  * Configure client.
721  * This method is used to setup the event table.
722  */
723  void configure()
724  {
725  using namespace std;
726  using namespace JNET;
727 
728  hostname = JSYSTEM::getHostname();
729 
730  full_name = KM3NETDAQ::getFullName (hostname, getName());
731  unique_tag = KM3NETDAQ::getUniqueTag(hostname, getName());
732 
733  for (JTag buffer[] = { RC_CMD, unique_tag, DISPTAG_UNDEFINED }, *tag = buffer; *tag != DISPTAG_UNDEFINED; ++tag) {
734 
735  eventTable.insert(*tag, ev_init);
736  eventTable.insert(*tag, ev_configure);
737  eventTable.insert(*tag, ev_start);
738  eventTable.insert(*tag, ev_pause);
739  eventTable.insert(*tag, ev_continue);
740  eventTable.insert(*tag, ev_stop);
741  eventTable.insert(*tag, ev_reset);
742  eventTable.insert(*tag, ev_quit);
743  eventTable.insert(*tag, ev_off);
744 
745  eventTable.insert(*tag, ev_check);
746  eventTable.insert(*tag, ev_input);
747 
748  eventTable.insert(*tag, ev_recover);
749  }
750 
751  JControlHost::Throw(true);
752 
753  setClockInterval(TIMEOUT_S * 1000000LL);
754  }
755 
756 
757  /**
758  * Action when entering state.
759  * This method provides for the hand shaking with the run control program.
760  *
761  * \param state entered state
762  * \param event event that triggered transition
763  */
764  void enterState(const CHSM::state& state,
765  const CHSM::event& event)
766  {
767  std::ostringstream os;
768 
769  os << getFullName()
770  << getTokenDelimeter()
771  << JEvent_t(event.name(), event_number)
772  << getTokenDelimeter()
773  << getStateName(state.name());
774 
775  server->PutFullString(RC_REPLY, os.str());
776  }
777 
778 
779  /**
780  * This method is called at <tt>ev_check</tt> and reports a system check by mimicing an enter state action.
781  *
782  * \param length number of characters
783  * \param buffer message
784  */
785  virtual void actionCheck(int length, const char* buffer)
786  {
787  if (Main.RunControl.Error.active()) {
788 
789  enterState(Main.RunControl.Error, ev_check);
790 
791  } else {
792 
793  for (CHSM::parent::iterator state = Main.RunControl.Operational.begin(); state != Main.RunControl.Operational.end(); ++state) {
794 
795  if (state->active()) {
796 
797  // mimic enter state
798 
799  enterState(*state, ev_check);
800  }
801  }
802  }
803  }
804 
805 
806  /**
807  * The method to execute the action.
808  *
809  * \param __action pointer to action method
810  * \param __event event that triggered the action
811  */
812  void execute(action __action, const CHSM::event& __event)
813  {
814  try {
815 
816  const JDAQStateMachine::ev_daq_event& event = dynamic_cast<const JDAQStateMachine::ev_daq_event&>(__event);
817 
818  (this->*__action)(event->length, event->buffer);
819  }
820  catch(const std::exception& error) {
821  logger.error(error.what());
822  logger.error("Trigger ev_error.");
823  ev_error();
824  }
825  }
826 
827 
828  JEventTable eventTable; //!< event table
829  std::string hostname;
830  std::string full_name;
832  JTimekeeper clock; //!< central clock
833  JSelectReader select; //!< select call
834  JParser<> parser; //!< parser method enter()
835  int event_number; //!< number of last event
836  };
837 }
838 
839 #endif
JParser parser
parser method enter()
Definition: JDAQClient.hh:834
ControlHost prefix.
Definition: JPrefix.hh:31
Utility class to parse command line options.
Definition: JParser.hh:1410
JNET::JSubscriptionList getSubscription(const JEventTable &event_table)
Convert event table to ControlHost subscription.
Definition: JEventTable.hh:125
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:665
Wrapper class around STL string class.
Definition: JString.hh:28
ControlHost class.
Message logging based on std::ostream.
virtual void setSelect(JFileDescriptorMask &mask) const
Set the file descriptor mask for the select call.
Definition: JDAQClient.hh:419
int Connected()
Send version.
JTag getUniqueTag(const std::string &hostname, const std::string &name)
Get unique tag of run control client.
JSelectReader select
select call
Definition: JDAQClient.hh:833
Message reporting compatible with STL output stream operations.
Interface for logging messages.
Definition: JLogger.hh:22
Message logging based on ControlHost.
Utility class to parse parameter values.
Definition: JProperties.hh:484
void setClockInterval(const long long int interval_us)
Set interval time.
Definition: JDAQClient.hh:385
JDAQClient(const std::string &name)
Constructor.
Definition: JDAQClient.hh:97
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Time keeper.
Definition: JTimekeeper.hh:34
void configure()
Configure client.
Definition: JDAQClient.hh:723
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
static const std::string TOKEN_DELIMETER
Definition: JDAQTags.hh:36
void execute(action __action, const CHSM::event &__event)
The method to execute the action.
Definition: JDAQClient.hh:812
JTimekeeper clock
central clock
Definition: JDAQClient.hh:832
void run()
Run as run control client following command messages via JNET::JControlHost.
Definition: JDAQClient.hh:493
int getSize() const
Get size.
Definition: JPrefix.hh:63
Utility class to parse parameter values.
static std::string getKey(const JNET::JTag &tag, const CHSM::event &event)
Get key for a given tag and event.
Definition: JEventTable.hh:55
static JEvent_t toValue(const std::string &buffer)
Convert string to event.
std::string full_name
Definition: JDAQClient.hh:830
Auxiliary class for time values.
Definition: JTimeval.hh:26
void run(const int port)
Run for ever.
Definition: JDAQClient.hh:573
long long int getClockDelay() const
Get total delay time.
Definition: JDAQClient.hh:352
virtual bool filter(const std::string &tag, int length, const char *buffer)
Filter message.
Definition: JDAQClient.hh:477
std::string getStateName(const std::string &name)
Get name of state.
int event_number
number of last event
Definition: JDAQClient.hh:835
Scheduling of actions via fixed latency intervals.
The template JSharedPointer class can be used to share a pointer to an object.
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
static const JNET::JTag RC_REPLY
Definition: JDAQTags.hh:45
const JNET::JTag & getUniqueTag() const
Get unique tag of this run control client.
Definition: JDAQClient.hh:259
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
JString & trim()
Trim string.
Definition: JString.hh:248
void enterState(const CHSM::state &state, const CHSM::event &event)
Action when entering state.
Definition: JDAQClient.hh:764
virtual bool enter()
Enter the state machine.
Definition: JDAQClient.hh:195
virtual void actionRunning()
This method is repeatedly called when this client machine is in state Running and the clock interval ...
Definition: JDAQClient.hh:440
Auxiliary class for method select.
Wrapper class for select call.
The JAbstractFile class encapsulates the c-style file descriptor.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:468
static const JTag DISPTAG_UNDEFINED(0)
Auxiliary class for handling event name and optional number.
Exception for ControlHost.
Definition: JException.hh:432
virtual bool exit()
Exit the state machine.
Definition: JDAQClient.hh:225
Data structure to store command line arguments.
Definition: JArgs.hh:24
char getTokenDelimeter()
Get the token delimeter for command messages.
bool isRunning() const
Check if this client is in runnig state.
Definition: JDAQClient.hh:281
JControlHost * AcceptClient(JTimeval timeout=JTimeval::max())
Accept new client.
std::string getHostname()
Get host name.
Definition: JNetwork.hh:75
void update()
Update state machine.
Definition: JDAQClient.hh:643
int WaitHead(JPrefix &prefix)
Wait for header.
void addParameter(const char option, T &parameter, const T &value)
Add parameter to parser used in method enter().
Definition: JDAQClient.hh:341
void addParameter(const char option, T &parameter)
Add parameter to parser used in method enter().
Definition: JDAQClient.hh:327
virtual void actionInput(int length, const char *buffer)
This method is called at ev_input.
Definition: JDAQClient.hh:450
std::string toString() const
Convert tag to string.
Definition: JTag.hh:167
General purpose message reporting.
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
Run control client base class.
Definition: JDAQClient.hh:88
Utility class to parse command line options.
int getEventNumber() const
Get last event number.
Definition: JDAQClient.hh:270
JEventTable eventTable
event table
Definition: JDAQClient.hh:828
void run(std::istream &in)
Run client with commands from input stream (e.g for debugging).
Definition: JDAQClient.hh:618
virtual bool enter(const JArgs &args)
Enter the state machine.
Definition: JDAQClient.hh:143
JDAQClient(const std::string &name, const std::string &server, JLogger *logger, const int level)
Constructor.
Definition: JDAQClient.hh:114
const char * getName()
Get ROOT name of given data type.
void resetClock()
Reset clock.
Definition: JDAQClient.hh:394
JMessageLogger logger
message logger
Definition: JDAQClient.hh:636
void replaceEvent(const JNET::JTag &oldTag, const JNET::JTag &newTag, JDAQEvent_t &event)
Replace tag of given event in event table.
Definition: JDAQClient.hh:294
Fixed parameters for KM3NeT DAQ.
static const JNET::JTag RC_CMD
Definition: JDAQTags.hh:44
void update(const JNET::JTag &tag, int length, const char *buffer)
Update state machine.
Definition: JDAQClient.hh:670
ControlHost tag.
Definition: JTag.hh:35
JDAQStateMachine::ev_daq_event JDAQEvent_t
Type definition of a DAQ event.
Definition: JEventTable.hh:22
const std::string & getFullName() const
Get full name of this run control client.
Definition: JDAQClient.hh:248
std::string getFullName(const std::string &hostname, const std::string &name)
Get full name of run control client.
void error(const JMessage_t &message)
static JNullStream null
Null I/O stream.
Definition: JNullStream.hh:51
void setSelect()
Set the file descriptor mask for the select call.
Definition: JDAQClient.hh:403
long long int getClockInterval() const
Get interval time.
Definition: JDAQClient.hh:374
Hostname and IP address functions.
virtual void actionSelect(const JFileDescriptorMask &mask)
Action method following last select call.
Definition: JDAQClient.hh:429
JDAQEvent_t * findEvent(const JNET::JTag &tag, const std::string &event_name)
Find event in event table.
Definition: JDAQClient.hh:309
virtual void actionCheck(int length, const char *buffer)
This method is called at ev_check and reports a system check by mimicing an enter state action...
Definition: JDAQClient.hh:785
static void Throw(const bool option)
Enable/disable throw option.
Definition: JThrow.hh:37
int GetFullData(void *buffer, int length)
Receive data.
const std::string & getHostname() const
Get hostname.
Definition: JDAQClient.hh:363
Light-weight wrapper class around server socket.
std::string hostname
Definition: JDAQClient.hh:829
int PutFullData(const JTag &tag, const void *buffer, const int length)
Send data.