DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
AbstractProcessor.hpp
Go to the documentation of this file.
1
9#ifndef TPGLIBS_ABSTRACTPROCESSOR_HPP_
10#define TPGLIBS_ABSTRACTPROCESSOR_HPP_
11
12#include <cstdint>
13#include <nlohmann/json.hpp>
14#include <memory>
15
19
20namespace tpglibs {
21
26template <class T>
29 std::shared_ptr<AbstractProcessor<T>> m_next_processor;
30
31 protected:
34
35 // Sample counting and collection control
36 std::atomic<uint64_t> m_samples{0};
38 uint64_t m_sample_period{1};
39
40 public:
42 using signal_type_t = T;
43
44 virtual ~AbstractProcessor() = default;
45
49
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
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) {
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
111};
112
113} // namespace tpglibs
114
115#endif // TPGLIBS_ABSTRACTPROCESSOR_HPP_
Abstract signal processor.
ProcessorInternalStateBufferManager< T > m_internal_state_buffer_manager
ProcessorInternalStateBufferManager< T > * _get_internal_state_buffer_manager()
std::atomic< uint64_t > m_samples
T signal_type_t
Signal type to process on. General __m256i.
virtual T process(const T &signal)
Simple signal pass-through.
virtual ~AbstractProcessor()=default
ProcessorInternalStateNameRegistry< T > m_internal_state_name_registry
virtual ProcessorMetricArray< std::array< int16_t, 16 > > read_internal_states_as_integer_array()
ProcessorInternalStateNameRegistry< T > * _get_internal_state_name_registry()
virtual void configure_internal_state_collection(const nlohmann::json &config)
Configure common internal state collection parameters.
virtual std::vector< std::string > get_requested_internal_state_names() const
Get the names of requested internal states (delegates to registry).
std::shared_ptr< AbstractProcessor< T > > m_next_processor
Points to next processor in the chain.
virtual void configure(const nlohmann::json &config, const int16_t *plane_numbers)=0
Pure virtual function that will configure the processor using plane numbers.
void set_next_processor(std::shared_ptr< AbstractProcessor< T > > next_processor)
Setter for next processor.
std::shared_ptr< AbstractProcessor< T > > get_next_processor()
Getter for next processor.
Manages the internal state storage buffers for a processor.
Dynamic array of processor metrics, templated on signal type.