private void simpleButton3_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Binary files|*.bin"; ofd.Multiselect = false; ofd.Title = "Select a file to extract VIN and Immobilizer code from"; if (ofd.ShowDialog() == DialogResult.OK) { if (_previousVIN == string.Empty) { _previousVIN = ChassisID; } if (_previousImmo == string.Empty) { _previousImmo = ImmoID; } T7FileHeader t7InfoHeader = new T7FileHeader(); t7InfoHeader.init(ofd.FileName, false); // fetch the immo & VIN from another binary file ChassisID = t7InfoHeader.getChassisID(); ImmoID = t7InfoHeader.getImmobilizerID(); simpleButton4.Enabled = true; Application.DoEvents(); } }
public frmTuningWizard(frmMain inParent, string in_m_currentfile) { InitializeComponent(); parent = inParent; // Set-up some navigation rules this.wizConfirmPage.AllowNext = false; this.wizCompletedPage.AllowBack = false; // Read software version from binary if (in_m_currentfile != string.Empty) { if (File.Exists(in_m_currentfile)) { T7FileHeader t7InfoHeader = new T7FileHeader(); t7InfoHeader.init(in_m_currentfile, false); softwareVersion = t7InfoHeader.getSoftwareVersion().Trim(); this.lblSoftwareVersion.Text = softwareVersion.Substring(0, 8); } } // List all compatible tuning packages foreach (frmMain.TuningAction t in frmMain.installedTunings) { if (t.compatibelSoftware(softwareVersion)) { this.listTuningActions.Items.Add(t); } } if (this.listTuningActions.ItemCount <= 0) { this.wizSelectActionPage.AllowNext = false; } }
private void btnVinDecoder_ItemClick(object sender, ItemClickEventArgs e) { frmDecodeVIN decode = new frmDecodeVIN(); if (m_currentfile != string.Empty) { T7FileHeader t7InfoHeader = new T7FileHeader(); t7InfoHeader.init(m_currentfile, m_appSettings.AutoFixFooter); decode.SetVinNumber(t7InfoHeader.getChassisID()); } decode.ShowDialog(); }
private void btnTuneBinary_ItemClick(object sender, ItemClickEventArgs e) { if (ValidateFile()) { // read tuned marker to see if binary has been tuned before T7FileHeader fh = new T7FileHeader(); fh.init(m_currentfile, m_appSettings.AutoFixFooter); PartNumberConverter pnc = new PartNumberConverter(); ECUInformation ecuinfo = pnc.GetECUInfo(fh.getPartNumber().Trim(), ""); //<GS-05102010> Need to validate the type of binary file loaded (which engine type and turbo type, A/M transmission) // and base the initially targeted torque and power figures on that frmTuningWizard tunWiz = new frmTuningWizard(); string msg = "Partnumber not recognized, tuning will continue anyway, please verify settings afterwards"; //msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm"; if (ecuinfo.Valid) { msg = "Partnumber " + fh.getPartNumber() + ", carmodel " + ecuinfo.Carmodel.ToString() + ", engine " + ecuinfo.Enginetype.ToString(); //msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm"; } tunWiz.ExtraInfo = msg; if (ecuinfo.Stage1torque != 0) { tunWiz.PeakTorque = Convert.ToInt32(ecuinfo.Stage1torque); } if (tunWiz.ShowDialog() == DialogResult.OK) { int desiredHP = tunWiz.DesiredHP; bool carRunsE85 = tunWiz.CarRunsE85; // convert HP to torque and airmass //int torque = PowerToTorque(desiredHP, 6000); //int peaktorque = (110 * torque) / 100; int peaktorque = tunWiz.PeakTorque; int maxairmass = TorqueToAirmass(peaktorque, carRunsE85); // give user a warning if airmass/c > 1300 mg/c if (maxairmass > 1300) { frmInfoBox info = new frmInfoBox("Your maximum requested airmass exceeds 1300 mg/c [" + maxairmass.ToString() + " mg/c]. Please make sure all your other maps will support this airflow!"); } TuneToStageNew(1, maxairmass, peaktorque, desiredHP, ecuinfo.Enginetype, carRunsE85); TuningReport tuningrep = new TuningReport(); tuningrep.DataSource = resumeTuning; tuningrep.CreateReport(); tuningrep.ShowPreview(defaultLookAndFeel1.LookAndFeel); } // start window to ask user for desired horses (depending on E85 usage?) /*frmTuneBinary frmTune = new frmTuneBinary(); if (ecuinfo.Stage1torque != 0) { frmTune.PeakTorque = Convert.ToInt32(ecuinfo.Stage1torque); } if (frmTune.ShowDialog() == DialogResult.OK) { int desiredHP = frmTune.DesiredHP; bool carRunsE85 = frmTune.CarRunsE85; // convert HP to torque and airmass //int torque = PowerToTorque(desiredHP, 6000); //int peaktorque = (110 * torque) / 100; int peaktorque = frmTune.PeakTorque; int maxairmass = TorqueToAirmass(peaktorque, carRunsE85); // give user a warning if airmass/c > 1300 mg/c if (maxairmass > 1300) { MessageBox.Show("Your maximum requested airmass exceeds 1300 mg/c [" + maxairmass.ToString() + " mg/c]. Please make sure all your other maps will support this airflow!", "Warning!", MessageBoxButtons.OK); } string msg = "Partnumber not recognized, tuning will continue anyway, please verify settings afterwards"; msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm"; if (ecuinfo.Valid) { msg = "Partnumber " + fh.getPartNumber() + ", carmodel " + ecuinfo.Carmodel.ToString() + ", engine " + ecuinfo.Enginetype.ToString(); msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm"; } PSTaskDialog.cTaskDialog.ForceEmulationMode = false; PSTaskDialog.cTaskDialog.EmulatedFormWidth = 600; PSTaskDialog.cTaskDialog.UseToolWindowOnXP = false; PSTaskDialog.cTaskDialog.VerificationChecked = true; PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Tune me up™ wizard", "This wizard will tune your binary.", "Several maps 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 up!|No thanks!", eTaskDialogButtons.None, eSysIcons.Information, eSysIcons.Warning); switch (PSTaskDialog.cTaskDialog.CommandButtonResult) { case 0: // tune to stage x // must use fixed maps, scaled to be good for the current airmass (e.g. pedalrequest map) TuneToStageNew(1, maxairmass, peaktorque, desiredHP, ecuinfo.Enginetype, carRunsE85); break; case 1: // cancel break; } if (PSTaskDialog.cTaskDialog.VerificationChecked && PSTaskDialog.cTaskDialog.CommandButtonResult != 1) { TuningReport tuningrep = new TuningReport(); tuningrep.DataSource = resumeTuning; tuningrep.CreateReport(); tuningrep.ShowPreview(defaultLookAndFeel1.LookAndFeel); } }*/ } }
private bool verifychecksum(bool showinterface) { //Verify checksums and show result bool m_checksums_ok = true; if (File.Exists(m_currentfile)) { T7FileHeader t7InfoHeader = null; t7InfoHeader = new T7FileHeader(); t7InfoHeader.init(m_currentfile, m_appSettings.AutoFixFooter); ChecksumHandler csHandler = new ChecksumHandler(); csHandler.SramOffset = m_currentSramOffsett; int fwLength = t7InfoHeader.getFWLength(); int calculatedFWChecksum = csHandler.calculateFWChecksum(m_currentfile); uint calculatedF2Checksum = csHandler.calculateF2Checksum(m_currentfile, 0, fwLength); int calculatedFBChecksum = csHandler.calculateFBChecksum(m_currentfile, 0, fwLength); int readF2checksum = t7InfoHeader.getChecksumF2(); int readFBchecksum = t7InfoHeader.getChecksumFB(); if (readF2checksum != 0) { if (t7InfoHeader.getChecksumF2() != (int)calculatedF2Checksum) { m_checksums_ok = false; } } if (t7InfoHeader.getChecksumFB() != calculatedFBChecksum) { m_checksums_ok = false; } if (csHandler.getFWChecksum(m_currentfile) != calculatedFWChecksum) { m_checksums_ok = false; } if (m_checksums_ok) { if (showinterface) { frmInfoBox info = new frmInfoBox("Checksums verified and all matched!"); } } else { if (m_appSettings.AutoChecksum) { logger.Debug("calculatedF2Checksum = " + calculatedF2Checksum.ToString("X8") + " readF2checksum = " + readF2checksum.ToString("X8")); logger.Debug("calculatedFBChecksum = " + calculatedFBChecksum.ToString("X8") + " readFBchecksum = " + readFBchecksum.ToString("X8")); logger.Debug("calculatedFWChecksum = " + calculatedFWChecksum.ToString("X8") + " csHandler.getFWChecksum(m_currentfile) = " + csHandler.getFWChecksum(m_currentfile).ToString("X8")); csHandler.setFWChecksum(m_currentfile, calculatedFWChecksum); t7InfoHeader.setChecksumF2((int)calculatedF2Checksum); t7InfoHeader.setChecksumFB(calculatedFBChecksum); t7InfoHeader.save(m_currentfile); if (showinterface) { frmInfoBox info = new frmInfoBox("Checksums did not verify ok, but were recalculated."); } } else { if (MessageBox.Show("Checksums did not verify ok, do you want to recalculate and update the checksums?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes) { csHandler.setFWChecksum(m_currentfile, calculatedFWChecksum); t7InfoHeader.setChecksumF2((int)calculatedF2Checksum); t7InfoHeader.setChecksumFB(calculatedFBChecksum); t7InfoHeader.save(m_currentfile); } } } } else { if (showinterface) { frmInfoBox info = new frmInfoBox("Current file does not exsist, please re-open the file."); } } return m_checksums_ok; }
private void UpdateChecksum(string m_fileName) { T7FileHeader t7InfoHeader = null; t7InfoHeader = new T7FileHeader(); t7InfoHeader.init(m_fileName, m_appSettings.AutoFixFooter); ChecksumHandler csHandler = new ChecksumHandler(); csHandler.SramOffset = m_currentSramOffsett; int fwLength = t7InfoHeader.getFWLength(); int calculatedFWChecksum = csHandler.calculateFWChecksum(m_fileName); logger.Debug("FW Checksum: " + calculatedFWChecksum.ToString("X8")); csHandler.setFWChecksum(m_fileName, calculatedFWChecksum); uint calculatedF2Checksum = csHandler.calculateF2Checksum(m_fileName, 0, fwLength); int calculatedFBChecksum = csHandler.calculateFBChecksum(m_fileName, 0, fwLength); t7InfoHeader.setChecksumF2((int)calculatedF2Checksum); t7InfoHeader.setChecksumFB(calculatedFBChecksum); t7InfoHeader.save(m_fileName); }
private Trionic7File TryToOpenFileUsingClass(string filename, out SymbolCollection symbol_collection, int filename_size, bool isWorkingFile) { Trionic7File retval = new Trionic7File(); retval.onProgress += retval_onProgress; SymbolTranslator translator = new SymbolTranslator(); string help = string.Empty; _softwareIsOpen = false; _softwareIsOpenDetermined = false; m_currentsramfile = string.Empty; // geen sramfile erbij barStaticItem1.Caption = ""; barFilenameText.Caption = ""; FileInfo fi = new FileInfo(filename); try { fi.IsReadOnly = false; btnReadOnly.Caption = "File access OK"; } catch (Exception E) { logger.Debug("Failed to remove read only flag: " + E.Message); btnReadOnly.Caption = "File is READ ONLY"; } try { if (isWorkingFile) { T7FileHeader t7InfoHeader = new T7FileHeader(); if (t7InfoHeader.init(filename, m_appSettings.AutoFixFooter)) { m_current_softwareversion = t7InfoHeader.getSoftwareVersion(); m_currentSramOffsett = ReverseInt(t7InfoHeader.Unknown_9cvalue); } else { m_current_softwareversion = ""; } } } catch (Exception E2) { logger.Debug(E2.Message); } AddFileToMRUList(filename); symbol_collection = retval.ExtractFile(filename, m_appSettings.ApplicationLanguage, m_current_softwareversion); SetProgressPercentage(60); SetProgress("Examining file"); System.Windows.Forms.Application.DoEvents(); if (isWorkingFile) { if (m_currentSramOffsett == 0) { m_currentSramOffsett = retval.SramOffsetForOpenFile; logger.Debug("Overrules m_currentSramOffsett with value from t7file: " + m_currentSramOffsett.ToString("X8")); } // <GS-27042010> now we need to check if there is a symbol information XML file present. try { IsSoftwareOpen(); // fill in the rest of the parameters barFilenameText.Caption = Path.GetFileNameWithoutExtension(filename); } catch (Exception E3) { logger.Debug(E3.Message); } } if (IsBinaryBiopower()) { foreach (SymbolHelper sh in symbol_collection) { if (sh.Varname == "BFuelCal.StartMap") { sh.Varname = "BFuelCal.E85Map"; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory sub = XDFSubCategory.Undocumented; sh.Description = translator.TranslateSymbolToHelpText(sh.Varname, out help, out cat, out sub, m_appSettings.ApplicationLanguage); } if (sh.Userdescription == "BFuelCal.StartMap") { sh.Userdescription = "BFuelCal.E85Map"; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory sub = XDFSubCategory.Undocumented; sh.Description = translator.TranslateSymbolToHelpText(sh.Userdescription, out help, out cat, out sub, m_appSettings.ApplicationLanguage); } } } return retval; }
private void LoadCompressorMapWithDetails() { // we should get the top line like for the chart if (gridControl1.DataSource != null) { DataTable dt = (DataTable)gridControl1.DataSource; double[] boost_req = new double[dt.Columns.Count]; /*PressureToTorque ptt = new PressureToTorque(); for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++) { double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i)); // we get the airmass from this.. now convert to boost pressure double trq = AirmassToTorque(Convert.ToInt32(o), Convert.ToInt32(x_axisvalues.GetValue(i)), checkEdit7.Checked); double val = ptt.CalculatePressureFromTorque(trq, TurboType.TD0415T); boost_req.SetValue(val, i); }*/ for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++) { double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i)); boost_req.SetValue(o, i); } ctrlCompressorMap1.Boost_request = boost_req; // set rpm range ctrlCompressorMap1.Rpm_points = x_axisvalues; PartNumberConverter pnc = new PartNumberConverter(); // T7FileHeader header = new T7FileHeader(); header.init(m_currentfile, false); ECUInformation ecuinfo = pnc.GetECUInfo(header.getPartNumber().Trim(), ""); if (ecuinfo.Is2point3liter) ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter23; else ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter2; //ctrlCompressorMap1.SetCompressorType(ctrlCompressorMap.CompressorMap.TD04); //TODO: always for now, later rewrite and add the GT17 map ctrlCompressorMap1.Redraw(); } }
private void File_CompareToOriginal_ItemClick(object sender, ItemClickEventArgs e) { T7FileHeader t7header = new T7FileHeader(); t7header.init(m_currentfile, false); if (Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\Binaries")) { string[] files = Directory.GetFiles(System.Windows.Forms.Application.StartupPath + "\\Binaries", t7header.getPartNumber() + ".bin"); if (files.Length == 1) { CompareToFile((string)files.GetValue(0)); } } }
private void Projects_btnCreateProject_ItemClick(object sender, ItemClickEventArgs e) { // show the project properties screen for the user to fill in // if a bin file is loaded, ask the user whether this should be the new projects binary file // the project XML should contain a reference to this binfile as well as a lot of other stuff frmProjectProperties projectprops = new frmProjectProperties(); if (m_currentfile != string.Empty) { projectprops.BinaryFile = m_currentfile; T7FileHeader fileheader = new T7FileHeader(); fileheader.init(m_currentfile, false); projectprops.CarModel = fileheader.getCarDescription().Trim(); projectprops.ProjectName = fileheader.getPartNumber().Trim() + " " + fileheader.getSoftwareVersion().Trim(); } if (projectprops.ShowDialog() == DialogResult.OK) { if (!Directory.Exists(m_appSettings.ProjectFolder)) Directory.CreateDirectory(m_appSettings.ProjectFolder); // create a new folder with these project properties. // also copy the binary file into the subfolder for this project if (Directory.Exists(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName))) { frmInfoBox info = new frmInfoBox("The chosen projectname already exists, please choose another one"); //TODO: reshow the dialog } else { // create the project Directory.CreateDirectory(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName)); // copy the selected binary file to this folder string binfilename = m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName) + "\\" + Path.GetFileName(projectprops.BinaryFile); File.Copy(projectprops.BinaryFile, binfilename); // now create the projectproperties.xml in this new folder System.Data.DataTable dtProps = new System.Data.DataTable("T5PROJECT"); dtProps.Columns.Add("CARMAKE"); dtProps.Columns.Add("CARMODEL"); dtProps.Columns.Add("CARMY"); dtProps.Columns.Add("CARVIN"); dtProps.Columns.Add("NAME"); dtProps.Columns.Add("BINFILE"); dtProps.Columns.Add("VERSION"); dtProps.Rows.Add(projectprops.CarMake, projectprops.CarModel, projectprops.CarMY, projectprops.CarVIN, MakeDirName(projectprops.ProjectName), binfilename, projectprops.Version); dtProps.WriteXml(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName) + "\\projectproperties.xml"); OpenProject(projectprops.ProjectName); //? } } }
private void OpenFile(string filename, bool showmessage) { m_fileiss19 = false; m_currentsramfile = string.Empty; // geen sramfile erbij barStaticItem1.Caption = ""; if (filename.ToUpper().EndsWith(".S19")) { m_fileiss19 = true; srec2bin convert = new srec2bin(); string convertedfile = string.Empty; if (convert.ConvertSrecToBin(filename, out convertedfile)) { filename = convertedfile; } else { frmInfoBox info = new frmInfoBox("Failed to convert S19 file to binary"); } } FileInfo fi = new FileInfo(filename); try { fi.IsReadOnly = false; } catch (Exception E) { logger.Debug("Failed to clear readonly flag: " + E.Message); // failed } m_currentfile = filename; m_appSettings.Lastfilename = m_currentfile; if (ValidateFile()) { m_symbols = new SymbolCollection(); t7file = TryToOpenFileUsingClass(m_currentfile, out m_symbols, m_currentfile_size, true); SetProgressPercentage(70); SetProgress("Sorting data"); System.Windows.Forms.Application.DoEvents(); m_symbols.SortColumn = "Length"; m_symbols.SortingOrder = GenericComparer.SortOrder.Descending; m_symbols.Sort(); SetProgressPercentage(80); SetProgress("Loading data into view"); gridControlSymbols.DataSource = m_symbols; //gridViewSymbols.BestFitColumns(); SetDefaultFilters(); Text = String.Format("T7SuitePro v{0} [ {1} ]", System.Windows.Forms.Application.ProductVersion, Path.GetFileName(m_currentfile)); SetProgressPercentage(90); SetProgress("Loading realtime info"); // also rearrange the symbolnumbers in the realtime view UpdateRealTimeDataTableWithNewSRAMValues(); SetProgressPercentage(100); System.Windows.Forms.Application.DoEvents(); } else { m_symbols = new SymbolCollection(); gridControlSymbols.DataSource = m_symbols; Text = String.Format("T7SuitePro v{0} [ none ]", System.Windows.Forms.Application.ProductVersion); if (showmessage) { frmInfoBox info = new frmInfoBox("File is not a Trionic 7 binary file!"); } m_currentfile = string.Empty; } logger.Debug("Number of symbols loaded: " + m_symbols.Count); try { int _width = 18; int _height = 16; if (m_appSettings.AutoCreateAFRMaps) { GetTableMatrixWitdhByName(m_currentfile, m_symbols, "BFuelCal.Map", out _width, out _height); m_AFRMap.RpmYSP = GetSymbolAsIntArray("BFuelCal.RpmYSP"); m_AFRMap.AirXSP = GetSymbolAsIntArray("BFuelCal.AirXSP"); m_AFRMap.InitializeMaps(_width * _height, m_currentfile); } } catch (Exception E) { logger.Debug("Failed to load AFR maps: " + E.Message); } try { T7FileHeader t7header = new T7FileHeader(); t7header.init(m_currentfile, false); if(CheckFileInLibrary(t7header.getPartNumber())) { btnCompareToOriginal.Enabled = true; } else btnCompareToOriginal.Enabled = false; } catch (Exception E) { logger.Debug(E.Message); } if (m_currentfile != string.Empty) LoadRealtimeTable(); // <GS-07072011> If the opened file is a BioPower file, then BFuelCal.StartMap = the actual fuel E85 map if (IsBinaryBiopower()) { barButtonItem67.Caption = "Petrol VE Map"; barButtonItem69.Caption = "E85 VE Map"; } else { barButtonItem67.Caption = "VE map"; barButtonItem69.Caption = "Startup VE map"; } DynamicTuningMenu(); System.Windows.Forms.Application.DoEvents(); }
private void simpleButton3_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Binary files|*.bin"; ofd.Multiselect = false; ofd.Title = "Select a file to extract VIN and Immobilizer code from"; if (ofd.ShowDialog() == DialogResult.OK) { if (_previousVIN == string.Empty) _previousVIN = ChassisID; if (_previousImmo == string.Empty) _previousImmo = ImmoID; T7FileHeader t7InfoHeader = new T7FileHeader(); t7InfoHeader.init(ofd.FileName, false); // fetch the immo & VIN from another binary file ChassisID = t7InfoHeader.getChassisID(); ImmoID = t7InfoHeader.getImmobilizerID(); simpleButton4.Enabled = true; Application.DoEvents(); } }
private void simpleButton3_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Binary files|*.bin"; if (ofd.ShowDialog() == DialogResult.OK) { m_current_comparefilename = ofd.FileName; SymbolTranslator translator = new SymbolTranslator(); string help = string.Empty; FileInfo fi = new FileInfo(m_current_comparefilename); fi.IsReadOnly = false; try { T7FileHeader t7InfoHeader = new T7FileHeader(); if (t7InfoHeader.init(m_current_comparefilename, false)) { m_current_softwareversion = t7InfoHeader.getSoftwareVersion(); } else { m_current_softwareversion = ""; } } catch (Exception E2) { logger.Debug(E2.Message); } Trionic7File t7file = new Trionic7File(); Compare_symbol_collection = t7file.ExtractFile(m_current_comparefilename, 44, m_current_softwareversion); // so... now determine the max values for the compare file // show the dynograph xtraTabControl1.SelectedTabPage = xtraTabPage2; LoadGraphWithDetails(); // initial values from original bin //DataTable dt = CalculateDataTable(m_current_comparefilename, Compare_symbol_collection); //LoadExtraGraphFromCompareBin(dt, m_current_comparefilename); } }
private void LoadCompressorMapWithDetails() { // we should get the top line like for the chart if (gridControl1.DataSource != null) { TurboType tt = TurboType.TD0415T; if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.T25_55 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.T25_60 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT17) { tt = TurboType.Stock; } else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD04 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD0416T) { tt = TurboType.TD0415T; } else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD0418T || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD0419T) { tt = TurboType.TD0419T; } else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT2871R || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT28RS) { tt = TurboType.GT28RS; } else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT3071R86 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT30R) { tt = TurboType.GT3071R; } else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT40R || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.HX40W) { tt = TurboType.HX40w; } DataTable dt = (DataTable)gridControl1.DataSource; double[] boost_req = new double[dt.Columns.Count]; /*PressureToTorque ptt = new PressureToTorque(); <GS-09032011> changed to airmass calculation for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++) { double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i)); // we get the airmass from this.. now convert to boost pressure double trq = AirmassToTorque(Convert.ToInt32(o), Convert.ToInt32(x_axisvalues.GetValue(i)), checkEdit7.Checked); double val = ptt.CalculatePressureFromTorque(trq, tt ); boost_req.SetValue(val, i); }*/ for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++) { double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i)); boost_req.SetValue(o, i); } ctrlCompressorMap1.Boost_request = boost_req; // set rpm range ctrlCompressorMap1.Rpm_points = x_axisvalues; PartNumberConverter pnc = new PartNumberConverter(); // T7FileHeader header = new T7FileHeader(); header.init(m_currentfile, false); ECUInformation ecuinfo = pnc.GetECUInfo(header.getPartNumber().Trim(), ""); if (!ctrlCompressorMap1.IsInitiallyLoaded) { if (ecuinfo.Is2point3liter) ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter23; else ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter2; if (ecuinfo.Isaero) ctrlCompressorMap1.SetCompressorType(ctrlCompressorMap.CompressorMap.TD04); else ctrlCompressorMap1.SetCompressorType(ctrlCompressorMap.CompressorMap.GT17); } ctrlCompressorMap1.IsInitiallyLoaded = true; ctrlCompressorMap1.Redraw(); } }
private void CompareToFile(string filename) { if (m_symbols.Count > 0) { dockManager1.BeginUpdate(); try { DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); CompareResults tabdet = new CompareResults(); tabdet.ShowAddressesInHex = m_appSettings.ShowAddressesInHex; tabdet.SetFilterMode(m_appSettings.ShowAddressesInHex); tabdet.Dock = DockStyle.Fill; tabdet.Filename = filename; tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelect); dockPanel.Controls.Add(tabdet); dockPanel.Text = "Compare results: " + Path.GetFileName(filename); dockPanel.DockTo(dockManager1, DockingStyle.Left, 1); dockPanel.Width = 700; SymbolCollection compare_symbols = new SymbolCollection(); FileInfo fi = new FileInfo(filename); Trionic7File compareFile = TryToOpenFileUsingClass(filename, out compare_symbols, (int)fi.Length, false); barProgress.EditValue = 60; barProgress.Caption = "Loading header"; System.Windows.Forms.Application.DoEvents(); T7FileHeader t7fh = new T7FileHeader(); t7fh.init(filename, false); int m_sramOffset = ReverseInt(t7fh.Unknown_9cvalue); if (m_sramOffset == 0) m_sramOffset = compareFile.SramOffsetForOpenFile; if (m_sramOffset == 0) m_sramOffset = 0xEFFC04; barProgress.EditValue = 90; barProgress.Caption = "Starting compare"; System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents(); barProgress.Visibility = BarItemVisibility.Always; barProgress.Caption = "Comparing symbols in files..."; barProgress.EditValue = 0; System.Windows.Forms.Application.DoEvents(); 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")); //0 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"); dt.Columns.Add("SymbolNumber1", Type.GetType("System.Int32")); dt.Columns.Add("SymbolNumber2", Type.GetType("System.Int32")); dt.Columns.Add("Userdescription"); dt.Columns.Add("MissingInOriFile", Type.GetType("System.Boolean")); dt.Columns.Add("MissingInCompareFile", Type.GetType("System.Boolean")); string category = ""; string ht = string.Empty; double diffperc = 0; int diffabs = 0; double diffavg = 0; int percentageDone = 0; int symNumber = 0; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; if (compare_symbols.Count > 0) { CompareResults cr = new CompareResults(); cr.ShowAddressesInHex = m_appSettings.ShowAddressesInHex; cr.SetFilterMode(m_appSettings.ShowAddressesInHex); SymbolTranslator st = new SymbolTranslator(); Int64 compareStartAddress = 0; Int64 orgStartAddress = 0; foreach (SymbolHelper sh_compare in compare_symbols) { try { symNumber++; percentageDone = (symNumber * 50) / compare_symbols.Count; if (Convert.ToInt32(barProgress.EditValue) != percentageDone) { barProgress.EditValue = percentageDone; System.Windows.Forms.Application.DoEvents(); } } catch (Exception E) { logger.Debug(E.Message); } string compareName = sh_compare.Varname; if (compareName.StartsWith("Symbolnumber")) compareName = sh_compare.Userdescription; compareStartAddress = sh_compare.Flash_start_address; if (IsSoftwareOpen(compare_symbols)) { // get address if (IsSymbolCalibration(compareName) && sh_compare.Length < 0x400 && sh_compare.Flash_start_address > m_currentfile_size) { compareStartAddress = sh_compare.Flash_start_address - m_sramOffset; } } foreach (SymbolHelper sh_org in m_symbols) { string originalName = sh_org.Varname; if (originalName.StartsWith("Symbolnumber")) originalName = sh_org.Userdescription; if (compareName.Equals(originalName) && compareName != String.Empty) { if (compareStartAddress > 0 && compareStartAddress < 0x80000) { orgStartAddress = (int)GetSymbolAddress(m_symbols, sh_org.Varname); if (orgStartAddress > 0 && orgStartAddress < 0x80000) { if (!CompareSymbolToCurrentFile(compareName, (int)compareStartAddress, sh_compare.Length, filename, out diffperc, out diffabs, out diffavg)) { category = ""; if (sh_org.Varname.Contains(".")) { try { category = sh_org.Varname.Substring(0, sh_org.Varname.IndexOf(".")); } catch (Exception cE) { logger.Debug("Failed to assign category to symbol: " + sh_org.Varname + " err: " + cE.Message); } } else if (sh_org.Userdescription.Contains(".")) { try { category = sh_org.Userdescription.Substring(0, sh_org.Userdescription.IndexOf(".")); } catch (Exception cE) { logger.Debug("Failed to assign category to symbol: " + sh_org.Userdescription + " err: " + cE.Message); } } dt.Rows.Add(sh_compare.Varname, sh_compare.Start_address, compareStartAddress, sh_compare.Length, sh_compare.Length, st.TranslateSymbolToHelpText(sh_compare.Varname, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage), false, 0, diffperc, diffabs, diffavg, category, "", sh_org.Symbol_number, sh_compare.Symbol_number, sh_org.Userdescription, false, false); } } } break; } } } symNumber = 0; string varnameori = string.Empty; string varnamecomp = string.Empty; foreach (SymbolHelper shtest in compare_symbols) { try { symNumber++; percentageDone = 50 + (symNumber * 25) / compare_symbols.Count; if (Convert.ToInt32(barProgress.EditValue) != percentageDone) { barProgress.EditValue = percentageDone; System.Windows.Forms.Application.DoEvents(); } } catch (Exception E) { logger.Debug(E.Message); } bool _foundSymbol = false; varnamecomp = shtest.Varname; if (varnamecomp.StartsWith("Symbolnumber")) varnamecomp = shtest.Userdescription; if (IsSymbolCalibration(varnamecomp)) { foreach (SymbolHelper shoritest in m_symbols) { varnameori = shoritest.Varname; if (varnameori.StartsWith("Symbolnumber")) varnameori = shoritest.Userdescription; if (varnamecomp == varnameori) { _foundSymbol = true; break; } } if (!_foundSymbol) { // add this symbol to the MissingInOriCollection dt.Rows.Add(varnamecomp, shtest.Start_address, shtest.Flash_start_address, shtest.Length, shtest.Length, st.TranslateSymbolToHelpText(varnamecomp, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage), false, 0, 0, 0, 0, "Missing in original", "", 0, shtest.Symbol_number, shtest.Userdescription, true, false); } } } symNumber = 0; foreach (SymbolHelper shtest in m_symbols) { try { symNumber++; percentageDone = 75 + (symNumber * 25) / compare_symbols.Count; if (Convert.ToInt32(barProgress.EditValue) != percentageDone) { barProgress.EditValue = percentageDone; System.Windows.Forms.Application.DoEvents(); } } catch (Exception E) { logger.Debug(E.Message); } bool _foundSymbol = false; varnamecomp = shtest.Varname; if (varnamecomp.StartsWith("Symbolnumber")) varnamecomp = shtest.Userdescription; if (IsSymbolCalibration(varnamecomp)) { foreach (SymbolHelper shoritest in compare_symbols) { varnameori = shoritest.Varname; if (varnameori.StartsWith("Symbolnumber")) varnameori = shoritest.Userdescription; if (varnamecomp == varnameori) { _foundSymbol = true; break; } } if (!_foundSymbol) { // add this symbol to the MissingInCompCollection dt.Rows.Add(varnamecomp, shtest.Start_address, shtest.Flash_start_address, shtest.Length, shtest.Length, st.TranslateSymbolToHelpText(varnamecomp, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage), false, 0, 0, 0, 0, "Missing in compare", "", 0, shtest.Symbol_number, shtest.Userdescription, false, true); } } } tabdet.CompareSymbolCollection = compare_symbols; tabdet.OriginalSymbolCollection = m_symbols; tabdet.OriginalFilename = m_currentfile; tabdet.CompareFilename = filename; tabdet.OpenGridViewGroups(tabdet.gridControl1, 1); tabdet.gridControl1.DataSource = dt.Copy(); barProgress.Visibility = BarItemVisibility.Never; barProgress.Caption = "Done"; } } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); } }
private void SaveAdditionalSymbols() { using (System.Data.DataTable dt = new System.Data.DataTable(Path.GetFileNameWithoutExtension(m_currentfile))) { dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); T7FileHeader fh = new T7FileHeader(); fh.init(m_currentfile, false); string checkstring = fh.getPartNumber() + fh.getSoftwareVersion(); string xmlfilename = String.Format("{0}\\repository\\{1}{2:yyyyMMddHHmmss}{3}.xml", System.Windows.Forms.Application.StartupPath, Path.GetFileNameWithoutExtension(m_currentfile), File.GetCreationTime(m_currentfile), checkstring); if (Directory.Exists(String.Format("{0}\\repository", System.Windows.Forms.Application.StartupPath))) { if (File.Exists(xmlfilename)) { File.Delete(xmlfilename); } } else { Directory.CreateDirectory(String.Format("{0}\\repository", System.Windows.Forms.Application.StartupPath)); } foreach (SymbolHelper sh in m_symbols) { if (sh.Userdescription != "") { if (sh.Userdescription == String.Format("Symbolnumber {0}", sh.Symbol_number)) { dt.Rows.Add(sh.Userdescription, sh.Symbol_number, sh.Flash_start_address, sh.Varname); } else { dt.Rows.Add(sh.Varname, sh.Symbol_number, sh.Flash_start_address, sh.Userdescription); } } } dt.WriteXml(xmlfilename); } }
private void DynamicTuningMenu() { // // Show Tuning menu shortcuts depening on which file that was loaded. // if (m_currentfile != string.Empty) { if (File.Exists(m_currentfile)) { T7FileHeader t7header = new T7FileHeader(); t7header.init(m_currentfile, false); string swVersion = t7header.getSoftwareVersion(); // B308E if (swVersion.Substring(8, 3) == ".CB") { } if (IsSymbolInBinary("BoostCal.RegMap")) { ribbonPageGroup22.Visible = true; } else { ribbonPageGroup22.Visible = false; } if (IsBinaryBiopower()) { barButtonItem37.Visibility = BarItemVisibility.Always; barButtonItem65.Visibility = BarItemVisibility.Always; if (IsSymbolInBinary("TorqueCal.M_EngMaxE85TabAut")) { barButtonItem95.Visibility = BarItemVisibility.Always; } else { barButtonItem95.Visibility = BarItemVisibility.Never; } } else { barButtonItem95.Visibility = BarItemVisibility.Never; barButtonItem37.Visibility = BarItemVisibility.Never; barButtonItem65.Visibility = BarItemVisibility.Never; } if (IsSymbolInBinary("TorqueCal.M_CabGearLim")) { barButtonItem54.Visibility = BarItemVisibility.Always; } else { barButtonItem54.Visibility = BarItemVisibility.Never; } } } }
private void TransferMapsToNewBinary(string filename) { SymbolCollection curSymbolCollection = new SymbolCollection(); //AddressLookupCollection curAddressLookupCollection = new AddressLookupCollection(); resumeTuning = new System.Data.DataTable(); resumeTuning.Columns.Add("Description"); if (filename != string.Empty) { frmTransferSelectionSymbolsSelection frmtransfer = new frmTransferSelectionSymbolsSelection(); SymbolCollection _onlyFlashSymbols = new SymbolCollection(); foreach (SymbolHelper shcopy in m_symbols) { if (shcopy.Flash_start_address > 0 && GetSymbolAddress(m_symbols, shcopy.Varname) < 524288 && shcopy.Length > 0 && ShouldTransferSymbol(shcopy)) { _onlyFlashSymbols.Symbols.Add(shcopy); } } frmtransfer.Symbols = /*m_symbols*/_onlyFlashSymbols; if (frmtransfer.ShowDialog() == DialogResult.OK) { barProgress.Visibility = BarItemVisibility.Always; barProgress.Caption = "Initializing"; barProgress.EditValue = 0; System.Windows.Forms.Application.DoEvents(); File.Copy(filename, Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + DateTime.Now.ToString("yyyyMMddHHmmss") + "beforetransferringmaps.bin", true); AddToResumeTable("Backup file created (" + Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + DateTime.Now.ToString("yyyyMMddHHmmss") + "beforetransferringmaps.bin)"); AddToResumeTable("Transferring data from " + Path.GetFileName(m_currentfile) + " to " + filename); //bool m_fileparsed = false; //listView1.Items.Clear(); SetStatusText("Start symbol parsing"); FileInfo fi = new FileInfo(filename); Trionic7File transferToFile = TryToOpenFileUsingClass(filename, out curSymbolCollection, (int)fi.Length, false); T7FileHeader t7fh = new T7FileHeader(); t7fh.init(filename, false); int m_sramOffset = ReverseInt(t7fh.Unknown_9cvalue); if (m_sramOffset == 0) m_sramOffset = transferToFile.SramOffsetForOpenFile; if (m_sramOffset == 0) m_sramOffset = 0xEFFC04; curSymbolCollection.SortColumn = "Flash_start_address"; curSymbolCollection.SortingOrder = GenericComparer.SortOrder.Ascending; curSymbolCollection.Sort(); //progress.SetProgress("Start transfer"); barProgress.Caption = "Start transferring"; barProgress.EditValue = 1; System.Windows.Forms.Application.DoEvents(); Int64 currentFlashAddress = 0; foreach (SymbolHelper sh in curSymbolCollection) { currentFlashAddress = sh.Flash_start_address; //TODO: Keep open bins in mind which have sram addresses in stead of normal addresses if (IsSoftwareOpen(curSymbolCollection)) { // get address if (IsSymbolCalibration(sh.Varname) && sh.Length < 0x400 && sh.Flash_start_address > m_currentfile_size) { currentFlashAddress = sh.Flash_start_address - m_sramOffset; } } if (currentFlashAddress > 0 && currentFlashAddress < m_currentfile_size && sh.Length < 0x1000) { foreach (SymbolHelper cfsh in m_symbols) { if (ShouldTransferSymbol(cfsh)) { if (cfsh.Varname == sh.Varname || cfsh.Userdescription == sh.Varname || sh.Userdescription == cfsh.Varname || (cfsh.Userdescription == sh.Userdescription && sh.Userdescription != "")) { // set correct symbolname string symbolname = cfsh.Varname; if (symbolname.StartsWith("Symbolnumber")) { if (!sh.Varname.StartsWith("Symbolnumber")) symbolname = sh.Varname; else if (sh.Userdescription != "") symbolname = sh.Userdescription; else if (cfsh.Userdescription != "") symbolname = cfsh.Userdescription; } if (SymbolInTransferCollection(frmtransfer.Symbols, symbolname)) { //progress.SetProgress("Transferring: " + symbolname); barProgress.Caption = "Transferring: " + symbolname; barProgress.EditValue = 50; System.Windows.Forms.Application.DoEvents(); CopySymbol(symbolname, m_currentfile, (int)GetSymbolAddress(m_symbols, cfsh.Varname), cfsh.Length, filename, (int)currentFlashAddress, sh.Length); } } } } } } //progress.SetProgress("Starting report..."); barProgress.Caption = "Starting report..."; barProgress.EditValue = 80; System.Windows.Forms.Application.DoEvents(); UpdateChecksum(filename); verifychecksum(false); SetStatusText("Idle."); barProgress.EditValue = 0; barProgress.Caption = "Done"; barProgress.Visibility = BarItemVisibility.Never; //progress.Close(); } } }
private void Information_firmwareInformation_ItemClick(object sender, ItemClickEventArgs e) { // show firmware information screen! bool _correctFooter = m_appSettings.AutoFixFooter; frmFirmwareInformation frminfo = new frmFirmwareInformation(); if (m_currentfile != null) { if (File.Exists(m_currentfile)) { T7FileHeader t7InfoHeader = new T7FileHeader(); t7InfoHeader.init(m_currentfile, m_appSettings.AutoFixFooter); string swVersion = t7InfoHeader.getSoftwareVersion(); PartNumberConverter pnc = new PartNumberConverter(); ECUInformation ecuinfo = pnc.GetECUInfo(t7InfoHeader.getPartNumber().Trim(), ""); frminfo.SIDDate = t7InfoHeader.getSIDDate(); if (ecuinfo.Valid) { frminfo.OriginalCarType = ecuinfo.Carmodel.ToString(); frminfo.OriginalEngineType = ecuinfo.Enginetype.ToString(); } if (swVersion.Trim() == "EU0AF01C.55P" || swVersion.Trim() == "EU0AF01C.46T" || swVersion.Trim().StartsWith("ET02U01C") || swVersion.Trim() == "ET03F01C.46S") { // additional requirements for the bytes in that location // http://www.trionictuning.com/forum/viewtopic.php?f=17&t=109&p=8569#p8537 // set these options correct if (swVersion.Trim().StartsWith("EU0AF01C") || swVersion.Trim() == "ET03F01C.46S") { if ((CheckBytesInFile(m_currentfile, 0x4968E, 0, 2) || (CheckBytesInFile(m_currentfile, 0x4968E, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x4968F, 0x80, 1))) && (CheckBytesInFile(m_currentfile, 0x496B4, 0, 2) || (CheckBytesInFile(m_currentfile, 0x496B4, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x496B5, 0x80, 1))) && (CheckBytesInFile(m_currentfile, 0x49760, 0, 2) || (CheckBytesInFile(m_currentfile, 0x49760, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x49761, 0x80, 1)))) { frminfo.EnableSIDAdvancedOptions(true); if (/*CheckBytesInFile(m_currentfile, 0x495FA, 0, 2) &&*/ CheckBytesInFile(m_currentfile, 0x4968E, 0, 2) && CheckBytesInFile(m_currentfile, 0x496B4, 0, 2)) { frminfo.SIDDisableStartScreen = true; } else { frminfo.SIDDisableStartScreen = false; } if (CheckBytesInFile(m_currentfile, 0x49760, 0, 2)) // should be 0x49760 in stead of 0x4975E { frminfo.SIDDisableAdaptionMessages = true; } else { frminfo.SIDDisableAdaptionMessages = false; } /* * Remove startup screen: change to 00 00 instead of 00 80 000495FA // not needed!!! <GS-11042011> 0004968E 000496B4 Remove adaptation messages: Change 0x49760 to 00 00 instead of 00 80 */ } else { frminfo.EnableSIDAdvancedOptions(false); } } else { if ((CheckBytesInFile(m_currentfile, 0x46F4D, 0, 1) || CheckBytesInFile(m_currentfile, 0x46F4D, 0x80, 1)) && (CheckBytesInFile(m_currentfile, 0x4701F, 0, 1) || CheckBytesInFile(m_currentfile, 0x4701F, 0x80, 1))) { frminfo.EnableSIDAdvancedOptions(true); //Disable startscreen, change 0x00046F4D to 00 in stead of 80 if (CheckBytesInFile(m_currentfile, 0x46F4D, 0, 1)) { frminfo.SIDDisableStartScreen = true; } else { frminfo.SIDDisableStartScreen = false; } //Remove the adaption messages, change 0x0004701F to 00 in stead of 80 if (CheckBytesInFile(m_currentfile, 0x4701F, 0, 1)) { frminfo.SIDDisableAdaptionMessages = true; } else { frminfo.SIDDisableAdaptionMessages = false; } } else { frminfo.EnableSIDAdvancedOptions(false); } } } else { frminfo.EnableSIDAdvancedOptions(false); } // Pavel Angelov created this modification. // Disable effect of the emission limitation function. if (swVersion.Trim().StartsWith("EU0AF01C")) { if (CheckBytesInFile(m_currentfile, 0x13837, 0x03, 1)) { frminfo.EmissionLimitation = true; frminfo.EnableEmissionLimitation(true); } else if (CheckBytesInFile(m_currentfile, 0x13837, 0x02, 1)) { frminfo.EmissionLimitation = false; frminfo.EnableEmissionLimitation(true); } else { frminfo.EnableEmissionLimitation(false); } } else { frminfo.EnableEmissionLimitation(false); } frminfo.SoftwareID = t7InfoHeader.getSoftwareVersion(); frminfo.ChassisID = t7InfoHeader.getChassisID(); frminfo.EngineType = t7InfoHeader.getCarDescription(); frminfo.Partnumber = t7InfoHeader.getPartNumber(); frminfo.ImmoID = t7InfoHeader.getImmobilizerID(); frminfo.SoftwareIsOpen = IsBinaryFileOpen(); frminfo.BioPowerSoftware = IsBinaryBiopower(); frminfo.BioPowerEnabled = IsBioPowerEnabled(); frminfo.CompressedSymboltable = IsBinaryPackedVersion(m_currentfile); frminfo.MissingSymbolTable = IsBinaryMissingSymbolTable(); if (frminfo.MissingSymbolTable) frminfo.BioPowerSoftware = true; // only missing in biopower software frminfo.ChecksumEnabled = HasBinaryChecksumEnabled(); frminfo.TorqueLimitersEnabled = HasBinaryTorqueLimiterEnabled(); if (!HasBinaryTorqueLimiters()) frminfo.TorqueLimitersPresent = false; //if (!frminfo.MissingSymbolTable) { frminfo.OBDIIPresent = HasBinaryOBDIIMaps(); if (!frminfo.OBDIIPresent) { frminfo.OBDIIEnabled = false; } else { frminfo.OBDIIEnabled = HasBinaryOBDIIEnabled(); } } if (HasBinaryOBDIIMaps()) { frminfo.OBDIIEnabled = HasBinaryOBDIIEnabled(); } frminfo.SecondLambdaEnabled = HasBinarySecondLambdaEnabled(); if (!HasBinarySecondLambdaMap()) frminfo.SecondLambdaPresent = false; if (!HasBinaryTipInOutParameters()) frminfo.FastThrottleResponsePresent = false; else frminfo.FastThrottleResponsePresent = true; frminfo.FastThrottleReponse = HasBinaryFastThrottleResponse(); frminfo.ExtraFastThrottleReponse = HasBinaryExtraFastThrottleResponse(); if (!HasBinaryTipInOutParameters()) { frminfo.FastThrottleReponse = false; frminfo.ExtraFastThrottleReponse = false; } if (!HasBinaryCatalystLightOffParameters()) frminfo.CatalystLightoffPresent = false; else frminfo.CatalystLightoffPresent = true; frminfo.CatalystLightOff = HasBinaryCatalystLightOffEnabled(); frminfo.ProgrammingDateTime = GetProgrammingDateTime(); if (!m_appSettings.WriteTimestampInBinary) { frminfo.DisableTimeStamping(); } if (frminfo.ShowDialog() == DialogResult.OK) { if (t7InfoHeader.IsTISBinary(m_currentfile)) { // user is trying to update a TIS file, ask for footer correction. if ((frminfo.ImmoID != t7InfoHeader.getImmobilizerID()) || frminfo.ChassisID != t7InfoHeader.getChassisID()) { if (!_correctFooter) { if (MessageBox.Show("It seems you are trying to update data in a TIS file, would you like T7Suite to correct the footer information?", "TIS file question", MessageBoxButtons.YesNo) == DialogResult.Yes) { //_correctFooter = true; // create a backup file at this point File.Copy(m_currentfile, Path.GetDirectoryName(m_currentfile) + "\\" + Path.GetFileNameWithoutExtension(m_currentfile) + DateTime.Now.ToString("yyyyMMddHHmmss") + ".binarybackup", true); t7InfoHeader.init(m_currentfile, true); } } } } t7InfoHeader.setImmobilizerID(frminfo.ImmoID); t7InfoHeader.setSoftwareVersion(frminfo.SoftwareID); t7InfoHeader.setCarDescription(frminfo.EngineType); t7InfoHeader.setChassisID(frminfo.ChassisID); t7InfoHeader.setSIDDate(frminfo.SIDDate); if (GetProgrammingDateTime() != frminfo.ProgrammingDateTime) { SetProgrammingDateTime(frminfo.ProgrammingDateTime); } if (frminfo.SoftwareIsOpen) { SetBinaryFileOpen(); } else { SetBinaryFileClosed(); } if (frminfo.TorqueLimitersEnabled && !HasBinaryTorqueLimiterEnabled() && HasBinaryTorqueLimiters()) { SetTorqueLimiterEnabled(true); } else if (!frminfo.TorqueLimitersEnabled && HasBinaryTorqueLimiterEnabled() && HasBinaryTorqueLimiters()) { SetTorqueLimiterEnabled(false); } if (frminfo.OBDIIEnabled && !HasBinaryOBDIIEnabled()) { SetOBDIIEnabled(true); } else if (!frminfo.OBDIIEnabled && HasBinaryOBDIIEnabled()) { SetOBDIIEnabled(false); } if (frminfo.SecondLambdaEnabled && HasBinarySecondLambdaMap()/*&& !HasBinarySecondLambdaEnabled()*/) { SetSecondLambdaEnabled(true); } else if (!frminfo.SecondLambdaEnabled && HasBinarySecondLambdaMap() && HasBinarySecondLambdaEnabled()) { SetSecondLambdaEnabled(false); } if (HasBinaryTipInOutParameters()) { if (frminfo.FastThrottleReponse && !HasBinaryFastThrottleResponse()) { SetFastThrottleResponse(true); } else if (!frminfo.FastThrottleReponse && HasBinaryFastThrottleResponse()) { SetFastThrottleResponse(false); } if (frminfo.ExtraFastThrottleReponse && !HasBinaryExtraFastThrottleResponse()) { SetExtraFastThrottleResponse(true); } else if (!frminfo.ExtraFastThrottleReponse && !frminfo.FastThrottleReponse && HasBinaryExtraFastThrottleResponse()) { SetExtraFastThrottleResponse(false); } else if (!frminfo.ExtraFastThrottleReponse && frminfo.FastThrottleReponse && HasBinaryExtraFastThrottleResponse()) { SetActG2(false); } } if (HasBinaryCatalystLightOffParameters()) { if (frminfo.CatalystLightOff && !HasBinaryCatalystLightOffEnabled()) { SetCatalystLightOff(true); } else if (!frminfo.CatalystLightOff && HasBinaryCatalystLightOffEnabled()) { SetCatalystLightOff(false); } } if (IsBinaryBiopower()) { if (frminfo.BioPowerEnabled && !IsBioPowerEnabled()) { SetBioPowerEnabled(true); } else if (!frminfo.BioPowerEnabled && IsBioPowerEnabled()) { SetBioPowerEnabled(false); } } t7InfoHeader.save(m_currentfile); if (swVersion.Trim() == "EU0AF01C.55P" || swVersion.Trim() == "EU0AF01C.46T" || swVersion.Trim().StartsWith("ET02U01C") || swVersion.Trim() == "ET03F01C.46S") { if (swVersion.Trim().StartsWith("EU0AF01C") || swVersion.Trim() == "ET03F01C.46S") { if ((CheckBytesInFile(m_currentfile, 0x4968E, 0, 2) || (CheckBytesInFile(m_currentfile, 0x4968E, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x4968F, 0x80, 1))) && (CheckBytesInFile(m_currentfile, 0x496B4, 0, 2) || (CheckBytesInFile(m_currentfile, 0x496B4, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x496B5, 0x80, 1))) && (CheckBytesInFile(m_currentfile, 0x49760, 0, 2) || (CheckBytesInFile(m_currentfile, 0x49760, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x49761, 0x80, 1)))) { if (frminfo.SIDDisableStartScreen) { byte[] data2write = new byte[2]; data2write.SetValue((byte)0x00, 0); data2write.SetValue((byte)0x00, 1); //savedatatobinary(0x495FA, 2, data2write, m_currentfile, false); savedatatobinary(0x4968E, 2, data2write, m_currentfile, false); savedatatobinary(0x496B4, 2, data2write, m_currentfile, false); } else { byte[] data2write = new byte[2]; data2write.SetValue((byte)0x00, 0); data2write.SetValue((byte)0x80, 1); //savedatatobinary(0x495FA, 2, data2write, m_currentfile, false); savedatatobinary(0x4968E, 2, data2write, m_currentfile, false); savedatatobinary(0x496B4, 2, data2write, m_currentfile, false); } if (frminfo.SIDDisableAdaptionMessages) { byte[] data2write = new byte[2]; data2write.SetValue((byte)0x00, 0); data2write.SetValue((byte)0x00, 1); savedatatobinary(0x49760, 2, data2write, m_currentfile, false); } else { byte[] data2write = new byte[2]; data2write.SetValue((byte)0x00, 0); data2write.SetValue((byte)0x80, 1); savedatatobinary(0x49760, 2, data2write, m_currentfile, false); } } } else { if ((CheckBytesInFile(m_currentfile, 0x46F4D, 0, 1) || CheckBytesInFile(m_currentfile, 0x46F4D, 0x80, 1)) && (CheckBytesInFile(m_currentfile, 0x4701F, 0, 1) || CheckBytesInFile(m_currentfile, 0x4701F, 0x80, 1))) { //Disable startscreen, change 0x00046F4D to 00 in stead of 80 //Remove the adaption messages, change 0x0004701F to 00 in stead of 80 if (frminfo.SIDDisableStartScreen) { byte[] data2write = new byte[1]; data2write.SetValue((byte)0x00, 0); savedatatobinary(0x46F4D, 1, data2write, m_currentfile, false); } else { byte[] data2write = new byte[1]; data2write.SetValue((byte)0x80, 0); savedatatobinary(0x46F4D, 1, data2write, m_currentfile, false); } if (frminfo.SIDDisableAdaptionMessages) { byte[] data2write = new byte[1]; data2write.SetValue((byte)0x00, 0); savedatatobinary(0x4701F, 1, data2write, m_currentfile, false); } else { byte[] data2write = new byte[1]; data2write.SetValue((byte)0x80, 0); savedatatobinary(0x4701F, 1, data2write, m_currentfile, false); } } } } // Disable effect of the emission limitation function. if (swVersion.Trim().StartsWith("EU0AF01C")) { if (frminfo.EmissionLimitation) { byte[] data2write = new byte[1]; data2write.SetValue((byte)0x03, 0); savedatatobinary(0x13837, 1, data2write, m_currentfile, false); } else { byte[] data2write = new byte[1]; data2write.SetValue((byte)0x02, 0); savedatatobinary(0x13837, 1, data2write, m_currentfile, false); } } UpdateChecksum(m_currentfile); } } } }
/// <summary> /// /// </summary> /// <param name="filename"></param> /// <param name="m_symbols"></param> /// <param name="LanguageID"></param> private static void TryToLoadAdditionalSymbols(string filename, SymbolCollection m_symbols, int LanguageID) { DataTable dt = new DataTable(Path.GetFileNameWithoutExtension(filename)); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); T7FileHeader fh = new T7FileHeader(); fh.init(filename, false); string checkstring = fh.getPartNumber() + fh.getSoftwareVersion(); string xmlfilename = String.Format("{0}\\repository\\{1}{2:yyyyMMddHHmmss}{3}.xml", Application.StartupPath, Path.GetFileNameWithoutExtension(filename), File.GetCreationTime(filename), checkstring); if (File.Exists(xmlfilename)) { dt.ReadXml(xmlfilename); } else { // check the file folder string[] xmlfiles = Directory.GetFiles(Path.GetDirectoryName(filename), "*.xml"); foreach (string xmlfile in xmlfiles) { if (Path.GetFileName(xmlfile).StartsWith(Path.GetFileNameWithoutExtension(filename))) { dt.ReadXml(xmlfile); logger.Debug(String.Format("Read: {0} symbols from {1}", dt.Rows.Count, xmlfile)); break; } } } // auto add symbols for 55P / 46T files only if no other sources of additional symbols can be found bool createRepositoryFile = false; if (dt.Rows.Count == 0) { if (fh.getSoftwareVersion().Trim().StartsWith("EU0AF01C", StringComparison.OrdinalIgnoreCase) || fh.getSoftwareVersion().Trim().StartsWith("EU0BF01C", StringComparison.OrdinalIgnoreCase) || fh.getSoftwareVersion().Trim().StartsWith("EU0CF01C", StringComparison.OrdinalIgnoreCase)) { if (MessageBox.Show("Do you want to load the known symbollist for EU0AF01C/EU0BF01C/EU0CF01C files now?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes) { string BioPowerXmlFile = String.Format("{0}\\EU0AF01C.xml", Application.StartupPath); if (File.Exists(BioPowerXmlFile)) { string binname = GetFileDescriptionFromFile(BioPowerXmlFile); if (binname != string.Empty) { dt = new DataTable(binname); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32")); dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32")); dt.Columns.Add("DESCRIPTION"); dt.ReadXml(BioPowerXmlFile); createRepositoryFile = true; } } } } } foreach (DataRow dr in dt.Rows) { try { SymbolHelper sh = m_symbols[Convert.ToInt32(dr["SYMBOLNUMBER"])]; if (dr["SYMBOLNAME"].ToString() == sh.Varname) { if (sh.Flash_start_address == Convert.ToInt32(dr["FLASHADDRESS"])) { if (sh.Varname == String.Format("Symbolnumber {0}", sh.Symbol_number)) { sh.Userdescription = sh.Varname; sh.Varname = dr["DESCRIPTION"].ToString(); } else { sh.Userdescription = dr["DESCRIPTION"].ToString(); } string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory sub = XDFSubCategory.Undocumented; SymbolTranslator st = new SymbolTranslator(); sh.Description = st.TranslateSymbolToHelpText(sh.Varname, out helptext, out cat, out sub, LanguageID); if (sh.Category == "Undocumented" || sh.Category == "") { if (sh.Varname.Contains(".")) { try { sh.Category = sh.Varname.Substring(0, sh.Varname.IndexOf(".")); //logger.Debug(String.Format("Set cat to {0} for {1}", sh.Category, sh.Userdescription)); } catch (Exception cE) { logger.Debug(String.Format("Failed to assign category to symbol: {0} err: {1}", sh.Userdescription, cE.Message)); } } } } } } catch (Exception E) { logger.Debug(E.Message); } } if (createRepositoryFile) { SaveAdditionalSymbols(filename, m_symbols); } foreach (SymbolHelper sh in m_symbols) { if (sh.Varname == "X_AccPedalManSP" || sh.Varname == "X_AccPedalAutTAB" || sh.Varname == "X_AccPedalAutSP" || sh.Varname == "X_AccPedalManTAB" || sh.Userdescription == "X_AccPedalManSP" || sh.Userdescription == "X_AccPedalAutTAB" || sh.Userdescription == "X_AccPedalAutSP" || sh.Userdescription == "X_AccPedalManTAB") { if (sh.Length == 4) { sh.Flash_start_address -= 0x0C; sh.Length = 0x0C; } } } dt.Dispose(); }