80 const std::string&
path) :
124 catch(
const std::exception& exception) {
134 long long int update_s = 10;
135 long long int logger_s = 5;
139 properties[
"path"] =
path;
140 properties[
"update_s"] = update_s;
141 properties[
"logger_s"] = logger_s;
145 if (update_s <= 0) { update_s = 1; }
146 if (logger_s <= 0) { logger_s = 1; }
207 catch(
const std::exception& exception) {
251 this->buffer.swap(
null);
286 JErrorStream(
logger) <<
"Fatal error receiving data: \"" << error.
what() <<
"\" -> disconnect and trigger ev_error.";
298 catch(
const std::exception& error) {
300 JErrorStream(
logger) <<
"Fatal error reading trigger parameters \"" << error.what() <<
"\"; trigger ev_error.";
317 TFile* out = i->second->GetCurrentFile();
319 if (out != NULL && out->IsOpen()) {
327 in >> preamble >> version >> header;
333 const Int_t nb = i->second->copy(in);
371 catch(
const std::exception& error) {
392 std::ostringstream message;
454 while (!this->empty() && this->begin()->first <
run) {
455 this->erase(this->begin());
467 const_iterator p = this->find(
run);
469 return p != this->end() && p->second.is_written;
478 void read(
const char*
const data,
const size_t size)
494 THROW(
JIOException,
"Error reading run number for trigger parameters " <<
run << endl << in.rdbuf());
499 in.clear(std::ios::eofbit);
507 if (value.
count == 0) {
530 if (p != this->end() && p->second.count != 0 && !p->second.is_written) {
532 file->WriteTObject(&p->second.parameters);
534 p->second.is_written =
true;
551 int main(
int argc,
char* argv[])
567 JParser<> zap(
"Application for writing real-time data to disk.");
569 zap[
'H'] =
make_field(
server,
"host name of server for command messages") =
"localhost";
570 zap[
'M'] =
make_field(
logger,
"host name of server for logger messages") =
"localhost";
571 zap[
'D'] =
make_field(
hostname,
"host name of server for incoming data from data filter") =
"localhost";
572 zap[
'u'] =
make_field(client_name,
"client name") =
"%";
573 zap[
'c'] =
make_field(use_cout,
"print to terminal");
574 zap[
'p'] =
make_field(
path,
"directory for permanent archival of data") =
"";
580 catch(
const exception &error) {
581 FATAL(error.what() << endl);
KM3NeT DAQ constants, bit handling, etc.
int main(int argc, char *argv[])
JSUPPORT::JAutoTreeWriter< JNET::JTag > JTreeWriter_t
Type definition of auto map.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
Utility class to parse parameter values.
ROOT TTree parameter settings of various packages.
Scheduling of actions via fixed latency intervals.
int getDetectorID() const
Get detector identifier.
int getRunNumber() const
Get run number.
JDAQStateMachine::ev_error_event ev_error
JDAQStateMachine::ev_configure_event ev_configure
Utility class to parse parameter values.
bool read(const JEquation &equation)
Read equation.
Auxiliary class for CPU timing and usage.
unsigned long long usec_wall
int tellg() const
Get read position.
void seekg(const int pos)
Set read position.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
virtual const char * what() const override
Get error message.
Auxiliary class for method select.
void set(const int file_descriptor)
Set file descriptor.
bool has(const int file_descriptor) const
Has file descriptor.
The template JSharedPointer class can be used to share a pointer to an object.
static void Throw(const bool option)
Enable/disable throw option.
Message logging based on ControlHost.
Interface for logging messages.
virtual void typeout(const std::string &tag, const std::string &message) override
Report message.
void status(const JMessage_t &message)
Message logger with time scheduler.
Message logging based on std::ostream.
int getSize() const
Get size.
std::string toString() const
Convert tag to string.
const JTag & getTag() const
Get tag.
Utility class to parse command line options.
TFile * getFile() const
Get file.
virtual bool is_open() const override
Check is file is open.
virtual void open(const char *file_name) override
Open file.
map_type::iterator iterator
void insert()
Insert (list of) data type(s).
virtual void close() override
Close file.
static JKey_t getKey(JType< T > type)
Get key.
int getRunNumber() const
Get run number.
Control unit client base class.
JSharedPointer< JControlHost > server
message server
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.
void run()
Run as run control client following command messages via JNET::JControlHost.
JMessageLogger logger
message logger
virtual bool enter(const JArgs &args)
Enter the state machine.
Runcontrol client to write data to disk.
virtual void actionStop(int length, const char *buffer) override
void typeout()
Report status of data writing.
std::string hostname
host name of data server
long long int numberOfBytes
virtual void actionSelect(const JFileDescriptorMask &mask) override
Action method following last select call.
virtual void actionInit(int length, const char *buffer) override
JTreeWriter_t writer
TTree writer.
JLANG::JSharedPointer< JControlHost > datawriter
JMessageScheduler logErrorFile
JMessageScheduler logErrorRun
virtual void actionRunning() override
This method is repeatedly called when this client machine is in state Running and the clock interval ...
virtual void actionQuit(int length, const char *buffer) override
virtual void setSelect(JFileDescriptorMask &mask) const override
Set the file descriptor mask for the select call.
JMessageScheduler logErrorState
std::vector< char > buffer
internal buffer for incoming data
virtual void actionReset(int length, const char *buffer) override
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 actionStart(int length, const char *buffer) override
virtual void actionConfigure(int length, const char *buffer) override
static const int MAXIMUM_FILE_NUMBER
maximum file number for overwrite protection.
JMessageScheduler logErrorTag
std::string getFullPath(const std::string &path)
Get full path, i.e. add JEEP::PATHNAME_SEPARATOR if necessary.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Support classes and methods for experiment specific I/O.
KM3NeT DAQ data structures and auxiliaries.
static const JNET::JTag RC_DWRITER
static const JNET::JTag IO_EVENT
static const int DWRITER_RECEIVE_BUFFER_SIZE
socket JDataWriter.cc <- JDataFilter.cc
static const JNET::JTag RC_CMD
static const JNET::JTag RC_LOG
std::string getProcessName(const std::string &name, const std::string &process)
Get process name of run control client.
char getTokenDelimeter()
Get the token delimeter for command messages.
static const JNET::JTag IO_TRIGGER_PARAMETERS
Auxiliary data structure for sequence of same character.
Auxiliary class for a type holder.
Level specific message streamers.
Auxiliary class for all subscription.
void setClockInterval(const long long int interval_us)
Set interval time.
const std::string & getFullName() const
Get full name of this run control client.
Map run number to trigger parameters.
void reset(const int run)
Remove all entries before given run.
void write(const int run, TFile *file)
Write trigger parameters for given run if not yet done.
bool is_written(const int run) const
Check if trigger parameters have been written for given run.
void read(const char *const data, const size_t size)
Read trigger parameters.
Auxiliary data structure for I/O of trigger parameters.
JValue_t()
Default constructor.
bool is_written
writer status
JTriggerParameters parameters
trigger parameters