Ejemplo n.º 1
0
        /// <summary>
        /// Handle the capability messages. There will be one such message for each pin
        /// </summary>
        public void Handle(CapabilityMessage message)
        {
            var pin = new Pin(message);

            // Add it to the collection
            Pins.Add(pin);
        }
Ejemplo n.º 2
0
        public void HasInputCapabilityTest()
        {
            var capability = new CapabilityMessage();

            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);

            Assert.IsTrue(pin.HasInputCapability());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handle the capability messages. There will be one such message for each pin
        /// </summary>
        public void Handle(CapabilityMessage message)
        {
            var pin = new Pin();

            foreach (var mes in message.Modes)
            {
                pin.Capabilities[mes.Key] = mes.Value;
            }

            // Add it to the collection
            Pins.Add(pin);
        }
Ejemplo n.º 4
0
 public Pin(CapabilityMessage message) : this()
 {
     foreach (var mes in message.Modes)
     {
         Capabilities[mes.Key] = mes.Value;
     }
     PinNo = message.PinNo;
     if (HasDigitalCapability())
     {
         Port = (byte)PinNo / 8;
     }
 }
Ejemplo n.º 5
0
        public void ResolutionOfCapabilityTest()
        {
            var capability = new CapabilityMessage();

            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);

            Assert.IsTrue(pin.ResolutionOfCapability(PinModes.Input) == 1);
            Assert.IsTrue(pin.ResolutionOfCapability(PinModes.Output) == -1);
        }
Ejemplo n.º 6
0
        public void CreationTest()
        {
            var capability = new CapabilityMessage();

            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);

            Assert.NotNull(pin);
            Assert.IsTrue(pin.Port == 0);
        }
Ejemplo n.º 7
0
        public void IsI2CModeTest()
        {
            var capability = new CapabilityMessage();

            capability.PinNo = 1;
            capability.Modes[PinModes.Analog] = 1;

            var pin = Pin(capability);

            Assert.IsFalse(pin.IsI2CMode());

            pin.CurrentMode = PinModes.I2C;
            Assert.IsTrue(pin.IsI2CMode());
        }
Ejemplo n.º 8
0
        public void HasAnalogCapabilityTest()
        {
            var capability = new CapabilityMessage();

            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);

            Assert.IsFalse(pin.HasAnalogCapability());

            pin.Capabilities[PinModes.Analog] = 1;
            Assert.IsTrue(pin.HasAnalogCapability());
        }
Ejemplo n.º 9
0
        public void IsInputModeTest()
        {
            var capability = new CapabilityMessage();

            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);

            //CurrentMode is set to PinModes.Input by default
            //http://stackoverflow.com/questions/1165402/initial-value-of-an-enum
            Assert.IsTrue(pin.IsInputMode());

            pin.CurrentMode = PinModes.I2C;
            Assert.IsFalse(pin.IsInputMode());
        }
Ejemplo n.º 10
0
 internal void OnCapability(CapabilityMessage message) => Capability?.Invoke(message);
Ejemplo n.º 11
0
 private Pin Pin(CapabilityMessage message)
 {
     return(new Pin(message));
 }