40int main(
int argc, 
char* argv[])
 
   46  unsigned int ts_duration = 100;
 
   50  std::string acou_recipient;
 
   51  std::string roy_server;
 
   52  unsigned int acoustic_port = 
no_port;
 
   53  unsigned int optical_port = 
no_port;
 
   55  std::string file_prefix(
"dump_file"), file_postfix(
".dqd");
 
   56  std::string roy_setup;
 
   58  std::size_t dump_size = 1024 * 1024 * 1024; 
 
   60  po::options_description desc(
"Options");
 
   62      (
"help,h",     
"Print this help and exit.")
 
   63      (
"version,v", 
"Print the version and exit.")
 
   65          po::value<unsigned int>(&optical_port),
 
   66          "Set the port to listen for optical data.")
 
   68          po::value<unsigned int>(&acoustic_port),
 
   69          "Set the port to listen for acoustic data.")
 
   72          po::value<unsigned int>(&ts_duration)->required(),
 
   73          "Set the value of the time slice duration in milliseconds.")
 
   76          po::value<std::size_t>(&dump_size)->default_value(dump_size),
 
   77          "Set the maximum size of the dump file.")
 
   80          po::value<std::string>(&file_prefix)->default_value(file_prefix),
 
   81          "Set the dump file name prefix.")
 
   84          po::value<std::string>(&file_postfix)->default_value(file_postfix),
 
   85          "Set the dump file name postfix.")
 
   93      (
"optical-recipients",
 
   94          po::value<std::vector<std::string> >(&opto_recipients)->multitoken(),
 
   95          "Set the list of ip addresses and ports of the optical DataFiters. E.g. --optical-recipients 192.168.1.10:5600 192.168.1.11:5600.")
 
   97      (
"acoustic-recipient",
 
   98          po::value<std::string>(&acou_recipient),
 
   99          "Set the ip addresse and port of the acoustic DataFiter. E.g. --acoustic-recipients 192.168.1.10:5800.")
 
  102          po::value<int>(&run_number)->default_value(run_number),
 
  103          "Set the run-number. If it is set, data not belonging to the specified run will be discarded.")
 
  105          po::value<int>(&detector_id)->default_value(detector_id),
 
  106          "Set the detector id.");
 
  115    po::variables_map vm;
 
  117        po::command_line_parser(argc, argv).options(desc).run(),
 
  120    if (vm.count(
"help"))
 
  122      std::cout << desc << std::endl;
 
  126    if (vm.count(
"version"))
 
  128      std::cout << dataqueue::version::v() << std::endl;
 
  134    opto = vm.count(
"optical");
 
  136    acou = vm.count(
"acoustic");
 
  138    if (! (acou || opto))
 
  140      throw std::runtime_error(
"FATAL: Both acoustic and optical port missing.");
 
  143    if (acou && !vm.count(
"acoustic-recipient"))
 
  145      throw std::runtime_error(
"You specified a port to listen for acoustic data but no aDF address was specified.");
 
  148    if (opto && !vm.count(
"optical-recipients"))
 
  150      throw std::runtime_error(
"You specified a port to listen for optical data but no oDF address was specified.");
 
  185  catch (
const po::error& e)
 
  187    std::cerr << 
"DataQueue: Error: " << e.what() << 
'\n' 
  188              << desc << std::endl;
 
  191  catch (
const std::runtime_error& e)
 
  193    std::cerr << 
"DataQueue: Error: " << e.what() << 
'\n' 
  194              << desc << std::endl;
 
  204  boost::thread* acou_thread = 0;
 
  205  boost::thread* opto_thread = 0;
 
  212    for (std::vector<std::string>::const_iterator it = opto_recipients.begin(), et = opto_recipients.end(); it != et; ++it)
 
  214      optoRecipients.
add(*it);
 
  220    acouRecipients.
add(acou_recipient);
 
  226  boost::thread* farm_threads[2] = {0, 0};
 
  232    std::cout << 
"Acoustics on\n";
 
  233    aFarm = 
new FrameFarm(ts_duration, 0, dump_size, file_prefix + 
"_a", file_postfix);
 
  237    farm_threads[1] = 
new boost::thread(boost::ref(*aFarm));
 
  239    acou_thread = 
new boost::thread(boost::ref(*aDFI));
 
  246    std::cout << 
"Optics on\n";
 
  247    oFarm = 
new FrameFarm(ts_duration, 0, dump_size, file_prefix + 
"_o", file_postfix);
 
  251    farm_threads[0] = 
new boost::thread(boost::ref(*oFarm));
 
  253    opto_thread = 
new boost::thread(boost::ref(*oDFI));
 
  258  doms_interface.
start();
 
  262  std::cout << 
"Hit \'q\' and press [Return] to exit\n";
 
  268    const timeval timeout = {10, 0};
 
  280  std::cout << 
"Closing DataQueue\n";
 
  284  doms_interface.
stop();
 
  286  std::cout << 
"DOMs interface closed\n";
 
  296  std::cout << 
"Farms closed\n";
 
  316  std::cout << 
"DataFilter Interfaces stopped\n";
 
  319    farm_threads[0]->join();
 
  322    farm_threads[1]->join();
 
  324  std::cout << 
"Farms returned\n";
 
  328  delete farm_threads[0];
 
  329  delete farm_threads[1];
 
  331  std::cout << 
"Bye bye\n";