/// <summary> /// Check binary file for anomalies that cannot be right /// </summary> /// <param name="filename"></param> public void CheckBinForAnomalies(string filename, Trionic5Resume resume, bool fixproblems, bool showreport, IECUFileInformation fileInformation) { m_fileInformation = fileInformation; if (showreport) { resume.AddToResumeTable("Checking file " + Path.GetFileName(filename)); resume.AddToResumeTable("Checking injection map against fuel knock map"); } CheckInjectionMapAgainstFuelKnockMap(filename, showreport, fixproblems, resume); if (showreport) { resume.AddToResumeTable("Checking injection constant value"); } CheckInjectionConstant(filename, showreport, resume); if (showreport) { resume.AddToResumeTable("Checking boost request maps agains boost limiters"); } CheckBoostRequestMapAgainstBoostLimiters(filename, showreport, resume); if (showreport) { resume.AddToResumeTable("Checking axis against maximum requested boost level"); } try { CheckBoostRequestAgainstAxisRanges(filename, true, resume); } catch (Exception E) { Console.WriteLine("CheckBoostRequestAgainstAxisRanges: " + E.Message); } if (showreport) { // seperator for next file... maybe resume.AddToResumeTable(""); } }
public void ConvertFileToThreeBarMapSensor(IECUFileInformation fileinformation, MapSensorType fromSensorType, MapSensorType toSensorType) { m_fileInformation = fileinformation; // frmProgress progress = new frmProgress(); // progress.Show(); // progress.SetProgress("Checking current configuration..."); m_resume = new Trionic5Resume(); m_resume.ResumeTuning = new System.Data.DataTable(); m_resume.ResumeTuning.Columns.Add("Description"); if (fromSensorType == toSensorType) return; string infoStr = "Tuning your binary from "; string infoCopyStr = "beforetuningfrom"; switch (fromSensorType) { case MapSensorType.MapSensor25: infoStr += " 2.5 bar sensor to "; infoCopyStr += "250kpasensorto"; break; case MapSensorType.MapSensor30: infoStr += " 3.0 bar sensor to "; infoCopyStr += "300kpasensorto"; break; case MapSensorType.MapSensor35: infoStr += " 3.5 bar sensor to "; infoCopyStr += "350kpasensorto"; break; case MapSensorType.MapSensor40: infoStr += " 4.0 bar sensor to "; infoCopyStr += "400kpasensorto"; break; case MapSensorType.MapSensor50: infoStr += " 5.0 bar sensor to "; infoCopyStr += "500kpasensorto"; break; } switch (toSensorType) { case MapSensorType.MapSensor25: infoStr += " 2.5 bar sensor"; infoCopyStr += "250kpasensor"; break; case MapSensorType.MapSensor30: infoStr += " 3.0 bar sensor"; infoCopyStr += "300kpasensor"; break; case MapSensorType.MapSensor35: infoStr += " 3.5 bar sensor"; infoCopyStr += "350kpasensor"; break; case MapSensorType.MapSensor40: infoStr += " 4.0 bar sensor"; infoCopyStr += "400kpasensor"; break; case MapSensorType.MapSensor50: infoStr += " 5.0 bar sensor"; infoCopyStr += "500kpasensor"; break; } infoStr += ": " + Path.GetFileName(m_fileInformation.Filename); m_resume.AddToResumeTable(infoStr); // get the software ID from the bainery //progress.SetProgress("Creating backup file..."); File.Copy(m_fileInformation.Filename, Path.GetDirectoryName(m_fileInformation.Filename) + "\\" + Path.GetFileNameWithoutExtension(m_fileInformation.Filename) + DateTime.Now.ToString("yyyyMMddHHmmss") + infoCopyStr + ".bin", true); m_resume.AddToResumeTable("Backup file created (" + Path.GetFileNameWithoutExtension(m_fileInformation.Filename) + DateTime.Now.ToString("yyyyMMddHHmmss") + infoCopyStr + ".bin" + ")"); // symbols with MAP as values infoStr = "Altering tables for"; switch (toSensorType) { case MapSensorType.MapSensor25: infoStr += " 2.5 bar sensor..."; break; case MapSensorType.MapSensor30: infoStr += " 3.0 bar sensor..."; break; case MapSensorType.MapSensor35: infoStr += " 3.5 bar sensor..."; break; case MapSensorType.MapSensor40: infoStr += " 4.0 bar sensor..."; break; } //progress.SetProgress(infoStr); double factor = CalculateConversionFactor(fromSensorType, toSensorType); AlterTableForThreeBarSensor("Tryck_mat!", factor); AlterTableForThreeBarSensor("Tryck_mat_a!", factor); AlterTableForThreeBarSensor("Tryck_vakt_tab!", factor); AlterTableForThreeBarSensor("Regl_tryck_fgaut!", factor); AlterTableForThreeBarSensor("Regl_tryck_fgm!", factor); AlterTableForThreeBarSensor("Regl_tryck_sgm!", factor); AlterTableForThreeBarSensor("Limp_tryck_konst!", factor); AlterTableForThreeBarSensor("Idle_tryck!", factor); AlterTableForThreeBarSensor("Knock_press_tab!", factor); AlterTableForThreeBarSensor("Turbo_knock_tab!", factor); AlterTableForThreeBarSensor("Iv_min_load!", factor); // new symbols 25/03/2008 AlterTableForThreeBarSensor("Open_loop!", factor); AlterTableForThreeBarSensor("Open_loop_knock!", factor); AlterTableForThreeBarSensor("Open_loop_adapt!", factor); AlterTableForThreeBarSensor("Lacc_clear_tab!", factor); AlterTableForThreeBarSensor("Lner_detekt!", factor); AlterTableForThreeBarSensor("Lupp_detekt!", factor); AlterTableForThreeBarSensor("Sond_heat_tab!", factor); AlterTableForThreeBarSensor("Grund_last!", factor); AlterTableForThreeBarSensor("Grund_last_max!", factor); //end /* Detect_map_x_axis (1.2 factor, normal) Reg_last (1.2 factor, normal) Overstid_tab op 0 gezet (bigger turbo???) Fuel_knock_xaxis factor 1.2 + increasing in last 5 stages Fuel_map_xaxis factor 1.2 + increasing in last 5 stages Ign_map_6_x_axis factor 1.2 Ign_map_2_x_axis factor 1.2 Ign_map_0_x_axis factor 1.2 + increasing in last 8 stages Misfire_map_x_axis factor 1.2 * * */ //progress.SetProgress("Altering axis for" + infoStr); // symbols with MAP in x axis // these three need increasing last steps AlterXAxisForThreeBarSensor("Fuel_map_xaxis!", false, factor); AlterXAxisForThreeBarSensor("Fuel_knock_xaxis!", false, factor); AlterXAxisForThreeBarSensor("Ign_map_0_x_axis!", true, factor); AlterXAxisForThreeBarSensor("Ign_map_2_x_axis!", true, factor); AlterXAxisForThreeBarSensor("Ign_map_3_x_axis!", true, factor); //AlterXAxisForThreeBarSensor("Ign_map_4_x_axis!", false, factor); AlterXAxisForThreeBarSensor("Ign_map_6_x_axis!", true, factor); AlterXAxisForThreeBarSensor("Ign_map_8_x_axis!", true, factor); AlterXAxisForThreeBarSensor("Temp_reduce_x_st!", false, factor); AlterXAxisForThreeBarSensor("Misfire_map_x_axis!", true, factor); //AlterXAxisForThreeBarSensor("Mis200_map!", factor); //AlterXAxisForThreeBarSensor("Misfire_map!", factor); AlterXAxisForThreeBarSensor("Detect_map_x_axis!", true, factor); //AlterXAxisForThreeBarSensor("Knock_ref_matrix!", factor); AlterXAxisForThreeBarSensor("Idle_st_last!", false, factor); AlterXAxisForThreeBarSensor("Reg_last!", false, factor); // new symbols 25/03/2008 AlterXAxisForThreeBarSensor("Min_load_gadapt!", false, factor); AlterXAxisForThreeBarSensor("Max_load_gadapt!", false, factor); AlterXAxisForThreeBarSensor("Kadapt_load_low!", false, factor); AlterXAxisForThreeBarSensor("Kadapt_load_high!", false, factor); AlterXAxisForThreeBarSensor("Last_cyl_komp!", false, factor); AlterXAxisForThreeBarSensor("Overs_tab_xaxis!", false, factor); // end //if (!m_appSettings.PreventThreeBarRescaling) { TuneAndSmoothTable("Insp_mat!", 16); TuneAndSmoothTable("Fuel_knock_mat!", 12); TuneAndSmoothTableSixteen("Ign_map_0!", 18); TuneAndSmoothTableSixteen("Ign_map_4!", 18); } // ALTER Grund_last! // ALTER Lam_laststeg! // symbols with MAP in Y axis //AlterYAxisForThreeBarSensor("Lambdamatris!"); // Also scale inj_konst with factor 1.2 because the measured MAP value will be 1.2 factor lower // and this value is used to determine Grund_tid in injection duration calculation. //<GS-30062010> Probably better to do this after all (have a look at ChrisDuram examples) ScaleInjectorConstant(factor); //<GS-06072010> ??? should this be done? WriteThreeBarConversionMarker(m_fileInformation.Filename, toSensorType); //TryVerifyChecksum(m_fileInformation.Filename); //CheckBinForAnomalies(m_fileInformation.Filename, true, false); //progress.Close(); }
public TuningResult TuneFileToStage(int stage, string filename, IECUFile m_TrionicFile, IECUFileInformation trionicFileInformation, bool SilentMode) { //<COPY FROM HERE> m_fileInformation = trionicFileInformation; m_resume = new Trionic5Resume(); TuningResult retval = TuningResult.TuningFailed; string enginetp = readenginetype(filename); string partnumber = readpartnumber(filename); PartNumberConverter pnc = new PartNumberConverter(); ECUInformation ecuinfo = pnc.GetECUInfo(partnumber, enginetp); bool isLpt = false; if (ReadTunedToStageMarker(filename) > 0 && !SilentMode) { retval = TuningResult.TuningFailedAlreadyTuned; } else if (ReadThreeBarConversionMarker(filename) > 0 && !SilentMode) { retval = TuningResult.TuningFailedThreebarSensor; } else if (SilentMode) { Trionic5Properties t5p = m_TrionicFile.GetTrionicProperties(); if (stage == 1) { TuneToStage(filename, stage, ecuinfo.Stage1boost, 0.72, 1.54, 0.62, ecuinfo.Stage1boost, 90, isLpt, t5p.TurboType, t5p.InjectorType, t5p.MapSensorType); retval = TuningResult.TuningSuccess; } else if (stage == 2) { TuneToStage(filename, stage, ecuinfo.Stage2boost, 0.72, 1.54, 0.62, ecuinfo.Stage2boost, 90, isLpt, t5p.TurboType, t5p.InjectorType, t5p.MapSensorType); retval = TuningResult.TuningSuccess; } else if (stage == 3) { TuneToStage(filename, stage, ecuinfo.Stage3boost, 0.72, 1.54, 0.62, ecuinfo.Stage3boost, 90, isLpt, t5p.TurboType, t5p.InjectorType, t5p.MapSensorType); retval = TuningResult.TuningSuccess; } } else { Trionic5Properties t5p = m_TrionicFile.GetTrionicProperties(); string msg = string.Empty; if (ecuinfo.Valid) { msg = "Tuning your: " + ecuinfo.Bhp.ToString() + " bhp "; msg += ecuinfo.Carmodel.ToString() + " (" + ecuinfo.Enginetype.ToString() + ") "; if (ecuinfo.Is2point3liter) msg += " 2.3 liter "; else msg += " 2.0 liter "; if (ecuinfo.Isaero) { t5p.TurboType = TurboType.TD0415T; msg += " Aero binary"; } else if (ecuinfo.Isfpt) msg += " Full pressure turbo binary"; else if (ecuinfo.Isturbo) { msg += " Low pressure turbo, you'll have to modify hardware (solenoid valve, hoses etc.) to get this working!"; isLpt = true; } else msg += " non turbo car to stage, you'll have to modify hardware to get this working!"; } else { msg = "Partnumber not recognized, tuning will continue anyway, please verify settings afterwards"; } PSTaskDialog.cTaskDialog.ForceEmulationMode = false; PSTaskDialog.cTaskDialog.EmulatedFormWidth = 600; PSTaskDialog.cTaskDialog.UseToolWindowOnXP = false; PSTaskDialog.cTaskDialog.VerificationChecked = true; string stageDescription = ConvertToStageDescription(stage); PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Tune me up™ to stage " + stageDescription + " wizard", "This wizard will tune your binary to a stage " + stageDescription + " equivalent.", "Boost request map, fuel injection and ignition tables will be altered" + Environment.NewLine + msg, "Happy driving!!!\nDilemma © 2009", "The author does not take responsibility for any damage done to your car or other objects in any form!", "Show me a summary after tuning", "", "Yes, tune me to stage " + stageDescription + "|No thanks!", PSTaskDialog.eTaskDialogButtons.None, PSTaskDialog.eSysIcons.Information, PSTaskDialog.eSysIcons.Warning); switch (PSTaskDialog.cTaskDialog.CommandButtonResult) { case 0: // tune to stage 1 if (stage == 1) { TuneToStage(filename, stage, ecuinfo.Stage1boost, 0.72, 1.54, 0.62, ecuinfo.Stage1boost, 90, isLpt, t5p.TurboType, t5p.InjectorType, t5p.MapSensorType); } else if (stage == 2) { TuneToStage(filename, stage, ecuinfo.Stage2boost, 0.72, 1.54, 0.62, ecuinfo.Stage2boost, 90, isLpt, t5p.TurboType, t5p.InjectorType, t5p.MapSensorType); } else if (stage == 3) { TuneToStage(filename, stage, ecuinfo.Stage3boost, 0.72, 1.54, 0.62, ecuinfo.Stage3boost, 90, isLpt, t5p.TurboType, t5p.InjectorType, t5p.MapSensorType); } else if (stage == 99) // stage X { // get parameters from user: // max boost, turbo type, injector type, rpm limit etc etc frmTuningSettings tunset = new frmTuningSettings(); tunset.Turbo = t5p.TurboType; tunset.Injectors = t5p.InjectorType; tunset.MapSensor = t5p.MapSensorType; if (t5p.MapSensorType != MapSensorType.MapSensor25) { // set max boost etc //tunset.PeakBoost = 1.75; //tunset.BoostFuelcut = 2.05; } if (tunset.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // write details to the file if (t5p.MapSensorType != tunset.MapSensor) { ConvertFileToThreeBarMapSensor(m_fileInformation, t5p.MapSensorType, tunset.MapSensor); } // check injector type if (t5p.InjectorType != tunset.Injectors) { int inj_konst_diff = DetermineDifferenceInInjectorConstant(t5p.InjectorType, tunset.Injectors); AddToInjectorConstant(filename, inj_konst_diff); // roughly set inj_konst // Stock = 21 // Green giants = 20 (minus 1) // Siemens 630 = 16 (minus 5) // Siemens 875 = 13 (minus 8) // Siemens 1000 = 10 (minus 11) // set battery correction voltage maps SetInjectorBatteryCorrectionMap(m_TrionicFile, tunset.Injectors); } t5p.TurboType = tunset.Turbo; t5p.InjectorType = tunset.Injectors; t5p.MapSensorType = tunset.MapSensor; // determine stage?? if (tunset.PeakBoost < 1.2) stage = 1; else if (tunset.PeakBoost < 1.3) stage = 2; else if (tunset.PeakBoost < 1.4) stage = 3; else if (tunset.PeakBoost < 1.5) stage = 4; else if (tunset.PeakBoost < 1.6) stage = 5; else if (tunset.PeakBoost < 1.7) stage = 6; else if (tunset.PeakBoost < 1.8) stage = 7; else if (tunset.PeakBoost < 1.9) stage = 8; else stage = 9; if (tunset.MapSensor == MapSensorType.MapSensor30) { // set correct values double conversion = CalculateConversionFactor(MapSensorType.MapSensor25, tunset.MapSensor); tunset.PeakBoost = (((((tunset.PeakBoost + 1) * 100) / conversion) / 100) - 1); tunset.BoostFirstGear = (((((tunset.BoostFirstGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostSecondGear = (((((tunset.BoostSecondGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostFuelcut = (((((tunset.BoostFuelcut + 1) * 100) / conversion) / 100) - 1); } else if (tunset.MapSensor == MapSensorType.MapSensor35) { // set correct values double conversion = CalculateConversionFactor(MapSensorType.MapSensor25, tunset.MapSensor); tunset.PeakBoost = (((((tunset.PeakBoost + 1) * 100) / conversion) / 100) - 1); tunset.BoostFirstGear = (((((tunset.BoostFirstGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostSecondGear = (((((tunset.BoostSecondGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostFuelcut = (((((tunset.BoostFuelcut + 1) * 100) / conversion) / 100) - 1); } else if (tunset.MapSensor == MapSensorType.MapSensor40) { // set correct values double conversion = CalculateConversionFactor(MapSensorType.MapSensor25, tunset.MapSensor); tunset.PeakBoost = (((((tunset.PeakBoost + 1) * 100) / conversion) / 100) - 1); tunset.BoostFirstGear = (((((tunset.BoostFirstGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostSecondGear = (((((tunset.BoostSecondGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostFuelcut = (((((tunset.BoostFuelcut + 1) * 100) / conversion) / 100) - 1); } else if (tunset.MapSensor == MapSensorType.MapSensor50) { // set correct values double conversion = CalculateConversionFactor(MapSensorType.MapSensor25, tunset.MapSensor); tunset.PeakBoost = (((((tunset.PeakBoost + 1) * 100) / conversion) / 100) - 1); tunset.BoostFirstGear = (((((tunset.BoostFirstGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostSecondGear = (((((tunset.BoostSecondGear + 1) * 100) / conversion) / 100) - 1); tunset.BoostFuelcut = (((((tunset.BoostFuelcut + 1) * 100) / conversion) / 100) - 1); } m_TrionicFile.SetTrionicOptions(t5p); TuneToStage(filename, stage, tunset.PeakBoost, tunset.BoostFirstGear, tunset.BoostSecondGear, tunset.BoostFirstGear, tunset.BoostFuelcut, 90, /*isLpt*/ true, t5p.TurboType, t5p.InjectorType, t5p.MapSensorType); } else { retval = TuningResult.TuningCancelled; return retval; } } retval = TuningResult.TuningSuccess; break; /* case 1: // tune to stage 2 TuneToStage(2, ecuinfo.Stage2boost, 0.72, 1.54, 0.62, 1.54, 90, isLpt); break; case 2: // tune to stage 3 TuneToStage(3, ecuinfo.Stage3boost, 0.72, 1.54, 0.62, 1.54, 90, isLpt); break;*/ case 1: // cancel retval = TuningResult.TuningCancelled; break; } } return retval; }
public bool SetBoostRegulationDivisor(int divisorToSet, int currentDivisor, IECUFileInformation trionicFileInformation) { bool retval = true; m_fileInformation = trionicFileInformation; int DivisorOffset = findBoostRegulationDivisorOffset(m_fileInformation.Filename, currentDivisor); if (DivisorOffset != -1) { Console.WriteLine("DivisorOffset: " + DivisorOffset.ToString("X8")); byte[] divisor_data = readdatafromfile(m_fileInformation.Filename, DivisorOffset, 7); divisor_data[5] = Convert.ToByte(divisorToSet); // set the divisor value savedatatobinary(DivisorOffset, 7, divisor_data, m_fileInformation.Filename); // also save to the bin file for later access // <GS-19052010> also update the max rp m range for which to check // this should be 28 bytes back from DivisorOffset int maxRpm = 2500 + (30 * (divisorToSet*10)); Console.WriteLine("Max rpm to set would be: " + maxRpm.ToString()); int currentRpm = Convert.ToInt32(readbytefromfile(m_fileInformation.Filename, DivisorOffset - 28)); currentRpm *= 256; currentRpm += Convert.ToInt32(readbytefromfile(m_fileInformation.Filename, DivisorOffset - 27)); currentRpm *= 10; Console.WriteLine("Current rpm limit: " + currentRpm.ToString()); maxRpm /= 10; byte b1rpmmax = (byte)(maxRpm / 256); byte b2rpmmax = (byte)(maxRpm - (256 * b1rpmmax)); byte[] bdata = new byte[2]; bdata.SetValue(b1rpmmax, 0); bdata.SetValue(b2rpmmax, 1); savedatatobinary(DivisorOffset - 28, 2, bdata, m_fileInformation.Filename); } else { retval = false; } return retval; }
public bool SetBoostAdaptionParameters(int rpmLowManual, int rpmHighManual, int rpmLowAut, int rpmHighAut, int boostError, IECUFileInformation trionicFileInformation) { bool retval = true; m_fileInformation = trionicFileInformation; rpmLowManual /= 10; rpmHighManual /= 10; rpmLowAut /= 10; rpmHighAut /= 10; byte b1rpmlowaut = (byte)(rpmLowAut / 256); byte b2rpmlowaut = (byte)(rpmLowAut - (256 * b1rpmlowaut)); byte b1rpmhighaut = (byte)(rpmHighAut / 256); byte b2rpmhighaut = (byte)(rpmHighAut - (256 * b1rpmhighaut)); byte b1rpmlowman = (byte)(rpmLowManual / 256); byte b2rpmlowman = (byte)(rpmLowManual - (256 * b1rpmlowman)); byte b1rpmhighman = (byte)(rpmHighManual / 256); byte b2rpmhighman = (byte)(rpmHighManual - (256 * b1rpmhighman)); // search the bin file for the known sequence in the boost adaption routine // HH LL HH LL //AUTOMATIC FIRST ENTRY 33 FC 01 13 00 00 XX XX 33 FC 01 C2 00 00 XX XX //MANUAL FIRST ENTRY: 33 FC 01 13 00 00 XX XX 33 FC 01 90 00 00 XX XX // HH LL HH LL //MANUAL SECOND ENTRY 0C 79 01 13 00 00 XX XX XX XX XX XX 0C 79 01 90 00 00 XX XX int AutomaticFirstOffset = findBoostAdpationAreaAutomatic(m_fileInformation.Filename); if (AutomaticFirstOffset != -1) { Console.WriteLine("AutomaticFirstOffset: " + AutomaticFirstOffset.ToString("X8")); byte[] Aut_1_data = readdatafromfile(m_fileInformation.Filename, AutomaticFirstOffset, 14); Aut_1_data[2] = b1rpmlowaut; Aut_1_data[3] = b2rpmlowaut; Aut_1_data[10] = b1rpmhighaut; Aut_1_data[11] = b2rpmhighaut; savedatatobinary(AutomaticFirstOffset, 14, Aut_1_data, m_fileInformation.Filename); // also save to the bin file for later access } else { retval = false; } int ManualFirstOffset = findBoostAdpationAreaManualFirst(m_fileInformation.Filename); if (ManualFirstOffset != -1) { Console.WriteLine("ManualFirstOffset: " + ManualFirstOffset.ToString("X8")); byte[] Manual_1_data = readdatafromfile(m_fileInformation.Filename, ManualFirstOffset, 14); Manual_1_data[2] = b1rpmlowman; Manual_1_data[3] = b2rpmlowman; Manual_1_data[10] = b1rpmhighman; Manual_1_data[11] = b2rpmhighman; savedatatobinary(ManualFirstOffset, 14, Manual_1_data, m_fileInformation.Filename); // also save to the bin file for later access } else { retval = false; } int ManualSecondOffset = findBoostAdpationAreaManualSecond(m_fileInformation.Filename); if (ManualSecondOffset != -1) { // read data Console.WriteLine("ManualSecondOffset: " + ManualSecondOffset.ToString("X8")); byte[] Manual_2_data = readdatafromfile(m_fileInformation.Filename, ManualSecondOffset, 18); Manual_2_data[2] = b1rpmlowman; Manual_2_data[3] = b2rpmlowman; Manual_2_data[14] = b1rpmhighman; Manual_2_data[15] = b2rpmhighman; savedatatobinary(ManualSecondOffset, 18, Manual_2_data, m_fileInformation.Filename); // also save to the bin file for later access } else { retval = false; } return retval; }
public TuningResult FreeTuneBinary(IECUFile m_File, double peakTorque, double peakBoost, bool tuneBasedOnTorque, MapSensorType mapType, TurboType turboType, InjectorType injectorType, BPCType valve, int rpmlimiter, int knockTime) { Trionic5Resume _localResume = new Trionic5Resume(); m_fileInformation = m_File.GetFileInfo(); string filename = m_fileInformation.Filename; // first set things right by running the tunetostagex wizard // generate a nice x_scale for ignition map (18 long) PressureToTorque ptt = new PressureToTorque(); double peak_boost = ptt.CalculatePressureFromTorque(peakTorque, turboType); if (!tuneBasedOnTorque) peak_boost = peakBoost; double peak_boost_request = peak_boost; double correction = 1.0; if (mapType == MapSensorType.MapSensor30) correction = 1.2; if (mapType == MapSensorType.MapSensor35) correction = 1.4; if (mapType == MapSensorType.MapSensor40) correction = 1.6; if (mapType == MapSensorType.MapSensor50) correction = 2.0; peak_boost_request *= 100; peak_boost_request += 100; peak_boost_request /= correction; peak_boost_request -= 100; peak_boost_request /= 100; double min_pressure = -1; double max_pressure = peak_boost; #region preparation /********* start of prepare phase *********/ string enginetp = readenginetype(filename); string partnumber = readpartnumber(filename); PartNumberConverter pnc = new PartNumberConverter(); ECUInformation ecuinfo = pnc.GetECUInfo(partnumber, enginetp); bool isLpt = true; if (ReadTunedToStageMarker(filename) > 0) { return TuningResult.TuningFailedAlreadyTuned; } else if (ReadThreeBarConversionMarker(filename) > 0) { return TuningResult.TuningFailedThreebarSensor; } Trionic5Properties t5p = m_File.GetTrionicProperties(); if (ecuinfo.Valid) { if (ecuinfo.Isaero || ecuinfo.Isfpt) { isLpt = false; } } if (t5p.MapSensorType != mapType) { ConvertFileToThreeBarMapSensor(m_fileInformation, t5p.MapSensorType, mapType); } // check injector type if (t5p.InjectorType != injectorType) { int inj_konst_diff = DetermineDifferenceInInjectorConstant(t5p.InjectorType, injectorType); AddToInjectorConstant(filename, inj_konst_diff); SetInjectorBatteryCorrectionMap(m_File, injectorType); //TODO: check this function for correctness! } /*if (injectorType == InjectorType.Stock) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 19); else if (injectorType == InjectorType.GreenGiants) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 18); else if (injectorType == InjectorType.Siemens630Dekas) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 15); else if (injectorType == InjectorType.Siemens875Dekas) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 13); else if (injectorType == InjectorType.Siemens875Dekas) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 13);*/ t5p.TurboType = turboType; t5p.InjectorType = injectorType; t5p.MapSensorType = mapType; // determine stage?? int stage = 0; if (peak_boost < 1.2) stage = 1; else if (peak_boost < 1.3) stage = 2; else if (peak_boost < 1.4) stage = 3; else if (peak_boost < 1.5) stage = 4; else if (peak_boost < 1.6) stage = 5; else if (peak_boost < 1.7) stage = 6; else if (peak_boost < 1.8) stage = 7; else if (peak_boost < 1.9) stage = 8; else stage = 9; m_File.SetTrionicOptions(t5p); TuneToStage(filename, stage, peak_boost_request, 0.52, 1.0, 0.52, 1.54, 90, isLpt, turboType, injectorType, mapType); _localResume.ResumeTuning = m_resume.ResumeTuning.Copy(); /*********** end of prepare phase **************/ // set limiter, bpc valve type and knock time SetBPCValveType(filename, valve); _localResume.AddToResumeTable("Set BPC driving frequencies"); SetRPMLimiter(filename, rpmlimiter); _localResume.AddToResumeTable("Set RPM limiter"); SetKnockTime(filename, knockTime); _localResume.AddToResumeTable("Set knock time value"); #endregion // if mapsensor != stock and injectors are 630 cc or bigger if (mapType != MapSensorType.MapSensor25 && (injectorType == InjectorType.Siemens630Dekas || injectorType == InjectorType.Siemens875Dekas || injectorType == InjectorType.Siemens1000cc)) { // now scale it double step = (max_pressure - min_pressure) / 17; double[] axisforIgnitionMap = new double[18]; for (int i = 0; i < 18; i++) { axisforIgnitionMap.SetValue(min_pressure + (i * step), i); } byte[] actualAxis = new byte[36]; int j = 0; for (int i = 0; i < 18; i++) { double currValue = Convert.ToDouble(axisforIgnitionMap.GetValue(i)); currValue *= 100; currValue += 100; if (mapType == MapSensorType.MapSensor30) currValue /= 1.2; else if (mapType == MapSensorType.MapSensor35) currValue /= 1.4; else if (mapType == MapSensorType.MapSensor40) currValue /= 1.6; else if (mapType == MapSensorType.MapSensor50) currValue /= 2.0; int ival = Convert.ToInt32(currValue); byte v1 = (byte)(ival / 256); byte v2 = (byte)(ival - (int)v1 * 256); actualAxis.SetValue(v1, j++); actualAxis.SetValue(v2, j++); } m_File.WriteData(actualAxis, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0_x_axis!")); _localResume.AddToResumeTable("Generated and saved new ignition map x axis"); //Generate the ignition map based on the axis values GenerateAndSaveNewIgnitionMap(m_File, false); _localResume.AddToResumeTable("Generated and saved new ignition map"); min_pressure = -0.8; step = (max_pressure - min_pressure) / 15; // now setup x axis for fuel map double[] axisforFuelMap = new double[16]; for (int i = 0; i < 16; i++) { axisforFuelMap.SetValue(min_pressure + (i * step), i); } byte[] actualFuelAxis = new byte[16]; for (int i = 0; i < 16; i++) { double currValue = Convert.ToDouble(axisforFuelMap.GetValue(i)); currValue *= 100; currValue += 100; if (mapType == MapSensorType.MapSensor30) currValue /= 1.2; else if (mapType == MapSensorType.MapSensor35) currValue /= 1.4; else if (mapType == MapSensorType.MapSensor40) currValue /= 1.6; else if (mapType == MapSensorType.MapSensor50) currValue /= 2.0; int ival = Convert.ToInt32(currValue); if (ival > 255) ival = 255; actualFuelAxis.SetValue((byte)ival, i); } m_File.WriteData(actualFuelAxis, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_map_xaxis!")); _localResume.AddToResumeTable("Generated and saved new fuel map x axis"); //Generate the ignition map based on the axis values GenerateAndSaveNewFuelMap(m_File); _localResume.AddToResumeTable("Generated and saved new fuel map"); min_pressure = -0.3; step = (max_pressure - min_pressure) / 11; // now setup x axis for fuel map double[] axisforFuelKnockMap = new double[12]; for (int i = 0; i < 12; i++) { axisforFuelKnockMap.SetValue(min_pressure + (i * step), i); } byte[] actualFuelKnockAxis = new byte[12]; for (int i = 0; i < 12; i++) { double currValue = Convert.ToDouble(axisforFuelKnockMap.GetValue(i)); currValue *= 100; currValue += 100; if (mapType == MapSensorType.MapSensor30) currValue /= 1.2; else if (mapType == MapSensorType.MapSensor35) currValue /= 1.4; else if (mapType == MapSensorType.MapSensor40) currValue /= 1.6; else if (mapType == MapSensorType.MapSensor50) currValue /= 2.0; int ival = Convert.ToInt32(currValue); if (ival > 255) ival = 255; actualFuelKnockAxis.SetValue((byte)ival, i); } m_File.WriteData(actualFuelKnockAxis, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_knock_xaxis!")); _localResume.AddToResumeTable("Generated and saved new fuel knock map x axis"); //Generate the ignition map based on the axis values GenerateAndSaveNewFuelKnockMap(m_File); _localResume.AddToResumeTable("Generated and saved new fuel knock map"); // mesh up a boost request map for this.. already possible // adjust peak boost to be scaled for the mapsensor type SetBoostRequestMaps(turboType, injectorType, mapType, m_File.GetFileInfo().Filename, peak_boost_request, 100, isLpt); _localResume.AddToResumeTable("Generated boost request maps"); } m_resume.ResumeTuning = _localResume.ResumeTuning.Copy(); return TuningResult.TuningSuccess; }
private bool OpenWorkingFile(string filename) { bool retval = false; if (File.Exists(filename)) { m_trionicFile = new Trionic5File(); m_trionicFile.LibraryPath = Application.StartupPath + "\\Binaries"; m_trionicFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum); FileInfo fi = new FileInfo(filename); //<GS-07102010> remove read only flag if possible try { fi.IsReadOnly = false; btnReadOnly.Caption = "File access OK"; } catch (Exception E) { Console.WriteLine("Failed to remove read only flag: " + E.Message); btnReadOnly.Caption = "File is READ ONLY"; } m_trionicFile.onDecodeProgress += new IECUFile.DecodeProgress(m_trionicFile_onDecodeProgress); m_trionicFile.onTransactionLogChanged += new IECUFile.TransactionLogChanged(m_trionicFile_onTransactionLogChanged); m_trionicFile.SelectFile(filename); //m_trionicFileInformation = m_trionicFile.ParseTrionicFile(ofd.FileName); m_trionicFileInformation = m_trionicFile.ParseFile(); props = m_trionicFile.GetTrionicProperties(); // set indicators and menu items accoring to the file that has been opened if (props.IsTrionic55) { barECUType.Caption = "T5.5"; // enable T5.5 maps EnableT55Maps(true); } else { barECUType.Caption = "T5.2"; EnableT55Maps(false); // disable T5.5 maps } barECUSpeed.Caption = props.CPUspeed; if (props.RAMlocked) { barECULocked.Caption = "RAM locked"; } else { barECULocked.Caption = "RAM unlocked"; } if (CheckFileInLibrary(props.Partnumber)) { btnCompareToOriginalFile.Enabled = true; } else { btnCompareToOriginalFile.Enabled = false; } _ecuConnection.MapSensorType = m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType); gridSymbols.DataSource = m_trionicFileInformation.SymbolCollection; barStaticItem2.Caption = "File: " + Path.GetFileName(m_trionicFileInformation.Filename); this.Text = "T5Suite Professional 2.0 [" + Path.GetFileName(m_trionicFileInformation.Filename) + "]"; OpenGridViewGroups(gridSymbols, 0); // enable buttons barButtonItem4.Enabled = true; btnConnectECU.Enabled = true; btnSwitchMode.Enabled = true; //btnSynchronizeMaps.Enabled = true; btnTuneForE85Fuel.Enabled = true; //<GS-06042010> todo btnTuneToLargerInjectors.Enabled = true; //<GS-06042010> todo btnTuneToStage1.Enabled = true; btnTuneToStage2.Enabled = true; btnTuneToStage3.Enabled = true; btnTuneToStageX.Enabled = true; // btnTuneToThreeBarSensor.Enabled = true; barConvertMapSensor.Enabled = true; btnBoostAdaptionWizard.Enabled = true; btnHardcodedRPMLimit.Enabled = true; if (m_trionicFileInformation.Has2DRegKonMat()) { btnChangeRegkonMatRange.Enabled = true; } else { btnChangeRegkonMatRange.Enabled = false; } m_appSettings.Lastfilename = filename; ctrlRealtime1.Currentfile = filename; if (m_AFRMaps != null) { m_AFRMaps.SaveMaps(); // first save changes that might have been done } m_AFRMaps = null; if (m_AFRMaps == null && m_appSettings.AlwaysCreateAFRMaps) { m_AFRMaps = new AFRMaps(); m_AFRMaps.onFuelmapCellChanged += new AFRMaps.FuelmapCellChanged(m_AFRMaps_onFuelmapCellChanged); m_AFRMaps.onIdleFuelmapCellChanged += new AFRMaps.IdleFuelmapCellChanged(m_AFRMaps_onIdleFuelmapCellChanged); m_AFRMaps.onCellLocked += new AFRMaps.CellLocked(m_AFRMaps_onCellLocked); m_AFRMaps.TrionicFile = m_trionicFile; m_AFRMaps.InitializeMaps(); } // add realtime symbollist to ctrlRealtime1 Trionic5Tools.SymbolCollection _rtSymbols = new Trionic5Tools.SymbolCollection(); foreach (Trionic5Tools.SymbolHelper symh in m_trionicFileInformation.SymbolCollection) { if (symh.Start_address > 0 && (symh.Length >= 1 && symh.Length <= 4)) // <GS-29072010> was 1 & 2 only { _rtSymbols.Add(symh); } } ctrlRealtime1.RealtimeSymbolCollection = _rtSymbols; try { LoadUserDefinedRealtimeSymbols(); // try to load it } catch (Exception E) { Console.WriteLine(E.Message); } LoadKnockMaps(); SetTaskProgress(0, false); retval = true; } return retval; }
private void CloseProject() { if (_ecuConnection.Opened) StopOnlineMode();// StopECUConnection(); if (m_CurrentWorkingProject != "") { if (m_AFRMaps != null) { m_AFRMaps.SaveMaps(); m_AFRMaps.SaveIdleMaps(); } } m_CurrentWorkingProject = string.Empty; // unload the current file m_trionicFile = null; m_trionicFileInformation = null; barECUType.Caption = "--"; barECUSpeed.Caption = "--"; barECULocked.Caption = "--"; gridSymbols.DataSource = null; barStaticItem2.Caption = "No file"; barButtonItem4.Enabled = false; btnConnectECU.Enabled = false; btnSynchronizeMaps.Enabled = false; btnWriteLogMarker.Enabled = false; btnClearKnockCounters.Enabled = false; btnErrorCodes.Enabled = false; btnSwitchMode.Enabled = false; btnTuneForE85Fuel.Enabled = false; btnTuneToLargerInjectors.Enabled = false; btnTuneToStage1.Enabled = false; btnTuneToStage2.Enabled = false; btnTuneToStage3.Enabled = false; btnTuneToStageX.Enabled = false; // btnTuneToThreeBarSensor.Enabled = false; barConvertMapSensor.Enabled = false; btnHardcodedRPMLimit.Enabled = false; btnBoostAdaptionWizard.Enabled = false; btnChangeRegkonMatRange.Enabled = false; m_appSettings.Lastfilename = string.Empty; btnCloseProject.Enabled = false; btnShowProjectLogbook.Enabled = false; btnProduceBinaryFromProject.Enabled = false; btnProjectNote.Enabled = false; btnEditProject.Enabled = false; btnRecreateFile.Enabled = false; btnRollback.Enabled = false; btnRollForward.Enabled = false; btnShowTransactionLog.Enabled = false; this.Text = "T5Suite Professional 2.0"; }