Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
KM3NETDAQ::JDataWriter Class Reference

Runcontrol client to write data to disk. More...

Inheritance diagram for KM3NETDAQ::JDataWriter:
KM3NETDAQ::JDAQClient JDAQStateMachine KM3NETDAQ::JDAQClient_t JDAQCHSM

Classes

struct  JRunDB
 Map run number to trigger parameters. More...
 
struct  JValue_t
 Auxiliary data structure for I/O of trigger parameters. More...
 

Public Member Functions

 JDataWriter (const std::string &name, const std::string &server, const std::string &hostname, JLogger *logger, const int level, const std::string &path)
 Constructor.
 
virtual void actionInit (int length, const char *buffer) override
 
virtual void actionConfigure (int length, const char *buffer) override
 
virtual void actionReset (int length, const char *buffer) override
 
virtual void actionQuit (int length, const char *buffer) override
 
virtual void actionStart (int length, const char *buffer) override
 
virtual void actionStop (int length, const char *buffer) override
 
virtual void setSelect (JFileDescriptorMask &mask) const override
 Set the file descriptor mask for the select call.
 
virtual void actionSelect (const JFileDescriptorMask &mask) override
 Action method following last select call.
 
virtual void actionRunning () override
 This method is repeatedly called when this client machine is in state Running and the clock interval time is non-zero.
 
void typeout ()
 Report status of data writing.
 
virtual bool enter (const JArgs &args)
 Enter the state machine.
 
virtual bool enter () override
 Enter the state machine.
 
virtual bool exit () override
 Exit the state machine.
 
bool isRunning () const
 Check if this client is in runnig state.
 
void replaceEvent (const JTag &oldTag, const JTag &newTag, JDAQEvent_t &event)
 Replace tag of given event in event table.
 
JDAQEvent_tfindEvent (const JTag &tag, const std::string &event_name)
 Find event in event table.
 
void addSubscription (const JSubscription &subscription)
 Add custom subscription.
 
template<class T >
void addParameter (const char option, T &parameter)
 Add parameter to parser used in method enter().
 
template<class T >
void addParameter (const char option, T &parameter, const T &value)
 Add parameter to parser used in method enter().
 
void setSelect ()
 Set the file descriptor mask for the select call.
 
virtual void actionInput (int length, const char *buffer) override
 This method is called at ev_input.
 
virtual bool filter (const JTag &tag, int length, const char *buffer)
 Filter message.
 
virtual void actionTagged (const JTag &tag, int length, const char *buffer)
 This method is called when a custom tag is encountered.
 
void run ()
 Run as run control client following command messages via JNET::JControlHost.
 
void run (const int port)
 Run for ever.
 
void run (std::istream &in)
 Run client with commands from input stream (e.g. for debugging).
 
void A1 (CHSM_ns_alias::event const &)
 
void A2 (CHSM_ns_alias::event const &)
 
void A3 (CHSM_ns_alias::event const &)
 
void A4 (CHSM_ns_alias::event const &)
 
void A5 (CHSM_ns_alias::event const &)
 
void A6 (CHSM_ns_alias::event const &)
 
void A7 (CHSM_ns_alias::event const &)
 
void A8 (CHSM_ns_alias::event const &)
 
void A9 (CHSM_ns_alias::event const &)
 
void A10 (CHSM_ns_alias::event const &)
 
void A11 (CHSM_ns_alias::event const &)
 
void A12 (CHSM_ns_alias::event const &)
 
void A13 (CHSM_ns_alias::event const &)
 
void A14 (CHSM_ns_alias::event const &)
 
void EAM4root (CHSM_ns_alias::state const &, CHSM_ns_alias::event const &)
 
void XAM4root (CHSM_ns_alias::state const &, CHSM_ns_alias::event const &)
 
const std::string & getName () const
 Get name of state machine.
 
int getDetectorID () const
 Get detector identifier.
 
int getRunNumber () const
 Get run number.
 
virtual void actionEnter ()
 Interface methods for actions corresponding to state transitions.
 
virtual void actionExit ()
 
virtual void actionPause (int, const char *)
 
virtual void actionContinue (int, const char *)
 
virtual void actionError ()
 
virtual void actionRecover (int, const char *)
 
const std::string & getHostname () const
 Get hostname.
 
const std::string & getFullName () const
 Get full name of this run control client.
 
const JTaggetUniqueTag () const
 Get unique tag of this run control client.
 
long long int getClockDelay () const
 Get total delay time.
 
long long int getClockInterval () const
 Get interval time.
 
void setClockInterval (const long long int interval_us)
 Set interval time.
 
void resetClock ()
 Reset clock.
 
const std::string & getEventInfo () const
 Get last event information.
 
void setEventInfo (const std::string &info)
 Set last event information.
 

Public Attributes

JMeta meta
 meta data
 
JDAQStateMachine::state_root root
 
JDAQStateMachine::state_Main Main
 
JDAQStateMachine::ev_daq_event ev_daq
 
char ev_daq_param_block [sizeof(ev_daq_event::param_block)]
 
JDAQStateMachine::ev_init_event ev_init
 
char ev_init_param_block [sizeof(ev_init_event::param_block)]
 
JDAQStateMachine::ev_configure_event ev_configure
 
char ev_configure_param_block [sizeof(ev_configure_event::param_block)]
 
JDAQStateMachine::ev_start_event ev_start
 
char ev_start_param_block [sizeof(ev_start_event::param_block)]
 
JDAQStateMachine::ev_pause_event ev_pause
 
char ev_pause_param_block [sizeof(ev_pause_event::param_block)]
 
JDAQStateMachine::ev_continue_event ev_continue
 
char ev_continue_param_block [sizeof(ev_continue_event::param_block)]
 
JDAQStateMachine::ev_stop_event ev_stop
 
char ev_stop_param_block [sizeof(ev_stop_event::param_block)]
 
JDAQStateMachine::ev_reset_event ev_reset
 
char ev_reset_param_block [sizeof(ev_reset_event::param_block)]
 
JDAQStateMachine::ev_quit_event ev_quit
 
char ev_quit_param_block [sizeof(ev_quit_event::param_block)]
 
JDAQStateMachine::ev_off_event ev_off
 
char ev_off_param_block [sizeof(ev_off_event::param_block)]
 
JDAQStateMachine::ev_check_event ev_check
 
char ev_check_param_block [sizeof(ev_check_event::param_block)]
 
