LCOV - code coverage report
Current view: top level - proto - dispatcher_art_job.cc (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 65 0
Test Date: 2026-10-29 00:35:58 Functions: 0.0 % 8 0

            Line data    Source code
       1              : #include "artdaq/Application/LoadParameterSet.hh"
       2              : #include "artdaq/ArtModules/detail/TransferWrapper.hh"
       3              : 
       4            0 : int main(int argc, char* argv[])
       5              : try
       6              : {
       7            0 :         std::ostringstream descstr;
       8              :         descstr << argv[0]  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
       9            0 :                 << " <-c <config>> <other-options> [<source-file>]+";
      10            0 :         bpo::options_description desc(descstr.str());
      11            0 :         desc.add_options()("config,c", bpo::value<std::string>(), "Configuration")("stop,s", "Stop an existing dispatcher art job")("dispatcherHost,d", bpo::value<std::string>()->default_value("localhost"), "Dispatcher host")("dispatcherPort,p", bpo::value<int>()->default_value(5266), "Dispatcher port")("unique_label,l", bpo::value<std::string>()->default_value("default_art_job"), "Unique label for this art job")("help,h", "produce help message");
      12            0 :         bpo::variables_map vm;
      13              :         try
      14              :         {
      15            0 :                 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
      16            0 :                 bpo::notify(vm);
      17              :         }
      18            0 :         catch (bpo::error const& e)
      19              :         {
      20            0 :                 TLOG_ERROR() << "Exception from command line processing in " << argv[0]  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
      21            0 :                              << ": " << e.what() << "\n";
      22            0 :                 exit(-1);
      23            0 :         }
      24            0 :         if (vm.count("help"))
      25              :         {
      26            0 :                 std::cout << desc << std::endl;
      27            0 :                 exit(1);
      28              :         }
      29              : 
      30            0 :         fhicl::ParameterSet art_pset;
      31              : 
      32            0 :         if (vm.count("config"))
      33              :         {
      34            0 :                 std::string config = vm["config"].as<std::string>();
      35              : 
      36            0 :                 if (config == "-" || config == "--")
      37              :                 {
      38            0 :                         TLOG_ERROR() << "Reading configuration from standard input. Press Ctrl-D to end" << std::endl;
      39            0 :                         std::stringstream ss;
      40            0 :                         std::string line;
      41            0 :                         while (std::getline(std::cin, line))
      42              :                         {
      43            0 :                                 ss << line << std::endl;
      44              :                         }
      45            0 :                         std::cin.clear();
      46              : 
      47            0 :                         art_pset = fhicl::ParameterSet::make(ss.str());
      48            0 :                 }
      49              :                 else
      50              :                 {
      51            0 :                         TLOG(TLVL_DEBUG + 32) << config << std::endl;
      52            0 :                         auto pset_tmp = LoadParameterSet(config);
      53            0 :                         if (pset_tmp.has_key("art")) { art_pset = pset_tmp.get<fhicl::ParameterSet>("art"); }
      54              :                         else
      55              :                         {
      56            0 :                                 art_pset = pset_tmp;
      57              :                         }
      58            0 :                 }
      59            0 :         }
      60            0 :         else if (!vm.count("stop"))
      61              :         {
      62            0 :                 TLOG_ERROR() << "Exception from command line processing in " << argv[0]  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
      63            0 :                              << ": no configuration given.\n"
      64            0 :                              << "For usage and an options list, please do '"
      65            0 :                              << argv[0] << " --help"  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
      66            0 :                              << "'.\n";
      67            0 :                 exit(2);
      68              :         }
      69              : 
      70            0 :         if (!art_pset.has_key("path") || !art_pset.has_key("filter_paths"))
      71              :         {
      72            0 :                 TLOG_ERROR() << "The art configuration must include 'path' and 'filter_paths' parameters to run correctly on a Dispatcher.";
      73            0 :                 TLOG_INFO() << "Path is a list of producer and analyzer modules to run, the Dispatcher only supports a single processing path.";
      74            0 :                 TLOG_INFO() << "filter_paths is a list of Fhicl tables, e.g. filter_paths: [ {name: pmod path: [prescale]} ], and can be empty. Any SelectEvents calls must use one of the named filter_paths";
      75            0 :                 exit(-3);
      76              :         }
      77              : 
      78            0 :         fhicl::ParameterSet transfer_wrapper_pset;
      79            0 :         transfer_wrapper_pset.put<std::string>("dispatcherHost", vm["dispatcherHost"].as<std::string>());
      80            0 :         transfer_wrapper_pset.put<int>("dispatcherPort", vm["dispatcherPort"].as<int>());
      81            0 :         transfer_wrapper_pset.put<fhicl::ParameterSet>("dispatcher_config", art_pset);
      82            0 :         transfer_wrapper_pset.put<std::string>("unique_label", vm["unique_label"].as<std::string>());
      83              : 
      84            0 :         auto transfer_wrapper = std::make_unique<artdaq::TransferWrapper>(transfer_wrapper_pset);
      85            0 :         if (vm.count("stop"))
      86              :         {
      87            0 :                 transfer_wrapper->unregisterMonitor(true, vm["unique_label"].as<std::string>());
      88              :         }
      89              :         else
      90              :         {
      91            0 :                 transfer_wrapper->registerMonitor(false);
      92            0 :                 transfer_wrapper->detachMonitor();
      93              :         }
      94              : 
      95            0 :         return 0;
      96            0 : }
      97            0 : catch (std::exception& ex)
      98              : {
      99            0 :         std::cerr << "Exception caught: " << ex.what() << std::endl;
     100            0 :         return -1;
     101            0 : }
     102            0 : catch (...)
     103              : {
     104            0 :         return -1;
     105            0 : }
        

Generated by: LCOV version 2.0-1