4#include "roo_transceivers/binding/binding.h"
9template <
typename State>
13 const roo_transceivers::SensorBinding& binding)
14 : bound_sensor_(universe, binding), state_() {}
17 Measurement m = bound_sensor_.read();
19 CHECK(m.quantity() == roo_control_Quantity_kBinaryState ||
20 m.quantity() == roo_control_Quantity_kMultiState);
21 if ((
int)m.value()) != m.value() {
22 LOG(ERROR) <<
"Selector value is not an integer: " << m.value();
25 result = (State)m.value();
28 LOG(ERROR) <<
"Unknown selector state " << bound_sensor_;
33 roo_transceivers::BoundSensor bound_sensor_;
41 roo_transceivers::Universe& universe,
42 const roo_transceivers::SensorBinding& binding)
43 : bound_sensor_(universe, binding) {}
46 roo_transceivers::Measurement m = bound_sensor_.read();
48 CHECK(m.quantity() == roo_control_Quantity_kBinaryState ||
49 m.quantity() == roo_control_Quantity_kMultiState);
50 if (m.value() != 0.0f && m.value() != 1.0f) {
51 LOG(ERROR) <<
"Selector value is invalid: " << m.value();
57 LOG(ERROR) <<
"Unknown selector state " << bound_sensor_;
62 roo_transceivers::BoundSensor bound_sensor_;
BinaryLogicalState specialization with stricter value checks.
bool getState(BinaryLogicalState &result) const override
Retrieves the current state, or returns false when it cannot be read.
Selector backed by a bound sensor from roo_transceivers.
BoundSelector(roo_transceivers::Universe &universe, const roo_transceivers::SensorBinding &binding)
bool getState(State &result) const override
Retrieves the current state, or returns false when it cannot be read.
An abstraction of a multi-state device.
BinaryLogicalState
Binary logical state used by selectors and switches.