Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Protected Attributes | Private Attributes | List of all members
KM3NETDAQ::MonitorRouter Class Reference
Inheritance diagram for KM3NETDAQ::MonitorRouter:
KM3NETDAQ::JDAQClient

Public Member Functions

 MonitorRouter (std::string const &name, std::string const &server, JLogger *logger, const int level, int port)
 
virtual void actionEnter ()
 Interface methods for actions corresponding to state transitions. More...
 
virtual void actionExit ()
 
virtual void actionInit (int length, const char *buffer)
 
virtual void actionReset (int length, const char *buffer)
 
virtual void actionConfigure (int length, const char *buffer)
 
virtual void actionQuit (int length, const char *buffer)
 
virtual void actionStart (int length, const char *buffer)
 
virtual void actionStop (int length, const char *buffer)
 
virtual void actionPause (int length, const char *buffer)
 
virtual void actionContinue (int length, const char *buffer)
 
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 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 bool enter (const JArgs &args)
 Enter the state machine. More...
 
virtual bool enter ()
 Enter the state machine. More...
 
virtual bool exit ()
 Exit the state machine. More...
 
const std::string & getFullName () const
 Get full name of this run control client. More...
 
const JNET::JTaggetUniqueTag () const
 Get unique tag of this run control client. More...
 
int getEventNumber () const
 Get last event number. More...
 
bool isRunning () const
 Check if this client is in runnig state. More...
 
void replaceEvent (const JNET::JTag &oldTag, const JNET::JTag &newTag, JDAQEvent_t &event)
 Replace tag of given event in event table. More...
 
JDAQEvent_tfindEvent (const JNET::JTag &tag, const std::string &event_name)
 Find event in event table. 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...
 
long long int getClockDelay () const
 Get total delay time. More...
 
const std::string & getHostname () const
 Get hostname. 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...
 
void setSelect ()
 Set the file descriptor mask for the select call. More...
 
virtual void actionInput (int length, const char *buffer)
 This method is called at ev_input. More...
 
virtual bool filter (const std::string &tag, int length, const char *buffer)
 Filter message. More...
 
void run ()
 Run as run control client following command messages via JNET::JControlHost. More...
 
void run (const int port)
 Run for ever. More...
 
void run (std::istream &in)
 Run client with commands from input stream (e.g for debugging). More...
 

Static Public Attributes

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

Protected Attributes

JSharedPointer< JControlHostserver
 message server More...
 
JMessageLogger logger
 message logger More...
 

Private Attributes

boost::scoped_ptr< JControlHostm_ch
 
boost::asio::io_service m_service
 
boost::asio::ip::udp::socket m_input
 
bool m_running
 
int m_port
 

Detailed Description

Definition at line 24 of file monrouter.cpp.

Constructor & Destructor Documentation

KM3NETDAQ::MonitorRouter::MonitorRouter ( std::string const &  name,
std::string const &  server,
JLogger logger,
const int  level,
int  port 
)
inline

Definition at line 35 of file monrouter.cpp.

42  :
43  JDAQClient(name, server, logger, level)
45  , m_running(false)
46  , m_port(port)
47  {
49  }
JDAQClient(const std::string &name)
Constructor.
Definition: JDAQClient.hh:97
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
boost::asio::io_service m_service
Definition: monrouter.cpp:28
boost::asio::ip::udp::socket m_input
Definition: monrouter.cpp:29
static const JNET::JTag RC_MONITORING_ROUTER
Definition: JDAQTags.hh:54
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
static const JNET::JTag RC_CMD
Definition: JDAQTags.hh:44

Member Function Documentation

virtual void KM3NETDAQ::MonitorRouter::actionEnter ( )
inlinevirtual

Interface methods for actions corresponding to state transitions.

Definition at line 54 of file monrouter.cpp.

54 {}
virtual void KM3NETDAQ::MonitorRouter::actionExit ( )
inlinevirtual

Definition at line 55 of file monrouter.cpp.

55 {}
virtual void KM3NETDAQ::MonitorRouter::actionInit ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 57 of file monrouter.cpp.

57 {}
virtual void KM3NETDAQ::MonitorRouter::actionReset ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 58 of file monrouter.cpp.

58 {}
virtual void KM3NETDAQ::MonitorRouter::actionConfigure ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 60 of file monrouter.cpp.

61  {
62  boost::property_tree::ptree const conf = detail::parse(
63  std::string(buffer, length)
64  );
65 
66  m_input.open(boost::asio::ip::udp::v4());
67 
68  m_input.bind(
69  boost::asio::ip::udp::endpoint(
70  boost::asio::ip::udp::v4()
71  , m_port
72  )
73  );
74 
75  m_ch.reset(
76  new JControlHost(
77  conf.get<std::string>("out_server_address")
78  , conf.get<unsigned>("out_server_port")
79  )
80  );
81  }
boost::property_tree::ptree parse(std::string str)
Definition: configure.hh:24
boost::asio::ip::udp::socket m_input
Definition: monrouter.cpp:29
boost::scoped_ptr< JControlHost > m_ch
Definition: monrouter.cpp:27
virtual void KM3NETDAQ::MonitorRouter::actionQuit ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 83 of file monrouter.cpp.