JDAQStateMachine::ev_input_event ev_input
 
char ev_input_param_block [sizeof(ev_input_event::param_block)]
 
JDAQStateMachine::ev_recover_event ev_recover
 
char ev_recover_param_block [sizeof(ev_recover_event::param_block)]
 
JDAQStateMachine::ev_error_event ev_error
 
char ev_error_param_block [sizeof(ev_error_event::param_block)]
 

Static Public Attributes

static const int MAXIMUM_FILE_NUMBER = 100
 maximum file number for overwrite protection.
 
static const int TIMEOUT_S = 1
 time out of update [s]
 

Protected Types

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

Protected Attributes

JSharedPointer< JControlHostserver
 message server
 
JMessageLogger logger
 message logger
 
std::string name
 
int detector_id
 
int run_number
 
JEventTable eventTable
 event table
 
std::string fullname
 
JTag unique_tag
 
JTimekeeper clock
 central clock
 
std::string event_info
 event information
 

Private Member Functions

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

Private Attributes

JLANG::JSharedPointer< JControlHostdatawriter
 
std::string path
 
JEEP::JTimer timer
 
Long64_t numberOfEvents
 
long long int numberOfBytes
 
JMessageScheduler logErrorRun
 
JMessageScheduler logErrorFile
 
JMessageScheduler logErrorTag
 
JMessageScheduler logErrorState
 
std::string hostname
 host name of data server
 
JTreeWriter_t writer
 TTree writer.
 
std::vector< char > buffer
 internal buffer for incoming data
 
JRunDB run_db
 
JSelectReader select
 select call
 
JParser parser
 parser method enter()
 
JSubscriptionList subscription
 custom subscription
 
CHSM_ns_alias::state * state_ [11]
 
CHSM_ns_alias::event const * taken_ [14]
 
CHSM_ns_alias::state * target_ [14]
 

Static Private Attributes

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

Detailed Description

Runcontrol client to write data to disk.

In state running, this application will write ROOT formatted data from the data filters to disk.

Definition at line 61 of file JDataWriter.cc.

Member Typedef Documentation

◆ action

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

Type definition of action method.

Definition at line 152 of file JDAQCHSM.hh.

Constructor & Destructor Documentation

◆ JDataWriter()

KM3NETDAQ::JDataWriter::JDataWriter ( const std::string & name,
const std::string & server,
const std::string & hostname,
JLogger * logger,
const int level,
const std::string & path )
inline

Constructor.

Parameters
namename of client
servername of command message server
hostnamename of data server
loggerpointer to logger
leveldebug level
pathdefault path

Definition at line 75 of file JDataWriter.cc.

80 :
81 JDAQClient(name, server, logger, level),
82 datawriter(),
83 path (path),
85 {
87
89
90 // map ControlHost tag to TTree writer.
91
93 }
std::string name
Definition JDAQCHSM.hh:165
JDAQStateMachine::ev_configure_event ev_configure
static void Throw(const bool option)
Definition JThrow.hh:37
void insert()
Insert (list of) data type(s).
JSharedPointer< JControlHost > server
message server
void replaceEvent(const JTag &oldTag, const JTag &newTag, JDAQEvent_t &event)
Replace tag of given event in event table.
JMessageLogger logger
message logger
JDAQClient(const std::string &name, const std::string &server, JLogger *logger, const int level)
Constructor.
std::string hostname
host name of data server
JTreeWriter_t writer
TTree writer.
JLANG::JSharedPointer< JControlHost > datawriter
static const JNET::JTag RC_DWRITER
Definition JDAQTags.hh:71
static const JNET::JTag RC_CMD
Definition JDAQTags.hh:66
Type list.
Definition JTypeList.hh:23

Member Function Documentation

◆ actionInit()

virtual void KM3NETDAQ::JDataWriter::actionInit ( int length,
const char * buffer )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 96 of file JDataWriter.cc.

97 {
98 using namespace std;
99 using namespace JPP;
100
101 // start server
102
103 try {
104
105 datawriter.reset(new JControlHost(hostname));
106
107 datawriter->setReceiveBufferSize(DWRITER_RECEIVE_BUFFER_SIZE);
108
109 datawriter->MyId(getFullName());
110
112
113 for (JTreeWriter_t::iterator i = writer.begin(); i != writer.end(); ++i) {
114 buffer.add(JSubscriptionAll(i->first));
115 }
116
118
119 datawriter->Subscribe(buffer);
120 datawriter->SendMeAlways();
121
122 JNoticeStream(logger) << "Established connection to " << hostname;
123 }
124 catch(const std::exception& exception) {
125 JErrorStream(logger) << exception.what();
126 }
127 }
ControlHost class.
Subscription list.
std::vector< char > buffer
internal buffer for incoming data
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const int DWRITER_RECEIVE_BUFFER_SIZE
socket JDataWriter.cc <- JDataFilter.cc
Definition JDAQTags.hh:39
static const JNET::JTag IO_TRIGGER_PARAMETERS
Definition JDAQTags.hh:90
Auxiliary class for all subscription.
const std::string & getFullName() const
Get full name of this run control client.

◆ actionConfigure()

virtual void KM3NETDAQ::JDataWriter::actionConfigure ( int length,
const char * buffer )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 130 of file JDataWriter.cc.

131 {
132 using namespace std;
133
134 long long int update_s = 10;
135 long long int logger_s = 5;
136
137 JProperties properties(JEquationParameters("=", ";", "", ""));
138
139 properties["path"] = path;
140 properties["update_s"] = update_s;
141 properties["logger_s"] = logger_s;
142
143 properties.read(string(buffer, length));
144
145 if (update_s <= 0) { update_s = 1; }
146 if (logger_s <= 0) { logger_s = 1; }
147
148 setClockInterval(update_s * 1000000LL);
149
150 JDebugStream(logger) << "Path <" << path << ">";
151 JDebugStream(logger) << "Update period [s] " << update_s;
152
153 logErrorRun = JMessageScheduler(logger, JTimekeeper(logger_s * 1000000LL));
154 logErrorFile = JMessageScheduler(logger, JTimekeeper(logger_s * 1000000LL));
155 logErrorTag = JMessageScheduler(logger, JTimekeeper(logger_s * 1000000LL));
156 logErrorState = JMessageScheduler(logger, JTimekeeper(logger_s * 1000000LL));
157
158 numberOfEvents = 0;
159 numberOfBytes = 0;
160 }
Utility class to parse parameter values.
Time keeper.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Message logger with time scheduler.
long long int numberOfBytes
JMessageScheduler logErrorFile
JMessageScheduler logErrorRun
JMessageScheduler logErrorState
JMessageScheduler logErrorTag
Level specific message streamers.
void setClockInterval(const long long int interval_us)
Set interval time.

