Beispiel #1
0
        /// <summary>
        /// 从报文提取 实时数据
        /// </summary>
        /// <param name="packet">报文</param>
        /// <returns>实时数据</returns>
        public static Models.Feedback.RealTimeData ToRealyTimeData(this byte[] packet)//LDC
        {
            var data = packet.PacketData(1).ToArray();

            Models.Feedback.RealTimeData model = new Models.Feedback.RealTimeData();
            model.PetrolsTime = ValueConvert.TwoBitTimeByusFrom(data[0], data[1]); //1(高位)、2(低位)字节:当前喷油时间;单位2.56us;
            model.GasesTime   = ValueConvert.TwoBitTimeByusFrom(data[2], data[3]); //3(高位)、4(低位)字节:当前喷气时间;单位2.56us;
            model.RPM         = ValueConvert.RealyDataRPMFrom(data[4], data[5]);   //5(高位)、6(低位)字节:当前发动机转速;单位rpm;
            model.TempRed     = ValueConvert.SingleTempFrom(data[6]);              //7字节:当前减压器温度;单位℃;
            model.TempGas     = ValueConvert.SingleTempFrom(data[7]);              //8字节:当前燃气温度;单位℃;
            model.MAPPress    = ValueConvert.PressFrom(data[8]);                   //9字节:当前真空压力;单位0.01bar;
            model.GasPress    = ValueConvert.PressFrom(data[9]);                   //10字节:当前燃气压力;单位0.01bar;
            model.Lambda      = ValueConvert.TwoBitKVFrom(data[10], data[11]);
            model.GasLevel    = ValueConvert.GasLevelFrom(data[12]);
            model.LEDLight    = ValueConvert.LEDLightFrom(data[13]);//14字节:开关LED灯状态;bit0:level0,bit1:level1,bit2:level2,bit3:level3,bit4:level4,bit5:gas,bit6:petrol,bit7:保留
            bool[] state = ValueConvert.SolenoidValveAndIgnitionStatusFrom(data[14]);
            model.SolenoidValveStatus = state[0];
            model.IgnitionStatus      = state[1];
            //model.RPMSource = ValueConvert.RPMSourceFrom(data[18]);
            return(model);
        }