public void TestRequestInclinometr() { ISensorAdapter ci = new GLSB40I70Laser_SensorAdapter(); // 64 06 02 94 100 var s = new Sensor { ModuleNo = 100 }; int err; var r = this.GetSensorAcqResult(); r.Sensor = s; ci.Request(ref r); byte[] buff = r.Request; Assert.AreEqual(4, buff.Length); Assert.AreEqual(0x64, buff[0]); Assert.AreEqual(0x06, buff[1]); Assert.AreEqual(0x02, buff[2]); Assert.AreEqual(0x94, buff[3]); }
public void TestParseInclinometrResponse() { DbAccessorHelper.Init(new MsDbAccessor(connstr));// 配置 ISensorAdapter ci = new GLSB40I70Laser_SensorAdapter(); string bs = "6406823030302e333131c1"; byte[] buff = ValueHelper.ToBytes(bs); SensorAcqResult r = new SensorAcqResult() { Response = buff, Sensor = new Sensor { ModuleNo = 100, TableColums = "Angle_X,Angle_Y" } }; r.Sensor.AddParameter(new SensorParam(new FormulaParam()) { Value = 0.1 }); ci.ParseResult(ref r); var data = r.Data; Assert.IsNotNull(data); Assert.AreEqual(0.311, data.RawValues[0]); Assert.AreEqual(0.211, data.PhyValues[0]); bs = "6406833030302e333131c1"; buff = ValueHelper.ToBytes(bs); r.Response = buff; ci.ParseResult(ref r); Assert.IsNotNull(data); Assert.AreEqual((int)Errors.ERR_INVALID_DATA, r.ErrorCode); bs = "6406823030302e33"; buff = ValueHelper.ToBytes(bs); r.Response = buff; ci.ParseResult(ref r); Assert.IsNotNull(data); Assert.AreEqual((int)Errors.ERR_INVALID_DATA, r.ErrorCode); }