◆ actionReset()

virtual void KM3NETDAQ::JDataWriter::actionReset ( int length,
const char * buffer )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 163 of file JDataWriter.cc.

164 {
165 datawriter.reset();
166 }

◆ actionQuit()

virtual void KM3NETDAQ::JDataWriter::actionQuit ( int length,
const char * buffer )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 169 of file JDataWriter.cc.

170 {}

◆ actionStart()

virtual void KM3NETDAQ::JDataWriter::actionStart ( int length,
const char * buffer )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 173 of file JDataWriter.cc.

174 {
175 using namespace std;
176 using namespace JPP;
177
178 JStatusStream(logger) << "Start run " << getDetectorID() << ' ' << getRunNumber();
179
180 if (writer.is_open()) {
181
182 JErrorStream (logger) << "Previous file still open -> close";
183
184 writer.close();
185 }
186
187 ostringstream os;
188
189 for (int i = 0; !writer.is_open() && i != MAXIMUM_FILE_NUMBER; ++i) {
190
191 os.str("");
192
193 os << getFullPath(path)
194 << "KM3NeT"
195 << "_" << FILL(8,'0') << getDetectorID()
196 << "_" << FILL(8,'0') << getRunNumber();
197
198 if (i != 0) {
199 os << "_" << i;
200 }
201
202 os << ".root";
203
204 try {
205 writer.open(os.str().c_str());
206 }
207 catch(const std::exception& exception) {
208 JErrorStream(logger) << exception.what();
209 }
210 }
211
212 if (writer.is_open())
213 JNoticeStream(logger) << "Output file " << os.str();
214 else
215 JErrorStream (logger) << "File not opened " << os.str();
216
217 numberOfEvents = 0;
218 numberOfBytes = 0;
219
221
222 timer.reset();
223
228
230 }
int getDetectorID() const
Get detector identifier.
Definition JDAQCHSM.hh:100
int getRunNumber() const
Get run number.
Definition JDAQCHSM.hh:111
void reset()
Reset timer.
Definition JTimer.hh:93
TFile * getFile() const
Get file.
Definition JRootFile.hh:66
virtual bool is_open() const override
Check is file is open.
Definition JRootFile.hh:77
virtual void open(const char *file_name) override
Open file.
virtual void close() override
Close file.
static const int MAXIMUM_FILE_NUMBER
maximum file number for overwrite protection.
std::string getFullPath(const std::string &path)
Get full path, i.e. add JEEP::PATHNAME_SEPARATOR if necessary.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
void reset(const int run)
Remove all entries before given run.

◆ actionStop()

virtual void KM3NETDAQ::JDataWriter::actionStop ( int length,
const char * buffer )
inlineoverridevirtual

Reimplemented from JDAQCHSM.

Definition at line 233 of file JDataWriter.cc.

234 {
235 typeout();
236
237 if (timer.usec_wall > 0) {
238 JStatusStream(logger) << "I/O " << (int) (numberOfBytes / timer.usec_wall) << " MB/s";
239 }
240
242 JErrorStream(logger) << "No trigger parameters written for run " << getRunNumber();
243 }
244
245 writer.close();
246
247 // Release resources.
248
250
251 this->buffer.swap(null);
252 }
unsigned long long usec_wall
Definition JTimer.hh:238
void typeout()
Report status of data writing.
static JNullStream null
Null I/O stream.
bool is_written(const int run) const
Check if trigger parameters have been written for given run.

◆ setSelect() [1/2]

virtual void KM3NETDAQ::JDataWriter::setSelect ( JFileDescriptorMask & mask) const
inlineoverridevirtual

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 255 of file JDataWriter.cc.

256 {
257 if (datawriter.is_valid()) {
258 mask.set(*datawriter);
259 }
260 }
void set(const int file_descriptor)
Set file descriptor.

◆ actionSelect()

virtual void KM3NETDAQ::JDataWriter::actionSelect ( const JFileDescriptorMask & mask)
inlineoverridevirtual

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 263 of file JDataWriter.cc.

264 {
265 using namespace std;
266 using namespace JPP;
267
268 if (datawriter.is_valid() && mask.has(*datawriter)) {
269
270 try {
271
272 JPrefix prefix;
273
274 try {
275
276 datawriter->WaitHead(prefix);
277
278 timer.start();
279
280 buffer.resize(prefix.getSize());
281
282 datawriter->GetFullData(buffer.data(), buffer.size());
283 }
284 catch(const JSocketException& error) {
285
286 JErrorStream(logger) << "Fatal error receiving data: \"" << error.what() << "\" -> disconnect and trigger ev_error.";
287
288 datawriter.reset();
289
290 ev_error();
291 }
292
293 if (prefix.getTag() == IO_TRIGGER_PARAMETERS) {
294
295 try {
296 run_db.read(buffer.data(), buffer.size());
297 }
298 catch(const std::exception& error) {
299
300 JErrorStream(logger) << "Fatal error reading trigger parameters \"" << error.what() << "\"; trigger ev_error.";
301
302 ev_error();
303 }
304 }
305
306
307 if (isRunning()) {
308
309 // Write trigger parameters for current run if not yet done
310
312
313 JTreeWriter_t::iterator i = writer.find(prefix.toString());
314
315 if (i != writer.end()) {
316
317 TFile* out = i->second->GetCurrentFile();
318
319 if (out != NULL && out->IsOpen()) {
320
321 JDAQPreamble preamble;
322 Version_t version;
323 JDAQHeader header;
324
325 JByteArrayReader in(buffer.data(), buffer.size());
326
327 in >> preamble >> version >> header;
328
329 in.seekg(0); // rewind
330
331 if (header.getRunNumber() == getRunNumber()) {
332
333 const Int_t nb = i->second->copy(in);
334
335 if (nb < (int) buffer.size() || in.tellg() != (int) buffer.size()) {
336 JWarningStream(logger) << "Inconsistency at copy of "
337 << prefix.toString() << ' '
338 << buffer.size() << ' '
339 << in.tellg() << ' '
340 << nb;
341 }
342
343 if (prefix.getTag() == IO_EVENT)
344 numberOfEvents += 1;
345 numberOfBytes += buffer.size();
346
347 if (prefix.getTag() == IO_EVENT && numberOfEvents == 1) {
348 typeout();
349 }
350
351 } else {
352 JErrorStream(logErrorRun) << "Inconsistent run number "
353 << header.getRunNumber()
354 << " != "
355 << getRunNumber();
356 }
357 } else {
358 JErrorStream(logErrorFile) << "Output file not open";
359 }
360 } else {
361 if (prefix.getTag() != IO_TRIGGER_PARAMETERS) {
362 JErrorStream(logErrorTag) << "Unknown tag <" << prefix.toString() << ">, no data written";
363 }
364 }
365 } else {
366 JWarningStream(logErrorState) << "Not in running state <" << prefix.toString() << ">, no data written";
367 }
368
369 timer.stop();
370 }
371 catch(const std::exception& error) {
372
373 JErrorStream(logger) << "Fatal error \"" << error.what() << "\"; trigger ev_error.";
374
375 ev_error();
376 }
377 }
378 }
JDAQStateMachine::ev_error_event ev_error
void stop()
Stop timer.
Definition JTimer.hh:127
void start()
Start timer.
Definition JTimer.hh:106
Byte array binary input.
virtual const char * what() const override
Get error message.
Definition JException.hh:64
bool has(const int file_descriptor) const
Has file descriptor.
Exception for socket.
ControlHost prefix.
Definition JPrefix.hh:33
int getSize() const
Get size.
Definition JPrefix.hh:62
std::string toString() const
Convert tag to string.
Definition JTag.hh:171
const JTag & getTag() const
Get tag.
Definition JTag.hh:86
int getRunNumber() const
Get run number.
bool isRunning() const
Check if this client is in runnig state.
static const JNET::JTag IO_EVENT
Definition JDAQTags.hh:88
void write(const int run, TFile *file)
Write trigger parameters for given run if not yet done.
void read(const char *const data, const size_t size)
Read trigger parameters.