84  {
85  m_input.close();
86  m_ch.reset();
87  }
boost::asio::ip::udp::socket m_input
Definition: monrouter.cpp:29
boost::scoped_ptr< JControlHost > m_ch
Definition: monrouter.cpp:27
virtual void KM3NETDAQ::MonitorRouter::actionStart ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 89 of file monrouter.cpp.

90  {
91  int const run_number = getRunNumber();
92 
93  int const detector_id = getDetectorID();
94 
95  assert(run_number >= 0);
96 
97  m_running = true;
98  }
virtual void KM3NETDAQ::MonitorRouter::actionStop ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 100 of file monrouter.cpp.

101  {
102  m_input.close();
103  m_ch.reset();
104  }
boost::asio::ip::udp::socket m_input
Definition: monrouter.cpp:29
boost::scoped_ptr< JControlHost > m_ch
Definition: monrouter.cpp:27
virtual void KM3NETDAQ::MonitorRouter::actionPause ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 106 of file monrouter.cpp.

107  {
108  m_running = false;
109  }
virtual void KM3NETDAQ::MonitorRouter::actionContinue ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 111 of file monrouter.cpp.

112  {
113  m_running = true;
114  }
virtual void KM3NETDAQ::MonitorRouter::actionRunning ( )
inlinevirtual

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 from KM3NETDAQ::JDAQClient.

Definition at line 116 of file monrouter.cpp.

116 {}
virtual void KM3NETDAQ::MonitorRouter::setSelect ( JFileDescriptorMask mask) const
inlinevirtual

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 from KM3NETDAQ::JDAQClient.

Definition at line 118 of file monrouter.cpp.

119  {
120  mask.set(m_input.native_handle());
121  }
boost::asio::ip::udp::socket m_input
Definition: monrouter.cpp:29
virtual void KM3NETDAQ::MonitorRouter::actionSelect ( const JFileDescriptorMask mask)
inlinevirtual

Action method following last select call.

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

Parameters
maskfile descriptor mask

Reimplemented from KM3NETDAQ::JDAQClient.

Definition at line 123 of file monrouter.cpp.

124  {
125  if (m_input.is_open()) {
126  if (mask.has(m_input.native_handle())) {
127  static size_t const max_size = 10000;
128  static char buffer[max_size];
129 
130  std::size_t const size = m_input.receive(
131  boost::asio::buffer(buffer, max_size)
132  );
133 
134  if (m_running) {
135  m_ch->PutFullData(IO_MONITORING_DATA, buffer, size);
136  }
137  }
138  }
139  }
boost::asio::ip::udp::socket m_input
Definition: monrouter.cpp:29
boost::scoped_ptr< JControlHost > m_ch
Definition: monrouter.cpp:27
static const JNET::JTag IO_MONITORING_DATA
Definition: JDAQTags.hh:67
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

Definition at line 143 of file JDAQClient.hh.

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  }
JParser parser
parser method enter()
Definition: JDAQClient.hh:834
ControlHost class.
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:635
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
virtual bool enter()
Enter the state machine.
Definition: JDAQClient.hh:195
Exception for ControlHost.
Definition: JException.hh:432
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1673
const char * getName()
Get ROOT name of given data type.
JMessageLogger logger
message logger
Definition: JDAQClient.hh:636
virtual bool KM3NETDAQ::JDAQClient::enter ( )
inlinevirtualinherited

Enter the state machine.

This method activates the subscription to JNET::JControlHost messages. In case of an error, the state machine is not entered.

Reimplemented in KM3NETDAQ::JDAQDriver.

Definition at line 195 of file JDAQClient.hh.

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  }
JNET::JSubscriptionList getSubscription(const JEventTable &event_table)
Convert event table to ControlHost subscription.
Definition: JEventTable.hh:125
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
Exception for ControlHost.
Definition: JException.hh:432
bool is_valid() const
Check validity of logger object.
JEventTable eventTable
event table
Definition: JDAQClient.hh:828
JMessageLogger logger
message logger
Definition: JDAQClient.hh:636
const std::string & getFullName() const
Get full name of this run control client.
Definition: JDAQClient.hh:248
virtual bool KM3NETDAQ::JDAQClient::exit ( )
inlinevirtualinherited

Exit the state machine.

This method releases the various resources.

