4#include "roo_transceivers/binding/binding.h"
9template <
typename State>
13 const roo_transceivers::ActuatorBinding* binding)
14 : bound_sensing_actuator_(universe, binding) {}
17 roo_transceivers::Measurement m = bound_sensing_actuator_.read();
19 CHECK(m.quantity() == roo_transceivers_Quantity_kBinaryState ||
20 m.quantity() == roo_transceivers_Quantity_kMultiState);
21 if ((
int)m.value() != m.value()) {
23 <<
"Selector value is not an integer: " << m.value();
26 result = (State)m.value();
34 return bound_sensing_actuator_.write((
float)state);
38 roo_transceivers::BoundSensingActuator bound_sensing_actuator_;
46 const roo_transceivers::ActuatorBinding* binding)
47 : bound_sensing_actuator_(universe, binding) {}
50 roo_transceivers::Measurement m = bound_sensing_actuator_.read();
52 if (m.quantity() != roo_transceivers_Quantity_kBinaryState &&
53 m.quantity() != roo_transceivers_Quantity_kMultiState) {
55 <<
"Unexpected quantity when reading bound actuator: "
56 << m.quantity() <<
" " << m.value();
59 if (m.value() != 0.0f && m.value() != 1.0f) {
60 LOG_EVERY_T(ERROR, 1) <<
"Selector value is invalid: " << m.value();
71 return bound_sensing_actuator_.write((
float)state);
75 roo_transceivers::BoundSensingActuator bound_sensing_actuator_;
BinaryLogicalState specialization with stricter value checks.
bool setState(BinaryLogicalState state) override
Updates the state of the switch. Returns true on success.
bool getState(BinaryLogicalState &result) const override
BoundSwitch(roo_transceivers::Universe &universe, const roo_transceivers::ActuatorBinding *binding)
Switch backed by a bound sensing actuator from roo_transceivers.
bool setState(State state) override
Updates the state of the switch. Returns true on success.
BoundSwitch(roo_transceivers::Universe &universe, const roo_transceivers::ActuatorBinding *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 settable switch.
BinaryLogicalState
Binary logical state used by selectors and switches.