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

Generated by: LCOV version 2.0-1