17 #include <boost/program_options.hpp>
22 namespace po = boost::program_options;
23 #include <boost/foreach.hpp>
24 #include <boost/scoped_ptr.hpp>
26 #include "version.hpp"
46 boost::scoped_ptr<DataInputInterface>
m_input;
54 boost::scoped_ptr<DFInterface>
m_adfi;
55 boost::scoped_ptr<DFInterface>
m_odfi;
85 virtual void actionInit(
int length,
const char* buffer) {}
92 std::string(buffer, length));
95 unsigned int const delta_ts = conf.get<
unsigned int>(
96 "timeslice_duration");
98 uint64_t
const run_start_time = conf.get<uint64_t>(
"run_start_time");
100 std::size_t
const max_dump_size = conf.get<std::size_t>(
"max_dump_size");
101 std::string
const prefix = conf.get<std::string>(
"dump_file_prefix");
102 std::string
const postfix = conf.get<std::string>(
"dump_file_postfix");
108 acou_ports = detail::vectorize<int>(conf.get<std::string>(
"acou_ports"));
112 opto_ports = detail::vectorize<int>(conf.get<std::string>(
"opto_ports"));
115 int const n_channels = acou_ports.size() + opto_ports.size();
143 std::string
const acou_recipient = conf.get<std::string>(
"acou_recipient");
152 conf.get<std::string>(
"opto_recipients"));
155 BOOST_FOREACH(std::string s, opto_recipients)
164 BOOST_FOREACH(
int port, acou_ports)
171 BOOST_FOREACH(
int port, opto_ports)
198 int const run_number = getRunNumber();
200 int const detector_id = getDetectorID();
202 assert(run_number >= 0);
208 m_afarm->runNumber(run_number);
209 m_afarm->detectorId(detector_id);
213 m_ofarm->runNumber(run_number);
214 m_ofarm->detectorId(detector_id);
294 assert(!
"No DQ mode set.");
300 int main(
int argc,
char* argv[])
302 __debug_abort_on_wrong_size_<CLBCommonHeader>(40);
303 __debug_abort_on_wrong_size_<DAQCommonHeader>(56);
304 __debug_abort_on_wrong_size_<UTCTime>(8);
306 std::string server(
"localhost");
307 std::string logger(
"localhost");
308 std::string client_name(
"DataQueue");
311 po::options_description desc(
"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.")
318 po::value<std::string>(&server)->default_value(server),
319 "Set the address of the SM server.")
321 po::value<std::string>(&logger)->default_value(logger),
322 "Set the address of the logger server.")
324 po::value<std::string>(&client_name)->default_value(client_name),
325 "Set the address of the client name.")
327 po::value<int>(&debug)->default_value(debug),
328 "Set the debug level.");
330 bool acou =
false, opto =
false;
334 po::variables_map vm;
336 po::command_line_parser(argc, argv).options(desc).run(),
339 if (vm.count(
"help"))
341 std::cout << desc << std::endl;
345 if (vm.count(
"version"))
347 std::cout << dataqueue::version::v() << std::endl;
353 opto = vm.count(
"optical");
355 acou = vm.count(
"acoustic");
357 if (! (acou || opto))
359 throw std::runtime_error(
"FATAL: no mode specified. Use -o, -a or both. See the help.");
362 catch (
const po::error& e)
364 std::cerr <<
"DataQueue: Error: " << e.what() <<
'\n'
365 << desc << std::endl;
368 catch (
const std::runtime_error& e)
370 std::cerr <<
"DataQueue: Error: " << e.what() <<
'\n'
371 << desc << std::endl;
boost::scoped_ptr< boost::thread > m_adfi_th
void initLogger(JLOGGER::JMessageLoggerThreadSafe const &second)
static const JNET::JTag RC_DQUEUE_OPT
virtual void actionRunning()
This method is repeatedly called when this client machine is in state Running and the clock interval ...
static const JNET::JTag RC_DQUEUE
Interface for logging messages.
Message logging based on ControlHost.
void setClockInterval(const long long int interval_us)
Set interval time.
boost::scoped_ptr< DFInterface > m_adfi
virtual void actionEnter()
Interface methods for actions corresponding to state transitions.
JSharedPointer< JControlHost > server
message server
virtual void actionContinue(int length, const char *buffer)
void run()
Run as run control client following command messages via JNET::JControlHost.
virtual void actionExit()
virtual void actionStop(int length, const char *buffer)
boost::scoped_ptr< FrameFarm > m_afarm
boost::scoped_ptr< boost::thread > m_odfi_th
boost::scoped_ptr< RecipientsHandler > m_orecipients
boost::property_tree::ptree parse(std::string str)
virtual void actionStart(int length, const char *buffer)
static boost::atomic< unsigned int > n_obj
const JNET::JTag & clientTag() const
virtual void actionInit(int length, const char *buffer)
Auxiliary class for method select.
virtual void actionQuit(int length, const char *buffer)
virtual void actionPause(int length, const char *buffer)
boost::scoped_ptr< boost::thread > m_aff_th
virtual void actionConfigure(int length, const char *buffer)
boost::scoped_ptr< FrameFarm > m_ofarm
boost::scoped_ptr< RecipientsHandler > m_arecipients
General purpose message reporting.
static InBufferCollector & getCollector()
Run control client base class.
virtual bool enter(const JArgs &args)
Enter the state machine.
void store(const JString &file_name, const JDetector &detector)
Store detector to output file.
boost::scoped_ptr< DFInterface > m_odfi
static const JNET::JTag RC_DQUEUE_ACS
JMessageLogger logger
message logger
void replaceEvent(const JNET::JTag &oldTag, const JNET::JTag &newTag, JDAQEvent_t &event)
Replace tag of given event in event table.
static const JNET::JTag RC_CMD
virtual void actionReset(int length, const char *buffer)
Thread-safe message logger.
DataQueue(const std::string &name, const std::string &server, JLogger *logger, const int level, bool acou, bool opto)
boost::scoped_ptr< DataInputInterface > m_input
boost::scoped_ptr< boost::thread > m_off_th
static boost::atomic< unsigned int > n_obj
virtual void actionSelect(const JFileDescriptorMask &)
Action method following last select call.
int main(int argc, char *argv[])