예제 #1
0
        private void GenerateAndSaveNewIgnitionMap(IECUFile m_File, bool runsE85)
        {
            //TODO: Implement
            // get the axis
            TuningReferenceMaps _referenceMaps = new TuningReferenceMaps();
            byte[] pressure_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0_x_axis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Ign_map_0_x_axis!"));
            byte[] rpm_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0_y_axis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Ign_map_0_y_axis!"));
            byte[] new_ignition_map = new byte[16 * 18 * 2];
            int ign_map_index = 0;
            for (int rpm_index = rpm_axis.Length-2; rpm_index >=0; rpm_index -= 2)
            {
                for (int pressure_index = 0; pressure_index < pressure_axis.Length; pressure_index += 2)
                {

                    int irpm = Convert.ToInt32(rpm_axis[rpm_index]) * 256;
                    irpm += Convert.ToInt32(rpm_axis[rpm_index+1]);
                    int ipressure = Convert.ToInt32(pressure_axis[pressure_index]) * 256;
                    ipressure += Convert.ToInt32(pressure_axis[pressure_index + 1]);
                    double correctionFactor = 1;
                    double pressure = ipressure;
                    MapSensorType mapsensor = m_File.GetMapSensorType(false);
                    if (mapsensor == MapSensorType.MapSensor30) correctionFactor = 1.2;
                    else if (mapsensor == MapSensorType.MapSensor35) correctionFactor = 1.4;
                    else if (mapsensor == MapSensorType.MapSensor40) correctionFactor = 1.6;
                    else if (mapsensor == MapSensorType.MapSensor50) correctionFactor = 2.0;
                    pressure *= correctionFactor;
                    pressure -= 100;
                    pressure /= 100;
                    double ignition_advance = _referenceMaps.GetIgnitionAdvanceForPressureRpm(pressure, (double)irpm);
                    if (runsE85) ignition_advance = _referenceMaps.GetIgnitionAdvanceE85ForPressureRpm(pressure, (double)irpm);
                    // write ignition advance into the map
                    ignition_advance *= 10; // correction factor
                    Int32 iAdvance = Convert.ToInt32(ignition_advance);
                    byte v1 = (byte)(iAdvance / 256);
                    byte v2 = (byte)(iAdvance - (int)v1 * 256);
                    //Console.WriteLine("Writing data rpmidx : " + rpm_index.ToString() + " mapidx: " + pressure_index.ToString() + " ignidx: " + ign_map_index.ToString());
                    new_ignition_map[ign_map_index++] = v1;
                    new_ignition_map[ign_map_index++] = v2;
                }
            }
            // now save the map
            m_File.WriteData(new_ignition_map, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0!"));
            m_File.WriteData(new_ignition_map, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_4!")); // save as warmup map as well
        }
예제 #2
0
        private void GenerateAndSaveNewFuelMap(IECUFile m_File)
        {
            TuningReferenceMaps _referenceMaps = new TuningReferenceMaps();
            byte[] pressure_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_map_xaxis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Fuel_map_xaxis!"));
            byte[] rpm_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_map_yaxis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Fuel_map_yaxis!"));
            byte[] new_fuel_map = new byte[16 * 16];
            int fuel_map_index = 0;
            for (int rpm_index = rpm_axis.Length - 2; rpm_index >= 0; rpm_index -= 2)
            {
                for (int pressure_index = 0; pressure_index < pressure_axis.Length; pressure_index ++)
                {

                    int irpm = Convert.ToInt32(rpm_axis[rpm_index]) * 256;
                    irpm += Convert.ToInt32(rpm_axis[rpm_index + 1]);
                    irpm *= 10;
                    int ipressure = Convert.ToInt32(pressure_axis[pressure_index]);
                    double correctionFactor = 1;
                    double pressure = ipressure;
                    MapSensorType mapsensor = m_File.GetMapSensorType(false);
                    if (mapsensor == MapSensorType.MapSensor30) correctionFactor = 1.2;
                    else if (mapsensor == MapSensorType.MapSensor35) correctionFactor = 1.4;
                    else if (mapsensor == MapSensorType.MapSensor40) correctionFactor = 1.6;
                    else if (mapsensor == MapSensorType.MapSensor50) correctionFactor = 2.0;
                    pressure *= correctionFactor;
                    pressure -= 100;
                    pressure /= 100;
                    double fuel_correction = _referenceMaps.FuelCorrectionForPressureRpm(pressure, (double)irpm);
                    // write ignition advance into the map
                    fuel_correction -= 0.5;
                    fuel_correction /= 0.00390625;

                    Int32 icorrection = Convert.ToInt32(fuel_correction);
                    if (icorrection > 255) icorrection = 255;
                    new_fuel_map[fuel_map_index++] = (byte)icorrection;
                }
            }
            // now save the map
            m_File.WriteData(new_fuel_map, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Insp_mat!"));
        }