public override void LoadSymbol(string symbolname, IECUFile trionic_file) { // autonomous m_trionic_file = trionic_file; m_trionic_file.LibraryPath = Application.StartupPath + "\\Binaries"; this.IsUpsideDown = true; // always? foreach (SymbolHelper sh in m_trionic_file.GetFileInfo().SymbolCollection) { if (sh.Varname == symbolname) { // get data from it IECUFile file = new Trionic5File(); file.LibraryPath = Application.StartupPath + "\\Binaries"; file.SetAutoUpdateChecksum(m_autoUpdateChecksum); file.SelectFile(m_trionic_file.GetFileInfo().Filename); byte[] symboldata = file.ReadData((uint)sh.Flash_start_address, (uint)sh.Length); //byte[] symboldata = file.readdatafromfile(m_trionic_file.GetFileInfo().Filename, sh.Flash_start_address, sh.Length); this.Map_content = symboldata; this.Map_length = symboldata.Length; this.Filename = m_trionic_file.GetFileInfo().Filename; if (m_trionic_file.IsTableSixteenBits(symbolname)) { //this.Map_length /= 2; } this.Map_name = symbolname; this.Correction_factor = m_trionic_file.GetCorrectionFactorForMap(symbolname); this.correction_offset = m_trionic_file.GetOffsetForMap(symbolname); this.SetViewSize(ViewSize.NormalView); //this.Viewtype = Trionic5Tools.ViewType.Easy; // set axis information SymbolAxesTranslator sat = new SymbolAxesTranslator(); sat.GetXaxisSymbol(symbolname); sat.GetYaxisSymbol(symbolname); this.X_axisvalues = m_trionic_file.GetMapXaxisValues(symbolname); this.Y_axisvalues = m_trionic_file.GetMapYaxisValues(symbolname); string x = string.Empty; string y = string.Empty; string z = string.Empty; m_trionic_file.GetMapAxisDescriptions(symbolname, out x, out y, out z); this.X_axis_name = x; this.Y_axis_name = y; this.Z_axis_name = z; int columns = 1; int rows = 1; m_trionic_file.GetMapMatrixWitdhByName(symbolname, out columns, out rows); this.ShowTable(columns, m_trionic_file.IsTableSixteenBits(symbolname)); break; } } }
private void TuneToStage(string m_currentfile, int stage, double maxBoostValue, double maxBoostFirstGear, double maxBoostSecondGear, double maxBoostFirstGearAUT, double fuelCutLevel, double AutoGearBoxPercentage, bool isLpt, TurboType turboType, InjectorType injectorType, MapSensorType mapSensorType) { m_resume = new Trionic5Resume(); m_resume.AddToResumeTable("Tuning your binary to stage: " + stage.ToString()); // get the software ID from the bainery string enginetp = readenginetype(m_currentfile); string partnumber = readpartnumber(m_currentfile); // look up parameters for this sw id PartNumberConverter pnc = new PartNumberConverter(); ECUInformation ecuinfo = pnc.GetECUInfo(partnumber, enginetp); File.Copy(m_currentfile, Path.GetDirectoryName(m_currentfile) + "\\" + Path.GetFileNameWithoutExtension(m_currentfile) + DateTime.Now.ToString("yyyyMMddHHmmss") + "beforetuningtostage" + stage.ToString() + ".bin", true); m_resume.AddToResumeTable("Backup file created (" + Path.GetFileNameWithoutExtension(m_currentfile) + DateTime.Now.ToString("yyyyMMddHHmmss") + "beforetuningtostage" + stage.ToString() + ".bin" + ")"); switch (stage) { case 1: SetRegKonMatFirstGearManual(m_currentfile, 30); SetRegKonMatSecondGearManual(m_currentfile, 45); SetRegKonMatFirstGearAutomatic(m_currentfile, 30); break; case 2: SetRegKonMatFirstGearManual(m_currentfile, 45); SetRegKonMatSecondGearManual(m_currentfile, 45); SetRegKonMatFirstGearAutomatic(m_currentfile, 45); break; case 3: default: SetRegKonMatFirstGearManual(m_currentfile, 45); SetRegKonMatSecondGearManual(m_currentfile, 45); SetRegKonMatFirstGearAutomatic(m_currentfile, 45); break; } if (CheckBoostRegulationMapEmpty(m_currentfile)) { // empty reg_kon_mat switch (stage) { case 1: FillRegulationMapValue(m_currentfile, 45); break; case 2: FillRegulationMapValue(m_currentfile, 45); break; case 3: default: FillRegulationMapValue(m_currentfile, 45); break; } } if (CheckBoostRegulationAUTMapEmpty(m_currentfile)) { switch (stage) { case 1: FillRegulationAUTMapValue(m_currentfile, 45); break; case 2: FillRegulationAUTMapValue(m_currentfile, 45); break; case 3: default: FillRegulationAUTMapValue(m_currentfile, 45); break; } } if (CheckPIDControlEmpty(m_currentfile)) { FillDefaultPIDControls(m_currentfile); } if (CheckPIDControlAUTEmpty(m_currentfile)) { FillDefaultPIDAUTControls(m_currentfile); } //depending on turbotype!!! SetBoostRequestMaps(turboType, injectorType, mapSensorType, m_currentfile, maxBoostValue, AutoGearBoxPercentage, isLpt); if (/*!isLpt*/true) // don't if T5.2&& m_currentfile_size > 0x20000 { // should be percentages /* SetInjectionMap(m_currentfile,15, 15, 255); SetInjectionMap(m_currentfile,14, 15, 253); SetInjectionMap(m_currentfile,13, 15, 253); SetInjectionMap(m_currentfile,12, 15, 249); SetInjectionMap(m_currentfile,11, 15, 248); SetInjectionMap(m_currentfile,10, 15, 245); SetInjectionMap(m_currentfile,9, 15, 236); SetInjectionMap(m_currentfile,15, 14, 255); SetInjectionMap(m_currentfile,14, 14, 253); SetInjectionMap(m_currentfile,13, 14, 253); SetInjectionMap(m_currentfile,12, 14, 235); SetInjectionMap(m_currentfile,11, 14, 234); SetInjectionMap(m_currentfile,10, 14, 226); SetInjectionMap(m_currentfile,9, 14, 225); SetInjectionMap(m_currentfile,15, 13, 248); SetInjectionMap(m_currentfile,14, 13, 245); SetInjectionMap(m_currentfile,13, 13, 245); SetInjectionMap(m_currentfile,12, 13, 224); SetInjectionMap(m_currentfile,11, 13, 217); SetInjectionMap(m_currentfile,10, 13, 205); SetInjectionMap(m_currentfile,9, 13, 189); SetInjectionMap(m_currentfile,15, 12, 219); SetInjectionMap(m_currentfile,14, 12, 215); SetInjectionMap(m_currentfile,13, 12, 213); SetInjectionMap(m_currentfile,12, 12, 206); SetInjectionMap(m_currentfile,11, 12, 205); SetInjectionMap(m_currentfile,10, 12, 198); SetInjectionMap(m_currentfile,9, 12, 176); SetInjectionMap(m_currentfile,15, 11, 198); SetInjectionMap(m_currentfile,14, 11, 192); SetInjectionMap(m_currentfile,13, 11, 191); SetInjectionMap(m_currentfile,12, 11, 190); SetInjectionMap(m_currentfile,11, 11, 190); SetInjectionMap(m_currentfile,10, 11, 183); SetInjectionMap(m_currentfile,9, 11, 163);*/ } IncreaseInjectionKnockMap(m_currentfile, 0, 4); IncreaseInjectionKnockMap(m_currentfile, 1, 4); IncreaseInjectionKnockMap(m_currentfile, 2, 4); //SetIgnitionMap(m_currentfile, 15, 17, 1.5); //SetIgnitionMap(m_currentfile, 14, 17, 1.0); //SetIgnitionMap(m_currentfile, 13, 17, 0.5); //byte fuelcut = (byte)((fuelCutLevel + 1) * 100); SetBoostLimitMap(m_currentfile, 254 /* fuelcut */); //m_resume.m_resume.AddToResumeTable("Updated fuelcut map to: " + fuelCutLevel.ToString() + " bar"); byte fglimit = (byte)((maxBoostFirstGear + 1) * 100); SetFirstGearLimiter(m_currentfile, fglimit); m_resume.AddToResumeTable("Updated first gear limiter (MAN) to: " + maxBoostFirstGear.ToString() + " bar"); byte fgalimit = (byte)((maxBoostFirstGearAUT + 1) * 100); SetFirstGearLimiterAutoTrans(m_currentfile, fgalimit); m_resume.AddToResumeTable("Updated first gear limiter (AUT) to: " + maxBoostFirstGearAUT.ToString() + " bar"); byte sglimit = (byte)((maxBoostSecondGear + 1) * 100); SetSecondGearLimiter(m_currentfile, sglimit); m_resume.AddToResumeTable("Updated second gear limiter (MAN) to: " + maxBoostSecondGear.ToString() + " bar"); // <Guido> add Max_regl_temp1 Max_regl_temp2 SetMaxReglTempValues(m_currentfile, 250); try { Trionic5Anomalies anomalies = new Trionic5Anomalies(); anomalies.CheckBinForAnomalies(m_currentfile, m_resume, false, true, m_fileInformation ); } catch (Exception E) { Console.WriteLine("CheckBinForAnomalies: " + E.Message); } // mark this particular file as tuned to stage X, to prevent running the wizard on this file again! //enginetp = enginetp.Substring(0, enginetp.Length - 4); //enginetp += "T5S" + stage.ToString(); //writeenginetype(enginetp); WriteTunedToStageMarker(m_currentfile, stage); m_resume.AddToResumeTable("Updated binary description with tuned stage"); Trionic5File file = new Trionic5File(); file.LibraryPath = Application.StartupPath + "\\Binaries"; file.SetAutoUpdateChecksum(m_autoUpdateChecksum); file.UpdateChecksum(m_currentfile); }
private Trionic5File CompareSymbolTable(string filename, Trionic5Tools.SymbolCollection curSymbolCollection, AddressLookupCollection curAddressLookupCollection, DevExpress.XtraGrid.GridControl curGridControl, out Trionic5FileInformation m_CompareInfo) { //bool m_fileparsed = false; //listView1.Items.Clear(); SetStatusText("Start symbol parsing"); SetTaskProgress(0, true); Trionic5File m_CompareToFile = new Trionic5File(); m_CompareToFile.LibraryPath = Application.StartupPath + "\\Binaries"; m_CompareToFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum); m_CompareToFile.SelectFile(filename); m_CompareToFile.onDecodeProgress += new IECUFile.DecodeProgress(m_CompareToFile_onDecodeProgress); m_CompareInfo = m_CompareToFile.ParseTrionicFile(filename); // available in repository? curSymbolCollection = m_CompareInfo.SymbolCollection; curAddressLookupCollection = m_CompareInfo.AddressCollection; // ParseFile(progress, filename, curTrionic5Tools.SymbolCollection, curAddressLookupCollection); // m_fileparsed = true; // AddLogItem("Start symbol export..."); curSymbolCollection.SortColumn = "Start_address"; curSymbolCollection.SortingOrder = Trionic5Tools.GenericComparer.SortOrder.Ascending; curSymbolCollection.Sort(); // progress.SetProgress("Filling list"); SetStatusText("Filling list"); //listView1.SuspendLayout(); System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SRAMADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHBYTES", Type.GetType("System.Int32")); dt.Columns.Add("LENGTHVALUES", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("ISCHANGED", Type.GetType("System.Boolean")); dt.Columns.Add("CATEGORY", Type.GetType("System.Int32")); dt.Columns.Add("DIFFPERCENTAGE", Type.GetType("System.Double")); dt.Columns.Add("DIFFABSOLUTE", Type.GetType("System.Int32")); dt.Columns.Add("DIFFAVERAGE", Type.GetType("System.Double")); dt.Columns.Add("CATEGORYNAME"); dt.Columns.Add("SUBCATEGORYNAME"); foreach (Trionic5Tools.SymbolHelper sh in curSymbolCollection) { float diffperc = 0; int diffabs = 0; float diffavg = 0; if (!CompareSymbolToCurrentFile(sh.Varname, sh.Flash_start_address, sh.Length, filename, out diffperc, out diffabs, out diffavg)) { dt.Rows.Add(sh.Varname, sh.Start_address, sh.Flash_start_address, sh.Length, sh.Length, m_trionicFileInformation.GetSymbolDescription(sh.Varname), false, (int)m_trionicFileInformation.GetSymbolCategory(sh.Varname), diffperc, diffabs, diffavg, m_trionicFileInformation.GetSymbolCategory(sh.Varname).ToString().Replace("_", " "), m_trionicFileInformation.GetSymbolSubcategory(sh.Varname).ToString().Replace("_", " ")); } } curGridControl.DataSource = dt; /*if (m_fileparsed) { CreateRepositoryItem(filename, curTrionic5Tools.SymbolCollection); }*/ //listView1.ResumeLayout(); SetStatusText("Idle"); SetTaskProgress(0, false); return m_CompareToFile; //barButtonItem14.Enabled = true; }
private void CompareSymbolTableToFile(string filename, Trionic5Tools.SymbolCollection curSymbolCollection, AddressLookupCollection curAddressLookupCollection, out int numberofsymboldifferent) { numberofsymboldifferent = 0; if (filename != string.Empty) { //bool m_fileparsed = false; SetTaskProgress(0, true); SetStatusText("Start symbol parsing"); // available in repository? //ParseFile(progress, filename, curTrionic5Tools.SymbolCollection, curAddressLookupCollection); Trionic5File m_CompareToFile = new Trionic5File(); m_CompareToFile.LibraryPath = Application.StartupPath + "\\Binaries"; m_CompareToFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum); m_CompareToFile.onDecodeProgress += new IECUFile.DecodeProgress(m_CompareToFile_onDecodeProgress); Trionic5FileInformation m_CompareInfo = m_CompareToFile.ParseTrionicFile(filename); // available in repository? curSymbolCollection = m_CompareInfo.SymbolCollection; curAddressLookupCollection = m_CompareInfo.AddressCollection; //m_fileparsed = true; // AddLogItem("Start symbol export..."); curSymbolCollection.SortColumn = "Start_address"; curSymbolCollection.SortingOrder = Trionic5Tools.GenericComparer.SortOrder.Ascending; curSymbolCollection.Sort(); //listView1.SuspendLayout(); foreach (Trionic5Tools.SymbolHelper sh in curSymbolCollection) { float diffperc = 0; int diffabs = 0; float diffavg = 0; if (!CompareSymbolToCurrentFile(sh.Varname, sh.Flash_start_address, sh.Length, filename, out diffperc, out diffabs, out diffavg)) { numberofsymboldifferent++; } } /*if (m_fileparsed) { CreateRepositoryItem(filename, curTrionic5Tools.SymbolCollection); }*/ //listView1.ResumeLayout(); SetTaskProgress(0, false); SetStatusText("Idle"); //barButtonItem14.Enabled = true; //progress.Close(); } else { frmInfoBox info = new frmInfoBox("No file selected, please select one first"); } }
private void TransferMapsToNewBinary(string filename, Trionic5Resume resume) { IECUFile m_FileToTransferTo = new Trionic5File(); m_FileToTransferTo.LibraryPath = Application.StartupPath + "\\Binaries"; m_FileToTransferTo.SetAutoUpdateChecksum(m_appSettings.AutoChecksum); m_FileToTransferTo.SelectFile(filename); Trionic5FileInformation m_FileInfoToTransferTo = new Trionic5FileInformation(); if (filename != string.Empty) { File.Copy(filename, Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + DateTime.Now.ToString("yyyyMMddHHmmss") + "beforetransferringmaps.bin", true); resume.AddToResumeTable("Backup file created"); //bool m_fileparsed = false; SetStatusText("Start symbol parsing"); m_FileInfoToTransferTo = m_FileToTransferTo.ParseFile(); //m_fileparsed = true; foreach (Trionic5Tools.SymbolHelper sh in m_FileInfoToTransferTo.SymbolCollection) { if (sh.Flash_start_address > 0) { foreach (Trionic5Tools.SymbolHelper cfsh in m_trionicFileInformation.SymbolCollection) { if (cfsh.Varname == sh.Varname) { //progress.SetProgress("Transferring: " + sh.Varname); CopySymbol(sh.Varname, m_trionicFileInformation.Filename, m_FileToTransferTo, cfsh.Flash_start_address, cfsh.Length, filename, sh.Flash_start_address, sh.Length, resume); } } } } SetStatusText("Idle."); } }