Esempio n. 1
0
        /// <summary>
        /// Exctract data from raw byte response.
        /// </summary>
        /// <param name="cal1">First word.</param>
        /// <param name="cal2">Second word.</param>
        /// <param name="cal3">Third word.</param>
        /// <returns>Sensor digit dictionary.</returns>
        public static Dictionary <SensorDigit, int> ExtractcalibrationData(byte[] cal1, byte[] cal2, byte[] cal3)
        {
            var calibrationData = new Dictionary <SensorDigit, int>(18)
            {
                { SensorDigit.DigitT1, ByteOperations.GetUShort(cal1, 0) },
                { SensorDigit.DigitT2, ByteOperations.GetShort(cal1, 2) },
                { SensorDigit.DigitT3, ByteOperations.GetShort(cal1, 4) },
                { SensorDigit.DigitP1, ByteOperations.GetUShort(cal1, 6) },
                { SensorDigit.DigitP2, ByteOperations.GetShort(cal1, 8) },
                { SensorDigit.DigitP3, ByteOperations.GetShort(cal1, 10) },
                { SensorDigit.DigitP4, ByteOperations.GetShort(cal1, 12) },
                { SensorDigit.DigitP5, ByteOperations.GetShort(cal1, 14) },
                { SensorDigit.DigitP6, ByteOperations.GetShort(cal1, 16) },
                { SensorDigit.DigitP7, ByteOperations.GetShort(cal1, 18) },
                { SensorDigit.DigitP8, ByteOperations.GetShort(cal1, 20) },
                { SensorDigit.DigitP9, ByteOperations.GetShort(cal1, 22) },
                { SensorDigit.DigitH1, ByteOperations.GetUChar(cal2, 0) },
                { SensorDigit.DigitH2, ByteOperations.GetUShort(cal3, 0) },
                { SensorDigit.DigitH3, ByteOperations.GetUChar(cal3, 2) },
                { SensorDigit.DigitH4, CalculateH4Offset(cal3, 3, 4) },
                { SensorDigit.DigitH5, CalculateH5Offset(cal3, 4, 5) },
                { SensorDigit.DigitH6, ByteOperations.GetChar(cal3, 6) },
            };

            return(calibrationData);
        }
        public void ByteArrayToUShortTest()
        {
            var value = ByteOperations.GetUShort(CalibrationBytes1, 0);

            Assert.Equal(28301, value);
        }