1 #ifndef ORG_EEROS_CONTROL_SWITCH_HPP_ 2 #define ORG_EEROS_CONTROL_SWITCH_HPP_ 13 using namespace safety;
15 template < u
int8_t N = 2,
typename T =
double >
18 Switch(uint8_t initInputIndex) : currentInput(initInputIndex) {
19 for(uint8_t i = 0; i < N; i++) in[i].setOwner(
this);
23 auto val = this->in[currentInput].getSignal().getValue();
24 if (armed && !switched) {
25 if (val < (switchLevel + delta) && val > (switchLevel - delta)) {
26 switchToInput(nextInput);
29 if(safetySystem !=
nullptr && safetyEvent !=
nullptr) {
30 safetySystem->triggerEvent(*safetyEvent);
35 this->out.getSignal().setValue(this->in[currentInput].getSignal().getValue());
36 this->out.getSignal().setTimestamp(this->in[currentInput].getSignal().getTimestamp());
44 if(index >= 0 && index < N) {
61 this->switchLevel = switchLevel;
80 bool switched =
false;
Safety system.
Definition: SafetySystem.hpp:19
Definition: Switch.hpp:16
uint8_t nextInput
Definition: Switch.hpp:77
virtual Input< T > & getIn(uint8_t index)
Definition: Switch.hpp:39
virtual bool triggered() const
Definition: Switch.hpp:71
T switchLevel
Definition: Switch.hpp:78
Definition: Block1o.hpp:12
Definition: Config.hpp:14
virtual bool switchToInput(uint8_t index)
Definition: Switch.hpp:43
virtual uint8_t getCurrentInput() const
Definition: Switch.hpp:51
virtual void arm()
Definition: Switch.hpp:66
virtual void setCondition(T switchLevel, T delta, uint8_t index)
Definition: Switch.hpp:60
virtual void registerSafetyEvent(SafetySystem &ss, SafetyEvent &e)
Definition: Switch.hpp:55
virtual void run()
Definition: Switch.hpp:22
Switch(uint8_t initInputIndex)
Definition: Switch.hpp:18
Definition: SafetyLevel.hpp:21