Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fae8ad8
Add new class ConfigurationHelper with a private Session pointer and …
gcrone Feb 20, 2025
7c1af59
Tidy up, remove commented out code
gcrone Feb 20, 2025
105c379
Update SmartDaqApplication.md
gcrone Feb 26, 2025
59c270a
Merge branch 'develop' into gcrone/private-session
gcrone Apr 29, 2025
a507614
Simplify derived classes method implementations, only
gcrone Apr 29, 2025
e6d9ee2
Also simplify method implementation in other schema files
gcrone Apr 29, 2025
9b7719e
Merge branch 'develop' into gcrone/private-session2
gcrone Jan 26, 2026
c1b960b
Rename enabled is_enabled and add is_disabled to helper class. Check …
gcrone Jan 26, 2026
457a458
Set source ids for non readout apps and simplify name of local function
gcrone Jan 27, 2026
ec0321d
Tidy up - remove redundant includes
gcrone Jan 27, 2026
d4d3913
Make sure only enabled streams returned by get_stream_source_ids
gcrone Jan 28, 2026
dad784a
More tidying up removing redundant includes
gcrone Jan 28, 2026
ea25250
Merge with develop
mroda88 Feb 18, 2026
f4d9ef9
Update for CIB application
mroda88 Feb 18, 2026
228def4
simplify name for CTB connections
mroda88 Feb 18, 2026
f8f7aa0
Merge pull request #273 from DUNE-DAQ/mroda/config_helper
gcrone Feb 18, 2026
dd54e59
Add new helper function to get source ids from any relationship, not …
gcrone Feb 18, 2026
745b6df
update for CTB
mroda88 Feb 26, 2026
2735999
fix compilation warning
mroda88 Feb 26, 2026
82b55ee
streamline the logic to avoid code duplication
mroda88 Feb 26, 2026
79ce60d
Merge pull request #276 from DUNE-DAQ/mroda/config_helper
mroda88 Feb 26, 2026
f2c5f4b
Merge branch 'develop' into gcrone/private-session
gcrone Feb 27, 2026
b165f71
Correct MLT logic for CTB
mroda88 Mar 2, 2026
57bffae
Merge pull request #277 from DUNE-DAQ/mroda/config_helper
gcrone Mar 2, 2026
7de297f
Add code to handle TPReplay
gcrone Mar 2, 2026
96b5793
Update internal ConfigurationHelper documentation
gcrone Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ find_package(Boost COMPONENTS unit_test_framework program_options REQUIRED)
daq_add_dal_library(application.schema.xml hermes.schema.xml fdmodules.schema.xml trigger.schema.xml wiec.schema.xml PDS.schema.xml tde.schema.xml CTB.schema.xml CIB.schema.xml
NAMESPACE dunedaq::appmodel DEP_PKGS confmodel
SOURCES
ConfigurationHelper.cpp
ConfigObjectFactory.cpp
CRTReaderApplication.cpp
CTBApplication.cpp
Expand All @@ -43,7 +44,7 @@ daq_add_dal_library(application.schema.xml hermes.schema.xml fdmodules.schema.xm
TRMonReqApplication.cpp
WIECApplication.cpp
CIBApplication.cpp
LINK_LIBRARIES conffwk::conffwk fmt::fmt logging::logging oks::oks ers::ers )
LINK_LIBRARIES confmodel::confmodel conffwk::conffwk fmt::fmt logging::logging oks::oks ers::ers )

daq_add_application(getAppsArguments get_apps_arguments.cxx
LINK_LIBRARIES confmodel::confmodel appmodel_dal conffwk::conffwk)
Expand Down
6 changes: 5 additions & 1 deletion docs/SmartDaqApplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ This section will use the "[DFOApplication](https://github.com/DUNE-DAQ/appmodel
Once instantiated at the start of `generate_modules`, it offers a set of methods to facilitate the creation of configurarion objects, queues and network connections.


### The generate_modules method

The boilerplate code above references a method called generate_modules() which you have to supply. The `confdb` and `dbfile` arguments are used to create configuration objects in the database (see below). The helper argument is a pointer to a helper object with methods for extracting configuration data not belonging to the current application.

### Creating a module