◆ actionRunning()

virtual void KM3NETDAQ::JDataWriter::actionRunning ( )
inlineoverridevirtual

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 381 of file JDataWriter.cc.

382 {
383 typeout();
384 }

◆ typeout()

void KM3NETDAQ::JDataWriter::typeout ( )
inline

Report status of data writing.

Definition at line 390 of file JDataWriter.cc.

391 {
392 std::ostringstream message;
393
395
396 logger.typeout(RC_LOG, message.str());
397 logger.status(message.str());
398 }
virtual void typeout(const std::string &tag, const std::string &message) override
Report message.
void status(const JMessage_t &message)
static const JNET::JTag RC_LOG
Definition JDAQTags.hh:72
char getTokenDelimeter()
Get the token delimeter for command messages.

◆ enter() [1/2]

virtual bool KM3NETDAQ::JDAQClient::enter ( const JArgs & args)
inlinevirtualinherited

Enter the state machine.

This overloaded method enter reproduces the constructor. All necessary input is parsed from the list of arguments. In case of an error, the state machine is not entered.

Parameters
argsarray of command line arguments
Returns
true if okay; else false

Definition at line 392 of file JDAQClient.hh.

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

◆ enter() [2/2]

virtual bool KM3NETDAQ::JDAQClient::enter ( )
inlineoverridevirtualinherited

Enter the state machine.

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

Returns
true if okay; else false

Reimplemented in KM3NETDAQ::JDAQDriver.

Definition at line 447 of file JDAQClient.hh.

448 {
449 using namespace std;
450 using namespace JPP;
451
452 if (server.is_valid() && logger.is_valid()) {
453
455
456 try {
457
458 server->Subscribe(buffer);
459 server->SendMeAlways();
460 server->MyId(getFullName());
461
462 JStatusStream(logger) << "Process with nick name \"" << getFullName() << "\" version \"" << getGITVersion() << "\" subscription: " << buffer.toString();
463
464 return CHSM::machine::enter();
465 }
466 catch(const std::exception& error) {
467 JErrorStream(logger) << error.what();
468 }
469
470 } else {
471 cerr << "Message server or logger not properly initialised." << endl;
472 }
473
474 return false;
475 }
bool is_valid() const
Check validity of logger object.
std::string toString() const
Convert subscription list to string.
JSubscriptionList subscription
custom subscription
const char * getGITVersion()
Get GIT version.
Definition Jpp.cc:9
JSubscriptionList getSubscription(const JEventTable &event_table)
Convert event table to ControlHost subscription.
JEventTable eventTable
event table

◆ exit()

virtual bool KM3NETDAQ::JDAQClient::exit ( )
inlineoverridevirtualinherited

Exit the state machine.

This method releases the various resources.

Returns
true if okay; else false

Definition at line 485 of file JDAQClient.hh.

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

◆ isRunning()

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

Check if this client is in runnig state.

Returns
true if running; else false

Definition at line 508 of file JDAQClient.hh.

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

◆ replaceEvent()

void KM3NETDAQ::JDAQClient::replaceEvent ( const JTag & oldTag,
const JTag & newTag,
JDAQEvent_t & event )
inlineinherited

Replace tag of given event in event table.

Parameters
oldTagold tag
newTagnew tag
eventevent

Definition at line 521 of file JDAQClient.hh.

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

◆ findEvent()

JDAQEvent_t * KM3NETDAQ::JDAQClient::findEvent ( const JTag & tag,
const std::string & event_name )
inlineinherited

Find event in event table.

Parameters
tagtag
event_nameevent name
Returns
pointer to event or NULL

Definition at line 536 of file JDAQClient.hh.

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

◆ addSubscription()

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

Add custom subscription.

Parameters
subscriptionsubscription

Definition at line 552 of file JDAQClient.hh.

553 {
555 }
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.

◆ addParameter() [1/2]

template<class T >
void KM3NETDAQ::JDAQClient::addParameter ( const char option,
T & parameter )
inlineinherited

Add parameter to parser used in method enter().

Parameters
optionoption
parameterparameter

Definition at line 565 of file JDAQClient.hh.

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

◆ addParameter() [2/2]

template<class T >
void KM3NETDAQ::JDAQClient::addParameter ( const char option,
T & parameter,
const T & value )
inlineinherited

Add parameter to parser used in method enter().

Parameters
optionoption
parameterparameter
valuedefault value

