75 out << static_cast<const std::string&>(source);
112 if (in >> index >> hostname) {
116 target.
connect(hostname.hostname, hostname.port);
126 cout << error << endl;
188 using namespace KM3NETDAQ;
193 Long64_t numberOfEvents = 1;
194 int numberOfFrames = numeric_limits<int>::max();
199 properties[
"source"] = source;
200 properties[
"target"] =
target;
201 properties[
"inputFile"] = inputFile;
202 properties[
"numberOfEvents"] = numberOfEvents;
203 properties[
"numberOfFrames"] = numberOfFrames;
204 properties[
"probability"] =
P;
206 properties.
read(
string(buffer, length));
216 if (inputFile.empty()) {
JErrorStream(logger) <<
"No input files"; }
219 const unsigned int index =
distance(source.begin(), find(source.begin(), source.end(),
getName()));
221 int number_of_hits = 0;
222 int number_of_errors = 0;
224 if (index < source.size()) {
226 while (inputFile.hasNext()) {
230 int i1 = (timeslice->size() * (index + 0)) / source.size();
231 int i2 = (timeslice->size() * (index + 1)) / source.size();
233 if (i2 - i1 > numberOfFrames) {
234 i2 = i1 + numberOfFrames;
237 for (
int i = i1; i != i2; ++i) {
245 if (gRandom->Rndm() <=
P) {
247 *hit =
JDAQHit(hit->getPMT(), getRandom<JDAQHit::JTDC_t>(), hit->getToT());
254 JDebugStream(logger) <<
"Processing timeslice: " << inputFile.getCounter() <<
" [" << i1 <<
"," << i2 <<
"]";
258 for (
int i = i1; i != i2; ++i) {
259 data.rbegin()->at(i - i1) << timeslice->at(i);
263 JNoticeStream(logger) <<
"Number of errors / hits " << number_of_errors <<
" / " << number_of_hits <<
" for P = " <<
P;
270 setClockInterval((
long long int) (1e-3 *
getFrameTime()));
286 virtual void actionQuit(
int length,
const char* buffer)
override
288 actionReset(0, NULL);
306 virtual void actionStop(
int length,
const char* buffer)
override
308 if (timer.usec_wall > 0) {
JNoticeStream(logger) <<
"I/O " << (int) (numberOfBytes / timer.usec_wall) <<
" MB/s"; }
309 if (numberOfSlices > 0) {
JNoticeStream(logger) <<
"Delay/slice " << (int) (getClockDelay() / numberOfSlices) <<
" us"; }
315 if (!data.empty() && !
target.empty()) {
333 socket.
write(frame->data(), frame->size());
335 numberOfBytes += frame->size();
381 for (
iterator timeslice = begin(); timeslice != end(); ++timeslice) {
418 if (page != end() && ++page == end()) {
422 for (
iterator timeslice = begin(); timeslice != end(); ++timeslice) {
477 int main(
int argc,
char* argv[])
489 JParser<> zap(
"Program for real-time simulation of data queue.");
493 zap[
'u'] =
make_field(client_name) =
"JDQSimulator";
499 catch(
const exception &error) {
500 FATAL(error.what() << endl);
504 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.
std::vector< JSource > source
JSource()
Default constructor.
Utility class to parse parameter values.
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.
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...
Control unit client base class.
General purpose class for object reading from a list of file names.
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.
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.
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
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