Exemplo n.º 1
0
        /// <summary>
        /// Calculate H4 offset.
        /// </summary>
        /// <param name="bytes">Raw bytes.</param>
        /// <param name="offset1">First offset.</param>
        /// <param name="offset2">Second offset.</param>
        /// <returns>H4 correction.</returns>
        public static int CalculateH4Offset(byte[] bytes, int offset1, int offset2)
        {
            var cal3_3 = ByteOperations.GetChar(bytes, offset1);
            var cal3_4 = ByteOperations.GetChar(bytes, offset2);

            return(((cal3_3 << 24) >> 20) | cal3_4);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculate H5 offset.
        /// </summary>
        /// <param name="bytes">Raw bytes.</param>
        /// <param name="offset1">First offset.</param>
        /// <param name="offset2">Second offset.</param>
        /// <returns>H5 correction.</returns>
        public static int CalculateH5Offset(byte[] bytes, int offset1, int offset2)
        {
            var cal3_4 = ByteOperations.GetChar(bytes, offset1);
            var cal3_5 = ByteOperations.GetChar(bytes, offset2);

            return(((cal3_5 << 24) >> 20) | cal3_4 >> 4 & 0x0F);
        }
Exemplo n.º 3
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 ByteArrayToUCharTest()
        {
            var value = ByteOperations.GetChar(CalibrationBytes2, 0);

            Assert.Equal(75, value);
        }
        public void ByteArrayToCharTest()
        {
            var value = ByteOperations.GetChar(CalibrationBytes3, 3);

            Assert.Equal(26, value);
        }