Definition at line 579 of file JDAQClient.hh.

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

◆ setSelect() [2/2]

void KM3NETDAQ::JDAQClient::setSelect ( )
inlineinherited

Set the file descriptor mask for the select call.

Definition at line 588 of file JDAQClient.hh.

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

◆ actionInput()

virtual void KM3NETDAQ::JDAQClient::actionInput ( int length,
const char * buffer )
inlineoverridevirtualinherited

This method is called at ev_input.

Parameters
lengthlength of data
bufferpointer to data

Reimplemented from JDAQCHSM.

Reimplemented in KM3NETDAQ::DataQueue.

Definition at line 635 of file JDAQClient.hh.

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

◆ filter()

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

Filter message.

The filter method can be overwritten so that a specific action is made before the corresponding message is processed by the state machine. The message is ignored if true is returned, else it is normally processed.

Parameters
tagtag
lengthnumber of characters
buffermessage
Returns
skip message or not

Reimplemented in KM3NETDAQ::JDAQDriver.

Definition at line 662 of file JDAQClient.hh.

663 {
664 return false;
665 }

◆ actionTagged()

virtual void KM3NETDAQ::JDAQClient::actionTagged ( const JTag & tag,
int length,
const char * buffer )
inlinevirtualinherited

This method is called when a custom tag is encountered.

Parameters
tagtag
lengthlength of data
bufferpointer to data

Reimplemented in KM3NETDAQ::JDataFilter.

Definition at line 675 of file JDAQClient.hh.

676 {
677 }

◆ run() [1/3]

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

691 {
692 using namespace std;
693 using namespace JPP;
694
695 while (active()) {
696
697 try {
698
699 setSelect();
700
701 if (select(JTimeval(TIMEOUT_S,0)) > 0) {
702
704 update();
705 }
706
708
709 } else {
710
711 continue;
712 }
713
714
715 if (isRunning() && clock.getInterval() != 0LL) {
716
717 long long int numberOfCalls = 0;
718
719 clock.reset();
720
721 do {
722
723 ++numberOfCalls;
724
725 setSelect();
726
728
730 update();
731 }
732
734
735 } else {
736
737 try {
739 }
740 catch(const std::exception& error) {
741 logger.error(error.what());
742 }
743 }
744
745 } while (isRunning());
746
747 if (numberOfCalls != 0) {
748 JNoticeStream(logger) << "Delay per call " << clock.getDelay() / numberOfCalls / 1000 << " ms";
749 }
750 }
751 }
752 catch(const JPP::JSocketException& error) {
753 JErrorStream(logger) << "method run(): \"" << error.what() << "\" -> trigger ev_error.";
754 ev_error();
755 }
756 catch(const std::exception& error) {
757 JErrorStream(logger) << "method run(): \"" << error.what() << "\"";
758 }
759 }
760 }
long long int getDelay() const
Get total delay time.
void wait() const
Wait until the number of time intervals has elapsed since the last call to the reset method.
void reset(const long long int t0)
Reset time.
long long int getInterval() const
Get interval time.
Auxiliary class for time values.
Definition JTimeval.hh:29
void error(const JMessage_t &message)
bool hasReaderMask(const JAbstractFile &file) const
Has reader file.
void update()
Update state machine.
virtual void actionSelect(const JFileDescriptorMask &mask)
Action method following last select call.
virtual void actionRunning()
This method is repeatedly called when this client machine is in state Running and the clock interval ...
JTimekeeper clock
central clock
static const int TIMEOUT_S
time out of update [s]
Definition JDAQClient.hh:63

◆ run() [2/3]

void KM3NETDAQ::JDAQClient::run ( const int port)
inlineinherited

Run for ever.

This method can be used when the run control client is started before the run control (e.g. at boot time of the host processor). This method should be called before the state machine is entered. It launches a server which accepts a JNET::JControlHost connection from a designated application e.g. the JDAQClientStarter.cc program. The state machine is entered using the available data in the JNET::JControlHost message. After the state machine is exited, it accepts a new a JNET::JControlHost connection.

Parameters
portport number

Definition at line 775 of file JDAQClient.hh.

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

◆ run() [3/3]

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

821 {
822 using namespace std;
823
824 string tag;
825 string buffer;
826
827 while (in >> tag && in >> skipws && getline(in, buffer, ';')) {
828 update(tag, buffer.length(), buffer.data());
829 }
830 }
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478

◆ update() [1/2]

void KM3NETDAQ::JDAQClient::update ( )
inlineprivateinherited

Update state machine.

This method waits for a message from JNET::JControlHost server.

Definition at line 842 of file JDAQClient.hh.

843 {
844 JNET::JPrefix prefix;
845
846 server->WaitHead(prefix);
847
848 const int length = prefix.getSize();
849
850 char* buffer = new char[length];
851
852 server->GetFullData(buffer, length);
853
854 update(prefix.getTag(), length, buffer);
855
856 delete [] buffer;
857 }

◆ update() [2/2]

void KM3NETDAQ::JDAQClient::update ( const JTag & tag,
int length,
const char * buffer )
inlineprivateinherited

Update state machine.

Parameters
tagtag
lengthnumber of characters
buffermessage

Definition at line 867 of file JDAQClient.hh.

