public void TestGetAzimuthAxisPositionFromBytes_CalculatedGreaterThan360_ReturnsOriginalValue()
        {
            // byte size for an axis position is 2 bytes
            byte[] pos = new byte[2];

            // Encode
            int    i            = 0;
            double initialValue = 361;
            short  encoded      = PacketEncodingTools.ConvertDegreesToRawAzData(initialValue);

            PacketEncodingTools.Add16BitValueToByteArray(ref pos, ref i, encoded);

            // Decode
            i = 0;
            int offset = 0;

            int expected = 10;

            double result = PacketDecodingTools.GetAzimuthAxisPositionFromBytes(ref i, pos, offset, 10);

            Assert.AreEqual(expected, result, 0.16);
        }
        public void TestGetAzimuthAxisPositionFromBytes_BytesToPosition_ReturnsPosition()
        {
            // byte size for an axis position is 2 bytes
            byte[] pos = new byte[2];

            // Encode
            int i = 0;

            // 310 is 50 degrees away from 0, on the opposite end of 50
            double expected = 50;
            short  encoded  = PacketEncodingTools.ConvertDegreesToRawAzData(expected);

            PacketEncodingTools.Add16BitValueToByteArray(ref pos, ref i, encoded);

            // Decode
            i = 0;
            int offset = 0;

            double result = PacketDecodingTools.GetAzimuthAxisPositionFromBytes(ref i, pos, offset, 0);

            Assert.AreEqual(expected, result, 0.16);
        }
        public void TestGetTemperatureFromBytes_BytesToTemperature_ReturnsTemperature()
        {
            // The byte size for one temperature is 2 bytes
            byte[] oneTemperature = new byte[2];

            // This will create temperature value of 1, because the temperature is divided by 16
            oneTemperature[0] = 0;
            oneTemperature[1] = 16;

            // Skipping the timestamp because we aren't concerned with that in this test
            Temperature[] expected = new Temperature[1];
            expected[0] = Temperature.Generate(0, 1, SensorLocationEnum.COUNTERBALANCE);

            // This is only used for the counter, becuase it needs a variable to be passed by reference
            int i = 0;

            var result = PacketDecodingTools.GetTemperatureFromBytes(ref i, oneTemperature, 1, SensorLocationEnum.COUNTERBALANCE);

            Assert.AreEqual(1, result.Length); // Only expecting one result

            Assert.AreEqual(expected[0].temp, result[0].temp);
            Assert.AreEqual(expected[0].location_ID, result[0].location_ID);
        }
        public void TestGetAzimuthAxisPositionFromBytes_BytesToPositionWithOffset_ReturnsNormalizedPosition()
        {
            // byte size for an axis position is 2 bytes
            byte[] pos = new byte[2];

            // Encode
            int    i            = 0;
            double initialValue = 50;
            short  encoded      = PacketEncodingTools.ConvertDegreesToRawAzData(initialValue);

            PacketEncodingTools.Add16BitValueToByteArray(ref pos, ref i, encoded);

            // Decode
            i = 0;
            // With an offset of 60, that would make the origination originally -10, but with normalization, it should be 350
            int offset = 60;

            double expected = 350;

            double result = PacketDecodingTools.GetAzimuthAxisPositionFromBytes(ref i, pos, offset, 0);

            Assert.AreEqual(expected, result, 0.16);
        }