Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        protected void SetState(IComponentState newState)
        {
            if (newState.Equals(_state))
            {
                return;
            }

            var oldValue = _state;

            _state = newState;

            OnActiveStateChanged(oldValue, newState);
        }