868 {
869 using namespace std;
870 using namespace JPP;
871
872 if (filter(tag, length, buffer)) {
873 return;
874 }
875
876 if (getSubscription(eventTable)->count(JSubscriptionAny(tag)) == 0 &&
877 getSubscription(eventTable)->count(JSubscriptionAll(tag)) == 0) {
878
879 actionTagged(tag, length, buffer);
880
881 return;
882 }
883
884
885 string::size_type pos = 0;
886
887 while (pos != (string::size_type) length && TOKEN_DELIMETER.find(*(buffer + pos)) == string::npos) {
888 ++pos;
889 }
890
891 const JEvent_t event = JEvent_t::toValue(string(buffer, pos));
892
893 if (event.hasInfo()) {
894 setEventInfo(event.getInfo());
895 }
896
897 while (pos != (string::size_type) length && TOKEN_DELIMETER.find(*(buffer + pos)) != string::npos) {
898 ++pos;
899 }
900
901
902 JEventTable::const_iterator i = eventTable.find(tag, event.getName());
903
904 if (i != eventTable.end()) {
905
906 const CHSM::state* const s0 = getState();
907
908 if (!i->second->active()) {
909
910 JWarningStream(logger) << "Event " << i->second->name() << " not active (" << (s0 != NULL ? s0->name() : "") << ")";
911
912 if (server.is_valid() && s0 != NULL) {
913 server->PutFullString(RC_FAIL, getMessage(*s0, *i->second));
914 }
915 }
916
917 // redirect all I/O
918
919 {
921 JErrorStream error(logger);
922
923 JRedirectStream rs_cin (cin, JLANG::null);
924 JRedirectStream rs_cout(cout, debug);
925 JRedirectStream rs_cerr(cerr, error);
926
927 if (rs_cin &&
928 rs_cout &&
929 rs_cerr) {
930
931 (*(i->second))(length - pos, buffer + pos);
932 }
933 }
934
935 const CHSM::state* const s1 = getState();
936
937 JStatusStream(logger) << "Transition "
938 << (s0 != NULL ? s0->name() : "")
939 << "->(" << i->second->name() << ")->"
940 << (s1 != NULL ? s1->name() : "");
941 } else {
942
943 JErrorStream(logger) << "Unknown key <" << tag << "," << event.getName() << ">";
944 }
945 }
int debug
debug level
Definition JSirene.cc:72
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
virtual bool filter(const JTag &tag, int length, const char *buffer)
Filter message.
virtual void actionTagged(const JTag &tag, int length, const char *buffer)
This method is called when a custom tag is encountered.
std::string getMessage(const CHSM::state &state, const CHSM::event &event) const
Get event message.
const CHSM::state * getState() const
Get current state.
static const std::string TOKEN_DELIMETER
Definition JDAQTags.hh:58
static const JNET::JTag RC_FAIL
Definition JDAQTags.hh:68
Auxiliary class for any subscription.
void setEventInfo(const std::string &info)
Set last event information.
static JEvent_t toValue(const std::string &buffer)
Convert string to event.
Definition JEvent_t.hh:99

◆ configure()

void KM3NETDAQ::JDAQClient::configure ( )
inlineprivateinherited

Configure client.

This method is used to setup the event table.

Definition at line 952 of file JDAQClient.hh.

953 {
954 }

◆ getMessage()

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

Get event message.

Parameters
statestate
eventevent
Returns
message

Definition at line 964 of file JDAQClient.hh.

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

◆ enterState()

virtual void KM3NETDAQ::JDAQClient::enterState ( const CHSM::state & state,
const CHSM::event & event )
inlineoverrideprivatevirtualinherited

Action when entering state.

This method provides for the hand shaking with the run control program.

Parameters
stateentered state
eventevent that triggered transition

Implements JDAQCHSM.

Reimplemented in KM3NETDAQ::JDAQDriver.

Definition at line 987 of file JDAQClient.hh.

988 {
989 if (server.is_valid()) {
990 server->PutFullString(RC_REPLY, getMessage(state, event));
991 }
992 }
static const JNET::JTag RC_REPLY
Definition JDAQTags.hh:67

◆ actionCheck()

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

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

Parameters
lengthnumber of characters
buffermessage

Reimplemented from JDAQCHSM.

Definition at line 1001 of file JDAQClient.hh.

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

◆ execute()

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

The method to execute the action.

Parameters
__actionpointer to action method
__eventevent that triggered the action

Implements JDAQCHSM.

Definition at line 1028 of file JDAQClient.hh.

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

◆ getState()

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

Get current state.

Returns
state

Definition at line 1048 of file JDAQClient.hh.

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

◆ A1()

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

Definition at line 344 of file JDAQCHSM.cc.

344{ actionError(); }
virtual void actionError()
Definition JDAQCHSM.hh:135

◆ A2()

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

Definition at line 346 of file JDAQCHSM.cc.

346{ execute(&JDAQCHSM::actionInit, event); }
virtual void actionInit(int, const char *)
Definition JDAQCHSM.hh:123
virtual void execute(action __action, const CHSM::event &__event)=0
The method to execute the action.

◆ A3()

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

Definition at line 348 of file JDAQCHSM.cc.

348{ JDAQCHSM::exit(); }

◆ A4()

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

Definition at line 350 of file JDAQCHSM.cc.

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

◆ A5()

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

Definition at line 352 of file JDAQCHSM.cc.

352{ execute(&JDAQCHSM::actionReset, event); }
virtual void actionReset(int, const char *)
Definition JDAQCHSM.hh:129

◆ A6()

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

Definition at line 354 of file JDAQCHSM.cc.

354 {
355
356 std::istringstream is(std::string(ev_start->buffer, ev_start->length));
357
358 is >> run_number >> detector_id;
359
361
362 }
int run_number
Definition JDAQCHSM.hh:167
virtual void actionStart(int, const char *)
Definition JDAQCHSM.hh:125
int detector_id
Definition JDAQCHSM.hh:166
JDAQStateMachine::ev_start_event ev_start

◆ A7()

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

Definition at line 364 of file JDAQCHSM.cc.

364{ execute(&JDAQCHSM::actionQuit, event); }
virtual void actionQuit(int, const char *)
Definition JDAQCHSM.hh:130

◆ A8()

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

Definition at line 366 of file JDAQCHSM.cc.

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

◆ A9()

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

Definition at line 368 of file JDAQCHSM.cc.

368{ execute(&JDAQCHSM::actionStop, event); }
virtual void actionStop(int, const char *)
Definition JDAQCHSM.hh:128

◆ A10()

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

Definition at line 370 of file JDAQCHSM.cc.

370{ execute(&JDAQCHSM::actionPause, event); }
virtual void actionPause(int, const char *)
Definition JDAQCHSM.hh:126

◆ A11()

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

Definition at line 372 of file JDAQCHSM.cc.

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

◆ A12()

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

Definition at line 374 of file JDAQCHSM.cc.

374{ JDAQCHSM::exit(); }

◆ A13()

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

Definition at line 376 of file JDAQCHSM.cc.

376{ execute(&JDAQCHSM::actionCheck, event); }
virtual void actionCheck(int, const char *)
Definition JDAQCHSM.hh:132

◆ A14()

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

Definition at line 378 of file JDAQCHSM.cc.

378{ execute(&JDAQCHSM::actionInput, event); }
virtual void actionInput(int, const char *)
Definition JDAQCHSM.hh:133

◆ EAM4root()

void JDAQStateMachine::EAM4root ( CHSM_ns_alias::state const & chsm_state_,
CHSM_ns_alias::event const & event )
inherited

