LCOV - code coverage report
Current view: top level - appmodel/src - TRMonReqApplication.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 52 0
Test Date: 2026-03-29 15:29:34 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /**
       2              :  * @file TRMonReqApplication.cpp
       3              :  *
       4              :  * Implementation of TRMonReqApplication'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/TRMonReqApplication.hpp"
      12              : #include "ConfigObjectFactory.hpp"
      13              : #include "appmodel/DataStoreConf.hpp"
      14              : #include "appmodel/DataWriterConf.hpp"
      15              : #include "appmodel/DataWriterModule.hpp"
      16              : #include "appmodel/FilenameParams.hpp"
      17              : #include "appmodel/NetworkConnectionDescriptor.hpp"
      18              : #include "appmodel/NetworkConnectionRule.hpp"
      19              : #include "appmodel/QueueConnectionRule.hpp"
      20              : #include "appmodel/QueueDescriptor.hpp"
      21              : #include "appmodel/TRMonRequestorConf.hpp"
      22              : #include "appmodel/TRMonRequestorModule.hpp"
      23              : #include "appmodel/appmodelIssues.hpp"
      24              : 
      25              : #include "conffwk/Configuration.hpp"
      26              : 
      27              : #include "confmodel/Connection.hpp"
      28              : #include "confmodel/DetectorStream.hpp"
      29              : #include "confmodel/DetectorToDaqConnection.hpp"
      30              : #include "confmodel/NetworkConnection.hpp"
      31              : #include "confmodel/Service.hpp"
      32              : 
      33              : #include "logging/Logging.hpp"
      34              : #include "oks/kernel.hpp"
      35              : 
      36              : #include <fmt/core.h>
      37              : #include <string>
      38              : #include <vector>
      39              : 
      40              : namespace dunedaq {
      41              : namespace appmodel {
      42              : 
      43              : void
      44            0 : TRMonReqApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> helper) const
      45              : {
      46              : 
      47            0 :   ConfigObjectFactory obj_fac(this);
      48              : 
      49            0 :   std::vector<const confmodel::DaqModule*> modules;
      50              : 
      51              :   // Containers for module specific config objects for output/input
      52            0 :   std::vector<const conffwk::ConfigObject*> trmrOutputObjs;
      53              : 
      54              :   // -- First, we process expected Queue and Network connections and create their objects.
      55              : 
      56              :   // Process the queue rules looking for the TriggerDecisionToken queue between DataWriterModule and TRMonRequestor
      57            0 :   const QueueDescriptor* tdtQDesc = nullptr;
      58            0 :   for (auto rule : get_queue_rules()) {
      59            0 :     auto destination_class = rule->get_destination_class();
      60            0 :     if (destination_class == "TRMonRequestorModule") {
      61            0 :       tdtQDesc = rule->get_descriptor();
      62              :     }
      63            0 :   }
      64            0 :   if (tdtQDesc == nullptr) { // BadConf if no descriptor between DataWriterModule and TRMonRequestor
      65            0 :     throw(BadConf(ERS_HERE, "Could not find queue descriptor rule for TriggerDecisionTokens!"));
      66              :   }
      67              :   // Create queue connection config object
      68            0 :   auto tdtQueueObj = obj_fac.create_queue_obj(tdtQDesc, UID());
      69              : 
      70              :   // Process the network rules looking for the TriggerRecord input for the DataWriter
      71            0 :   const NetworkConnectionDescriptor* dwNetDesc = nullptr;
      72            0 :   for (auto rule : get_network_rules()) {
      73            0 :     auto descriptor = rule->get_descriptor();
      74            0 :     auto data_type = descriptor->get_data_type();
      75            0 :     if (data_type == "TriggerRecord") {
      76            0 :       dwNetDesc = rule->get_descriptor();
      77              :     }
      78            0 :   }
      79            0 :   if (dwNetDesc == nullptr) { // BadConf if no descriptor for TriggerRecords into DW
      80            0 :     throw(BadConf(ERS_HERE, "Could not find network descriptor rule for input TriggerRecords!"));
      81              :   }
      82              :   // Create network connection config object
      83            0 :   auto dwInputObj = obj_fac.create_net_obj(dwNetDesc, "");
      84              : 
      85              :   // Create network connections for all DFApplications in session
      86            0 :   std::vector<conffwk::ConfigObject> trmonreqNetObjs;
      87            0 :   for (auto [uid, descriptor]:
      88            0 :          helper->get_netdescriptors("TRMonRequest", "DFApplication")) {
      89            0 :     trmonreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid));
      90            0 :   }    
      91              : 
      92              :   // Get pointers to objects here, after vector has been filled so they don't move on us
      93            0 :   for (auto& obj : trmonreqNetObjs) {
      94            0 :     trmrOutputObjs.push_back(&obj);
      95              :   }
      96              : 
      97              :   // -- Second, we create the Module objects and assign their configs, with the precreated
      98              :   // -- connection config objects above.
      99              : 
     100              :   // Get TRB Config Object
     101            0 :   auto trmrConf = get_trmonreq();
     102            0 :   if (trmrConf == nullptr) {
     103              :     throw(BadConf(ERS_HERE, "No TRMonRequestor configuration given"));
     104              :   }
     105            0 :   auto trmrConfObj = trmrConf->config_object();
     106              :   // Prepare TRMR Module Object and assign its Config Object.
     107            0 :   std::string trmrUid(UID() + "-trmr");
     108            0 :   conffwk::ConfigObject trmrObj = obj_fac.create("TRMonRequestorModule", trmrUid);
     109            0 :   trmrObj.set_obj("configuration", &trmrConfObj);
     110            0 :   trmrObj.set_objs("inputs", { &tdtQueueObj });
     111            0 :   trmrObj.set_objs("outputs", trmrOutputObjs);
     112            0 :   trmrObj.set_obj("trigger_record_destination", &dwInputObj);
     113              :   // Push TRMR Module Object from confdb
     114            0 :   modules.push_back(obj_fac.get_dal<TRMonRequestorModule>(trmrUid));
     115              : 
     116              :   // Get DataWriterModule Config Object (only one for now, maybe more later?)
     117            0 :   auto dwrConf = get_data_writer();
     118            0 :   if (dwrConf == nullptr) {
     119              :     throw(BadConf(ERS_HERE, "No DataWriterModule configuration given"));
     120              :   }
     121              : 
     122            0 :   auto dwrConfObj = dwrConf->config_object();
     123              : 
     124              :   // Prepare DataWriterModule Module Object and assign its Config Object.
     125            0 :   std::string dwrUid(fmt::format("{}-dw", UID()));
     126            0 :   conffwk::ConfigObject dwrObj = obj_fac.create("DataWriterModule", dwrUid);
     127            0 :   dwrObj.set_by_val("writer_identifier", fmt::format("{}_dw", UID()));
     128            0 :   dwrObj.set_obj("configuration", &dwrConfObj);
     129            0 :   dwrObj.set_objs("inputs", { &dwInputObj });
     130            0 :   dwrObj.set_objs("outputs", { &tdtQueueObj });
     131              :   // Push DataWriterModule Module Object from confdb
     132            0 :   modules.push_back(obj_fac.get_dal<DataWriterModule>(dwrUid));
     133              : 
     134            0 :   obj_fac.update_modules(modules);
     135            0 : }
     136              : 
     137              : } // namespace appmodel
     138              : } // namespace dunedaq
        

Generated by: LCOV version 2.0-1