```C++
Expand Down Expand Up @@ -84,4 +88,4 @@ Once the fixed connections are retrieved using the network rules, the module's i

### Summary

These basic steps are repeated in all SmartDaqApplication instances, with differences depending on the specific applciation being implemented. The DFOApplication is one of the simplest applications in the system, but it demonstrates the basic logic followed by all SmartDaqApplications.
These basic steps are repeated in all SmartDaqApplication instances, with differences depending on the specific applciation being implemented. The DFOApplication is one of the simplest applications in the system, but it demonstrates the basic logic followed by all SmartDaqApplications.
130 changes: 130 additions & 0 deletions include/appmodel/ConfigurationHelper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/**
* @file ConfigurationHelper.hpp
*
* Define a helper class for SmartDaqApplication module generators
*
* This is part of the DUNE DAQ Software Suite, copyright 2023.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/
#ifndef APPMODEL_INCLUDE_CONFIGURATIONHELPER_HPP_
#define APPMODEL_INCLUDE_CONFIGURATIONHELPER_HPP_

#include <cstdint>
#include <map>
#include <string>
#include <utility>
#include <vector>

namespace dunedaq::confmodel {
class Session;
class Service;
} //namespace dunedaq::confmodel
namespace dunedaq::conffwk {
class DalObject;
} // namespace dunedaq::conffwk

namespace dunedaq::appmodel {
class NetworkConnectionDescriptor;
class SourceIDConf;

/// Helper class to extract information from Session object without
/// exposing the Session to user code
///
/// Provides methods that loop over all applications in the session
/// to get source IDs etc. avoiding the need for individual
/// application's code to access configuration objects of other
/// applications.
class ConfigurationHelper {
public:
explicit ConfigurationHelper(const confmodel::Session* ses)
: m_session(ses) {}


/// @brief Get the exposed Services of all network connections
/// with given data_type from all smart daq applications of given
/// class
///
/// @param app_class Dal class of applications to match
/// @param data_type Data type of network descriptor to match
///
/// @returns A vector of pointers to matching Services
std::vector<const confmodel::Service*> get_services(std::string app_class,
std::string data_type);


/// @brief Get all NetworkConnectionDescriptors with given
/// data_type from all applications of given type
///
/// @param data_type Data type to match in network descriptor
/// @param app_class Optional dal class name to match
///
/// @returns a vector of application uid / network descriptor pairs
std::vector<std::pair<std::string, const appmodel::NetworkConnectionDescriptor*>>
get_netdescriptors (
const std::string& data_type,
const std::string& app_class="");


/// @brief Get the source ids of all DetectorStreams in the Session
///
/// @returns A map of application uids to vectors of streams that
/// they contain
std::map<std::string, std::vector<uint32_t>> get_stream_source_ids();


/// @brief Get the source ids of all the TP streams in all
/// ReadoutApplications and TriggerApplications
///
/// @returns A map of application uids to vectors of contained
/// TP source ids
std::map<std::string, std::vector<const SourceIDConf*>>
get_tp_source_ids();


/// @brief Get list of uids of applications that match given type
///
/// @param app_class Class of applications to match
///
/// @returns A vector of uids of matching applications
std::vector<std::string> get_app_uids(std::string app_class="");


/// @brief Get list of source ids for applications that match
/// given type
///
/// @returns A map of application uids to application source ids
std::map<std::string, const SourceIDConf*> get_app_source_ids(
std::string app_class="");


/// @brief Get list of all source ids for applications that match
/// given type. Follows any single value SourceIDConf relationship
///
/// NB: Does not look at multi-value SourceIDConf relationships
///
/// @returns A map of application uids to maps relationship to contained
/// source ids
std::map<std::string, std::map<std::string, const SourceIDConf*>>
get_all_app_source_ids(std::string app_class="");


/// @brief Check the enabled state of the given item
///
/// @returns True if the object is not disabled
inline bool is_enabled(const conffwk::DalObject* item) {
return !is_disabled(item);
}

/// @brief Check the enabled state of the given item
///
/// @returns True if the object is disabled
bool is_disabled(const conffwk::DalObject* item);

private:
const confmodel::Session* m_session;
};

} //namespace dunedaq::appmodel

#endif // APPMODEL_INCLUDE_CONFIGURATIONHELPER_HPP_
13 changes: 12 additions & 1 deletion include/appmodel/appmodelIssues.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ namespace dunedaq {
"Method '" << method_name << "' was called but is not implemented in this class",
((std::string)method_name))

}

ERS_DECLARE_ISSUE(appmodel,
NotSmart,
"Object is not a SmartDaqApplication: " << obj,
((std::string)obj))

ERS_DECLARE_ISSUE(appmodel,
BadD2d,
"Contained object is not a DetectorToDaqConnection: " << obj,
((std::string)obj))

} // namespace dunedaq


#endif // APPDALISSUES_HPP
3 changes: 2 additions & 1 deletion pybindsrc/dal_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ namespace dunedaq::appmodel::python {
auto session =
const_cast<conffwk::Configuration&>(confdb).get<confmodel::Session>(session_id);

app->generate_modules(session);
auto helper = std::make_shared<ConfigurationHelper>(session);
app->generate_modules(helper);
std::vector<ObjectLocator> mods;
for (auto mod : app->get_modules()) {
mods.push_back({mod->UID(),mod->class_name()});
Expand Down
2 changes: 1 addition & 1 deletion schema/appmodel/CIB.schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<!-- generating methods -->
<method name="generate_modules" description="Generate DaqModule dal objects for streams of the application on the fly">
<method-implementation language="c++" prototype="void generate_modules(const confmodel::Session*) const override" body=""/>
<method-implementation language="c++" prototype="void generate_modules(std::shared_ptr&lt;appmodel::ConfigurationHelper&gt;) const override" body=""/>
</method>

<method name="contained_resources" description="">
Expand Down
2 changes: 1 addition & 1 deletion schema/appmodel/CTB.schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<relationship name="link_handler" class-type="DataHandlerConf" low-cc="one" high-cc="one" is-composite="no" is-exclusive="no" is-dependent="no"/>
<relationship name="LLT_source" description="The source ID of the smart application itself will be used for HLT. &#xA;We need an additional source of the LLT, and this is that. " class-type="SourceIDConf" low-cc="one" high-cc="one" is-composite="no" is-exclusive="no" is-dependent="no"/>
<method name="generate_modules" description="Generate DaqModule dal objects for streams of the application on the fly">
<method-implementation language="c++" prototype="void generate_modules(const confmodel::Session*) const override" body=""/>
<method-implementation language="c++" prototype="void generate_modules(std::shared_ptr&lt;appmodel::ConfigurationHelper&gt;) const override" body=""/>
</method>
<method name="get_sources" description="The CTB HSI has two sources, one for HLT and one for LLT. &#xA;This methods gets the right information in a way that makes easy to loop over the information">
<method-implementation language="C++" prototype="std::vector&lt;std::pair&lt;std::string, const appmodel::SourceIDConf*&gt;&gt; get_sources() const" body="return {{ &quot;HLT&quot;, get_source_id() }, &#xA; { &quot;LLT&quot;, get_LLT_source() }};"/>
Expand Down
3 changes: 1 addition & 2 deletions schema/appmodel/PDS.schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@
<relationship name="configuration" class-type="DaphneConf" low-cc="one" high-cc="one" is-composite="no" is-exclusive="no" is-dependent="no"/>
<relationship name="detector_connections" description="List of detector components controlled by this application" class-type="DetectorToDaqConnection" low-cc="zero" high-cc="many" is-composite="no" is-exclusive="no" is-dependent="no"/>
<relationship name="hermes_module_conf" class-type="HermesModuleConf" low-cc="zero" high-cc="one" is-composite="no" is-exclusive="no" is-dependent="no"/>

<method name="generate_modules" description="Generate DaqModule dal objects for streams of the application on the fly">
<method-implementation language="c++" prototype="void generate_modules(const confmodel::Session*) const override" body=""/>
<method-implementation language="c++" prototype="void generate_modules(std::shared_ptr&lt;appmodel::ConfigurationHelper&gt;) const override" body="BEGIN_HEADER_PROLOGUE&#xA;#include &quot;appmodel/ConfigurationHelper.hpp&quot;&#xA;END_HEADER_PROLOGUE"/>
</method>
<method name="contained_resources" description="">
<method-implementation language="c++" prototype="virtual std::vector&lt;const Resource*&gt; contained_resources() const override" body=""/>
Expand Down
Loading