Пример #1
0
        public void TestRequestOldInclinometr()
        {
            ISensorAdapter ci = new Inclination_OLD_SensorAdapter();
            // fe 43 58 20 cc 00 00 00 00 00 00 00 00 00 00 09 ef
            // 8432
            var s = new Sensor {
                ModuleNo = 8396
            };
            int err;
            var r = this.GetSensorAcqResult();

            r.Sensor = s;
            ci.Request(ref r);
            byte[] buff = r.Request;
            Assert.AreEqual(17, buff.Length);
            Assert.AreEqual(buff[0], 0xfe);
            Assert.AreEqual(buff[1], 0x43);
            Assert.AreEqual(buff[2], 0x58);
            Assert.AreEqual(buff[3], 0x20);
            Assert.AreEqual(buff[4], 0xcc);
            Assert.AreEqual(buff[5], 0x00);
            Assert.AreEqual(buff[6], 0x00);
            Assert.AreEqual(buff[7], 0x00);
            Assert.AreEqual(buff[8], 0x00);
            Assert.AreEqual(buff[9], 0x00);
            Assert.AreEqual(buff[10], 0x00);
            Assert.AreEqual(buff[11], 0x00);
            Assert.AreEqual(buff[12], 0x00);
            Assert.AreEqual(buff[13], 0x00);
            Assert.AreEqual(buff[14], 0x00);
            Assert.AreEqual(buff[15], 0x09);
            Assert.AreEqual(buff[16], 0xef);
        }
Пример #2
0
        public void TestParseOldInclinometrResponse()
        {
            ISensorAdapter ci = new Inclination_OLD_SensorAdapter();
            string         bs = "fe 43 58 00 00 20 cc 0b 00 2f 1c 0d 00 2c 03 13 ef";

            byte[] buff = ValueHelper.StrToToHexByte(bs);
            var    r    = new SensorAcqResult()
            {
                Response = buff,
                Sensor   = new Sensor
                {
                    ModuleNo    = 8396,
                    TableColums = "Angle_X,Angle_Y"
                }
            };

            ci.ParseResult(ref r);
            var data = r.Data;

            Assert.IsNotNull(data);
            Assert.AreEqual("0.7911", data.RawValues[0].ToString("0.####"));
            Assert.AreEqual("-0.7342", data.RawValues[1].ToString("0.####"));
        }