78 const std::string&
path) :
128 long long int logger_s = 5;
129 long long int update_s = 10;
133 properties[
"path"] =
path;
134 properties[
"update_s"] = update_s;
135 properties[
"logger_s"] = logger_s;
137 properties.
read(
string(buffer, length));
140 if (update_s <= 0) update_s = 1;
141 if (logger_s <= 0) logger_s = 1;
183 <<
"_" << setw(8) << setfill(
'0') << getDetectorID()
184 <<
"_" << setw(8) << setfill(
'0') << getRunNumber();
239 this->buffer.swap(null);
275 istringstream in(__str__);
296 TFile* out = i->second->GetCurrentFile();
298 if (out != NULL && out->IsOpen()) {
305 in >> preamble >> header;
309 if (header.getRunNumber() == getRunNumber()) {
311 const Int_t nb = i->second->copy(in);
313 if (nb < (
int)
buffer.size() || in.tellg() != (int)
buffer.size()) {
331 << header.getRunNumber()
367 std::ostringstream message;
429 while (!this->empty() && this->begin()->first < run) {
430 this->erase(this->begin());
442 const_iterator p = this->find(run);
444 return p != this->end() && p->second.is_written;
458 in >> run >> parameters;
460 in.clear(std::ios::eofbit);
462 if (in && run != -1) {
466 if (value.
count == 0) {
490 if (p != this->end() && p->second.count != 0 && !p->second.is_written) {
492 file->WriteTObject(&p->second.parameters);
494 p->second.is_written =
true;
511 int main(
int argc,
char* argv[])
525 JParser<> zap(
"Application for writing real-time data to disk.");
537 catch(
const exception &error) {
538 FATAL(error.what() << endl);
542 using namespace KM3NETDAQ;
548 out =
new JStreamLogger(cout);
550 out =
new JControlHostLogger(
logger);
JDataWriter(const std::string &name, const std::string &server, const std::string &hostname, JLogger *logger, const int level, const std::string &path)
Constructor.
Message logger with time scheduler.
Utility class to parse command line options.
Runcontrol client to write data to disk.
bool read(const JEquation &equation)
Read equation.
Data structure for all trigger parameters.
std::vector< char > buffer
internal buffer for incoming data
void status(const JMessage_t &message)
static const int MAXIMUM_FILE_NUMBER
maximum file number for overwrite protection.
virtual void actionInit(int length, const char *buffer)
std::string getProcessName(const std::string &name, const std::string &process)
Get process name of run control client.
bool has(const int file_descriptor) const
Has file descriptor.
void set(const int file_descriptor)
Set file descriptor.
virtual void setSelect(JFileDescriptorMask &mask) const
Set the file descriptor mask for the select call.
void reset(const int run)
Remove all entries before given run.
virtual void close()
Close file.
JMessageScheduler logErrorState
Interface for logging messages.
Utility class to parse parameter values.
void setClockInterval(const long long int interval_us)
Set interval time.
Auxiliary data structure for I/O of trigger parameters.
std::string hostname
host name of data server
Simple data structure to support I/O of equations (see class JLANG::JEquation).
static const JNET::JTag IO_TRIGGER_PARAMETERS
JTreeWriter_t writer
TTree writer.
JSharedPointer< JControlHost > server
message server
Auxiliary class for a type holder.
void run()
Run as run control client following command messages via JNET::JControlHost.
bool is_written(const int run) const
Check if trigger parameters have been written for given run.
int getSize() const
Get size.
Utility class to parse parameter values.
virtual void actionReset(int length, const char *buffer)
long long int numberOfBytes
Map run number to trigger parameters.
JMessageScheduler logErrorRun
virtual void actionConfigure(int length, const char *buffer)
static JKey_t getKey(JType< T > type)
Get key.
TFile * getFile() const
Get file.
virtual void actionQuit(int length, const char *buffer)
Scheduling of actions via fixed latency intervals.
The template JSharedPointer class can be used to share a pointer to an object.
static const JNET::JTag RC_LOG
JMessageScheduler logErrorFile
virtual void actionStart(int length, const char *buffer)
JSUPPORT::JAutoTreeWriter< JNET::JTag > JTreeWriter_t
Type definition of auto map.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
virtual void open(const char *file_name)
Open file.
JValue_t()
Default constructor.
Auxiliary class for method select.
Auxiliary class for CPU timing and usage.
JMessageScheduler logErrorTag
virtual void actionStop(int length, const char *buffer)
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
map_type::iterator iterator
Level specific message streamers.
Exception for ControlHost.
JTriggerParameters parameters
trigger parameters
char getTokenDelimeter()
Get the token delimeter for command messages.
bool isRunning() const
Check if this client is in runnig state.
Auxiliary class for all subscription.
const JTag & getTag() const
Get tag.
static const JNET::JTag RC_DWRITER
virtual bool is_open() const
Check is file is open.
void write(const int run, TFile *file)
Write trigger parameters for given run if not yet done.
std::string toString() const
Convert tag to string.
void insert()
Insert (list of) data type(s).
void typeout()
Report status of data writing.
Run control client base class.
Utility class to parse command line options.
virtual void actionRunning()
This method is repeatedly called when this client machine is in state Running and the clock interval ...
JTYPELIST< JDAQTimesliceTypes_t, JDAQEvent, JDAQSummaryslice >::typelist JDAQTypes_t
Type list of DAQ data types for I/O.
ROOT TTree parameter settings.
virtual bool enter(const JArgs &args)
Enter the state machine.
JMessageLogger logger
message logger
void replaceEvent(const JNET::JTag &oldTag, const JNET::JTag &newTag, JDAQEvent_t &event)
Replace tag of given event in event table.
static const JNET::JTag RC_CMD
static const JNET::JTag IO_EVENT
virtual void typeout(const std::string &tag, const std::string &message)
Report message.
const std::string & getFullName() const
Get full name of this run control client.
KM3NeT DAQ constants, bit handling, etc.
bool is_written
writer status
static JNullStream null
Null I/O stream.
JLANG::JSharedPointer< JControlHost > datawriter
virtual void actionSelect(const JFileDescriptorMask &mask)
Action method following last select call.
static void Throw(const bool option)
Enable/disable throw option.
unsigned long long usec_wall
bool read(std::istream &in)
Read trigger parameters.
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.
int main(int argc, char *argv[])