ChimeraTK-ApplicationCore 04.07.01
Loading...
Searching...
No Matches
StatusAggregator.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include "ApplicationModule.h"
6#include "ModuleGroup.h"
7#include "StatusAccessor.h"
8#include "StatusWithMessage.h"
9#include "VoidAccessor.h"
10
11#include <list>
12#include <string>
13#include <vector>
14
15namespace ChimeraTK {
16
17 /********************************************************************************************************************/
18
41 enum class PriorityMode {
42 fwok,
43 fwko,
45 ofwk
46 };
47
72 StatusAggregator(ModuleGroup* owner, const std::string& outputName, const std::string& description,
73 PriorityMode mode = PriorityMode::fwok, std::unordered_set<std::string> tagsToAggregate = {},
74 const std::unordered_set<std::string>& outputTags = {},
75 std::string warnMixedMessage = "warning - StatusAggregator inputs have mixed values");
76
78 StatusAggregator() = default;
80
81 void mainLoop() override;
82
83 DataValidity getDataValidity() const override;
84
87 void setWarnMixedMessage(std::string message);
88
89 protected:
92
95 constexpr static auto tagAggregatedStatus = "_ChimeraTK_StatusAggregator_aggregatedStatus";
96
98 constexpr static auto tagInternalVars = "_ChimeraTK_StatusAggregator_internalVars";
99
102
104 std::vector<StatusWithMessageInput> _inputs;
105
108
110 std::unordered_set<std::string> _tagsToAggregate;
111
115 int getPriority(StatusOutput::Status status) const;
116
118 VoidInput _debug{this, "/Debug/statusAggregators", "Print debug info for all status aggregators once."};
119
121 std::string _warnMixedMessage;
122 };
123
124 /********************************************************************************************************************/
125
126} // namespace ChimeraTK
Convenience class for input accessors.
InvalidityTracer application module.
The StatusAggregator collects results of multiple StatusMonitor instances and aggregates them into a ...
StatusAggregator & operator=(StatusAggregator &&other)=default
VoidInput _debug
Allow runtime debugging.
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
PriorityMode
Possible status priority modes used during aggregation of unequal Status values.
@ fw_warn_mixed
fault - warning - ok or off, mixed state of ok or off results in warning
@ ofwk
off - fault - warning - ok
@ fwko
fault - warning - ok - off
@ fwok
fault - warning - off - ok
void populateStatusInput()
Recursivly search for StatusMonitors and other StatusAggregators.
void setWarnMixedMessage(std::string message)
Set a custom message for the warn mixed state.
StatusAggregator(StatusAggregator &&other)=default
std::vector< StatusWithMessageInput > _inputs
All status inputs to be aggregated.
int getPriority(StatusOutput::Status status) const
Convert Status value into a priority (high integer value = high priority), depending on chosen Priori...
PriorityMode _mode
Priority mode used in aggregation.
StatusWithMessage _output
The aggregated status output.
DataValidity getDataValidity() const override
Return the data validity flag.
std::string _warnMixedMessage
Error message for the warn_mixed condition.
static constexpr auto tagInternalVars
Reserved tag which is used to mark internal variables which should not be visible in the virtual hier...
std::unordered_set< std::string > _tagsToAggregate
List of tags to aggregate.
static constexpr auto tagAggregatedStatus
Reserved tag which is used to mark aggregated status outputs (need to stop searching further down the...
A VariableGroup for error status and message reporting.