15 static_assert(Capacity >= 1 && Capacity <= 64);
23 std::array<float, Capacity>
values{};
24 static constexpr std::size_t
capacity() noexcept {
29static_assert(std::is_trivially_copyable_v<ExternalInputFrame<1>>);
30static_assert(std::is_trivially_copyable_v<ExternalInputFrame<64>>);
61 if (policy.source_id != 0 && frame.source_id != policy.source_id) {
62 ++counters_.rejected_source;
65 if (has_seen_ && frame.epoch == epoch_ && frame.sequence == sequence_) {
66 ++counters_.unchanged;
70 if (has_seen_ && (frame.epoch < epoch_ || (frame.epoch == epoch_ &&
71 (frame.sequence <= sequence_ ||
72 frame.provider_time_ns < provider_time_ns_)))) {
73 ++counters_.rejected_order;
77 last_status_ = frame.status;
78 advance_watermark(frame);
80 ++counters_.rejected_status;
83 if (frame.count == 0 || frame.count > Capacity ||
84 (policy.expected_count != 0 && frame.count != policy.expected_count) ||
85 !std::isfinite(frame.confidence)) {
86 ++counters_.rejected_malformed;
89 for (std::size_t i = 0; i < frame.count; ++i) {
90 if (!std::isfinite(frame.values[i])) {
91 ++counters_.rejected_malformed;
95 if (frame.confidence < 0.0f || frame.confidence > 1.0f ||
96 frame.confidence < policy.minimum_confidence) {
97 ++counters_.rejected_confidence;
100 values_ = frame.values;
101 count_ = frame.count;
103 advance_watermark(frame);
105 last_status_ = frame.status;
106 ++counters_.accepted;
107 if (frame.epoch != prior_epoch_) {
109 prior_epoch_ = frame.epoch;
115 if (!has_frame_ || policy.max_age_samples == 0)
117 age_samples_ = (UINT64_MAX - age_samples_ < samples) ? UINT64_MAX : age_samples_ + samples;
118 if (age_samples_ >= policy.max_age_samples) {
133 std::span<const float>
values() const noexcept {
134 return {values_.data(),
static_cast<std::size_t
>(has_frame_ ? count_ : 0)};
136 float value(std::size_t index,
float fallback)
const noexcept {
137 return has_frame_ && index < count_ ? values_[index] : fallback;
139 std::uint32_t
epoch() const noexcept {
159 void advance_watermark(
const Frame& frame)
noexcept {
161 epoch_ = frame.epoch;
162 sequence_ = frame.sequence;
163 provider_time_ns_ = frame.provider_time_ns;
165 std::array<float, Capacity> values_{};
166 ExternalInputCounters counters_{};
168 std::uint32_t epoch_ = 0, prior_epoch_ = 0;
169 std::uint64_t sequence_ = 0, provider_time_ns_ = 0, age_samples_ = 0;
170 std::uint8_t count_ = 0;
171 bool has_frame_ =
false;
172 bool has_seen_ =
false;
Definition generated_event_source.hpp:33
ExternalInputFrame< 1 > ExternalInputScalar
Definition external_input.hpp:31
ExternalInputVerdict
Definition external_input.hpp:40
@ rejected_malformed
Definition external_input.hpp:46
@ rejected_source
Definition external_input.hpp:44
@ accepted
Definition external_input.hpp:41
@ rejected_status
Definition external_input.hpp:43
@ rejected_order
Definition external_input.hpp:45
@ unchanged
Definition external_input.hpp:42
@ rejected_confidence
Definition external_input.hpp:47
ExternalInputStatus
Definition external_input.hpp:12
@ unavailable
Definition external_input.hpp:12
@ denied
Definition external_input.hpp:12
@ valid
Definition external_input.hpp:12
@ paused
Definition external_input.hpp:12
@ invalid
Definition external_input.hpp:12