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::DataQueue Class Reference
Inheritance diagram for KM3NETDAQ::DataQueue:
KM3NETDAQ::JDAQClient

Public Member Functions

 DataQueue (const std::string &name, const std::string &server, JLogger *logger, const int level, bool acou, bool opto)
 
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 actionSelect (const JFileDescriptorMask &)
 Action method following last select call. More...
 
const JNET::JTagclientTag () const
 
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 setSelect (JFileDescriptorMask &mask) const
 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

bool const m_acou
 
bool const m_opto
 
boost::scoped_ptr
< DataInputInterface
m_input
 
boost::scoped_ptr< FrameFarmm_afarm
 
boost::scoped_ptr< FrameFarmm_ofarm
 
boost::scoped_ptr
< RecipientsHandler
m_orecipients
 
boost::scoped_ptr
< RecipientsHandler
m_arecipients
 
boost::scoped_ptr< DFInterfacem_adfi
 
boost::scoped_ptr< DFInterfacem_odfi
 
boost::scoped_ptr< boost::thread > m_aff_th
 
boost::scoped_ptr< boost::thread > m_off_th
 
boost::scoped_ptr< boost::thread > m_adfi_th
 
boost::scoped_ptr< boost::thread > m_odfi_th
 

Detailed Description

Definition at line 40 of file DataQueue.cc.

Constructor & Destructor Documentation

KM3NETDAQ::DataQueue::DataQueue ( const std::string &  name,
const std::string &  server,
JLogger logger,
const int  level,
bool  acou,
bool  opto 
)
inline

Definition at line 65 of file DataQueue.cc.

71  :
72  JDAQClient(name, server, logger, level),
73  m_acou(acou),
74  m_opto(opto)
75  {
76  replaceEvent(RC_CMD, clientTag(), ev_configure);
77  }
bool const m_opto
Definition: DataQueue.cc:43
bool const m_acou
Definition: DataQueue.cc:42
JDAQClient(const std::string &name)
Constructor.
Definition: JDAQClient.hh:97
JSharedPointer< JControlHost > server
message server
Definition: JDAQClient.hh:635
const JNET::JTag & clientTag() const
Definition: DataQueue.cc:279
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::DataQueue::actionEnter ( )
inlinevirtual

Interface methods for actions corresponding to state transitions.

Definition at line 82 of file DataQueue.cc.

82 {}
virtual void KM3NETDAQ::DataQueue::actionExit ( )
inlinevirtual

Definition at line 83 of file DataQueue.cc.

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

Definition at line 85 of file DataQueue.cc.

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

Definition at line 86 of file DataQueue.cc.

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

Definition at line 88 of file DataQueue.cc.

