LCOV - code coverage report
Current view: top level - appmodel/src - FakeHSIApplication.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 77 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /**
       2              :  * @file FakeHSIApplication.cpp
       3              :  *
       4              :  * Implementation of FakeHSIApplication's generate_modules dal method
       5              :  *
       6              :  * This is part of the DUNE DAQ Software Suite, copyright 2023.
       7              :  * Licensing/copyright details are in the COPYING file that you should have
       8              :  * received with this code.
       9              :  */
      10              : 
      11              : #include "appmodel/FakeHSIApplication.hpp"
      12              : #include "ConfigObjectFactory.hpp"
      13              : #include "appmodel/ConfigurationHelper.hpp"
      14              : #include "appmodel/DataHandlerConf.hpp"
      15              : #include "appmodel/DataHandlerModule.hpp"
      16              : #include "appmodel/FakeHSIEventGeneratorConf.hpp"
      17              : #include "appmodel/FakeHSIEventGeneratorModule.hpp"
      18              : #include "appmodel/NetworkConnectionDescriptor.hpp"
      19              : #include "appmodel/NetworkConnectionRule.hpp"
      20              : #include "appmodel/QueueConnectionRule.hpp"
      21              : #include "appmodel/QueueDescriptor.hpp"
      22              : #include "appmodel/SourceIDConf.hpp"
      23              : #include "appmodel/appmodelIssues.hpp"
      24              : #include "conffwk/Configuration.hpp"
      25              : #include "confmodel/Connection.hpp"
      26              : #include "confmodel/NetworkConnection.hpp"
      27              : #include "confmodel/Service.hpp"
      28              : #include "logging/Logging.hpp"
      29              : #include "oks/kernel.hpp"
      30              : 
      31              : #include <iostream>
      32              : #include <string>
      33              : #include <vector>
      34              : 
      35              : namespace dunedaq {
      36              : namespace appmodel {
      37              : 
      38              : void
      39            0 : FakeHSIApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> helper) const
      40              : {
      41            0 :   std::vector<const confmodel::DaqModule*> modules;
      42              : 
      43            0 :   ConfigObjectFactory obj_fac(this);
      44              : 
      45            0 :   auto dlhConf = get_link_handler();
      46            0 :   auto dlhClass = dlhConf->get_template_for();
      47              : 
      48              :   // 23-Sep-2025, KAB et al: prevent a mis-configuration of the system in which the
      49              :   // FakeHSI DLH is told to generate TimeSync messages. (TimeSync messages should only
      50              :   // be sent from Readout DLH modules so that we don't get confusing system behavior.)
      51            0 :   if (dlhConf->get_generate_timesync()) {
      52            0 :     throw(BadConf(ERS_HERE, "TimeSync generation is enabled for a FakeHSIApplication and this is not allowed"));
      53              :   }
      54              : 
      55            0 :   const QueueDescriptor* dlhInputQDesc = nullptr;
      56              : 
      57            0 :   for (auto rule : get_queue_rules()) {
      58            0 :     auto destination_class = rule->get_destination_class();
      59            0 :     auto data_type = rule->get_descriptor()->get_data_type();
      60            0 :     if (destination_class == "DataHandlerModule" || destination_class == dlhClass) {
      61            0 :       dlhInputQDesc = rule->get_descriptor();
      62              :     }
      63            0 :   }
      64              : 
      65            0 :   const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr;
      66            0 :   const NetworkConnectionDescriptor* tsNetDesc = nullptr;
      67            0 :   const NetworkConnectionDescriptor* hsiNetDesc = nullptr;
      68              : 
      69            0 :   for (auto rule : get_network_rules()) {
      70            0 :     auto endpoint_class = rule->get_endpoint_class();
      71            0 :     auto data_type = rule->get_descriptor()->get_data_type();
      72              : 
      73            0 :     if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) {
      74            0 :       if (data_type == "TimeSync") {
      75            0 :         tsNetDesc = rule->get_descriptor();
      76              :       }
      77            0 :       if (data_type == "DataRequest") {
      78            0 :         dlhReqInputNetDesc = rule->get_descriptor();
      79              :       }
      80              :     }
      81            0 :     if (data_type == "HSIEvent") {
      82            0 :       hsiNetDesc = rule->get_descriptor();
      83              :     }
      84            0 :   }
      85              : 
      86            0 :   auto rdrConf = get_generator();
      87            0 :   if (rdrConf == 0) {
      88              :     throw(BadConf(ERS_HERE, "No FakeHSIEventGeneratorModule configuration given"));
      89              :   }
      90            0 :   if (dlhInputQDesc == nullptr) {
      91            0 :     throw(BadConf(ERS_HERE, "No DLH data input queue descriptor given"));
      92              :   }
      93            0 :   if (dlhReqInputNetDesc == nullptr) {
      94            0 :     throw(BadConf(ERS_HERE, "No DLH request input network descriptor given"));
      95              :   }
      96            0 :   if (hsiNetDesc == nullptr) {
      97            0 :     throw(BadConf(ERS_HERE, "No HSIEvent output network descriptor given"));
      98              :   }
      99              : 
     100            0 :   auto idconf = get_source_id();
     101            0 :   if (idconf == nullptr) {
     102            0 :     throw(BadConf(ERS_HERE, "No SourceIDConf given"));
     103              :   }
     104            0 :   auto id = idconf->get_sid();
     105              : 
     106            0 :   auto det_id =
     107              :     1; // TODO Eric Flumerfelt <eflumerf@fnal.gov>, 08-Feb-2024: This is a magic number corresponding to kDAQ
     108            0 :   std::string uid("DLH-" + std::to_string(id));
     109            0 :   TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id;
     110            0 :   conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid);
     111            0 :   dlhObj.set_by_val<uint32_t>("source_id", id);
     112            0 :   dlhObj.set_by_val<uint32_t>("detector_id", det_id);
     113            0 :   dlhObj.set_by_val<bool>("post_processing_enabled", false);
     114            0 :   dlhObj.set_obj("module_configuration", &dlhConf->config_object());
     115              : 
     116              :   // Process special Network rules!
     117              :   // Looking for Fragment rules from DFAppplications in current Session
     118            0 :   std::vector<conffwk::ConfigObject> fragOutObjs;
     119            0 :   for (auto [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) {
     120            0 :     fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid));
     121            0 :   }
     122              : 
     123              :   // start building the list of outputs
     124            0 :   std::vector<const conffwk::ConfigObject*> fh_output_objs;
     125            0 :   for (auto& fNet : fragOutObjs) {
     126            0 :     fh_output_objs.push_back(&fNet);
     127              :   }
     128              : 
     129              :   // Time Sync network connection
     130            0 :   if (dlhConf->get_generate_timesync()) {
     131            0 :     conffwk::ConfigObject tsNetObj = obj_fac.create_net_obj(tsNetDesc, std::to_string(id));
     132            0 :     fh_output_objs.push_back(&tsNetObj);
     133            0 :   }
     134            0 :   dlhObj.set_objs("outputs", fh_output_objs);
     135              : 
     136            0 :   conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id);
     137            0 :   conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(dlhReqInputNetDesc, UID());
     138              : 
     139            0 :   dlhObj.set_objs("inputs", { &queueObj, &faNetObj });
     140              : 
     141            0 :   modules.push_back(obj_fac.get_dal<DataHandlerModule>(uid));
     142              : 
     143            0 :   auto hsiServiceObj = hsiNetDesc->get_associated_service()->config_object();
     144            0 :   conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, "");
     145              : 
     146            0 :   std::string genuid("FakeHSI-" + std::to_string(id));
     147            0 :   conffwk::ConfigObject fakehsiObj = obj_fac.create("FakeHSIEventGeneratorModule", genuid);
     148            0 :   fakehsiObj.set_obj("configuration", &rdrConf->config_object());
     149            0 :   fakehsiObj.set_objs("outputs", { &queueObj, &hsiNetObj });
     150            0 :   if (tsNetDesc != nullptr) {
     151            0 :     conffwk::ConfigObject tsNetObjIn = obj_fac.create_net_obj(tsNetDesc, ".*");
     152            0 :     fakehsiObj.set_objs("inputs", { &tsNetObjIn });
     153            0 :   }
     154              : 
     155            0 :   modules.push_back(obj_fac.get_dal<FakeHSIEventGeneratorModule>(genuid));
     156              : 
     157            0 :   obj_fac.update_modules(modules);
     158            0 : }
     159              : 
     160              : } // namespace appmodel
     161              : } // namespace dunedaq
        

Generated by: LCOV version 2.0-1