public override void SetState(IComponentState state, params IHardwareParameter[] parameters) { if (state == null) { throw new ArgumentNullException(nameof(state)); } if (state.Equals(_state)) { return; } if (state.Equals(RollerShutterStateId.Off)) { _endpoint.Stop(parameters); } else if (state.Equals(RollerShutterStateId.MovingUp)) { _endpoint.StartMoveUp(parameters); RestartTracking(); } else if (state.Equals(RollerShutterStateId.MovingDown)) { _endpoint.StartMoveDown(parameters); RestartTracking(); } var oldState = _state; _state = state; OnActiveStateChanged(oldState, _state); }
public IComponentState GetNextState(IComponentState baseStateId) { if (baseStateId.Equals(BinaryStateId.Off)) { return(BinaryStateId.On); } if (baseStateId.Equals(BinaryStateId.On)) { return(BinaryStateId.Off); } throw new StateNotSupportedException(baseStateId); }
protected void SetState(IComponentState newState) { if (newState.Equals(_state)) { return; } var oldValue = _state; _state = newState; OnActiveStateChanged(oldValue, newState); }