89  {
90  // parse the configuration
91  boost::property_tree::ptree const conf = detail::parse(
92  std::string(buffer, length));
93 
94  // initialize some global flavor-independent variables
95  unsigned int const delta_ts = conf.get<unsigned int>(
96  "timeslice_duration");
97 
98  uint64_t const run_start_time = conf.get<uint64_t>("run_start_time");
99 
100  std::size_t const max_dump_size = conf.get<std::size_t>("max_dump_size");
101  std::string const prefix = conf.get<std::string>("dump_file_prefix");
102  std::string const postfix = conf.get<std::string>("dump_file_postfix");
103 
104  std::vector<int> acou_ports;
105  std::vector<int> opto_ports;
106 
107  if (m_acou) {
108  acou_ports = detail::vectorize<int>(conf.get<std::string>("acou_ports"));
109  }
110 
111  if (m_opto) {
112  opto_ports = detail::vectorize<int>(conf.get<std::string>("opto_ports"));
113  }
114 
115  int const n_channels = acou_ports.size() + opto_ports.size();
116 
117  // create DataInputInterface
118  m_input.reset(new DataInputInterface(n_channels));
119 
120  // create the FrameFarms
121  if (m_acou) {
122  m_afarm.reset(
123  new FrameFarm(
124  delta_ts,
125  run_start_time,
126  max_dump_size,
127  prefix + "_a",
128  postfix));
129  }
130 
131  if (m_opto) {
132  m_ofarm.reset(
133  new FrameFarm(
134  delta_ts,
135  run_start_time,
136  max_dump_size,
137  prefix + "_o",
138  postfix));
139  }
140 
141  // create the RecipientsHandlers and the DFInterfaces
142  if (m_acou) {
143  std::string const acou_recipient = conf.get<std::string>("acou_recipient");
144 
145  m_arecipients.reset(new RecipientsHandler(10));
146  m_arecipients->add(acou_recipient);
147  m_adfi.reset(new DFInterface(*m_afarm, *m_arecipients));
148  }
149 
150  if (m_opto) {
151  std::vector<std::string> const opto_recipients = detail::vectorize<std::string>(
152  conf.get<std::string>("opto_recipients"));
153 
154  m_orecipients.reset(new RecipientsHandler(10));
155  BOOST_FOREACH(std::string s, opto_recipients)
156  {
157  m_orecipients->add(s);
158  }
159  m_odfi.reset(new DFInterface(*m_ofarm, *m_orecipients));
160  }
161 
162  // add the channels to DataInputInterface
163  if (m_acou) {
164  BOOST_FOREACH(int port, acou_ports)
165  {
166  m_input->add_channel(port, *m_afarm);
167  }
168  }
169 
170  if (m_opto) {
171  BOOST_FOREACH(int port, opto_ports)
172  {
173  m_input->add_channel(port, *m_ofarm);
174  }
175  }
176  }
bool const m_opto
Definition: DataQueue.cc:43
bool const m_acou
Definition: DataQueue.cc:42
boost::scoped_ptr< DFInterface > m_adfi
Definition: DataQueue.cc:54
boost::scoped_ptr< FrameFarm > m_afarm
Definition: DataQueue.cc:48
boost::scoped_ptr< RecipientsHandler > m_orecipients
Definition: DataQueue.cc:51
boost::property_tree::ptree parse(std::string str)
Definition: configure.hh:24
boost::scoped_ptr< FrameFarm > m_ofarm
Definition: DataQueue.cc:49
boost::scoped_ptr< RecipientsHandler > m_arecipients
Definition: DataQueue.cc:52
boost::scoped_ptr< DFInterface > m_odfi
Definition: DataQueue.cc:55
boost::scoped_ptr< DataInputInterface > m_input
Definition: DataQueue.cc:46
virtual void KM3NETDAQ::DataQueue::actionQuit ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 178 of file DataQueue.cc.

179  {
180  // reset the DataFilter interfaces
181  m_odfi.reset();
182  m_adfi.reset();
183 
184  // reset the RecipientsHandlers
185  m_orecipients.reset();
186  m_arecipients.reset();
187 
188  // reset the FrameFarms
189  m_ofarm.reset();
190  m_afarm.reset();
191 
192  // reset the DataInputInterface
193  m_input.reset();
194  }
boost::scoped_ptr< DFInterface > m_adfi
Definition: DataQueue.cc:54
boost::scoped_ptr< FrameFarm > m_afarm
Definition: DataQueue.cc:48
boost::scoped_ptr< RecipientsHandler > m_orecipients
Definition: DataQueue.cc:51
boost::scoped_ptr< FrameFarm > m_ofarm
Definition: DataQueue.cc:49
boost::scoped_ptr< RecipientsHandler > m_arecipients
Definition: DataQueue.cc:52
boost::scoped_ptr< DFInterface > m_odfi
Definition: DataQueue.cc:55
boost::scoped_ptr< DataInputInterface > m_input
Definition: DataQueue.cc:46
virtual void KM3NETDAQ::DataQueue::actionStart ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 196 of file DataQueue.cc.