Definition at line 337 of file JDAQCHSM.cc.

337 {
338#line 164 "JDAQCHSM.chsm"
339 CHSM_ns_alias::cluster const &state = (CHSM_ns_alias::cluster const&)chsm_state_; actionEnter(); }
virtual void actionEnter()
Interface methods for actions corresponding to state transitions.
Definition JDAQCHSM.hh:120

◆ XAM4root()

void JDAQStateMachine::XAM4root ( CHSM_ns_alias::state const & chsm_state_,
CHSM_ns_alias::event const & event )
inherited

Definition at line 340 of file JDAQCHSM.cc.

340 {
341#line 165 "JDAQCHSM.chsm"
342 CHSM_ns_alias::cluster const &state = (CHSM_ns_alias::cluster const&)chsm_state_; actionExit(); }
virtual void actionExit()
Definition JDAQCHSM.hh:121

◆ getName()

const std::string & JDAQCHSM::getName ( ) const
inlineinherited

Get name of state machine.

Returns
name

Definition at line 89 of file JDAQCHSM.hh.

90 {
91 return name;
92 }

◆ getDetectorID()

int JDAQCHSM::getDetectorID ( ) const
inlineinherited

Get detector identifier.

Returns
detector identifier.

Definition at line 100 of file JDAQCHSM.hh.

101 {
102 return detector_id;
103 }

◆ getRunNumber()

int JDAQCHSM::getRunNumber ( ) const
inlineinherited

Get run number.

Returns
run number

Definition at line 111 of file JDAQCHSM.hh.

112 {
113 return run_number;
114 }

◆ actionEnter()

virtual void JDAQCHSM::actionEnter ( )
inlinevirtualinherited

Interface methods for actions corresponding to state transitions.

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

Definition at line 120 of file JDAQCHSM.hh.

120{}

◆ actionExit()

virtual void JDAQCHSM::actionExit ( )
inlinevirtualinherited

◆ actionPause()

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

◆ actionContinue()

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

◆ actionError()

virtual void JDAQCHSM::actionError ( )
inlinevirtualinherited

Definition at line 135 of file JDAQCHSM.hh.

135{}

◆ actionRecover()

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

Definition at line 136 of file JDAQCHSM.hh.

136{}

◆ getHostname()

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

Get hostname.

Returns
host name

Definition at line 109 of file JDAQClient.hh.

110 {
111 return hostname;
112 }

◆ getFullName()

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

Get full name of this run control client.

Returns
full name

Definition at line 120 of file JDAQClient.hh.

121 {
122 return fullname;
123 }

◆ getUniqueTag()

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

Get unique tag of this run control client.

Returns
unique tag

Definition at line 131 of file JDAQClient.hh.

132 {
133 return unique_tag;
134 }

◆ getClockDelay()

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

Get total delay time.

Returns
delay time [us]

Definition at line 142 of file JDAQClient.hh.

143 {
144 return clock.getDelay();
145 }

◆ getClockInterval()

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

Get interval time.

Returns
interval time [us]

Definition at line 154 of file JDAQClient.hh.

155 {
156 return clock.getInterval();
157 }

◆ setClockInterval()

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

Set interval time.

Parameters
interval_usinterval time [us]

Definition at line 165 of file JDAQClient.hh.

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

◆ resetClock()

void KM3NETDAQ::JDAQClient_t::resetClock ( )
inlineinherited

Reset clock.

Definition at line 174 of file JDAQClient.hh.

175 {
176 clock.reset();
177 }

◆ getEventInfo()

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

Get last event information.

Returns
event information

Definition at line 185 of file JDAQClient.hh.

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

◆ setEventInfo()

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

Set last event information.

Parameters
infoevent information

Definition at line 196 of file JDAQClient.hh.

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

Member Data Documentation

◆ meta

JMeta KM3NETDAQ::JDataWriter::meta

meta data

Definition at line 400 of file JDataWriter.cc.

◆ MAXIMUM_FILE_NUMBER

const int KM3NETDAQ::JDataWriter::MAXIMUM_FILE_NUMBER = 100
static

maximum file number for overwrite protection.

Definition at line 402 of file JDataWriter.cc.

◆ datawriter

JLANG::JSharedPointer<JControlHost> KM3NETDAQ::JDataWriter::datawriter
private

Definition at line 406 of file JDataWriter.cc.

◆ path

std::string KM3NETDAQ::JDataWriter::path
private

Definition at line 407 of file JDataWriter.cc.

◆ timer

JEEP::JTimer KM3NETDAQ::JDataWriter::timer
private

Definition at line 409 of file JDataWriter.cc.

◆ numberOfEvents

Long64_t KM3NETDAQ::JDataWriter::numberOfEvents
private

Definition at line 410 of file JDataWriter.cc.

◆ numberOfBytes

long long int KM3NETDAQ::JDataWriter::numberOfBytes
private

Definition at line 411 of file JDataWriter.cc.

◆ logErrorRun

JMessageScheduler KM3NETDAQ::JDataWriter::logErrorRun
private

Definition at line 413 of file JDataWriter.cc.

◆ logErrorFile

JMessageScheduler KM3NETDAQ::JDataWriter::logErrorFile
private

Definition at line 414 of file JDataWriter.cc.

◆ logErrorTag

JMessageScheduler KM3NETDAQ::JDataWriter::logErrorTag
private

Definition at line 415 of file JDataWriter.cc.

◆ logErrorState

JMessageScheduler KM3NETDAQ::JDataWriter::logErrorState
private

Definition at line 416 of file JDataWriter.cc.

◆ hostname

std::string KM3NETDAQ::JDataWriter::hostname
private

host name of data server

Definition at line 418 of file JDataWriter.cc.

◆ writer

JTreeWriter_t KM3NETDAQ::JDataWriter::writer
private

TTree writer.

Definition at line 419 of file JDataWriter.cc.

◆ buffer

std::vector<char> KM3NETDAQ::JDataWriter::buffer
private

internal buffer for incoming data

Definition at line 420 of file JDataWriter.cc.

◆ run_db

JRunDB KM3NETDAQ::JDataWriter::run_db
private

Definition at line 540 of file JDataWriter.cc.

◆ server

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

message server

Definition at line 834 of file JDAQClient.hh.

◆ logger

JMessageLogger KM3NETDAQ::JDAQClient::logger
protectedinherited

message logger

Definition at line 835 of file JDAQClient.hh.

