Jpp
|
Run control client base class. More...
#include <JDAQClient.hh>
Public Member Functions | |
JDAQClient (const std::string &name) | |
Constructor. More... | |
JDAQClient (const std::string &name, const std::string &server, JLogger *logger, const int level) | |
Constructor. 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::JTag & | getUniqueTag () 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_t * | findEvent (const JNET::JTag &tag, const std::string &event_name) |
Find event in event table. More... | |
template<class T > | |
void | addParameter (const char option, T ¶meter) |
Add parameter to parser used in method enter(). More... | |
template<class T > | |
void | addParameter (const char option, T ¶meter, 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 | actionSelect (const JFileDescriptorMask &mask) |
Action method following last select call. More... | |
virtual void | actionRunning () |
This method is repeatedly called when this client machine is in state Running and the clock interval time is non-zero. More... | |
virtual void | actionInput (int length, const char *buffer) |
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< JControlHost > | server |
message server More... | |
JMessageLogger | logger |
message logger More... | |
Private Member Functions | |
void | update () |
Update state machine. More... | |
void | update (const JNET::JTag &tag, int length, const char *buffer) |
Update state machine. More... | |
void | configure () |
Configure client. More... | |
void | enterState (const CHSM::state &state, const CHSM::event &event) |
Action when entering state. More... | |
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. More... | |
void | execute (action __action, const CHSM::event &__event) |
The method to execute the action. More... | |
Private Attributes | |
JEventTable | eventTable |
event table More... | |
std::string | hostname |
std::string | full_name |
JNET::JTag | unique_tag |
JTimekeeper | clock |
central clock More... | |
JSelectReader | select |
select call More... | |
JParser | parser |
parser method enter() More... | |
int | event_number |
number of last event More... | |
Run control client base class.
This base class implements the protocol for the communication with the central run control program. This protocol is based on JNET::JControlHost tags and CHSM event names. The method run can be used to process JNET::JControlHost messages and accordingly update the state machine.
For client specific events with a designated JNET::JControlHost tag, the corresponding entry in the event table should be replaced. This should be done in the constructor of the derived class using method JDAQClient::replaceEvent.
The method JDAQClient::addParameter can be used to add a parameter of the derived class to the list that is parsed in method enter.
The method JDAQClient::filter 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 this method returns true, else it is normally processed.
The method JDAQClient::setSelect can be used to set the file descriptor mask of the select call and the method actionSelect can be used to take client specific actions following the select call.
If the clock interval is non-zero, the method JDAQClient::actionRunning is repeatedly called when this client machine is in state Running
. The clock interval can be set using method JDAQClient::setClockInterval.
Definition at line 88 of file JDAQClient.hh.
|
inline |
Constructor.
name | name of client |
Definition at line 97 of file JDAQClient.hh.
|
inline |
Constructor.
name | name of client |
server | name of command message server |
logger | pointer to logger |
level | debug level |
Definition at line 114 of file JDAQClient.hh.
|
inlinevirtual |
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.
args | array of command line arguments |
Definition at line 143 of file JDAQClient.hh.
|
inlinevirtual |
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.
|
inlinevirtual |
Exit the state machine.
This method releases the various resources.
Definition at line 225 of file JDAQClient.hh.
|
inline |
Get full name of this run control client.
Definition at line 248 of file JDAQClient.hh.
|
inline |
Get unique tag of this run control client.
Definition at line 259 of file JDAQClient.hh.
|
inline |
Get last event number.
Definition at line 270 of file JDAQClient.hh.
|
inline |
Check if this client is in runnig state.
Definition at line 281 of file JDAQClient.hh.
|
inline |
Replace tag of given event in event table.
oldTag | old tag |
newTag | new tag |
event | event |
Definition at line 294 of file JDAQClient.hh.
|
inline |
Find event in event table.
tag | tag |
event_name | event name |
Definition at line 309 of file JDAQClient.hh.
|
inline |
Add parameter to parser used in method enter().
option | option |
parameter | parameter |
Definition at line 327 of file JDAQClient.hh.
|
inline |
Add parameter to parser used in method enter().
option | option |
parameter | parameter |
value | default value |
Definition at line 341 of file JDAQClient.hh.
|
inline |
Get total delay time.
Definition at line 352 of file JDAQClient.hh.
|
inline |
|
inline |
Get interval time.
Definition at line 374 of file JDAQClient.hh.
|
inline |
Set interval time.
interval_us | interval time [us] |
Definition at line 385 of file JDAQClient.hh.
|
inline |
Reset clock.
Definition at line 394 of file JDAQClient.hh.
|
inline |
Set the file descriptor mask for the select call.
Definition at line 403 of file JDAQClient.hh.
|
inlinevirtual |
Set the file descriptor mask for the select call.
This implementation does nothing but may be redefined by the derived class.
mask | file descriptor mask |
Reimplemented in KM3NETDAQ::JDataWriter, and KM3NETDAQ::MonitorRouter.
Definition at line 419 of file JDAQClient.hh.
|
inlinevirtual |
Action method following last select call.
This implementation does nothing but may be redefined by the derived class.
mask | file descriptor mask |
Reimplemented in KM3NETDAQ::DataQueue, KM3NETDAQ::JDataWriter, and KM3NETDAQ::MonitorRouter.
Definition at line 429 of file JDAQClient.hh.
|
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 in JDataFilter, KM3NETDAQ::JDataWriter, KM3NETDAQ::JDOMSimulator, KM3NETDAQ::DataQueue, KM3NETDAQ::JEventGenerator, KM3NETDAQ::MonitorRouter, and AcousticDataFilter.
Definition at line 440 of file JDAQClient.hh.
|
inlinevirtual |
This method is called at ev_input
.
length | length of data |
buffer | pointer to data |
Reimplemented in AcousticDataFilter.
Definition at line 450 of file JDAQClient.hh.
|
inlinevirtual |
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.
tag | tag |
length | number of characters |
buffer | message |
Definition at line 477 of file JDAQClient.hh.
|
inline |
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.
|
inline |
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.
port | port number |
Definition at line 573 of file JDAQClient.hh.
|
inline |
Run client with commands from input stream (e.g for debugging).
Example input format:
<tag> <event name>[#data]; <tag> <event name>[#data];
in | input stream |
Definition at line 618 of file JDAQClient.hh.
|
inlineprivate |
Update state machine.
This method waits for a message from JNET::JControlHost server.
Definition at line 643 of file JDAQClient.hh.
|
inlineprivate |
Update state machine.
tag | tag |
length | number of characters |
buffer | message |
Definition at line 670 of file JDAQClient.hh.
|
inlineprivate |
Configure client.
This method is used to setup the event table.
Definition at line 723 of file JDAQClient.hh.
|
inlineprivate |
Action when entering state.
This method provides for the hand shaking with the run control program.
state | entered state |
event | event that triggered transition |
Definition at line 764 of file JDAQClient.hh.
|
inlineprivatevirtual |
This method is called at ev_check
and reports a system check by mimicing an enter state action.
length | number of characters |
buffer | message |
Definition at line 785 of file JDAQClient.hh.
|
inlineprivate |
The method to execute the action.
__action | pointer to action method |
__event | event that triggered the action |
Definition at line 812 of file JDAQClient.hh.
|
static |
time out of update [s]
Definition at line 631 of file JDAQClient.hh.
|
protected |
message server
Definition at line 635 of file JDAQClient.hh.
|
protected |
message logger
Definition at line 636 of file JDAQClient.hh.
|
private |
event table
Definition at line 828 of file JDAQClient.hh.
|
private |
Definition at line 829 of file JDAQClient.hh.
|
private |
Definition at line 830 of file JDAQClient.hh.
|
private |
Definition at line 831 of file JDAQClient.hh.
|
private |
central clock
Definition at line 832 of file JDAQClient.hh.
|
private |
select call
Definition at line 833 of file JDAQClient.hh.
|
private |
parser method enter()
Definition at line 834 of file JDAQClient.hh.
|
private |
number of last event
Definition at line 835 of file JDAQClient.hh.