28{
   32 
   33  string          source;
   35  int             report_interval;  
   40 
   41  try {
   42 
   43    JParser<> zap(
"Program to forward messages from one ControlHost server to another.");
 
   44 
   52 
   53    zap(argc, argv);
   54  }
   55  catch(const exception &error) {
   56    FATAL(error.what() << endl);
 
   57  }
   58 
   59 
   60  if (tagList.empty() && TagList.empty()) {
   61    FATAL(
"No tags specified.");
 
   62  }
   63 
   64  NOTICE(
"Forwarding messages from " << endl << 
"    " << source << 
" -> " << 
target << endl);
 
   65 
   66 
   68 
   69  try {
   70 
   73 
   74    {
   75      NOTICE(
"with the following tags: ");
 
   76 
   78 
   82      }
   83 
   87      }
   88 
   90 
   91      in.Subscribe(buffer);
   92      in.SendMeAlways();
   93    }
   94 
   95 
   98    unsigned int message_count[] = { 0, 0 };
   99    float        milliseconds_passed;
  100    std::chrono::steady_clock::time_point start_time = std::chrono::steady_clock::now();
  101 
  102    for (const string stop("stop"); buffer.size() != stop.size() || string(buffer.data(), stop.size()) != stop; ) {
  103 
  104      in.WaitHead(prefix);
  105 
  106      buffer.resize(prefix.
getSize());
 
  107 
  108      in.GetFullData(buffer.data(), buffer.size());
  109 
  110      message_count[0] += 1;
  111 
  113 
  114      bool dos = false;
  115 
  117 
  119        Version_t        version;
  121 
  123 
  124        reader >> preamble;
  125        reader >> version;
  126        reader >> header;
  127 
  129 
  130      } else {
  131 
  132        dos = true;
  133      }
  134 
  135      if (dos) {
  136 
  137        message_count[1] += 1;
  138 
  139        out.PutFullData(prefix.
getTag(), buffer.data(), buffer.size());
 
  140      }
  141 
  142      milliseconds_passed = chrono::duration_cast<chrono::milliseconds>(std::chrono::steady_clock::now() - start_time).count();
  143 
  144      if (milliseconds_passed > report_interval * 1e3) {
  145 
  147               << message_count[0] / milliseconds_passed * 1e3 << " "
  148               << message_count[1] / milliseconds_passed * 1e3 << " Hz" << endl);
  149 
  150        start_time = std::chrono::steady_clock::now();
  151 
  152        message_count[0] = 0;
  153        message_count[1] = 0;
  154      }
  155    }
  156  }
  158    ERROR(error << endl);
 
  159  }
  160}
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Exception for ControlHost.
 
static void Throw(const bool option)
 
int getSize() const
Get size.
 
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
 
const JTag & getTag() const
Get tag.
 
Utility class to parse command line options.
 
Auxiliary class for trigger mask.
 
bool hasTriggerMask(const JDAQTriggerMask &mask) const
Has trigger bit pattern.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
static JDateAndTime getDateAndTime
Function object to get current date and time.
 
KM3NeT DAQ data structures and auxiliaries.
 
static const JDAQTriggerMask TRIGGER_MASK_ON
Trigger mask on;.
 
static const JNET::JTag IO_EVENT
 
Auxiliary class for all subscription.
 
Auxiliary class for any subscription.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...