197  {
198  int const run_number = getRunNumber();
199 
200  int const detector_id = getDetectorID();
201 
202  assert(run_number >= 0);
203 
205 
206  // launch the FrameFarm threads
207  if (m_acou) {
208  m_afarm->runNumber(run_number);
209  m_afarm->detectorId(detector_id);
210  m_aff_th.reset(new boost::thread(boost::ref(*m_afarm)));
211  }
212  if (m_opto) {
213  m_ofarm->runNumber(run_number);
214  m_ofarm->detectorId(detector_id);
215  m_off_th.reset(new boost::thread(boost::ref(*m_ofarm)));
216  }
217 
218  // launch the DFInterface threads
219  if (m_acou) m_adfi_th.reset(new boost::thread(boost::ref(*m_adfi)));
220  if (m_opto) m_odfi_th.reset(new boost::thread(boost::ref(*m_odfi)));
221 
222  // launch the DataInputInterface
223  m_input->start();
224  }
boost::scoped_ptr< boost::thread > m_adfi_th
Definition: DataQueue.cc:60
bool const m_opto
Definition: DataQueue.cc:43
bool const m_acou
Definition: DataQueue.cc:42
boost::scoped_ptr< DFInterface > m_adfi
Definition: DataQueue.cc:54
static Counter & get()
Definition: log.hh:53
boost::scoped_ptr< FrameFarm > m_afarm
Definition: DataQueue.cc:48
boost::scoped_ptr< boost::thread > m_odfi_th
Definition: DataQueue.cc:61
boost::scoped_ptr< boost::thread > m_aff_th
Definition: DataQueue.cc:58
boost::scoped_ptr< FrameFarm > m_ofarm
Definition: DataQueue.cc:49
boost::scoped_ptr< DFInterface > m_odfi
Definition: DataQueue.cc:55
void reset()
Definition: log.hh:73
boost::scoped_ptr< DataInputInterface > m_input
Definition: DataQueue.cc:46
boost::scoped_ptr< boost::thread > m_off_th
Definition: DataQueue.cc:59
virtual void KM3NETDAQ::DataQueue::actionStop ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 226 of file DataQueue.cc.

227  {
228  // stop the DataInputInterface
229  m_input->stop();
230 
231  // stop the FrameFarms
232  if (m_opto) m_ofarm->stop();
233  if (m_acou) m_afarm->stop();
234 
235  // stop the DataFilter interfaces
236  if (m_opto) m_odfi->stop();
237  if (m_acou) m_adfi->stop();
238 
239  // join the DataFilter interfaces
240  if (m_opto) m_odfi_th->join();
241  if (m_acou) m_adfi_th->join();
242 
243  // join the FramFarms
244  if (m_opto) m_off_th->join();
245  if (m_acou) m_aff_th->join();
246 
247  // call reset to go in stand-by
248  actionQuit(length, buffer);
249 
250  // reset the DataFilter interfaces threads
251  m_odfi_th.reset();
252  m_adfi_th.reset();
253 
254  // reset the FrameFarms threads
255  m_off_th.reset();
256  m_aff_th.reset();
257  }
boost::scoped_ptr< boost::thread > m_adfi_th
Definition: DataQueue.cc:60
bool const m_opto
Definition: DataQueue.cc:43
bool const m_acou
Definition: DataQueue.cc:42
boost::scoped_ptr< DFInterface > m_adfi
Definition: DataQueue.cc:54
boost::scoped_ptr< FrameFarm > m_afarm
Definition: DataQueue.cc:48
boost::scoped_ptr< boost::thread > m_odfi_th
Definition: DataQueue.cc:61
virtual void actionQuit(int length, const char *buffer)
Definition: DataQueue.cc:178
boost::scoped_ptr< boost::thread > m_aff_th
Definition: DataQueue.cc:58
boost::scoped_ptr< FrameFarm > m_ofarm
Definition: DataQueue.cc:49
boost::scoped_ptr< DFInterface > m_odfi
Definition: DataQueue.cc:55
boost::scoped_ptr< DataInputInterface > m_input
Definition: DataQueue.cc:46
boost::scoped_ptr< boost::thread > m_off_th
Definition: DataQueue.cc:59
virtual void KM3NETDAQ::DataQueue::actionPause ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 259 of file DataQueue.cc.

