Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
To be checked if the handling of uncertain value is correct.

Signed-off-by: Alexander Krimm <[email protected]>
  • Loading branch information
wirew0rm committed Dec 3, 2024
1 parent 6df1d15 commit 0e521e5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions blocks/basic/include/gnuradio-4.0/basic/Trigger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ The information is stored (info only) in `trigger_name`, `trigger_time`, `trigge
template<typename U, gr::meta::fixed_string description = "", typename... Arguments>
using A = gr::Annotated<U, description, Arguments...>;
constexpr static std::size_t N_HISTORY = 16UZ;
using value_t = meta::fundamental_base_value_type_t<T>;

PortIn<T> in;
PortOut<T> out;

A<T, "offset", Doc<"trigger offset">, Visible> offset{T(0)};
A<T, "threshold", Doc<"trigger threshold">, Visible> threshold{T(1)};
A<value_t, "offset", Doc<"trigger offset">, Visible> offset{value_t(0)};
A<value_t, "threshold", Doc<"trigger threshold">, Visible> threshold{value_t(1)};
A<std::string, "rising trigger", Doc<"trigger name generated on detected rising edge (N.B. \"\" omits trigger)">, Visible> trigger_name_rising_edge{magic_enum::enum_name(RISING)};
A<std::string, "falling trigger", Doc<"trigger name generated on detected falling edge (N.B. \"\" omits trigger)">, Visible> trigger_name_falling_edge{magic_enum::enum_name(FALLING)};
A<float, "avg. sample rate", Visible> sample_rate = 1.f;
Expand Down Expand Up @@ -111,7 +112,11 @@ The information is stored (info only) in `trigger_name`, `trigger_time`, `trigge

if (_trigger.lastEdge == RISING && !trigger_name_rising_edge.value.empty()) { // generate rising tag
const std::size_t nPublish = i + 1UZ;
outputSpan.publishTag(genTag(trigger_name_rising_edge), i - static_cast<std::size_t>(-_trigger.lastEdgeIdx));
if constexpr (UncertainValueLike<T>) {
outputSpan.publishTag(genTag(trigger_name_rising_edge), i - static_cast<std::size_t>(-_trigger.lastEdgeIdx.value));
} else {
outputSpan.publishTag(genTag(trigger_name_rising_edge), i - static_cast<std::size_t>(-_trigger.lastEdgeIdx));
}
std::copy_n(inputSpan.begin(), nPublish, outputSpan.begin());
inputSpan.consume(nPublish);
outputSpan.publish(nPublish);
Expand All @@ -120,7 +125,11 @@ The information is stored (info only) in `trigger_name`, `trigger_time`, `trigge

if (_trigger.lastEdge == FALLING && !trigger_name_falling_edge.value.empty()) { // generate rising tag
const std::size_t nPublish = i + 1UZ;
outputSpan.publishTag(genTag(trigger_name_falling_edge), i - static_cast<std::size_t>(-_trigger.lastEdgeIdx));
if constexpr (UncertainValueLike<T>) {
outputSpan.publishTag(genTag(trigger_name_falling_edge), i - static_cast<std::size_t>(-_trigger.lastEdgeIdx.value));
} else {
outputSpan.publishTag(genTag(trigger_name_falling_edge), i - static_cast<std::size_t>(-_trigger.lastEdgeIdx));
}
std::copy_n(inputSpan.begin(), nPublish, outputSpan.begin());
inputSpan.consume(nPublish);
outputSpan.publish(nPublish);
Expand All @@ -141,6 +150,6 @@ The information is stored (info only) in `trigger_name`, `trigger_time`, `trigge

const inline auto registerTrigger = gr::registerBlock<gr::blocks::basic::SchmittTrigger, gr::trigger::InterpolationMethod::NO_INTERPOLATION, std::int16_t, std::int32_t, float, gr::UncertainValue<float>>(gr::globalBlockRegistry()) //
+ gr::registerBlock<gr::blocks::basic::SchmittTrigger, gr::trigger::InterpolationMethod::BASIC_LINEAR_INTERPOLATION, std::int16_t, std::int32_t, float, gr::UncertainValue<float>>(gr::globalBlockRegistry()) //
gr::registerBlock<gr::blocks::basic::SchmittTrigger, gr::trigger::InterpolationMethod::LINEAR_INTERPOLATION, std::int16_t, std::int32_t, float, gr::UncertainValue<float>>(gr::globalBlockRegistry());
+ gr::registerBlock<gr::blocks::basic::SchmittTrigger, gr::trigger::InterpolationMethod::LINEAR_INTERPOLATION, std::int16_t, std::int32_t, float, gr::UncertainValue<float>>(gr::globalBlockRegistry());

#endif // TRIGGER_HPP

0 comments on commit 0e521e5

Please sign in to comment.