Veethree D7 SDK
Loading...
Searching...
No Matches
io_event_common.h
Go to the documentation of this file.
1
5#ifndef IO_EVENT_COMMON_H
6#define IO_EVENT_COMMON_H
7
8#include "io_event_source.h"
9
10#include <cstdint>
11
12namespace vsdk::io {
13
50
60 range_value(double s, double e)
61 : start(s)
62 , end(e)
63 {}
64
68 : range_value(0.0, 0.0)
69 {}
70
74 double start{};
78 double end{};
79
85 bool is_in_range(const double value) const { return value >= start && value < end; }
91 bool is_out_of_range(const double value) const { return value < start || value > end; }
92};
93
94
95} // namespace vsdk::io
96
97#include <utils/fmt_wrapper.h>
98
99#ifndef DOXYGEN_SKIP_THIS
100
104template<>
105struct fmt::formatter<vsdk::io::event_source> : fmt::formatter<uint32_t> {
112 auto format(vsdk::io::event_source src, format_context& ctx) const -> format_context::iterator
113 {
114 return formatter<uint32_t>::format(src.hash(), ctx);
115 }
116};
117
121template<>
122struct fmt::formatter<vsdk::io::event_type> : fmt::formatter<uint32_t> {
129 auto format(vsdk::io::event_type type, format_context& ctx) const -> format_context::iterator
130 {
131 return formatter<uint32_t>::format(static_cast<uint32_t>(type), ctx);
132 }
133};
134
138template<>
139struct fmt::formatter<vsdk::io::range_value> : fmt::formatter<std::string> {
146 auto format(vsdk::io::range_value range, format_context& ctx) const -> format_context::iterator
147 {
148 return formatter<std::string>::format(fmt::format("s:{},e:{}", range.start, range.end), ctx);
149 }
150};
151
152#endif // DOXYGEN_SKIP_THIS
153
154#endif // IO_EVENT_COMMON_H
Describes the source of an event.
Definition io_event_source.h:25
Include this file to your file so you have access to fmtlib header-only implementation.
event_type
Describes the event type.
Definition io_event_common.h:41
@ in_range
any value inside of [start, end) - including start, excluding end.
Definition io_event_common.h:46
@ target_state
indicates a digital input value has changed to a specific state.
Definition io_event_common.h:48
@ state_change
indicates a digital input value has changed state.
Definition io_event_common.h:47
@ threshold_below
any value less than the threshold specified.
Definition io_event_common.h:44
@ threshold_above
any value greater than the threshold specified.
Definition io_event_common.h:43
IO event source interface.
Any entities that belong to the IO library.
@ out_of_range
Value is out of valid range.
Definition io_common.h:25
@ none
No unit.
Definition io_common.h:41
Any entities that belong to the Veethree SDK libraries.
Definition can_adapter.h:11
bool is_out_of_range(const double value) const
Return a boolean indicating if a value is out of range.
Definition io_event_common.h:91
bool is_in_range(const double value) const
Return a boolean indicating if a value is in range.
Definition io_event_common.h:85
double start
Start of range.
Definition io_event_common.h:74
range_value()
Default constructor.
Definition io_event_common.h:67
range_value(double s, double e)
Constructor that takes the 'start' and 'end' values for a range.
Definition io_event_common.h:60
double end
End of range.
Definition io_event_common.h:78