Ejemplo n.º 1
0
        public void BytesToCelsius(byte[] input, Measure <Celsius> expected)
        {
            var final = new byte[10];

            Array.Copy(input, 0, final, 3, input.Length);
            var result = Dpt9001.BytesToCelsius(new ArraySegment <byte>(final, 3, 2));

            Assert.Equal(expected, result);
        }
Ejemplo n.º 2
0
        private IMessagePayload CreateBusMessage(KnxAddressBindingTypes bindingType, CemiFrame cemiFrame)
        {
            switch (bindingType)
            {
            case KnxAddressBindingTypes.Switch:
                bool onOff = (cemiFrame.Apdu & 1) == 1;
                return(new SwitchMessage(onOff));

            case KnxAddressBindingTypes.Temperature:
                return(new TemperatureMessage(Dpt9001.BytesToCelsius(new ArraySegment <byte>(cemiFrame.Data.Array, cemiFrame.Data.Offset, cemiFrame.Data.Count))));

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(bindingType), bindingType, null);
            }
        }
Ejemplo n.º 3
0
 public void Degree_celsius_above_670760_throws()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Dpt9001.BytesToCelsius(new ArraySegment <byte>(new byte[] { 0x7f, 0xff }, 0, 2)));
 }
Ejemplo n.º 4
0
 public void Degree_celsius_below_273_throws()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Dpt9001.BytesToCelsius(new ArraySegment <byte>(new byte[] { 0xf8, 0x02 }, 0, 2)));
 }
Ejemplo n.º 5
0
 public void CelsiusToBytes(byte[] input, Measure <Celsius> expected)
 {
     byte[] outBytes = new byte[5];
     Dpt9001.CelsiusToBytes(expected, outBytes, 3);
     Assert.Equal(input, outBytes.Skip(3).ToArray());
 }