Пример #1
0
        public void Write(BinaryState state, WriteBinaryStateMode mode = WriteBinaryStateMode.Commit)
        {
            if (mode != WriteBinaryStateMode.Commit)
            {
                return;
            }

            lock (_syncRoot)
            {
                if (state == BinaryState.High)
                {
                    _remoteSocketService.SendCode(_codePair.OnCode);
                }
                else if (state == BinaryState.Low)
                {
                    _remoteSocketService.SendCode(_codePair.OffCode);
                }
                else
                {
                    throw new NotSupportedException();
                }

                _state = state;
            }
        }
Пример #2
0
        public void Write(BinaryState state, WriteBinaryStateMode mode = WriteBinaryStateMode.Commit)
        {
            if (mode != WriteBinaryStateMode.Commit)
            {
                return;
            }

            lock (_syncRoot)
            {
                var oldState = state;
                _state = state;

                StateChanged?.Invoke(this, new BinaryStateChangedEventArgs(oldState, state));
            }

            if (state == BinaryState.High)
            {
                _adapter.SendCode(_codePair.OnCode);
            }
            else if (state == BinaryState.Low)
            {
                _adapter.SendCode(_codePair.OffCode);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Пример #3
0
 public void Write(BinaryState state, WriteBinaryStateMode mode = WriteBinaryStateMode.Commit)
 {
     lock (_syncRoot)
     {
         _state = CoerceState(state);
     }
 }
Пример #4
0
        public void Write(BinaryState state, WriteBinaryStateMode mode)
        {
            state = CoerceState(state);
            Board.SetPortState(Number, state);

            if (mode == WriteBinaryStateMode.Commit)
            {
                Board.CommitChanges();
            }
        }
Пример #5
0
        public void Write(BinaryState state, WriteBinaryStateMode mode = WriteBinaryStateMode.Commit)
        {
            if (state == _state)
            {
                return;
            }

            var oldState = _state;

            _state = state;

            StateChanged?.Invoke(this, new BinaryStateChangedEventArgs(oldState, state));
        }
Пример #6
0
        public void Write(BinaryState state, WriteBinaryStateMode mode = WriteBinaryStateMode.Commit)
        {
            lock (_syncRoot)
            {
                state = CoerceState(state);

                if (state == _previousState)
                {
                    return;
                }

                Pin.Write(state == BinaryState.High ? GpioPinValue.High : GpioPinValue.Low);

                var oldState = _previousState;
                _previousState = state;
                StateChanged?.Invoke(this, new BinaryStateChangedEventArgs(oldState, state));
            }
        }
Пример #7
0
        public void Write(BinaryState state, WriteBinaryStateMode mode = WriteBinaryStateMode.Commit)
        {
            if (_state == state)
            {
                return;
            }

            var payload = "off";

            if (state == BinaryState.High)
            {
                payload = "on";
            }

            _messageBroker.Publish(_topic, Encoding.UTF8.GetBytes(payload), MqttQosLevel.AtMostOnce, true);
            StateChanged?.Invoke(this, new BinaryStateChangedEventArgs(_state, state));

            _state = state;
        }
Пример #8
0
        public void Write(BinaryState state, WriteBinaryStateMode mode)
        {
            state = CoerceState(state);

            // TODO: Implement animations here.
            foreach (var output in _outputs)
            {
                output.Write(state, WriteBinaryStateMode.NoCommit);
            }

            if (mode == WriteBinaryStateMode.Commit)
            {
                foreach (var output in _outputs)
                {
                    output.Write(state, WriteBinaryStateMode.Commit);
                }
            }

            _state = state;
        }
Пример #9
0
        public void Write(BinaryState state, WriteBinaryStateMode mode)
        {
            // TODO: Implement animations here.
            foreach (var output in _outputs)
            {
                output.Write(state, WriteBinaryStateMode.NoCommit);
            }

            if (mode == WriteBinaryStateMode.Commit)
            {
                foreach (var output in _outputs)
                {
                    output.Write(state);
                }
            }

            var oldState = _state;

            _state = state;

            StateChanged?.Invoke(this, new BinaryStateChangedEventArgs(oldState, _state));
        }
Пример #10
0
        public void Write(BinaryState state, WriteBinaryStateMode mode)
        {
            if (mode != WriteBinaryStateMode.Commit)
            {
                return;
            }

            BinaryState oldState;

            lock (_syncRoot)
            {
                if (state == _latestState)
                {
                    return;
                }

                _pin.Write(state == BinaryState.High ? GpioPinValue.High : GpioPinValue.Low);

                oldState     = _latestState;
                _latestState = state;
            }

            StateChanged?.Invoke(this, new BinaryStateChangedEventArgs(oldState, state));
        }
Пример #11
0
 public void Write(BinaryState state, WriteBinaryStateMode mode)
 {
     _board.SetPortState(_id, state, mode == WriteBinaryStateMode.Commit);
 }
Пример #12
0
 public void Execute(WriteBinaryStateMode mode)
 {
     BinaryOutput?.Write(State, mode);
 }
Пример #13
0
 public void Write(BinaryState state, WriteBinaryStateMode mode = WriteBinaryStateMode.Commit)
 {
     _binaryOutput.Write(CoerceState(state), mode);
 }