LCOV - code coverage report
Current view: top level - appmodel/src - DTSHSIApplication.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 66 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /**
       2              :  * @file DFO.cpp
       3              :  *
       4              :  * Implementation of Dune Timing System HSIApplication'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              : 
      12              : #include "ConfigObjectFactory.hpp"
      13              : #include "appmodel/DTSHSIApplication.hpp"
      14              : #include "appmodel/NetworkConnectionDescriptor.hpp"
      15              : #include "appmodel/NetworkConnectionRule.hpp"
      16              : #include "appmodel/QueueConnectionRule.hpp"
      17              : #include "appmodel/QueueDescriptor.hpp"
      18              : #include "appmodel/DataHandlerModule.hpp"
      19              : #include "appmodel/DataHandlerConf.hpp"
      20              : #include "appmodel/SourceIDConf.hpp"
      21              : #include "appmodel/HSIReadout.hpp"
      22              : #include "appmodel/HSIReadoutConf.hpp"
      23              : #include "appmodel/appmodelIssues.hpp"
      24              : #include "confmodel/Connection.hpp"
      25              : #include "confmodel/NetworkConnection.hpp"
      26              : #include "confmodel/Service.hpp"
      27              : #include "logging/Logging.hpp"
      28              : #include "conffwk/Configuration.hpp"
      29              : 
      30              : #include <iostream>
      31              : #include <string>
      32              : #include <vector>
      33              : 
      34              : namespace dunedaq {
      35              : namespace appmodel {
      36              : 
      37              : void
      38            0 : DTSHSIApplication::generate_modules(const confmodel::Session* /*session*/) const
      39              : {
      40            0 :   ConfigObjectFactory obj_fac(this);
      41              :   
      42            0 :   std::vector<const confmodel::DaqModule*> modules;
      43              : 
      44            0 :   auto dlhConf = get_link_handler();
      45            0 :   auto dlhClass = dlhConf->get_template_for();
      46              : 
      47            0 :   const QueueDescriptor* dlhInputQDesc = nullptr;
      48              : 
      49            0 :   for (auto rule : get_queue_rules()) {
      50            0 :     auto destination_class = rule->get_destination_class();
      51            0 :     auto data_type = rule->get_descriptor()->get_data_type();
      52            0 :     if (destination_class == "DataHandlerModule" || destination_class == dlhClass) {
      53            0 :       dlhInputQDesc = rule->get_descriptor();
      54              :     }
      55            0 :   }
      56              : 
      57            0 :   const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr;
      58            0 :   const NetworkConnectionDescriptor* tsNetDesc = nullptr;
      59            0 :   const NetworkConnectionDescriptor* hsiNetDesc = nullptr;
      60              : 
      61            0 :   for (auto rule : get_network_rules()) {
      62            0 :     auto endpoint_class = rule->get_endpoint_class();
      63            0 :     auto data_type = rule->get_descriptor()->get_data_type();
      64              : 
      65            0 :     if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) {
      66            0 :       if (data_type == "TimeSync") {
      67            0 :         tsNetDesc = rule->get_descriptor();
      68              :       }
      69            0 :       if (data_type == "DataRequest") {
      70            0 :         dlhReqInputNetDesc = rule->get_descriptor();
      71              :       }
      72              :     }
      73            0 :     if (data_type == "HSIEvent") {
      74            0 :       hsiNetDesc = rule->get_descriptor();
      75              :     }
      76            0 :   }
      77              : 
      78            0 :   auto rdrConf = get_generator();
      79            0 :   if (rdrConf == 0) {
      80            0 :     throw(BadConf(ERS_HERE, "No HSIEventGeneratorModule configuration given"));
      81              :   }
      82            0 :   if (dlhInputQDesc == nullptr) {
      83            0 :     throw(BadConf(ERS_HERE, "No DLH data input queue descriptor given"));
      84              :   }
      85            0 :   if (dlhReqInputNetDesc == nullptr) {
      86            0 :     throw(BadConf(ERS_HERE, "No DLH request input network descriptor given"));
      87              :   }
      88            0 :   if (hsiNetDesc == nullptr) {
      89            0 :     throw(BadConf(ERS_HERE, "No HSIEvent output network descriptor given"));
      90              :   }
      91              : 
      92            0 :   auto idconf = get_source_id();
      93            0 :   if (idconf == nullptr) {
      94            0 :     throw(BadConf(ERS_HERE, "No SourceIDConf given"));
      95              :   }
      96            0 :   auto id = idconf->get_sid();
      97              : 
      98            0 :   auto det_id = 1; // TODO Eric Flumerfelt <eflumerf@fnal.gov>, 08-Feb-2024: This is a magic number corresponding to kDAQ
      99            0 :   std::string uid("DLH-" + std::to_string(id));
     100            0 :   TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id;
     101            0 :   conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid);
     102            0 :   dlhObj.set_by_val<uint32_t>("source_id", id);
     103            0 :   dlhObj.set_by_val<uint32_t>("detector_id", det_id);
     104            0 :   dlhObj.set_by_val<bool>("post_processing_enabled", false);
     105            0 :   dlhObj.set_obj("module_configuration", &dlhConf->config_object());
     106              : 
     107              :   // Time Sync network connection
     108            0 :   if (dlhConf->get_generate_timesync()) {
     109            0 :     auto tsServiceObj = tsNetDesc->get_associated_service()->config_object();
     110            0 :     auto tsNetObj = obj_fac.create_net_obj(tsNetDesc, std::to_string(id));
     111              : 
     112            0 :     dlhObj.set_objs("outputs", { &tsNetObj });
     113            0 :   } else {
     114            0 :     dlhObj.set_objs("outputs", {});
     115              :   }
     116            0 :   conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc,id);
     117            0 :   conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(dlhReqInputNetDesc, UID());
     118            0 :   dlhObj.set_objs("inputs", { &queueObj, &faNetObj });
     119              : 
     120            0 :   modules.push_back(obj_fac.get_dal<DataHandlerModule>(uid));
     121              : 
     122            0 :   auto hsiServiceObj = hsiNetDesc->get_associated_service()->config_object();
     123            0 :   conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, "");
     124              :   
     125            0 :   std::string genuid("HSI-" + std::to_string(id));
     126            0 :   conffwk::ConfigObject hsiObj = obj_fac.create("HSIReadout", genuid);
     127            0 :   hsiObj.set_obj("configuration", &rdrConf->config_object());
     128            0 :   hsiObj.set_objs("outputs", { &queueObj, &hsiNetObj });
     129              : 
     130            0 :   modules.push_back(obj_fac.get_dal<HSIReadout>(genuid));
     131              : 
     132            0 :   obj_fac.update_modules(modules);
     133            0 : }
     134              :  
     135              : } // namespace appmodel  
     136              : } // namespace dunedaq
        

Generated by: LCOV version 2.0-1