◆ select

JSelectReader KM3NETDAQ::JDAQClient::select
privateinherited

select call

Definition at line 1064 of file JDAQClient.hh.

◆ parser

JParser KM3NETDAQ::JDAQClient::parser
privateinherited

parser method enter()

Definition at line 1065 of file JDAQClient.hh.

◆ subscription

JSubscriptionList KM3NETDAQ::JDAQClient::subscription
privateinherited

custom subscription

Definition at line 1066 of file JDAQClient.hh.

◆ root

JDAQStateMachine::state_root JDAQStateMachine::root
inherited

◆ Main

JDAQStateMachine::state_Main JDAQStateMachine::Main
inherited

◆ ev_daq_transitions

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

Definition at line 52 of file JDAQCHSM.hh.

◆ ev_daq

JDAQStateMachine::ev_daq_event JDAQStateMachine::ev_daq
inherited

◆ ev_daq_param_block

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

Definition at line 238 of file JDAQCHSM.hh.

◆ ev_init_transitions

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

Definition at line 69 of file JDAQCHSM.hh.

◆ ev_init

JDAQStateMachine::ev_init_event JDAQStateMachine::ev_init
inherited

◆ ev_init_param_block

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

Definition at line 258 of file JDAQCHSM.hh.

◆ ev_configure_transitions

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

Definition at line 86 of file JDAQCHSM.hh.

◆ ev_configure

JDAQStateMachine::ev_configure_event JDAQStateMachine::ev_configure
inherited

◆ ev_configure_param_block

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

Definition at line 278 of file JDAQCHSM.hh.

◆ ev_start_transitions

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

Definition at line 103 of file JDAQCHSM.hh.

◆ ev_start

JDAQStateMachine::ev_start_event JDAQStateMachine::ev_start
inherited

◆ ev_start_param_block

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

Definition at line 298 of file JDAQCHSM.hh.

◆ ev_pause_transitions

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

Definition at line 120 of file JDAQCHSM.hh.

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

◆ ev_pause

JDAQStateMachine::ev_pause_event JDAQStateMachine::ev_pause
inherited

◆ ev_pause_param_block

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

Definition at line 318 of file JDAQCHSM.hh.

◆ ev_continue_transitions

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

Definition at line 137 of file JDAQCHSM.hh.

139 :
140

◆ ev_continue

JDAQStateMachine::ev_continue_event JDAQStateMachine::ev_continue
inherited

◆ ev_continue_param_block

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

Definition at line 338 of file JDAQCHSM.hh.

◆ ev_stop_transitions

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

Definition at line 154 of file JDAQCHSM.hh.

◆ ev_stop

JDAQStateMachine::ev_stop_event JDAQStateMachine::ev_stop
inherited

◆ ev_stop_param_block

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

Definition at line 358 of file JDAQCHSM.hh.

◆ ev_reset_transitions

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

Definition at line 171 of file JDAQCHSM.hh.

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

◆ ev_reset

JDAQStateMachine::ev_reset_event JDAQStateMachine::ev_reset
inherited

◆ ev_reset_param_block

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

Definition at line 378 of file JDAQCHSM.hh.

◆ ev_quit_transitions

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

Definition at line 188 of file JDAQCHSM.hh.

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

◆ ev_quit

JDAQStateMachine::ev_quit_event JDAQStateMachine::ev_quit
inherited

◆ ev_quit_param_block

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

Definition at line 398 of file JDAQCHSM.hh.

◆ ev_off_transitions

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

Definition at line 205 of file JDAQCHSM.hh.

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

◆ ev_off

JDAQStateMachine::ev_off_event JDAQStateMachine::ev_off
inherited

◆ ev_off_param_block

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

Definition at line 418 of file JDAQCHSM.hh.

◆ ev_check_transitions

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

Definition at line 222 of file JDAQCHSM.hh.

◆ ev_check

JDAQStateMachine::ev_check_event JDAQStateMachine::ev_check
inherited

◆ ev_check_param_block

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

Definition at line 438 of file JDAQCHSM.hh.

◆ ev_input_transitions

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

Definition at line 239 of file JDAQCHSM.hh.

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

◆ ev_input

JDAQStateMachine::ev_input_event JDAQStateMachine::ev_input
inherited

◆ ev_input_param_block

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

Definition at line 458 of file JDAQCHSM.hh.

◆ ev_recover_transitions

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

Definition at line 256 of file JDAQCHSM.hh.

◆ ev_recover

JDAQStateMachine::ev_recover_event JDAQStateMachine::ev_recover
inherited

◆ ev_recover_param_block

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

Definition at line 478 of file JDAQCHSM.hh.

◆ ev_error_transitions

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

Definition at line 273 of file JDAQCHSM.hh.

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

◆ ev_error

JDAQStateMachine::ev_error_event JDAQStateMachine::ev_error
inherited

◆ ev_error_param_block

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

Definition at line 495 of file JDAQCHSM.hh.

◆ state_

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

Definition at line 522 of file JDAQCHSM.hh.

◆ transition_

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

Definition at line 280 of file JDAQCHSM.hh.

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

◆ taken_

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

Definition at line 524 of file JDAQCHSM.hh.

◆ target_

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

Definition at line 525 of file JDAQCHSM.hh.

◆ name

std::string JDAQCHSM::name
protectedinherited

Definition at line 165 of file JDAQCHSM.hh.

◆ detector_id

int JDAQCHSM::detector_id
protectedinherited

Definition at line 166 of file JDAQCHSM.hh.

◆ run_number

int JDAQCHSM::run_number
protectedinherited

Definition at line 167 of file JDAQCHSM.hh.

◆ TIMEOUT_S

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

time out of update [s]

Definition at line 63 of file JDAQClient.hh.

◆ eventTable

JEventTable KM3NETDAQ::JDAQClient_t::eventTable
protectedinherited

event table

Definition at line 203 of file JDAQClient.hh.

◆ fullname

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

Definition at line 205 of file JDAQClient.hh.

◆ unique_tag

JTag KM3NETDAQ::JDAQClient_t::unique_tag
protectedinherited

Definition at line 206 of file JDAQClient.hh.

◆ clock

JTimekeeper KM3NETDAQ::JDAQClient_t::clock
protectedinherited

central clock

Definition at line 207 of file JDAQClient.hh.

◆ event_info

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

event information

Definition at line 208 of file JDAQClient.hh.


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