DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
tpglibs
include
tpglibs
AbstractProcessor.hpp
Go to the documentation of this file.
1
8
9
#ifndef TPGLIBS_ABSTRACTPROCESSOR_HPP_
10
#define TPGLIBS_ABSTRACTPROCESSOR_HPP_
11
12
#include <cstdint>
13
#include <nlohmann/json.hpp>
14
#include <memory>
15
16
#include "
tpglibs/ProcessorMetricArray.hpp
"
17
#include "
tpglibs/ProcessorInternalStateBufferManager.hpp
"
18
#include "
tpglibs/ProcessorInternalStateNameRegistry.hpp
"
19
20
namespace
tpglibs
{
21
26
template
<
class
T>
27
class
AbstractProcessor
{
29
std::shared_ptr<AbstractProcessor<T>>
m_next_processor
;
30
31
protected
:
32
ProcessorInternalStateBufferManager<T>
m_internal_state_buffer_manager
;
33
ProcessorInternalStateNameRegistry<T>
m_internal_state_name_registry
;
34
35
// Sample counting and collection control
36
std::atomic<uint64_t>
m_samples
{0};
37
bool
m_collect_internal_state_flag
{
false
};
38
uint64_t
m_sample_period
{1};
39
40
public
:
42
using
signal_type_t
= T;
43
44
virtual
~AbstractProcessor
() =
default
;
45
46
ProcessorInternalStateBufferManager<T>
*
_get_internal_state_buffer_manager
() {
47
return
&
m_internal_state_buffer_manager
;
48
}
49
50
ProcessorInternalStateNameRegistry<T>
*
_get_internal_state_name_registry
() {
51
return
&
m_internal_state_name_registry
;
52
}
53
63
virtual
void
configure_internal_state_collection
(
const
nlohmann::json& config) {
64
m_collect_internal_state_flag
= config.value(
"metric_collect_toggle_state"
,
false
);
65
m_sample_period
= config.value(
"metric_collect_time_sample_period"
, 1);
66
67
if
(
m_collect_internal_state_flag
) {
68
if
(config.contains(
"requested_internal_states"
)) {
69
m_internal_state_name_registry
.parse_requested_internal_state_items(config[
"requested_internal_states"
]);
70
}
else
{
71
m_internal_state_name_registry
.parse_requested_internal_state_items(
""
);
72
}
73
74
// Only configure if we actually have states to collect
75
auto
num_items =
m_internal_state_name_registry
.get_number_of_requested_internal_states();
76
if
(num_items > 0) {
77
m_internal_state_buffer_manager
.configure_from_registry(&
m_internal_state_name_registry
);
78
}
79
}
80
}
81
83
virtual
void
configure
(
const
nlohmann::json& config,
const
int16_t* plane_numbers) = 0;
84
86
void
set_next_processor
(std::shared_ptr<
AbstractProcessor<T>
> next_processor) {
87
m_next_processor
= next_processor;
88
}
89
91
std::shared_ptr<AbstractProcessor<T>>
get_next_processor
() {
92
return
m_next_processor
;
93
}
94
96
virtual
T
process
(
const
T& signal) {
97
if
(
m_next_processor
) {
98
return
m_next_processor
->process(signal);
99
}
100
return
signal;
101
}
102
104
virtual
std::vector<std::string>
get_requested_internal_state_names
()
const
{
105
return
m_internal_state_name_registry
.get_names_of_requested_internal_states();
106
}
107
108
virtual
ProcessorMetricArray<std::array<int16_t, 16>
>
read_internal_states_as_integer_array
() {
109
return
m_internal_state_buffer_manager
.switch_buffer_and_read_casted();
110
}
111
};
112
113
}
// namespace tpglibs
114
115
#endif
// TPGLIBS_ABSTRACTPROCESSOR_HPP_
ProcessorInternalStateBufferManager.hpp
ProcessorInternalStateNameRegistry.hpp
ProcessorMetricArray.hpp
tpglibs::AbstractProcessor
Abstract signal processor.
Definition
AbstractProcessor.hpp:27
tpglibs::AbstractProcessor::m_internal_state_buffer_manager
ProcessorInternalStateBufferManager< T > m_internal_state_buffer_manager
Definition
AbstractProcessor.hpp:32
tpglibs::AbstractProcessor::_get_internal_state_buffer_manager
ProcessorInternalStateBufferManager< T > * _get_internal_state_buffer_manager()
Definition
AbstractProcessor.hpp:46
tpglibs::AbstractProcessor::m_samples
std::atomic< uint64_t > m_samples
Definition
AbstractProcessor.hpp:36
tpglibs::AbstractProcessor::signal_type_t
T signal_type_t
Signal type to process on. General __m256i.
Definition
AbstractProcessor.hpp:42
tpglibs::AbstractProcessor::process
virtual T process(const T &signal)
Simple signal pass-through.
Definition
AbstractProcessor.hpp:96
tpglibs::AbstractProcessor::~AbstractProcessor
virtual ~AbstractProcessor()=default
tpglibs::AbstractProcessor::m_internal_state_name_registry
ProcessorInternalStateNameRegistry< T > m_internal_state_name_registry
Definition
AbstractProcessor.hpp:33
tpglibs::AbstractProcessor::read_internal_states_as_integer_array
virtual ProcessorMetricArray< std::array< int16_t, 16 > > read_internal_states_as_integer_array()
Definition
AbstractProcessor.hpp:108
tpglibs::AbstractProcessor::_get_internal_state_name_registry
ProcessorInternalStateNameRegistry< T > * _get_internal_state_name_registry()
Definition
AbstractProcessor.hpp:50
tpglibs::AbstractProcessor::m_sample_period
uint64_t m_sample_period
Definition
AbstractProcessor.hpp:38
tpglibs::AbstractProcessor::configure_internal_state_collection
virtual void configure_internal_state_collection(const nlohmann::json &config)
Configure common internal state collection parameters.
Definition
AbstractProcessor.hpp:63
tpglibs::AbstractProcessor::get_requested_internal_state_names
virtual std::vector< std::string > get_requested_internal_state_names() const
Get the names of requested internal states (delegates to registry).
Definition
AbstractProcessor.hpp:104
tpglibs::AbstractProcessor::m_collect_internal_state_flag
bool m_collect_internal_state_flag
Definition
AbstractProcessor.hpp:37
tpglibs::AbstractProcessor::m_next_processor
std::shared_ptr< AbstractProcessor< T > > m_next_processor
Points to next processor in the chain.
Definition
AbstractProcessor.hpp:29
tpglibs::AbstractProcessor::configure
virtual void configure(const nlohmann::json &config, const int16_t *plane_numbers)=0
Pure virtual function that will configure the processor using plane numbers.
tpglibs::AbstractProcessor::set_next_processor
void set_next_processor(std::shared_ptr< AbstractProcessor< T > > next_processor)
Setter for next processor.
Definition
AbstractProcessor.hpp:86
tpglibs::AbstractProcessor::get_next_processor
std::shared_ptr< AbstractProcessor< T > > get_next_processor()
Getter for next processor.
Definition
AbstractProcessor.hpp:91
tpglibs::ProcessorInternalStateBufferManager
Manages the internal state storage buffers for a processor.
Definition
ProcessorInternalStateBufferManager.hpp:32
tpglibs::ProcessorInternalStateNameRegistry
Registry of internal state names.
Definition
ProcessorInternalStateNameRegistry.hpp:27
tpglibs
Definition
AbstractFactory.hpp:20
tpglibs::ProcessorMetricArray
Dynamic array of processor metrics, templated on signal type.
Definition
ProcessorMetricArray.hpp:19
Generated on
for DUNE-DAQ by
1.17.0