DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DisabledResources.cpp
Go to the documentation of this file.
6
9
10#include "logging/Logging.hpp"
11
13
14using namespace dunedaq::confmodel;
15
17
18
20 std::vector<const Resource*> initial_list)
21{
22 TLOG_DEBUG(2) << "construct the object from Resource " << root->UID() ;
23 update(root, initial_list);
24}
25
26
28 std::vector<const Resource*> initial_list) {
29
30 m_disabled.clear();
31
32 m_initialised = true;
33 if (initial_list.empty()) {
34 TLOG_DEBUG( 6) << "We have no disabled components";
35 return;
36 }
37
38 // get list of all root's resource-sets also test any
39 // circular dependencies between segments and resource sets
40 TestCircularDependency cd_fuse("component \'is-disabled\' status", root);
41 std::vector<const ResourceSet*> resource_sets;
42 fill(*root, resource_sets, cd_fuse);
43
44 for (auto & comp : initial_list) {
45 disable(*comp);
46 TLOG_DEBUG(6) << comp->UID() << " is disabled in session";
47 if (const ResourceSet * rs = comp->cast<ResourceSet>()) {
49 }
50 }
51
52 for (unsigned long count = 1; true; ++count) {
53 const unsigned long num(size()); // Remember current size
54
55 TLOG_DEBUG(6) << "before auto-disabling iteration " << count << " the number of disabled components is " << num ;
56 for (const auto& res_set : resource_sets) {
57 if (is_enabled(res_set)) {
58 if (res_set->compute_disabled_state(m_disabled)) {
59 TLOG_DEBUG(6) << "disable custom resource-set- " << res_set->UID() << " because children are disabled" ;
60 disable(*res_set);
61 disable_children(*res_set);
62 }
63 }
64 }
65
66 if (size() == num) {
67 TLOG_DEBUG(6) << "after " << count << " iteration(s) auto-disabling algorithm found no newly disabled sets, exiting loop ..." ;
68 break;
69 }
70
71 unsigned int iLimit(1000);
72 if (count > iLimit) {
73 ers::error(ReadMaxAllowedIterations(ERS_HERE, iLimit));
74 break;
75 }
76 }
77}
78
79// fill data from resource sets
81 std::vector<const ResourceSet*>& all_resource_sets,
83{
84 TLOG_DEBUG(6) << "rs.UID=" << rs.UID() << ", class=" << rs.class_name();
85 all_resource_sets.push_back(&rs);
86 auto rptr = &rs;
87 if (rptr->cast<Resource>() == nullptr) {
88 throw (MissingConstructor(ERS_HERE, "Resource", rs.full_name()));
89 }
90 for (auto & res : rs.contained_resources()) {
91 AddTestOnCircularDependency add_fuse_test(cd_fuse, res);
92 if (const ResourceSet * rs2 = res->cast<ResourceSet>()) {
93 fill(*rs2, all_resource_sets, cd_fuse);
94 }
95 }
96}
97
98
99
100void
102{
103 TLOG_DEBUG(6) << "Disabling children of " << rs.UID();
104 for (auto & res : rs.contained_resources()) {
105 TLOG_DEBUG(6) << "Disabling child " << res->UID();
106 disable(*res);
107 if (const auto * rs2 = res->cast<ResourceSet>()) {
108 disable_children(*rs2);
109 }
110 }
111}
112
#define ERS_HERE
std::string full_name() const noexcept
const TARGET * cast() const noexcept
Casts object to different class.
const std::string & class_name() const noexcept
const std::string & UID() const noexcept
bool is_enabled(const Resource *component) const
void update(const ResourceSet *root, std::vector< const Resource * > initial_list)
void fill(const ResourceSet &rs, std::vector< const ResourceSet * > &all_resource_sets, TestCircularDependency &cd_fuse)
void disable(const Resource &component)
virtual std::vector< const Resource * > contained_resources() const =0
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
void error(const Issue &issue)
Definition ers.hpp:81