Definition at line 225 of file JDAQClient.hh.

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  }
void reset(JLogger *__logger=NULL)
Reset logger.
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
Exception for ControlHost.
Definition: JException.hh:432
bool is_valid() const
Check validity of logger object.
JMessageLogger logger
message logger
Definition: JDAQClient.hh:636
const std::string& KM3NETDAQ::JDAQClient::getFullName ( ) const
inlineinherited

Get full name of this run control client.

Returns
full name

Definition at line 248 of file JDAQClient.hh.

249  {
250  return full_name;
251  }
std::string full_name
Definition: JDAQClient.hh:830
const JNET::JTag& KM3NETDAQ::JDAQClient::getUniqueTag ( ) const
inlineinherited

Get unique tag of this run control client.

Returns
unique tag

Definition at line 259 of file JDAQClient.hh.

260  {
261  return unique_tag;
262  }
int KM3NETDAQ::JDAQClient::getEventNumber ( ) const
inlineinherited

Get last event number.

Returns
event number

Definition at line 270 of file JDAQClient.hh.

271  {
272  return event_number;
273  }
int event_number
number of last event
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 281 of file JDAQClient.hh.

282  {
283  return Main.RunControl.Operational.Running.active();
284  }
void KM3NETDAQ::JDAQClient::replaceEvent ( const JNET::JTag oldTag,
const JNET::JTag newTag,
JDAQEvent_t event 
)
inlineinherited

Replace tag of given event in event table.

Parameters
oldTagold tag
newTagnew tag
eventevent

Definition at line 294 of file JDAQClient.hh.

297  {
298  eventTable.replace(oldTag, newTag, event);
299  }
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
JEventTable eventTable
event table
Definition: JDAQClient.hh:828
void replace(const JNET::JTag &oldTag, const JNET::JTag &newTag, JDAQEvent_t &event)
Replace entry in table.
Definition: JEventTable.hh:93
JDAQEvent_t* KM3NETDAQ::JDAQClient::findEvent ( const JNET::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 309 of file JDAQClient.hh.

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  }
const_iterator find(const JNET::JTag &tag, const std::string &event_name) const
Find entry.
Definition: JEventTable.hh:112
JEventTable eventTable
event table
Definition: JDAQClient.hh:828
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 327 of file JDAQClient.hh.

328  {
329  parser[option] = make_field(parameter);
330  }
JParser parser
parser method enter()
Definition: JDAQClient.hh:834
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
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 341 of file JDAQClient.hh.

342  {
343  parser[option] = make_field(parameter) = value;
344  }
JParser parser
parser method enter()
Definition: JDAQClient.hh:834
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
long long int KM3NETDAQ::JDAQClient::getClockDelay ( ) const
inlineinherited

Get total delay time.

Returns
delay time [us]

Definition at line 352 of file JDAQClient.hh.

353  {
354  return clock.getDelay();
355  }
long long int getDelay() const
Get total delay time.
Definition: JTimekeeper.hh:78
JTimekeeper clock
central clock
Definition: JDAQClient.hh:832
const std::string& KM3NETDAQ::JDAQClient::getHostname ( ) const
inlineinherited

Get hostname.

Returns
host name

Definition at line 363 of file JDAQClient.hh.

364  {
365  return hostname;
366  }
std::string hostname
Definition: JDAQClient.hh:829
long long int KM3NETDAQ::JDAQClient::getClockInterval ( ) const
inlineinherited

Get interval time.

Returns
interval time [us]

Definition at line 374 of file JDAQClient.hh.

375  {
376  return clock.getInterval();
377  }
JTimekeeper clock
central clock
Definition: JDAQClient.hh:832
long long int getInterval() const
Get interval time.
Definition: JTimekeeper.hh:67
void KM3NETDAQ::JDAQClient::setClockInterval ( const long long int  interval_us)
inlineinherited

Set interval time.

Parameters
interval_usinterval time [us]

Definition at line 385 of file JDAQClient.hh.

386  {
387  clock.setInterval(interval_us);
388  }
JTimekeeper clock
central clock
Definition: JDAQClient.hh:832
void setInterval(const long long int interval_us)
Set interval time.
Definition: JTimekeeper.hh:89
void KM3NETDAQ::JDAQClient::resetClock ( )
inlineinherited

Reset clock.

Definition at line 394 of file JDAQClient.hh.

395  {
396  clock.reset();
397  }
void reset(const long long int t0)
Reset time.
Definition: JTimekeeper.hh:100
JTimekeeper clock
central clock
Definition: JDAQClient.hh:832
void KM3NETDAQ::JDAQClient::setSelect ( )
inlineinherited

Set the file descriptor mask for the select call.

Definition at line 403 of file JDAQClient.hh.

404  {
405  select.reset();
406 
408 
410  }
JSelectReader select
select call
Definition: JDAQClient.hh:833
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
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:403
virtual void KM3NETDAQ::JDAQClient::actionInput ( int  length,
const char *  buffer 
)
inlinevirtualinherited

