Beispiel #1
0
        /// <summary>
        /// 从下位机获取MAP标定参数
        /// </summary>
        /// <param name="io"></param>
        /// <returns></returns>
        internal static Models.Settings.MAPCalibrationParams GetMAPCalibrationParams(this SerialPortsUtils.Agents.Agent io)
        {
            var data      = io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, InstructionSet.MAPCalibrationParamsPart2_12RPMs).PacketData(2);
            var data2     = io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, InstructionSet.MAPCalibrationParamsPart2_12Tinj).PacketData(2);
            var mapValues = InstructionSet.MAPCalibrationParamsPart2_MAPValue
                            .Select(m => io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, m).PacketData(2)
                                    .Select(m2 =>
            {
                unchecked
                {
                    //return (sbyte)m2;//LDC MAP修改
                    return((int)m2);       ////LDC MAP修改<Sbyte>改为<byte>
                }
            }).ToArray()).ToArray();
            //var petrolCurve = InstructionSet.MAPCalibrationParamsPart2_PetrolCurve.Select(m =>//LDC删除
            //    io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, m).PacketData(2)
            //    .Select(m2 => ValueConvert.MapTableInjectionFrom(m2)).ToArray()).ToArray();
            //var gasCurve = InstructionSet.MAPCalibrationParamsPart2_GasCurve.Select(m =>
            //    io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, m).PacketData(2)
            //    .Select(m2 => ValueConvert.MapTableInjectionFrom(m2)).ToArray()).ToArray();
            //var packet3 = io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, InstructionSet.MAPCalibrationParamsPart2_DataLockStatus).PacketData(2).ToArray();
            var model = new Models.Settings.MAPCalibrationParams();

            byte[] temp = data.ToArray();
            //model.RPMs = data.Select(m => ValueConvert.MapTableRPMFrom(m)).ToArray();
            model.RPMs      = ValueConvert.MapTableRPMFrom(temp);
            temp            = data2.ToArray();
            model.Injection = ValueConvert.MapTableInjectionFrom(temp);
            //model.Injection = data2.Select(m => ValueConvert.MapTableInjectionFrom(m)).ToArray();//LDC删除
            model.MAPValues = mapValues;
            //model.PetrolCurve = petrolCurve;
            //model.GasCurve = gasCurve;
            //model.DataLockStatus = new bool[InstructionSet.MAPCalibrationParamsPart2_MAPValue.Length][];
            //for (int i = 0; i < model.DataLockStatus.Length; i++)
            //{
            //    model.DataLockStatus[i] = ValueConvert.DataLockStatusFrom(packet3[i * 3], packet3[i * 3 + 1], packet3[i * 3 + 2]);
            //}
            //var tt = io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, InstructionSet.MAPCalibrationParamsPart2_2DGasCurve);
            //model.GasCurve2D = tt.PacketData(2)
            //    .Select(m => m * 0.1f).ToArray();
            //model.PetrolCurve2D = io.SendAndRead(InstructionSet.MAPCalibrationParamsPart1, InstructionSet.MAPCalibrationParamsPart2_2DPetrolCurve).PacketData(2)
            //    .Select(m => m * 0.1f).ToArray();

            return(model);
        }