Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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

namespace  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

Definition at line 38 of file jlog.cc.

39{
40 MLSing::get().init(second);
41}
static MLSing & get()
Definition jlog.cc:20
void init(JMessageLoggerThreadSafe const &second)
Definition jlog.cc:27

◆ 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}
void setLevel(const int __level)
Set debug level.
JMessageLoggerThreadSafe & logger()
Definition jlog.cc:32

◆ 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 << " - "
37}
static boost::atomic< unsigned int > n_obj
static Counter & get()
Definition log.hh:53
static boost::atomic< unsigned int > n_obj
#define LOG_NOTICE
Definition log.hh:112

◆ main()

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

Definition at line 314 of file DataQueue.cc.

315{
319
320 std::string server("localhost");
321 std::string logger("localhost");
322 std::string client_name("DataQueue");
323 int debug = 0;
324
325 po::options_description desc("Options");
326 desc.add_options()
327 ("help,h", "Print this help and exit.")
328 ("version,v", "Print the version and exit.")
329 ("optical,o", "Set the optical mode.")
330 ("acoustic,a", "Set the acoustic mode.")
331 (",H",
332 po::value<std::string>(&server)->default_value(server),
333 "Set the address of the SM server.")
334 (",M",
335 po::value<std::string>(&logger)->default_value(logger),
336 "Set the address of the logger server.")
337 (",u",
338 po::value<std::string>(&client_name)->default_value(client_name),
339 "Set the address of the client name.")
340 (",d",
341 po::value<int>(&debug)->default_value(debug),
342 "Set the debug level.");
343
344 bool acou = false, opto = false;
345
346 try
347 {
348 po::variables_map vm;
349 po::store(
350 po::command_line_parser(argc, argv).options(desc).run(),
351 vm);
352
353 if (vm.count("help"))
354 {
355 std::cout << desc << std::endl;
356 return EXIT_SUCCESS;
357 }
358
359 if (vm.count("version"))
360 {
361 std::cout << dataqueue::version::v() << std::endl;
362 return EXIT_SUCCESS;
363 }
364
365 po::notify(vm);
366
367 opto = vm.count("optical");
368
369 acou = vm.count("acoustic");
370
371 if (! (acou || opto))
372 {
373 throw std::runtime_error("FATAL: no mode specified. Use -o, -a or both. See the help.");
374 }
375 }
376 catch (const po::error& e)
377 {
378 std::cerr << "DataQueue: Error: " << e.what() << '\n'
379 << desc << std::endl;
380 return EXIT_FAILURE;
381 }
382 catch (const std::runtime_error& e)
383 {
384 std::cerr << "DataQueue: Error: " << e.what() << '\n'
385 << desc << std::endl;
386 return EXIT_FAILURE;
387 }
388
389 // Call to singleton in a thread-safe environment
390
392
393 // Don't delete this object. It will be handled by the DataQueue class.
396 new JLOGGER::JControlHostLogger(logger),
397 client_name,
398 debug);
399
400 // Thread-safe logger for the threads different from main
401 initLogger(*log);
402
403 KM3NETDAQ::DataQueue dqueue(client_name, server, log, debug, acou, opto);
404
405 dqueue.setClockInterval(30*1000*1000);
406
407 dqueue.enter();
408 dqueue.run();
409}
void initLogger(JLOGGER::JMessageLoggerThreadSafe const &second)
Definition jlog.cc:38
int debug
debug level
Definition JSirene.cc:72
static InBufferCollector & getCollector()
Message logging based on ControlHost.
Thread-safe message logger.
void __debug_abort_on_wrong_size_(size_t size)
Definition debug_abrt.hh:11