public void ShowSymbolCollection(SymbolCollection sc) { DataTable dt = new DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("XAXIS"); dt.Columns.Add("XAXISDESCRIPTION"); dt.Columns.Add("YAXIS"); dt.Columns.Add("YAXISDESCRIPTION"); SymbolAxesTranslator sat = new SymbolAxesTranslator(); SymbolTranslator symtrans = new SymbolTranslator(); string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; string xaxis = string.Empty; string yaxis = string.Empty; string xaxisdescr = ""; string yaxisdescr = ""; string zaxisdescr = ""; foreach (SymbolHelper sh in sc) { string name = sh.Varname; if (sh.Userdescription != "" && sh.Userdescription != String.Format("Symbolnumber {0}", sh.Symbol_number)) { name = sh.Userdescription; } sat.GetAxisSymbols(name, out xaxis, out yaxis, out xaxisdescr, out yaxisdescr, out zaxisdescr); string symboldescr = symtrans.TranslateSymbolToHelpText(name, out helptext, out cat, out subcat, m_ApplicationLanguage); if (xaxis != "") { xaxisdescr = symtrans.TranslateSymbolToHelpText(xaxis, out helptext, out cat, out subcat, m_ApplicationLanguage); } if (yaxis != "") { yaxisdescr = symtrans.TranslateSymbolToHelpText(yaxis, out helptext, out cat, out subcat, m_ApplicationLanguage); } if (xaxis != "" || yaxis != "") { dt.Rows.Add(name, symboldescr, xaxis, xaxisdescr, yaxis, yaxisdescr); } } gridControl1.DataSource = dt; }
public void ShowSymbolCollection(SymbolCollection sc) { DataTable dt = new DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("XAXIS"); dt.Columns.Add("XAXISDESCRIPTION"); dt.Columns.Add("YAXIS"); dt.Columns.Add("YAXISDESCRIPTION"); SymbolAxesTranslator sat = new SymbolAxesTranslator(); SymbolTranslator symtrans = new SymbolTranslator(); string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; foreach (SymbolHelper sh in sc) { string xaxis = sat.GetXaxisSymbol(sh.Varname); string yaxis = sat.GetYaxisSymbol(sh.Varname); string symboldescr = symtrans.TranslateSymbolToHelpText(sh.Varname, out helptext, out cat, out subcat); string xaxisdescr = ""; string yaxisdescr = ""; if (xaxis != "") { xaxisdescr = symtrans.TranslateSymbolToHelpText(xaxis, out helptext, out cat, out subcat); } if (yaxis != "") { yaxisdescr = symtrans.TranslateSymbolToHelpText(yaxis, out helptext, out cat, out subcat); } if (xaxis != "" || yaxis != "") { dt.Rows.Add(sh.Varname, symboldescr, xaxis, xaxisdescr, yaxis, yaxisdescr); } } gridControl1.DataSource = dt; }
private double GetMapCorrectionFactor(string symbolname) { double returnvalue = 1; try { SymbolTranslator st = new SymbolTranslator(); string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; string text = st.TranslateSymbolToHelpText(symbolname, out helptext, out cat, out subcat, m_appSettings.ApplicationLanguage); if (helptext.Contains("Resolution is")) { int idx = helptext.IndexOf("Resolution is"); idx += 14; string value = helptext.Substring(idx).Trim(); if (value.Contains(" ")) { int idx2 = value.IndexOf(" "); value = value.Substring(0, idx2); value = ClearToNumber(value); returnvalue = ConvertToDouble(value); } else { value = ClearToNumber(value); returnvalue = ConvertToDouble(value); } } } catch (Exception E) { logger.Debug(E.Message); } if (returnvalue == 0) { returnvalue = 1; if (symbolname == "KnkSoundRedCal.fi_OffsMap") returnvalue = 0.1; else if (symbolname == "IgnE85Cal.fi_AbsMap") returnvalue = 0.1; else if (symbolname == "BstKnkCal.OffsetXSP") returnvalue = 0.1; //else if (symbolname == "IgnNormCal.Map") returnvalue = 0.1; else if (symbolname == "MAFCal.cd_ThrottleMap") returnvalue = 0.0009765625; else if (symbolname == "HotStCal2.RestartMap") returnvalue = 0.001; } return returnvalue; }
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 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 TryToLoadAdditionalSymbols(string filename) { System.Data.DataTable dt; string binname = GetFileDescriptionFromFile(filename); if (binname != string.Empty) { dt = new System.Data.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"); if (File.Exists(filename)) { dt.ReadXml(filename); } foreach (SymbolHelper sh in m_symbols) { 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, m_appSettings.ApplicationLanguage); 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); } } } } }
private void TryToLoadAdditionalCSVSymbols(string filename) { // convert to CSV file format // 56;AreaCal.A_MaxAdap;;; try { SymbolTranslator st = new SymbolTranslator(); char[] sep = new char[1]; sep.SetValue(';', 0); string[] fileContent = File.ReadAllLines(filename); foreach (string line in fileContent) { string[] values = line.Split(sep); try { string varname = (string)values.GetValue(1); int symbolnumber = Convert.ToInt32(values.GetValue(0)); foreach (SymbolHelper sh in m_symbols) { if (sh.Symbol_number == symbolnumber) { sh.Userdescription = varname; string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory sub = XDFSubCategory.Undocumented; sh.Description = st.TranslateSymbolToHelpText(sh.Userdescription, out helptext, out cat, out sub, m_appSettings.ApplicationLanguage); //if(sh.Category == if (sh.Category == "Undocumented" || sh.Category == "") { if (sh.Userdescription.Contains(".")) { try { sh.Category = sh.Userdescription.Substring(0, sh.Userdescription.IndexOf(".")); //logger.Debug("Set cat to " + sh.Category + " for " + sh.Userdescription); } catch (Exception cE) { logger.Debug("Failed to assign category to symbol: " + sh.Userdescription + " err: " + cE.Message); } } } } } } catch (Exception lineE) { logger.Debug("Failed to import a symbol from CSV file " + line + ": " + lineE.Message); } } } catch (Exception E) { logger.Debug("Failed to import additional CSV symbols: " + E.Message); } }
private void Actions_SearchMapContent_ItemClick(object sender, ItemClickEventArgs e) { // ask the user for which value to search and if searching should include symbolnames and/or symbol description if (ValidateFile()) { SymbolCollection result_Collection = new SymbolCollection(); frmSearchMaps searchoptions = new frmSearchMaps(); if (searchoptions.ShowDialog() == DialogResult.OK) { frmProgress progress = new frmProgress(); progress.SetProgress("Start searching data..."); progress.SetProgressPercentage(0); progress.Show(); System.Windows.Forms.Application.DoEvents(); int cnt = 0; foreach (SymbolHelper sh in m_symbols) { progress.SetProgress("Searching " + sh.Varname); progress.SetProgressPercentage((cnt * 100) / m_symbols.Count); bool hit_found = false; if (searchoptions.UseSpecificMapLength) { if (sh.Length != (int)searchoptions.MapLength) { continue; } } if (searchoptions.IncludeSymbolNames) { if (searchoptions.SearchForNumericValues) { if (sh.Varname.Contains(searchoptions.NumericValueToSearchFor.ToString())) { hit_found = true; } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor != string.Empty) { if (sh.Varname.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } if (searchoptions.IncludeSymbolDescription) { if (searchoptions.SearchForNumericValues) { if (sh.Description.Contains(searchoptions.NumericValueToSearchFor.ToString())) { hit_found = true; } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor != string.Empty) { if (sh.Description.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } // now search the symbol data if (sh.Flash_start_address < m_currentfile_size) { byte[] symboldata = readdatafromfile(m_currentfile, (int)sh.Flash_start_address, sh.Length); if (searchoptions.SearchForNumericValues) { if (isSixteenBitTable(sh.Varname)) { for (int i = 0; i < symboldata.Length / 2; i += 2) { float value = Convert.ToInt32(symboldata.GetValue(i)) * 256; value += Convert.ToInt32(symboldata.GetValue(i + 1)); value *= (float)GetMapCorrectionFactor(sh.Varname); value += (float)GetMapCorrectionOffset(sh.Varname); if (value == (float)searchoptions.NumericValueToSearchFor) { hit_found = true; } } } else { for (int i = 0; i < symboldata.Length; i++) { float value = Convert.ToInt32(symboldata.GetValue(i)); value *= (float)GetMapCorrectionFactor(sh.Varname); value += (float)GetMapCorrectionOffset(sh.Varname); if (value == (float)searchoptions.NumericValueToSearchFor) { hit_found = true; } } } } if (searchoptions.SearchForStringValues) { if (searchoptions.StringValueToSearchFor.Length > symboldata.Length) { // possible... string symboldataasstring = System.Text.Encoding.ASCII.GetString(symboldata); if (symboldataasstring.Contains(searchoptions.StringValueToSearchFor)) { hit_found = true; } } } } if (hit_found) { // add to collection result_Collection.Add(sh); } cnt++; } progress.Close(); if (result_Collection.Count == 0) { frmInfoBox info = new frmInfoBox("No results found..."); } else { // start result screen dockManager1.BeginUpdate(); try { SymbolTranslator st = new SymbolTranslator(); 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.UseForFind = true; tabdet.Filename = m_currentfile; tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelectForFind); dockPanel.Controls.Add(tabdet); dockPanel.Text = "Search results: " + Path.GetFileName(m_currentfile); dockPanel.DockTo(dockManager1, DockingStyle.Left, 1); dockPanel.Width = 700; 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"); //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")); //string category = ""; string ht = string.Empty; //double diffperc = 0; //int diffabs = 0; //double diffavg = 0; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; foreach (SymbolHelper shfound in result_Collection) { string helptext = st.TranslateSymbolToHelpText(shfound.Varname, out ht, out cat, out subcat, m_appSettings.ApplicationLanguage); if (shfound.Varname.Contains(".")) { try { shfound.Category = shfound.Varname.Substring(0, shfound.Varname.IndexOf(".")); } catch (Exception cE) { logger.Debug("Failed to assign category to symbol: " + shfound.Varname + " err: " + cE.Message); } } dt.Rows.Add(shfound.Varname, shfound.Start_address, shfound.Flash_start_address, shfound.Length, shfound.Length, helptext, false, 0, 0, 0, 0, shfound.Category, "", shfound.Symbol_number, shfound.Symbol_number); } tabdet.CompareSymbolCollection = result_Collection; tabdet.OpenGridViewGroups(tabdet.gridControl1, 1); tabdet.gridControl1.DataSource = dt.Copy(); } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); } } } }
public void ShowSymbolCollection(SymbolCollection sc) { DataTable dt = new DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("XAXIS"); dt.Columns.Add("XAXISDESCRIPTION"); dt.Columns.Add("YAXIS"); dt.Columns.Add("YAXISDESCRIPTION"); SymbolAxesTranslator sat = new SymbolAxesTranslator(); SymbolTranslator symtrans = new SymbolTranslator(); string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; string xaxis = string.Empty; string yaxis = string.Empty; string xaxisdescr = ""; string yaxisdescr = ""; string zaxisdescr = ""; foreach (SymbolHelper sh in sc) { string name = sh.Varname; if (sh.Userdescription != "" && sh.Userdescription != String.Format("Symbolnumber {0}", sh.Symbol_number)) { name = sh.Userdescription; } sat.GetAxisSymbols(name, out xaxis, out yaxis, out xaxisdescr, out yaxisdescr, out zaxisdescr); string symboldescr = symtrans.TranslateSymbolToHelpText(name, out helptext, out cat, out subcat, m_ApplicationLanguage); if (xaxis != "") { xaxisdescr = symtrans.TranslateSymbolToHelpText(xaxis, out helptext, out cat, out subcat, m_ApplicationLanguage); } if (yaxis != "") { yaxisdescr = symtrans.TranslateSymbolToHelpText(yaxis, out helptext, out cat, out subcat, m_ApplicationLanguage); } if (xaxis != "" || yaxis != "") { dt.Rows.Add(name, symboldescr, xaxis, xaxisdescr, yaxis, yaxisdescr); } } gridControl1.DataSource = dt; }
/// <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(); }
/// <summary> /// /// </summary> /// <param name="symbol_collection"></param> /// <param name="allSymbolNames"></param> /// <param name="LanguageID"></param> private static void AddNamesToSymbols(SymbolCollection symbol_collection, string[] allSymbolNames, int LanguageID) { for (int i = 0; i < allSymbolNames.Length; i++) { try { SymbolHelper sh = symbol_collection[(i)]; sh.Varname = allSymbolNames[i].Trim(); //logger.Debug(String.Format("Set symbolnumber: {0} to be {1}", sh.Symbol_number, symbol)); SymbolTranslator translator = new SymbolTranslator(); string help = string.Empty; XDFCategories category = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; sh.Description = translator.TranslateSymbolToHelpText(sh.Varname, out help, out category, out subcat, LanguageID); if (sh.Varname.Contains(".")) { try { sh.Category = sh.Varname.Substring(0, sh.Varname.IndexOf(".")); } catch (Exception cE) { logger.Debug(String.Format("Failed to assign category to symbol: {0} err: {1}", sh.Varname, cE.Message)); } } } catch (Exception E) { logger.Debug("Failed to add symbolnames: " + E.Message); } } }
/// <summary> /// /// </summary> /// <param name="filename"></param> /// <param name="languageID"></param> /// <param name="m_current_softwareversion"></param> /// <returns></returns> public SymbolCollection ExtractFile(string filename, int languageID, string m_current_softwareversion) { m_fileName = filename; FileInfo fi = new FileInfo(filename); m_Filelength = (int)fi.Length; SymbolTranslator translator = new SymbolTranslator(); XDFCategories category = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; string help = string.Empty; try { fi.IsReadOnly = false; } catch (Exception E) { logger.Debug(String.Format("Failed to clear read-only flag: {0}", E.Message)); } symbol_collection = new SymbolCollection(); try { int sym_count = 0; // altered CastProgressEvent("Opening file", 0); try { symbol_collection = new SymbolCollection(); if (filename != string.Empty) { if (File.Exists(filename)) { if (!IsBinaryPackedVersion(filename, (int)fi.Length)) { CastProgressEvent("Getting symbol list offset", 5); int SymbolListOffSet = GetSymbolListOffSet(filename, (int)fi.Length); if (SymbolListOffSet > 0) { using (FileStream fsread = new FileStream(filename, FileMode.Open, FileAccess.Read)) { using (BinaryReader br = new BinaryReader(fsread)) { fsread.Seek(SymbolListOffSet, SeekOrigin.Begin); // 0x15FA in 5168646.BIN string symbolname = ""; bool endoftable = false; while (!endoftable) { byte b = br.ReadByte(); switch (b) { case 0xFF: // 0xFF used to keep the start of each string 'word' aligned break; case 0x02: endoftable = true; break; case 0x00: // 0x00 end of Symbol name string SymbolHelper sh = new SymbolHelper() { Varname = symbolname, Description = translator.TranslateSymbolToHelpText(symbolname, out help, out category, out subcat, languageID) }; if (sh.Varname.Contains(".")) { try { sh.Category = sh.Varname.Substring(0, sh.Varname.IndexOf(".")); } catch (Exception cE) { logger.Debug(String.Format("Failed to assign category to symbol: {0} err: {1}", sh.Varname, cE.Message)); } } sh.Internal_address = (int)fsread.Position - symbolname.Length - 1; sh.Symbol_number = sym_count; symbol_collection.Add(sh); symbolname = ""; sym_count++; if ((sym_count % 500) == 0) { CastProgressEvent(String.Format("Symbol: {0}", sh.Varname), 10); } break; default: // Another character in the Symbol name symbolname += Convert.ToChar(b); break; } } // now, try to get the addresses // 00 00 00 00 00 00 00 00 20 00 00 00 15 FA // 00 F0 75 3E 00 01 00 00 24 00 00 00 16 04 // 00 F0 75 3F 00 01 00 00 24 00 00 00 16 10 // 00 F0 75 40 00 01 00 00 24 00 00 00 16 1E // 00 F0 75 42 00 02 00 00 20 00 00 00 16 2C // 00 F0 75 44 00 02 00 00 ... if (symbol_collection.Count > 0) { sym_count = 0; CastProgressEvent("Searching address lookup table", 15); byte firstaddr_high = (byte)(symbol_collection[0].Internal_address >> 8); byte firstaddr_low = (byte)(symbol_collection[0].Internal_address); byte[] searchPattern = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0 }; searchPattern.SetValue(firstaddr_high, 12); searchPattern.SetValue(firstaddr_low, 13); int addressTableOffset = bytePatternSearch(filename, searchPattern, 0); if (addressTableOffset != -1) { fsread.Seek(addressTableOffset, SeekOrigin.Begin); // steeds 14 karaketers for (int t = 0; t < symbol_collection.Count; t++) { try { byte[] bytes = br.ReadBytes(14); if (bytes.Length == 14) { int internal_address = 0; for (int i = 0; i < 4; i++) { internal_address <<= 8; internal_address |= Convert.ToInt32(bytes.GetValue(i + 10)); } int symbollength = 0; for (int i = 0; i < 2; i++) { symbollength <<= 8; symbollength |= Convert.ToInt32(bytes.GetValue(i + 4)); } int sramaddress = 0; for (int i = 0; i < 4; i++) { sramaddress <<= 8; sramaddress |= Convert.ToInt32(bytes.GetValue(i)); } int realromaddress; if (sramaddress > 0xF00000) realromaddress = sramaddress - 0xef02f0; else realromaddress = 0; foreach (SymbolHelper sh in symbol_collection) { if (sh.Internal_address == internal_address) { /*if (sh.Varname == "BFuelCal.Map") { logger.Debug("Break for fuel map: " + internal_address.ToString("X6")); }*/ if (sramaddress > 0 && sh.Flash_start_address == 0) sh.Start_address = sramaddress; // TEST if (realromaddress > 0 && sh.Varname.Contains(".")) sh.Flash_start_address = realromaddress; else sh.Flash_start_address = sramaddress; sh.Length = symbollength; sym_count++; if ((sym_count % 500) == 0) { CastProgressEvent(String.Format("{0} : {1:X6}", sh.Varname, sh.Flash_start_address), 20); } break; } } } } catch (Exception E) { logger.Debug(E.Message); } } } else { if (!tryToDecodePackedBinary(filename, out symbol_collection, languageID)) { logger.Debug("Failed to extract packed binary!"); //<GS-23022010> } } } } } } else { Application.DoEvents(); logger.Debug("Couldn't find symboltable, file is probably packed!");//<GS-23022010> } } else { tryToDecodePackedBinary(filename, out symbol_collection, languageID); } // try to load additional symboltranslations that the user entered TryToLoadAdditionalSymbols(filename, symbol_collection, languageID); } } } catch (Exception eBin) { logger.Debug("Failed to open binfile: " + eBin.Message); } CastProgressEvent("Decoding done", 55); } catch (Exception E) { logger.Debug(String.Format("TryOpenFile filed: {0} err: {1}", filename, E.Message)); } return symbol_collection; }
private void TryToLoadAdditionalAS2Symbols(string filename) { // convert to AS2 file format try { SymbolTranslator st = new SymbolTranslator(); string[] fileContent = File.ReadAllLines(filename); int symbolnumber = 0; foreach (string line in fileContent) { if (line.StartsWith("*")) { symbolnumber++; try { string varname = line.Substring(1); int idxSymTab = 0; foreach (SymbolHelper sh in m_symbols) { if (sh.Length > 0) { idxSymTab++; } if (idxSymTab == symbolnumber) { sh.Userdescription = varname; string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory sub = XDFSubCategory.Undocumented; sh.Description = st.TranslateSymbolToHelpText(sh.Userdescription, out helptext, out cat, out sub, m_appSettings.ApplicationLanguage); if (sh.Category == "Undocumented" || sh.Category == "") { sh.createAndUpdateCategory(sh.Userdescription); } break; } } } catch (Exception lineE) { logger.Debug("Failed to import a symbol from AS2 file " + line + ": " + lineE.Message); } } } } catch (Exception E) { logger.Debug("Failed to import additional AS2 symbols: " + E.Message); } }