260  {
261  m_input->pause();
262  }
boost::scoped_ptr< DataInputInterface > m_input
Definition: DataQueue.cc:46
virtual void KM3NETDAQ::DataQueue::actionContinue ( int  length,
const char *  buffer 
)
inlinevirtual

Definition at line 264 of file DataQueue.cc.

265  {
266  m_input->cont();
267  }
boost::scoped_ptr< DataInputInterface > m_input
Definition: DataQueue.cc:46
virtual void KM3NETDAQ::DataQueue::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 269 of file DataQueue.cc.

270  {
271  monitor();
272  }
static void monitor()
Definition: DataQueue.cc:31
virtual void KM3NETDAQ::DataQueue::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 274 of file DataQueue.cc.

275  {
276  monitor();
277  }
static void monitor()
Definition: DataQueue.cc:31
const JNET::JTag& KM3NETDAQ::DataQueue::clientTag ( ) const
inline

Definition at line 279 of file DataQueue.cc.

280  {
281  if (m_acou && m_opto)
282  {
283  return RC_DQUEUE;
284  }
285  else if (m_acou)
286  {
287  return RC_DQUEUE_ACS;
288  }
289  else if (m_opto)
290  {
291  return RC_DQUEUE_OPT;
292  }
293 
294  assert(!"No DQ mode set.");
295  }
static const JNET::JTag RC_DQUEUE_OPT
Definition: JDAQTags.hh:53
bool const m_opto
Definition: DataQueue.cc:43
static const JNET::JTag RC_DQUEUE
Definition: JDAQTags.hh:51
bool const m_acou
Definition: DataQueue.cc:42
static const JNET::JTag RC_DQUEUE_ACS
Definition: JDAQTags.hh:52
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::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::JDataWriter, and KM3NETDAQ::MonitorRouter.

Definition at line 419 of file JDAQClient.hh.

420  {}
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

bool const KM3NETDAQ::DataQueue::m_acou
private

Definition at line 42 of file DataQueue.cc.

bool const KM3NETDAQ::DataQueue::m_opto
private

Definition at line 43 of file DataQueue.cc.

boost::scoped_ptr<DataInputInterface> KM3NETDAQ::DataQueue::m_input
private

Definition at line 46 of file DataQueue.cc.

boost::scoped_ptr<FrameFarm> KM3NETDAQ::DataQueue::m_afarm
private

Definition at line 48 of file DataQueue.cc.

boost::scoped_ptr<FrameFarm> KM3NETDAQ::DataQueue::m_ofarm
private

Definition at line 49 of file DataQueue.cc.

boost::scoped_ptr<RecipientsHandler> KM3NETDAQ::DataQueue::m_orecipients
private

Definition at line 51 of file DataQueue.cc.

boost::scoped_ptr<RecipientsHandler> KM3NETDAQ::DataQueue::m_arecipients
private

Definition at line 52 of file DataQueue.cc.

boost::scoped_ptr<DFInterface> KM3NETDAQ::DataQueue::m_adfi
private

Definition at line 54 of file DataQueue.cc.

boost::scoped_ptr<DFInterface> KM3NETDAQ::DataQueue::m_odfi
private

Definition at line 55 of file DataQueue.cc.

boost::scoped_ptr<boost::thread> KM3NETDAQ::DataQueue::m_aff_th
private

Definition at line 58 of file DataQueue.cc.

boost::scoped_ptr<boost::thread> KM3NETDAQ::DataQueue::m_off_th
private

Definition at line 59 of file DataQueue.cc.

boost::scoped_ptr<boost::thread> KM3NETDAQ::DataQueue::m_adfi_th
private

Definition at line 60 of file DataQueue.cc.

boost::scoped_ptr<boost::thread> KM3NETDAQ::DataQueue::m_odfi_th
private

Definition at line 61 of file DataQueue.cc.

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: