예제 #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);
        }
예제 #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);
            }
        }
예제 #3
0
 public void Degree_celsius_above_670760_throws()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Dpt9001.BytesToCelsius(new ArraySegment <byte>(new byte[] { 0x7f, 0xff }, 0, 2)));
 }
예제 #4
0
 public void Degree_celsius_below_273_throws()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Dpt9001.BytesToCelsius(new ArraySegment <byte>(new byte[] { 0xf8, 0x02 }, 0, 2)));
 }