DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
list_apps.cxx
Go to the documentation of this file.
1#include "logging/Logging.hpp"
2
4
10
11#include <iostream>
12// #include <set>
13#include <string>
14
15using namespace dunedaq;
16using namespace dunedaq::confmodel;
17
18void
20 const Segment* segment,
21 const std::set<std::string>& excluded_objects,
22 std::string spacer)
23{
24 std::cout << spacer << "Segment " << segment->UID();
25 bool segment_excluded = segment->is_excluded(*session);
26 std::string reason = "";
27 if (segment_excluded) {
28 std::cout << " excluded";
29 reason = "segment";
30 }
31 std::cout << "\n";
32 for (auto subseg : segment->get_segments()) {
33 process_segment(session, subseg, excluded_objects, spacer + " ");
34 }
35
36 for (auto app : segment->get_applications()) {
37 bool excluded = segment_excluded;
38 std::cout << spacer << " Application: " << app->UID();
39 if (!excluded) {
40 auto rset = app->cast<ExcludableEntitySet>();
41 if (rset) {
42 if (rset->is_excluded(*session)) {
43 excluded = true;
44 if (excluded_objects.find(app->UID()) != excluded_objects.end()) {
45 reason = "directly";
46 } else {
47 reason = "due to state of related objects";
48 }
49 }
50 std::cout << " contains: {";
51 std::string seperator = "";
52 for (auto mod : rset->contained_excludable_entities()) {
53 std::cout << seperator << mod->UID();
54 if (mod->is_excluded(*session)) {
55 std::cout << "<excluded ";
56 if (excluded_objects.find(mod->UID()) == excluded_objects.end()) {
57 std::cout << "in";
58 }
59 std::cout << "directly>";
60 }
61 seperator = ", ";
62 }
63 std::cout << "}";
64 }
65 }
66 if (excluded) {
67 std::cout << " <excluded " << reason << ">";
68 }
69 auto daqApp = app->cast<DaqApplication>();
70 if (daqApp) {
71 std::cout << " Modules:";
72 for (auto mod : daqApp->get_modules()) {
73 std::cout << " " << mod->UID();
74 }
75 }
76
77 std::cout << std::endl;
78 }
79}
80
81int
82main(int argc, char* argv[])
83{
84
85 if (argc < 2) {
86 std::cout << "Usage: " << argv[0] << " [session] database-file\n";
87 return 0;
88 }
89
90 int filearg = 1;
91 if (argc == 3) {
92 filearg = 2;
93 }
94 std::string confimpl = "oksconflibs:" + std::string(argv[filearg]);
95 auto confdb = new conffwk::Configuration(confimpl);
96
97 std::vector<std::string> sessionList;
98 if (argc == 3) {
99 sessionList.emplace_back(std::string(argv[1]));
100 } else {
101 std::vector<conffwk::ConfigObject> session_obj;
102 confdb->get("Session", session_obj);
103 if (session_obj.size() == 0) {
104 std::cerr << "Can't find any Sessions in database\n";
105 return -1;
106 }
107 for (auto obj : session_obj) {
108 sessionList.push_back(obj.UID());
109 }
110 }
111 dunedaq::logging::Logging::setup(sessionList[0], "list-apps");
112
113 std::string separator{};
114 for (const auto& sessionName : sessionList) {
115 const Session* session;
116 session = confdb->get<Session>(sessionName);
117 if (session == nullptr) {
118 std::cerr << "Session " << sessionName << " not found in database\n";
119 return -1;
120 }
121
122 std::cout << separator << " Applications in Session: " << sessionName << "\n";
123 std::set<std::string> excluded_objects;
124 for (auto object : session->get_excluded()) {
125 TLOG_DEBUG(11) << object->UID() << " is in excluded list of Session";
126 excluded_objects.insert(object->UID());
127 }
128
129 process_segment(session, session->get_segment(), excluded_objects, "");
130 separator = "\n ----------------------------------------------\n\n";
131 }
132 delete confdb;
133}
const std::string & UID() const noexcept
bool is_excluded(const dunedaq::confmodel::ExcludableEntityTree &session) const
const std::vector< const dunedaq::confmodel::Segment * > & get_segments() const
Get "segments" relationship value. Nested list of Segments that form part of this Segment.
Definition Segment.hpp:114
const std::vector< const dunedaq::confmodel::Application * > & get_applications() const
Get "applications" relationship value. List of Applications that run in this Segment.
Definition Segment.hpp:141
static void setup(const std::string &session, const std::string &application)
Setup the Logger service Currently no args.
Definition Logging.hpp:31
conffwk entry point
int main(int argc, char *argv[])
void process_segment(const Session *session, const Segment *segment, const std::set< std::string > &excluded_objects, std::string spacer)
Definition list_apps.cxx:19
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
The DUNE-DAQ namespace.
msgpack::object obj