62 in >> index >>
static_cast<std::string&
>(source);
77 out << static_cast<const std::string&>(source);
114 if (in >> index >> hostname) {
120 target.setTcpNoDelay (
true);
121 target.setReuseAddress(
true);
122 target.setKeepAlive (
true);
123 target.setReceiveBufferSize(1024);
124 target.setSendBufferSize (1024*1024);
125 target.setNonBlocking (
false);
128 cout << error << endl;
148 out <<
"TCP no-delay " <<
target.getTcpNoDelay() << endl;
149 out <<
"Reuse address " <<
target.getReuseAddress() << endl;
150 out <<
"Keep alive " <<
target.getKeepAlive() << endl;
151 out <<
"Receive buffer " <<
target.getReceiveBufferSize() << endl;
152 out <<
"Send buffer " <<
target.getSendBufferSize() << endl;
153 out <<
"Non blocking " <<
target.getNonBlocking() << endl;
181 const std::string& server,
198 Long64_t numberOfEvents = 1;
199 int numberOfFrames = numeric_limits<int>::max();
204 properties[
"source"] = source;
205 properties[
"target"] =
target;
206 properties[
"snooze"] = snooze;
207 properties[
"inputFile"] = inputFile;
208 properties[
"numberOfEvents"] = numberOfEvents;
209 properties[
"numberOfFrames"] = numberOfFrames;
210 properties[
"probability"] = P;
212 properties.
read(
string(buffer, length));
222 if (inputFile.empty()) {
JErrorStream(logger) <<
"No input files"; }
225 if (!snooze.empty()) {
231 for (map_type::const_iterator i = snooze.begin(); i != snooze.end(); ++i) {
232 os <<
' ' << setw(8) << i->first <<
" [" <<
FILL(6,
'0') << i->second.getLowerLimit() <<
"," <<
FILL(6,
'0') << i->second.getUpperLimit() <<
"]";
238 const unsigned int index =
distance(source.begin(), find(source.begin(), source.end(),
getName()));
240 int number_of_hits = 0;
241 int number_of_errors = 0;
243 if (index < source.size()) {
249 int i1 = (timeslice->size() * (index + 0)) / source.size();
250 int i2 = (timeslice->size() * (index + 1)) / source.size();
252 if (i2 - i1 > numberOfFrames) {
253 i2 = i1 + numberOfFrames;
256 for (
int i = i1; i != i2; ++i) {
264 if (gRandom->Rndm() <= P) {
266 *hit =
JDAQHit(hit->getPMT(), getRandom<JDAQHit::JTDC_t>(), hit->getToT());
273 JDebugStream(logger) <<
"Processing timeslice: " << inputFile.
getCounter() <<
" [" << i1 <<
"," << i2 <<
"]";
277 for (
int i = i1; i != i2; ++i) {
278 data.rbegin()->at(i - i1) << timeslice->at(i);
282 JNoticeStream(logger) <<
"Number of errors / hits " << number_of_errors <<
" / " << number_of_hits <<
" for P = " << P;
289 setClockInterval((
long long int) (1e-3 *
getFrameTime()));
305 virtual void actionQuit(
int length,
const char* buffer)
override
307 actionReset(0, NULL);
325 virtual void actionStop(
int length,
const char* buffer)
override
327 if (timer.usec_wall > 0) {
JNoticeStream(logger) <<
"I/O " << (int) (numberOfBytes / timer.usec_wall) <<
" MB/s"; }
328 if (numberOfSlices > 0) {
JNoticeStream(logger) <<
"Delay/slice " << (int) (getClockDelay() / numberOfSlices) <<
" us"; }
350 if (snooze.count(header.getModuleID()) == 0 || !snooze[header.getModuleID()](header.getFrameIndex())) {
354 socket.
write(frame->data(), frame->size());
356 numberOfBytes += frame->size();
405 for (
iterator timeslice = begin(); timeslice != end(); ++timeslice) {
442 if (page != end() && ++page == end()) {
446 for (
iterator timeslice = begin(); timeslice != end(); ++timeslice) {
502 int main(
int argc,
char* argv[])
514 JParser<> zap(
"Program for real-time simulation of data queue.");
518 zap[
'u'] =
make_field(client_name) =
"JDQSimulator";
524 catch(
const exception &error) {
525 FATAL(error.what() << endl);
KM3NeT DAQ constants, bit handling, etc.
int main(int argc, char *argv[])
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse parameter values.
Definition of random value generator.
Auxiliary class to define a range between two values.
Base class for interprocess communication.
ROOT TTree parameter settings of various packages.
Scheduling of actions via fixed latency intervals.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Utility class to parse parameter values.
bool read(const JEquation &equation)
Read equation.
Auxiliary class for CPU timing and usage.
void seekg(const int pos)
Set read position.
Byte array binary output.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Message logging based on ControlHost.
Interface for logging messages.
Message logging based on std::ostream.
int write(const char *buffer, const int length) override
Write data to socket.
Utility class to parse command line options.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
std::vector< value_type >::const_iterator const_iterator
std::vector< value_type >::iterator iterator
void setFrameIndex(const int frame_index)
Set frame index.
void setRunNumber(const int run)
Set run number.
Control unit client base class.
void run()
Run as run control client following command messages via JNET::JControlHost.
virtual bool enter(const JArgs &args)
Enter the state machine.
const_iterator end() const
const_iterator begin() const
Data frame of one optical module.
Data structure for UTC time.
void reset()
Reset internal iterator to begin.
JData()
Default constructor.
JData::const_iterator page
void setRunNumber(int run_number)
Set run number.
void next()
Increment internal iterator.
const_iterator operator->()
Smart pointer operator.
Runcontrol client to simulate data queue.
long long int numberOfBytes
std::vector< JFrame > JTimeslice
virtual void actionConfigure(int length, const char *buffer) override
virtual void actionStart(int length, const char *buffer) override
virtual void actionRunning() override
This method is repeatedly called when this client machine is in state Running and the clock interval ...
virtual void actionStop(int length, const char *buffer) override
std::vector< JTarget > target
JIO::JByteArrayWriter JFrame
Memory management for sending of raw data.
virtual void actionReset(int length, const char *buffer) override
virtual void actionQuit(int length, const char *buffer) override
JDQSimulator(const std::string &name, const std::string &server, JLogger *logger, const int level)
Constructor.
long long int numberOfSlices
std::vector< JSource > source
Data structure for configuration of JDQSimulator.
friend std::ostream & operator<<(std::ostream &out, const JSource &source)
Write JSource to output stream.
friend std::istream & operator>>(std::istream &in, JSource &source)
Read JSource from input stream.
JSource()
Default constructor.
Data structure for configuration of JDataFilter.
friend std::istream & operator>>(std::istream &in, JTarget &target)
Read JTarget from input stream.
friend std::ostream & operator<<(std::ostream &out, const JTarget &target)
Write JTarget to output stream.
JTarget()
Default constructor.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getName()
Get ROOT name of given data type.
int getRunNumber(const std::string &file_name)
Get run number for given file name of data taking run.
KM3NeT DAQ data structures and auxiliaries.
double getFrameTime()
Get frame time duration.
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
size_t getSizeof< JDAQSuperFrameHeader >()
Get size of type.
static const JNET::JTag RC_CMD
size_t getSizeof< JDAQPreamble >()
Get size of type.
std::map< int, range_type > map_type
static const JNET::JTag RC_DQSIMULATOR
Auxiliary data structure for sequence of same character.
Level specific message streamers.
Auxiliary data structure for hostname and port number.