This method is called at ev_input.

Parameters
lengthlength of data
bufferpointer to data

Reimplemented in AcousticDataFilter.

Definition at line 450 of file JDAQClient.hh.

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  }
Utility class to parse parameter values.
Definition: JProperties.hh:484
Simple data structure to support I/O of equations (see class JLANG::JEquation).
JMessageLogger logger
message logger
Definition: JDAQClient.hh:636
void setLevel(const int __level)
Set debug level.
JLevel_t getLevel()
Get debug level.
virtual bool KM3NETDAQ::JDAQClient::filter ( const std::string &  tag,
int  length,
const char *  buffer 
)
inlinevirtualinherited

Filter message.

The filter method can be overloaded 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 477 of file JDAQClient.hh.

478  {
479  return false;
480  }
void KM3NETDAQ::JDAQClient::run ( )
inlineinherited

Run as run control client following command messages via JNET::JControlHost.

This method can be called once the state machine is entered. It returns when the state machine is exited. If the clock interval is non-zero, the method actionRunning() is repeatedly called when this client machine is in state Running. The file descriptor mask can be set to interrupt the timeout of the select call and clock method wait() in this calling sequence (see methods setSelect() and actionSelect()).

Definition at line 493 of file JDAQClient.hh.

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 
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 
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  }
long long int getDelay() const
Get total delay time.
Definition: JTimekeeper.hh:78
JSelectReader select
select call
Definition: JDAQClient.hh:833
void reset(const long long int t0)
Reset time.
Definition: JTimekeeper.hh:100
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
JFileDescriptorMask & getReaderMask()
Get reader mask.
JTimekeeper clock
central clock
Definition: JDAQClient.hh:832
void wait() const
Wait until the number of time intervals has elapsed since the last call to the reset method...
Definition: JTimekeeper.hh:145
Auxiliary class for time values.
Definition: JTimeval.hh:26
virtual void actionRunning()
This method is repeatedly called when this client machine is in state Running and the clock interval ...
Definition: JDAQClient.hh:440
bool isRunning() const
Check if this client is in runnig state.
Definition: JDAQClient.hh:281
void update()
Update state machine.
Definition: JDAQClient.hh:643
long long int getInterval() const
Get interval time.
Definition: JTimekeeper.hh:67
static const int TIMEOUT_S
time out of update [s]
Definition: JDAQClient.hh:631
JMessageLogger logger
message logger
Definition: JDAQClient.hh:636
void error(const JMessage_t &message)
void setSelect()
Set the file descriptor mask for the select call.
Definition: JDAQClient.hh:403
virtual void actionSelect(const JFileDescriptorMask &mask)
Action method following last select call.
Definition: JDAQClient.hh:429
bool hasReaderMask(const JAbstractFile &file) const
Has reader file.
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 573 of file JDAQClient.hh.

574  {
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  }
ControlHost prefix.
Definition: JPrefix.hh:31
ControlHost class.
int Connected()
Send version.
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
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
virtual bool enter()
Enter the state machine.
Definition: JDAQClient.hh:195
virtual bool exit()
Exit the state machine.
Definition: JDAQClient.hh:225
int WaitHead(JPrefix &prefix)
Wait for header.
std::string toString() const
Convert tag to string.
Definition: JTag.hh:167
int GetFullData(void *buffer, int length)
Receive data.
Light-weight wrapper class around server socket.
int PutFullData(const JTag &tag, const void *buffer, const int length)
Send data.
void KM3NETDAQ::JDAQClient::run ( std::istream &  in)
inlineinherited

Run client with commands from input stream (e.g for debugging).

Example input format:

<tag> <event name>[#data];
<tag> <event name>[#data];
Parameters
ininput stream

Definition at line 618 of file JDAQClient.hh.

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  }
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:468
void update()
Update state machine.
Definition: JDAQClient.hh:643

Member Data Documentation

boost::scoped_ptr<JControlHost> KM3NETDAQ::MonitorRouter::m_ch
private

Definition at line 27 of file monrouter.cpp.

boost::asio::io_service KM3NETDAQ::MonitorRouter::m_service
private

Definition at line 28 of file monrouter.cpp.

boost::asio::ip::udp::socket KM3NETDAQ::MonitorRouter::m_input
mutableprivate

Definition at line 29 of file monrouter.cpp.

bool KM3NETDAQ::MonitorRouter::m_running
private

Definition at line 30 of file monrouter.cpp.

int KM3NETDAQ::MonitorRouter::m_port
private

Definition at line 31 of file monrouter.cpp.

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

time out of update [s]

Definition at line 631 of file JDAQClient.hh.

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

message server

Definition at line 635 of file JDAQClient.hh.

JMessageLogger KM3NETDAQ::JDAQClient::logger
protectedinherited

message logger

Definition at line 636 of file JDAQClient.hh.


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