77 out << static_cast<const std::string&>(source);
114 if (in >> index >> hostname) {
118 target.
connect(hostname.hostname, hostname.port);
128 cout << error << endl;
193 using namespace KM3NETDAQ;
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()) {
245 while (inputFile.hasNext()) {
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);
529 using namespace KM3NETDAQ;
void setReuseAddress(const bool on)
Set reuse address.
Utility class to parse command line options.
std::vector< value_type >::const_iterator const_iterator
int getSendBufferSize() const
Get send buffer size.
bool read(const JEquation &equation)
Read equation.
int main(int argc, char *argv[])
ROOT TTree parameter settings of various packages.
virtual void actionStart(int length, const char *buffer) override
bool getReuseAddress() const
Get reuse address.
JTarget()
Default constructor.
Message logging based on std::ostream.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
void setSendBufferSize(const int size)
Set send buffer size.
JData()
Default constructor.
void next()
Increment internal iterator.
bool getTcpNoDelay() const
Get TCP no-delay.
int getReceiveBufferSize() const
Set receive buffer size.
int write(const char *buffer, const int length) override
Write data to socket.
Interface for logging messages.
Message logging based on ControlHost.
then echo Enter input within $TIMEOUT_S seconds echo n User name
Utility class to parse parameter values.
std::vector< value_type >::iterator iterator
virtual void actionReset(int length, const char *buffer) override
Simple data structure to support I/O of equations (see class JLANG::JEquation).
std::vector< JFrame > JTimeslice
Definition of random value generator.
Runcontrol client to simulate data queue.
void run()
Run as run control client following command messages via JNET::JControlHost.
Auxiliary data structure for hostname and port number.
Data structure for UTC time.
std::vector< JSource > source
JSource()
Default constructor.
Utility class to parse parameter values.
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
bool getKeepAlive() const
Get keep alive of socket.
friend std::istream & operator>>(std::istream &in, JSource &source)
Read JSource from input stream.
long long int numberOfSlices
Scheduling of actions via fixed latency intervals.
virtual void actionStop(int length, const char *buffer) override
virtual void actionConfigure(int length, const char *buffer) override
JIO::JByteArrayWriter JFrame
Memory management for sending of raw data.
JDQSimulator(const std::string &name, const std::string &server, JLogger *logger, const int level)
Constructor.
event< ev_daq > ev_configure
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
const_iterator begin() const
double getFrameTime()
Get frame time duration.
int getRunNumber(const std::string &file_name)
Get run number for given file name of data taking run.
long long int numberOfBytes
Auxiliary class for CPU timing and usage.
void setTcpNoDelay(const bool on)
Set TCP no-delay.
Data structure for configuration of JDQSimulator.
Level specific message streamers.
bool getNonBlocking() const
Get non-blocking of I/O.
Auxiliary data structure for sequence of same character.
std::vector< JTarget > target
void setReceiveBufferSize(const int size)
Set receive buffer size.
Data structure for configuration of JDataFilter.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Auxiliary class to define a range between two values.
Control unit client base class.
General purpose class for object reading from a list of file names.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Utility class to parse command line options.
JData::const_iterator page
void setRunNumber(int run_number)
Set run number.
friend std::ostream & operator<<(std::ostream &out, const JSource &source)
Write JSource to output stream.
void connect(const int port)
Connect to port on local host.
virtual bool enter(const JArgs &args)
Enter the state machine.
void setNonBlocking(const bool on)
Set non-blocking of I/O.
const char * getName()
Get ROOT name of given data type.
virtual void actionQuit(int length, const char *buffer) override
size_t getSizeof< JDAQSuperFrameHeader >()
Get size of type.
static const JNET::JTag RC_CMD
static const JNET::JTag RC_DQSIMULATOR
void setKeepAlive(const bool on)
Set keep alive of socket.
void setRunNumber(const int run)
Set run number.
std::map< int, range_type > map_type
Byte array binary output.
friend std::istream & operator>>(std::istream &in, JTarget &target)
Read JTarget from input stream.
size_t getSizeof< JDAQPreamble >()
Get size of type.
KM3NeT DAQ constants, bit handling, etc.
Base class for interprocess communication.
void setFrameIndex(const int frame_index)
Set frame index.
void reset()
Reset internal iterator to begin.
friend std::ostream & operator<<(std::ostream &out, const JTarget &target)
Write JTarget to output stream.
virtual void actionRunning() override
This method is repeatedly called when this client machine is in state Running and the clock interval ...
Data frame of one optical module.
const_iterator operator->()
Smart pointer operator.
const_iterator end() const