Jpp
Classes | Namespaces | Functions
DataQueue.cc File Reference
#include <iostream>
#include <string>
#include <cassert>
#include <JRuncontrol/JDAQClient.hh>
#include <JLogger/JControlHostLogger.hh>
#include <JLogger/JMessageLogger.hh>
#include <JDAQ/JDAQTags.hh>
#include <CLBInterface/data_input_interface.hh>
#include <FrameFactory/frame_farm.hh>
#include <DFInterface/DFInterface.hh>
#include "debug_abrt.hh"
#include "log.hh"
#include <boost/program_options.hpp>
#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include "configure.hh"
#include "version.hpp"

Go to the source code of this file.

Classes

class  KM3NETDAQ::DataQueue
 

Namespaces

 KM3NETDAQ
 KM3NeT DAQ data structures and auxiliaries.
 

Functions

void initLogger (JLOGGER::JMessageLoggerThreadSafe const &second)
 
void setLogLevel (int level)
 
static void monitor ()
 
int main (int argc, char *argv[])
 

Function Documentation

◆ initLogger()

void initLogger ( JLOGGER::JMessageLoggerThreadSafe const &  second)
Author
cpellegrino

◆ setLogLevel()

void setLogLevel ( int  level)

Definition at line 43 of file jlog.cc.

44 {
45  // This shall be protected from race conditions with a mutex to avoid UB.
46  // But this very UB won't really produce any problem, hopefully.
47  MLSing::get().logger().setLevel(level);
48 }

◆ monitor()

static void monitor ( )
static

Definition at line 32 of file DataQueue.cc.

33 {
34  LOG_NOTICE << "# pframes: " << PuzzledFrame::n_obj
35  << " - # dgrams: " << CLBDataGram::n_obj << " - "
36  << Log::Counter::get();
37 }

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 309 of file DataQueue.cc.

310 {
311  __debug_abort_on_wrong_size_<CLBCommonHeader>(40);
312  __debug_abort_on_wrong_size_<DAQCommonHeader>(56);
313  __debug_abort_on_wrong_size_<UTCTime>(8);
314 
315  std::string server("localhost");
316  std::string logger("localhost");
317  std::string client_name("DataQueue");
318  int debug = 0;
319 
320  po::options_description desc("Options");
321  desc.add_options()
322  ("help,h", "Print this help and exit.")
323  ("version,v", "Print the version and exit.")
324  ("optical,o", "Set the optical mode.")
325  ("acoustic,a", "Set the acoustic mode.")
326  (",H",
327  po::value<std::string>(&server)->default_value(server),
328  "Set the address of the SM server.")
329  (",M",
330  po::value<std::string>(&logger)->default_value(logger),
331  "Set the address of the logger server.")
332  (",u",
333  po::value<std::string>(&client_name)->default_value(client_name),
334  "Set the address of the client name.")
335  (",d",
336  po::value<int>(&debug)->default_value(debug),
337  "Set the debug level.");
338 
339  bool acou = false, opto = false;
340 
341  try
342  {
343  po::variables_map vm;
344  po::store(
345  po::command_line_parser(argc, argv).options(desc).run(),
346  vm);
347 
348  if (vm.count("help"))
349  {
350  std::cout << desc << std::endl;
351  return EXIT_SUCCESS;
352  }
353 
354  if (vm.count("version"))
355  {
356  std::cout << dataqueue::version::v() << std::endl;
357  return EXIT_SUCCESS;
358  }
359 
360  po::notify(vm);
361 
362  opto = vm.count("optical");
363 
364  acou = vm.count("acoustic");
365 
366  if (! (acou || opto))
367  {
368  throw std::runtime_error("FATAL: no mode specified. Use -o, -a or both. See the help.");
369  }
370  }
371  catch (const po::error& e)
372  {
373  std::cerr << "DataQueue: Error: " << e.what() << '\n'
374  << desc << std::endl;
375  return EXIT_FAILURE;
376  }
377  catch (const std::runtime_error& e)
378  {
379  std::cerr << "DataQueue: Error: " << e.what() << '\n'
380  << desc << std::endl;
381  return EXIT_FAILURE;
382  }
383 
384  // Call to singleton in a thread-safe environment
385 
387 
388  // Don't delete this object. It will be handled by the DataQueue class.
391  new JLOGGER::JControlHostLogger(logger),
392  client_name,
393  debug);
394 
395  // Thread-safe logger for the threads different from main
396  initLogger(*log);
397 
398  KM3NETDAQ::DataQueue dqueue(client_name, server, log, debug, acou, opto);
399 
400  dqueue.setClockInterval(30*1000*1000);
401 
402  dqueue.enter();
403  dqueue.run();
404 }
PuzzledFrame::n_obj
static boost::atomic< unsigned int > n_obj
Definition: puzzled_frame.hh:39
MLSing::logger
JMessageLoggerThreadSafe & logger()
Definition: jlog.cc:32
CLBDataGram::n_obj
static boost::atomic< unsigned int > n_obj
Definition: clb_datagram.hh:35
LOG_NOTICE
#define LOG_NOTICE
Definition: log.hh:112
KM3NETDAQ::DataQueue
Definition: DataQueue.cc:41
debug
int debug
debug level
Definition: JSirene.cc:59
JLOGGER::JMessageLoggerThreadSafe
Thread-safe message logger.
Definition: JMessageLogger.hh:238
JLOGGER::JControlHostLogger
Message logging based on ControlHost.
Definition: JControlHostLogger.hh:26
JTOOLS::v
data_type v[N+1][M+1]
Definition: JPolint.hh:707
JDETECTOR::store
void store(const JString &file_name, const JDetector &detector)
Store detector to output file.
Definition: JDetectorToolkit.hh:532
MLSing::get
static MLSing & get()
Definition: jlog.cc:20
InBufferCollector::getCollector
static InBufferCollector & getCollector()
Definition: input_buffer_collector.hh:27
Log::Counter::get
static Counter & get()
Definition: log.hh:53
initLogger
void initLogger(JLOGGER::JMessageLoggerThreadSafe const &second)