public void IsHigh_Pins_Is255()
 {
     var state = new DigitalPortState() { Pins = 255 };
     Assert.AreEqual(true, state.IsSet(0));
     Assert.AreEqual(true, state.IsSet(1));
     Assert.AreEqual(true, state.IsSet(2));
     Assert.AreEqual(true, state.IsSet(3));
     Assert.AreEqual(true, state.IsSet(4));
     Assert.AreEqual(true, state.IsSet(5));
     Assert.AreEqual(true, state.IsSet(6));
     Assert.AreEqual(true, state.IsSet(7));
 }
 public void IsHigh_Pin_Argument_IsNegative()
 {
     var state = new DigitalPortState();
     state.IsSet(-1);
 }
 public void IsHigh_Pin_Argument_Is8()
 {
     var state = new DigitalPortState();
     typeof(DigitalPortState).GetProperty("Pins").SetValue(state, 0);
     state.IsSet(8);
 }
示例#4
0
        private void ProcessDigitalStateMessage(int messageByte)
        {
            if (_messageBufferIndex < 2)
            {
                WriteMessageByte(messageByte);
            }
            else
            {
                var currentState = new DigitalPortState
                {
                    Port = _messageBuffer[0] & 0x0F,
                    Pins = _messageBuffer[1] | (messageByte << 7)
                };
                _processMessage = null;

                if (MessageReceived != null)
                    MessageReceived(this, new FirmataMessageEventArgs(new FirmataMessage(currentState, MessageType.DigitalPortState)));

                if (DigitalStateReceived != null)
                    DigitalStateReceived(this, new FirmataEventArgs<DigitalPortState>(currentState));
            }
        }