Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 
static void monitor ()
 
int main (int argc, char *argv[])
 

Function Documentation

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

Definition at line 31 of file DataQueue.cc.

32 {
33  LOG_NOTICE << "# pframes: " << PuzzledFrame::n_obj
34  << " - # dgrams: " << CLBDataGram::n_obj << " - "
35  << Log::Counter::get();
36 }
static Counter & get()
Definition: log.hh:53
#define LOG_NOTICE
Definition: log.hh:112
static boost::atomic< unsigned int > n_obj
Definition: clb_datagram.hh:35
static boost::atomic< unsigned int > n_obj
int main ( int  argc,
char *  argv[] 
)

Definition at line 300 of file DataQueue.cc.

301 {
302  __debug_abort_on_wrong_size_<CLBCommonHeader>(40);
303  __debug_abort_on_wrong_size_<DAQCommonHeader>(56);
304  __debug_abort_on_wrong_size_<UTCTime>(8);
305 
306  std::string server("localhost");
307  std::string logger("localhost");
308  std::string client_name("DataQueue");
309  int debug = 0;
310 
311  po::options_description desc("Options");
312  desc.add_options()
313  ("help,h", "Print this help and exit.")
314  ("version,v", "Print the version and exit.")
315  ("optical,o", "Set the optical mode.")
316  ("acoustic,a", "Set the acoustic mode.")
317  (",H",
318  po::value<std::string>(&server)->default_value(server),
319  "Set the address of the SM server.")
320  (",M",
321  po::value<std::string>(&logger)->default_value(logger),
322  "Set the address of the logger server.")
323  (",u",
324  po::value<std::string>(&client_name)->default_value(client_name),
325  "Set the address of the client name.")
326  (",d",
327  po::value<int>(&debug)->default_value(debug),
328  "Set the debug level.");
329 
330  bool acou = false, opto = false;
331 
332  try
333  {
334  po::variables_map vm;
335  po::store(
336  po::command_line_parser(argc, argv).options(desc).run(),
337  vm);
338 
339  if (vm.count("help"))
340  {
341  std::cout << desc << std::endl;
342  return EXIT_SUCCESS;
343  }
344 
345  if (vm.count("version"))
346  {
347  std::cout << dataqueue::version::v() << std::endl;
348  return EXIT_SUCCESS;
349  }
350 
351  po::notify(vm);
352 
353  opto = vm.count("optical");
354 
355  acou = vm.count("acoustic");
356 
357  if (! (acou || opto))
358  {
359  throw std::runtime_error("FATAL: no mode specified. Use -o, -a or both. See the help.");
360  }
361  }
362  catch (const po::error& e)
363  {
364  std::cerr << "DataQueue: Error: " << e.what() << '\n'
365  << desc << std::endl;
366  return EXIT_FAILURE;
367  }
368  catch (const std::runtime_error& e)
369  {
370  std::cerr << "DataQueue: Error: " << e.what() << '\n'
371  << desc << std::endl;
372  return EXIT_FAILURE;
373  }
374 
375  // Call to singleton in a thread-safe environment
376 
378 
379  // Don't delete this object. It will be handled by the DataQueue class.
382  new JLOGGER::JControlHostLogger(logger),
383  client_name,
384  debug);
385 
386  // Thread-safe logger for the threads different from main
387  initLogger(*log);
388 
389  KM3NETDAQ::DataQueue dqueue(client_name, server, log, debug, acou, opto);
390 
391  dqueue.setClockInterval(30*1000*1000);
392 
393  dqueue.enter();
394  dqueue.run();
395 }
void initLogger(JLOGGER::JMessageLoggerThreadSafe const &second)
Message logging based on ControlHost.
int debug
debug level
Definition: JSirene.cc:59
static InBufferCollector & getCollector()
void store(const JString &file_name, const JDetector &detector)
Store detector to output file.
Thread-safe message logger.