add option to directly check switch state
This commit is contained in:
parent
bbe21e7e89
commit
4b5e3e70f7
@ -45,12 +45,24 @@ void PowerSwitcher::commandSwitches(ReturnValue_t onOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
void PowerSwitcher::turnOn() {
|
||||
void PowerSwitcher::turnOn(bool checkCurrentState) {
|
||||
if(checkCurrentState) {
|
||||
if(getStateOfSwitches() == PowerSwitchIF::SWITCH_ON) {
|
||||
state = SWITCH_IS_ON;
|
||||
return;
|
||||
}
|
||||
}
|
||||
commandSwitches(PowerSwitchIF::SWITCH_ON);
|
||||
state = WAIT_ON;
|
||||
}
|
||||
|
||||
void PowerSwitcher::turnOff() {
|
||||
void PowerSwitcher::turnOff(bool checkCurrentState) {
|
||||
if(checkCurrentState) {
|
||||
if(getStateOfSwitches() == PowerSwitchIF::SWITCH_OFF) {
|
||||
state = SWITCH_IS_OFF;
|
||||
return;
|
||||
}
|
||||
}
|
||||
commandSwitches(PowerSwitchIF::SWITCH_OFF);
|
||||
state = WAIT_OFF;
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ class PowerSwitcher : public HasReturnvaluesIF {
|
||||
static const ReturnValue_t SWITCH_STATE_MISMATCH = MAKE_RETURN_CODE(2);
|
||||
PowerSwitcher(PowerSwitchIF* switcher, uint8_t setSwitch1, uint8_t setSwitch2 = power::NO_SWITCH,
|
||||
State_t setStartState = SWITCH_IS_OFF);
|
||||
void turnOn();
|
||||
void turnOff();
|
||||
void turnOn(bool checkCurrentState = true);
|
||||
void turnOff(bool checkCurrentState = true);
|
||||
bool active();
|
||||
void doStateMachine();
|
||||
State_t getState();
|
||||
|
Loading…
Reference in New Issue
Block a user