private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e) { // Stop monitoring if session is active ResizeControls(); bool _loggingWasActive = false; if (m_loggingActive) { _loggingWasActive = m_loggingActive; m_loggingActive = false; } if (_EnableAdvancedMode) btnMapEdit.Visible = true; digitalDisplayControl7.Visible = false; type = RealtimeMonitoringType.Fuel; SymbolCollection sc = new SymbolCollection(); // notify parent of changed tabpage, the realtime stuff should be filled differently in that case if (e.Page.Text == xtraTabPage1.Text) { type = RealtimeMonitoringType.Fuel; // fill with fuel map SymbolHelper sh_fuel = new SymbolHelper(); sh_fuel.Varname = "Insp_mat!"; sh_fuel.Helptext = "Main fuel map"; sc.Add(sh_fuel); SymbolHelper sh_korr = new SymbolHelper(); sh_korr.Varname = "Adapt_korr!"; sh_korr.Helptext = "Fuel adaption"; sc.Add(sh_korr); SymbolHelper sh_fuel_mut = new SymbolHelper(); sh_fuel_mut.Varname = "FuelAdjustmentMap"; sh_fuel_mut.Helptext = "Autotune fuel"; sc.Add(sh_fuel_mut); SymbolHelper sh_knock = new SymbolHelper(); sh_knock.Varname = "Fuel_knock_mat!"; sh_knock.Helptext = "Knock fuel map"; sc.Add(sh_knock); SymbolHelper sh_injconst = new SymbolHelper(); sh_injconst.Varname = "Inj_konst!"; sh_injconst.Helptext = "Injector constant"; sc.Add(sh_injconst); btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage2.Text) { type = RealtimeMonitoringType.Ignition; // fill with ignition maps SymbolHelper sh_ign = new SymbolHelper(); sh_ign.Varname = "Ign_map_0!"; sh_ign.Helptext = "Main ignition map"; sc.Add(sh_ign); SymbolHelper sh_ignwarmup = new SymbolHelper(); sh_ignwarmup.Varname = "Ign_map_4!"; sh_ignwarmup.Helptext = "Warmup ignition map"; sc.Add(sh_ignwarmup); SymbolHelper sh_ignknock = new SymbolHelper(); sh_ignknock.Varname = "Ign_map_2!"; sh_ignknock.Helptext = "Knock ignition map"; sc.Add(sh_ignknock); btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage3.Text) { type = RealtimeMonitoringType.Boost; SymbolHelper sh_boostrequest = new SymbolHelper(); sh_boostrequest.Varname = "Tryck_mat!"; sh_boostrequest.Helptext = "Boost request map"; sc.Add(sh_boostrequest); SymbolHelper sh_regkonmat = new SymbolHelper(); sh_regkonmat.Varname = "Reg_kon_mat!"; sh_regkonmat.Helptext = "Boost bias map"; sc.Add(sh_regkonmat); SymbolHelper sh_pfact = new SymbolHelper(); sh_pfact.Varname = "P_fors!"; sh_pfact.Helptext = "P factors"; sc.Add(sh_pfact); SymbolHelper sh_ifact = new SymbolHelper(); sh_ifact.Varname = "I_fors!"; sh_ifact.Helptext = "I factors"; sc.Add(sh_ifact); SymbolHelper sh_dfact = new SymbolHelper(); sh_dfact.Varname = "D_fors!"; sh_dfact.Helptext = "D factors"; sc.Add(sh_dfact); btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage4.Text) { type = RealtimeMonitoringType.Knock; SymbolHelper sh_knock_ref = new SymbolHelper(); sh_knock_ref.Varname = "Knock_ref_matrix!"; sh_knock_ref.Helptext = "Knock sensitivity"; sc.Add(sh_knock_ref); SymbolHelper sh_knock_count = new SymbolHelper(); sh_knock_count.Varname = "Knock_count_map"; sh_knock_count.Helptext = "Knock counter map"; sc.Add(sh_knock_count); SymbolHelper sh_ignknock = new SymbolHelper(); sh_ignknock.Varname = "Ign_map_2!"; sh_ignknock.Helptext = "Knock ignition map"; sc.Add(sh_ignknock); SymbolHelper sh_knock = new SymbolHelper(); sh_knock.Varname = "Fuel_knock_mat!"; sh_knock.Helptext = "Knock fuel map"; sc.Add(sh_knock); btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage5.Text) { type = RealtimeMonitoringType.Dashboard; btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage6.Text) { type = RealtimeMonitoringType.Settings; btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage7.Text) { type = RealtimeMonitoringType.Userdefined; // only show symbol that are in the watchlist // clear the map, it will be filled by itself System.Data.DataTable dtnew = new System.Data.DataTable(); if (gridControl4.DataSource == null) { dtnew.TableName = "RTSymbols"; dtnew.Columns.Add("SYMBOLNAME"); dtnew.Columns.Add("MINVALUE", Type.GetType("System.Double")); // autosense max and min! dtnew.Columns.Add("MAXVALUE", Type.GetType("System.Double")); dtnew.Columns.Add("VALUE", Type.GetType("System.Double")); dtnew.Columns.Add("PEAK", Type.GetType("System.Double")); gridControl4.DataSource = dtnew; } btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage8.Text) { type = RealtimeMonitoringType.EngineStatus; btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == xtraTabPage9.Text) { type = RealtimeMonitoringType.OnlineGraph; btnMapEdit.Relevantsymbols = sc; } else if (e.Page.Text == tabAutoTuneIgnition.Text) { type = RealtimeMonitoringType.AutotuneIgnition; } else if (e.Page.Text == tabAutoTune.Text) { type = RealtimeMonitoringType.AutotuneFuel; btnMapEdit.Visible = false; digitalDisplayControl7.Visible = true; } else if (e.Page.Text == tabUserMaps.Text) { type = RealtimeMonitoringType.UserMaps; btnMapEdit.Relevantsymbols = sc; // load the grid DataTable dt = new DataTable(); dt.TableName = "UserMaps"; dt.Columns.Add("Mapname"); dt.Columns.Add("Description"); if (File.Exists(Application.StartupPath + "\\UserMaps.xml")) { dt.ReadXml(Application.StartupPath + "\\UserMaps.xml"); } /*else { dt.Columns.Add("Mapname"); dt.Columns.Add("Description"); }*/ gridControl5.DataSource = dt; } if (e.PrevPage.Text == tabUserMaps.Text) { // save if (gridControl5.DataSource != null) { DataTable dt = (DataTable)gridControl5.DataSource; dt.WriteXml(Application.StartupPath + "\\UserMaps.xml"); } } if (onMonitorTypeChanged != null) { // disable all controls in the bottom to indicate we don't have data for them at this point. // next, when data is received for one of the controls, enable them again DisableGenericControls(); onMonitorTypeChanged(this, new RealtimeMonitoringEventArgs(type)); } if (_loggingWasActive) { m_loggingActive = true; m_logfileName = DetermineNewLogFileName(); } }
public ctrlRealtime() { InitializeComponent(); LoadExtraMeasurements(); SymbolCollection sc = new SymbolCollection(); SymbolHelper sh_fuel = new SymbolHelper(); sh_fuel.Varname = "Insp_mat!"; sh_fuel.Helptext = "Main fuel map"; sc.Add(sh_fuel); SymbolHelper sh_korr = new SymbolHelper(); //<GS-29112010> different for T5.2 sh_korr.Varname = "Adapt_korr!"; sh_korr.Helptext = "Fuel adaption"; sc.Add(sh_korr); SymbolHelper sh_fuel_mut = new SymbolHelper(); sh_fuel_mut.Varname = "FuelAdjustmentMap"; sh_fuel_mut.Helptext = "Autotune fuel"; sc.Add(sh_fuel_mut); SymbolHelper sh_knock = new SymbolHelper(); sh_knock.Varname = "Fuel_knock_mat!"; sh_knock.Helptext = "Knock fuel map"; sc.Add(sh_knock); SymbolHelper sh_injconst = new SymbolHelper(); sh_injconst.Varname = "Inj_konst!"; sh_injconst.Helptext = "Injector constant"; sc.Add(sh_injconst); btnMapEdit.Relevantsymbols = sc; try { sndplayer = new System.Media.SoundPlayer(); } catch (Exception E) { Console.WriteLine(E.Message); } }
private void LoadUserDefinedRealtimeSymbols(string filename) { if (File.Exists(filename)) { m_watchListCollection = new Trionic5Tools.SymbolCollection(); // first empty char[] sep = new char[1]; sep.SetValue(';', 0); using (StreamReader sr = new StreamReader(filename)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { string[] values = line.Split(sep); foreach (Trionic5Tools.SymbolHelper sh in m_RealtimeSymbolCollection) { if (sh.Varname == values.GetValue(0).ToString()) { Trionic5Tools.SymbolHelper shnew = new Trionic5Tools.SymbolHelper(); shnew.Varname = sh.Varname; shnew.Flash_start_address = sh.Flash_start_address; shnew.Length = sh.Length; shnew.Start_address = sh.Start_address; shnew.Color = sh.Color; shnew.UserCorrectionFactor = ConvertToDouble(values.GetValue(1).ToString()); shnew.UserCorrectionOffset = ConvertToDouble(values.GetValue(2).ToString()); shnew.UseUserCorrection = true; m_watchListCollection.Add(shnew); } } } } SetRealtimeSymbollist(m_watchListCollection); } }
private void SetupLogFilters() { // setup the export filters LogFilters filterhelper = new LogFilters(); frmLogFilters frmfilters = new frmLogFilters(); LogFilterCollection filters = filterhelper.GetFiltersFromRegistry(); frmfilters.SetFilters(filters); Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection(); foreach (Trionic5Tools.SymbolHelper sh in m_trionicFileInformation.SymbolCollection) { if (!sh.Varname.Contains("!")) sc.Add(sh); } frmfilters.SetSymbols(sc); if (frmfilters.ShowDialog() == DialogResult.OK) { filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters()); } }
private bool TryToAddSymbolToCollection(string hexstring, SymbolCollection curSymbolCollection) { //1A 0C 00 05 41 4D 4F 53 5F 73 74 61 74 75 73 00 //19 3A 00 04 49 6E 74 5F 61 64 72 65 73 73 //19 74 00 04 44 61 5F 35 //40 B6 00 01 42 75 69 6C 64 5F 75 70 5F 74 69 6D 65 5F 73 77 69 74 63 68 21 00 bool retval = false; int address = 0x00000; int length = 0x00; bool symbol_invalid = false; int invalid_char_count = 0; string name = string.Empty; try { address = Convert.ToInt32(hexstring.Substring(0, 5).Replace(" ", ""), 16); length = Convert.ToInt32(hexstring.Substring(6, 5).Replace(" ", ""), 16); for (int i = 12; i < hexstring.Length; i += 3) { int val = Convert.ToInt16(hexstring.Substring(i, 3).Replace(" ", ""), 16); if (val < 10) invalid_char_count++; if (invalid_char_count > 2) symbol_invalid = true; name += Convert.ToChar(val); } if (symbol_invalid) { //AddLogItem("Found invalid symbol: " + name + " at " + address.ToString("X4") + " len " + length.ToString("X4")); } else { name = name.Replace("\0", ""); if (name.Length > 0) { SymbolHelper sh = new SymbolHelper(); sh.Varname = name; sh.Start_address = address; sh.Length = length; curSymbolCollection.Add(sh); /*if (name == "Tryck_mat!") { SymbolHelper sh2 = new SymbolHelper(); sh2.Varname = "Pressure map scaled for 3 bar mapsensor"; sh2.Start_address = address; sh2.Length = length; curSymbolCollection.Add(sh2); } if (name == "Tryck_mat_a!") { SymbolHelper sh2 = new SymbolHelper(); sh2.Varname = "Pressure map (AUT) scaled for 3 bar mapsensor"; sh2.Start_address = address; sh2.Length = length; curSymbolCollection.Add(sh2); }*/ retval = true; } else { retval = false; } } } catch (Exception E) { // AddLogItem("Failed to convert symbol: " + E.Message); Console.WriteLine(E.Message); } return retval; }
private void LoadUserDefinedRealtimeSymbols() { string savePath = Path.Combine(Application.LocalUserAppDataPath, "rtsymbols.txt"); if (File.Exists(savePath)) { m_RealtimeUserSymbols = new Trionic5Tools.SymbolCollection(); // first empty char[] sep = new char[1]; sep.SetValue(';', 0); using (StreamReader sr = new StreamReader(savePath)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { string[] values = line.Split(sep); foreach (Trionic5Tools.SymbolHelper sh in m_trionicFileInformation.SymbolCollection) { if (sh.Varname == values.GetValue(0).ToString()) { Trionic5Tools.SymbolHelper shnew = new Trionic5Tools.SymbolHelper(); shnew.Varname = sh.Varname; shnew.Flash_start_address = sh.Flash_start_address; shnew.Length = sh.Length; shnew.Start_address = sh.Start_address; shnew.Color = sh.Color; shnew.UserCorrectionFactor = ConvertToDouble(values.GetValue(1).ToString()); shnew.UserCorrectionOffset = ConvertToDouble(values.GetValue(2).ToString()); shnew.UseUserCorrection = true; m_RealtimeUserSymbols.Add(shnew); } } } } ctrlRealtime1.SetRealtimeSymbollist(m_RealtimeUserSymbols); } }
private bool OpenWorkingFile(string filename) { bool retval = false; if (File.Exists(filename)) { m_trionicFile = new Trionic5File(); m_trionicFile.LibraryPath = Application.StartupPath + "\\Binaries"; m_trionicFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum); FileInfo fi = new FileInfo(filename); //<GS-07102010> remove read only flag if possible try { fi.IsReadOnly = false; btnReadOnly.Caption = "File access OK"; } catch (Exception E) { Console.WriteLine("Failed to remove read only flag: " + E.Message); btnReadOnly.Caption = "File is READ ONLY"; } m_trionicFile.onDecodeProgress += new IECUFile.DecodeProgress(m_trionicFile_onDecodeProgress); m_trionicFile.onTransactionLogChanged += new IECUFile.TransactionLogChanged(m_trionicFile_onTransactionLogChanged); m_trionicFile.SelectFile(filename); //m_trionicFileInformation = m_trionicFile.ParseTrionicFile(ofd.FileName); m_trionicFileInformation = m_trionicFile.ParseFile(); props = m_trionicFile.GetTrionicProperties(); // set indicators and menu items accoring to the file that has been opened if (props.IsTrionic55) { barECUType.Caption = "T5.5"; // enable T5.5 maps EnableT55Maps(true); } else { barECUType.Caption = "T5.2"; EnableT55Maps(false); // disable T5.5 maps } barECUSpeed.Caption = props.CPUspeed; if (props.RAMlocked) { barECULocked.Caption = "RAM locked"; } else { barECULocked.Caption = "RAM unlocked"; } if (CheckFileInLibrary(props.Partnumber)) { btnCompareToOriginalFile.Enabled = true; } else { btnCompareToOriginalFile.Enabled = false; } _ecuConnection.MapSensorType = m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType); gridSymbols.DataSource = m_trionicFileInformation.SymbolCollection; barStaticItem2.Caption = "File: " + Path.GetFileName(m_trionicFileInformation.Filename); this.Text = "T5Suite Professional 2.0 [" + Path.GetFileName(m_trionicFileInformation.Filename) + "]"; OpenGridViewGroups(gridSymbols, 0); // enable buttons barButtonItem4.Enabled = true; btnConnectECU.Enabled = true; btnSwitchMode.Enabled = true; //btnSynchronizeMaps.Enabled = true; btnTuneForE85Fuel.Enabled = true; //<GS-06042010> todo btnTuneToLargerInjectors.Enabled = true; //<GS-06042010> todo btnTuneToStage1.Enabled = true; btnTuneToStage2.Enabled = true; btnTuneToStage3.Enabled = true; btnTuneToStageX.Enabled = true; // btnTuneToThreeBarSensor.Enabled = true; barConvertMapSensor.Enabled = true; btnBoostAdaptionWizard.Enabled = true; btnHardcodedRPMLimit.Enabled = true; if (m_trionicFileInformation.Has2DRegKonMat()) { btnChangeRegkonMatRange.Enabled = true; } else { btnChangeRegkonMatRange.Enabled = false; } m_appSettings.Lastfilename = filename; ctrlRealtime1.Currentfile = filename; if (m_AFRMaps != null) { m_AFRMaps.SaveMaps(); // first save changes that might have been done } m_AFRMaps = null; if (m_AFRMaps == null && m_appSettings.AlwaysCreateAFRMaps) { m_AFRMaps = new AFRMaps(); m_AFRMaps.onFuelmapCellChanged += new AFRMaps.FuelmapCellChanged(m_AFRMaps_onFuelmapCellChanged); m_AFRMaps.onIdleFuelmapCellChanged += new AFRMaps.IdleFuelmapCellChanged(m_AFRMaps_onIdleFuelmapCellChanged); m_AFRMaps.onCellLocked += new AFRMaps.CellLocked(m_AFRMaps_onCellLocked); m_AFRMaps.TrionicFile = m_trionicFile; m_AFRMaps.InitializeMaps(); } // add realtime symbollist to ctrlRealtime1 Trionic5Tools.SymbolCollection _rtSymbols = new Trionic5Tools.SymbolCollection(); foreach (Trionic5Tools.SymbolHelper symh in m_trionicFileInformation.SymbolCollection) { if (symh.Start_address > 0 && (symh.Length >= 1 && symh.Length <= 4)) // <GS-29072010> was 1 & 2 only { _rtSymbols.Add(symh); } } ctrlRealtime1.RealtimeSymbolCollection = _rtSymbols; try { LoadUserDefinedRealtimeSymbols(); // try to load it } catch (Exception E) { Console.WriteLine(E.Message); } LoadKnockMaps(); SetTaskProgress(0, false); retval = true; } return retval; }
//string skinMask = "Skin: "; /// <summary> /// InitSkins: Initialiseer de skin engine om het voor de gebruiker mogelijk te maken /// om een skin te kiezen voor de user interface /// </summary> void InitSkins() { ribbonControl1.ForceInitialize(); BarButtonItem item; int skinCount = 0; DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.BonusSkins).Assembly); DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.OfficeSkins).Assembly); Trionic5Tools.SymbolCollection symcol = new Trionic5Tools.SymbolCollection(); foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins) { Trionic5Tools.SymbolHelper sh = new Trionic5Tools.SymbolHelper(); sh.Varname = cnt.SkinName; symcol.Add(sh); } symcol.SortColumn = "Varname"; symcol.SortingOrder = Trionic5Tools.GenericComparer.SortOrder.Ascending; symcol.Sort(); foreach(Trionic5Tools.SymbolHelper sh in symcol) { item = new BarButtonItem(); item.Caption = sh.Varname; BarItemLink il = rbnPageSkins.ItemLinks.Add(item); if ((skinCount++ % 3) == 0) il.BeginGroup = true; item.ItemClick += new ItemClickEventHandler(OnSkinClick); } try { if (m_appSettings.Skinname != string.Empty) { if (IsChristmasTime()) { // set chrismas skin DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Xmas 2008 Blue"); // don't save } else if (IsHalloweenTime()) { // set Halloween skin DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Pumpkin"); // don't save } else if (IsValetineTime()) { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Valentine"); // don't save } else { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(m_appSettings.Skinname); } } } catch (Exception E) { Console.WriteLine(E.Message); } SetToolstripTheme(); }
private void ConvertFileToDif(string filename, bool AutoExport) { System.Windows.Forms.Application.DoEvents(); DateTime startDate = DateTime.MaxValue; DateTime endDate = DateTime.MinValue; try { Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection(); string[] alllines = File.ReadAllLines(filename); //using (StreamReader sr = new StreamReader(filename)) { //string line = string.Empty; char[] sep = new char[1]; char[] sep2 = new char[1]; //int linecount = 0; sep.SetValue('|', 0); sep2.SetValue('=', 0); //while ((line = sr.ReadLine()) != null) foreach(string line in alllines) { string[] values = line.Split(sep); if (values.Length > 0) { try { //dd/MM/yyyy HH:mm:ss //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|"; string dtstring = (string)values.GetValue(0); DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2))); if (dt > endDate) endDate = dt; if (dt < startDate) startDate = dt; for (int t = 1; t < values.Length; t++) { string subvalue = (string)values.GetValue(t); string[] subvals = subvalue.Split(sep2); if (subvals.Length == 2) { string varname = (string)subvals.GetValue(0); bool sfound = false; foreach (Trionic5Tools.SymbolHelper sh in sc) { if (sh.Varname == varname) { sfound = true; } } Trionic5Tools.SymbolHelper nsh = new Trionic5Tools.SymbolHelper(); nsh.Varname = varname; if (!sfound) sc.Add(nsh); } } } catch (Exception pE) { Console.WriteLine(pE.Message); } } } } if (AutoExport) { foreach (Trionic5Tools.SymbolHelper sh in sc) { sh.Color = GetColorFromRegistry(sh.Varname); } DifGenerator difgen = new DifGenerator(); difgen.LowAFR = m_appSettings.WidebandLowAFR / 1000; difgen.HighAFR = m_appSettings.WidebandHighAFR / 1000; difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage / 1000; difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage / 1000; difgen.WidebandSymbol = m_appSettings.WidebandLambdaSymbol; difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol; difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress); System.Windows.Forms.Application.DoEvents(); try { difgen.ConvertFileToDif(filename, sc, startDate, endDate, true, true); } catch (Exception expE1) { Console.WriteLine(expE1.Message); } } else { // show selection screen frmPlotSelection plotsel = new frmPlotSelection(); foreach (Trionic5Tools.SymbolHelper sh in sc) { if (sh.Varname != "Pgm_status") { plotsel.AddItemToList(sh.Varname); } } plotsel.Startdate = startDate; plotsel.Enddate = endDate; plotsel.SelectAllSymbols(); if (plotsel.ShowDialog() == DialogResult.OK) { sc = plotsel.Sc; endDate = plotsel.Enddate; startDate = plotsel.Startdate; DifGenerator difgen = new DifGenerator(); LogFilters filterhelper = new LogFilters(); difgen.SetFilters(filterhelper.GetFiltersFromRegistry()); difgen.LowAFR = m_appSettings.WidebandLowAFR / 1000; difgen.HighAFR = m_appSettings.WidebandHighAFR / 1000; difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage / 1000; difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage / 1000; difgen.WidebandSymbol = m_appSettings.WidebandLambdaSymbol; difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol; difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress); try { if (difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, true)) { //difgen.ConvertFileToDif(filename, sc, startDate, endDate, false, false); StartLogWorksWithCurrentFile(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".dif"); } else { frmInfoBox info = new frmInfoBox("No data was found to export!"); } } catch (Exception expE2) { Console.WriteLine(expE2.Message); } } TimeSpan ts = new TimeSpan(endDate.Ticks - startDate.Ticks); } } catch (Exception E) { Console.WriteLine(E.Message); } }
private void btnViewMatrixFromLog_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // let the user select x axis, y axis and z axis symbols from the logfile // OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Trionic 5 logfiles|*.t5l"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { string[] alllines = File.ReadAllLines(ofd.FileName); avgTable = null; System.Windows.Forms.Application.DoEvents(); DateTime startDate = DateTime.MaxValue; DateTime endDate = DateTime.MinValue; Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection(); try { //using (StreamReader sr = new StreamReader(ofd.FileName)) { //string line = string.Empty; char[] sep = new char[1]; char[] sep2 = new char[1]; //int linecount = 0; sep.SetValue('|', 0); sep2.SetValue('=', 0); //while ((line = sr.ReadLine()) != null) foreach(string line in alllines) { string[] values = line.Split(sep); if (values.Length > 0) { try { //dd/MM/yyyy HH:mm:ss //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|"; string dtstring = (string)values.GetValue(0); DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2))); if (dt > endDate) endDate = dt; if (dt < startDate) startDate = dt; for (int t = 1; t < values.Length; t++) { string subvalue = (string)values.GetValue(t); string[] subvals = subvalue.Split(sep2); if (subvals.Length == 2) { string varname = (string)subvals.GetValue(0); bool sfound = false; foreach (Trionic5Tools.SymbolHelper sh in sc) { if (sh.Varname == varname) { sfound = true; } } Trionic5Tools.SymbolHelper nsh = new Trionic5Tools.SymbolHelper(); nsh.Varname = varname; if (!sfound) sc.Add(nsh); } } } catch (Exception pE) { Console.WriteLine(pE.Message); } } } } } catch (Exception E) { Console.WriteLine(E.Message); } frmMatrixSelection sel = new frmMatrixSelection(); sel.SetSymbolList(sc); sel.SetXSelection(m_appSettings.LastXAxisFromMatrix); sel.SetYSelection(m_appSettings.LastYAxisFromMatrix); sel.SetZSelection(m_appSettings.LastZAxisFromMatrix); if (sel.ShowDialog() == DialogResult.OK) { // get selected for x, y and z int type = sel.GetViewType(); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values string x = sel.GetXAxisSymbol(); string y = sel.GetYAxisSymbol(); string z = sel.GetZAxisSymbol(); m_appSettings.LastXAxisFromMatrix = x; m_appSettings.LastYAxisFromMatrix = y; m_appSettings.LastZAxisFromMatrix = z; double xmin = Double.MaxValue; double xmax = Double.MinValue; double ymin = Double.MaxValue; double ymax = Double.MinValue; double zmin = Double.MaxValue; double zmax = Double.MinValue; //using (StreamReader sr = new StreamReader(ofd.FileName)) { //string line = string.Empty; char[] sep = new char[1]; char[] sep2 = new char[1]; //int linecount = 0; sep.SetValue('|', 0); sep2.SetValue('=', 0); //while ((line = sr.ReadLine()) != null) foreach(string line in alllines) { string[] values = line.Split(sep); if (values.Length > 0) { try { //dd/MM/yyyy HH:mm:ss //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|"; string dtstring = (string)values.GetValue(0); DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2))); if (dt > endDate) endDate = dt; if (dt < startDate) startDate = dt; for (int t = 1; t < values.Length; t++) { string subvalue = (string)values.GetValue(t); string[] subvals = subvalue.Split(sep2); if (subvals.Length == 2) { string varname = (string)subvals.GetValue(0); double value = ConvertToDouble((string)subvals.GetValue(1)); if (value > 65535) value = 0; if (value < -65535) value = 0; if (varname == x) { // get max and min if (value > xmax) xmax = value; if (value < xmin) xmin = value; } else if (varname == y) { // get max and min if (value > ymax) ymax = value; if (value < ymin) ymin = value; } else if (varname == z) { // get max and min if (value > zmax) zmax = value; if (value < zmin) zmin = value; } } } } catch (Exception pE) { Console.WriteLine(pE.Message); } } } } // now we have it all if (xmin == xmax || ymin == ymax) { frmInfoBox info = new frmInfoBox("No data to display ... x or y axis contains no differentiated values"); return; } frmMatrixResult result = new frmMatrixResult(); result.SetViewType(type); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values // parse the file again and add the points DataTable dtresult = new DataTable(); // xmin = -0.8 // xmin = 2.01 double[] x_values = new double[16]; double[] y_values = new double[16]; // fill x and y axis for (int i = 0; i < 16; i++) { double xvalue = xmin; if(i>0) xvalue = xmin + i * ((xmax - xmin) / (15)); //Console.WriteLine("Adding: " + xvalue.ToString()); dtresult.Columns.Add(xvalue.ToString(), Type.GetType("System.Double")); x_values.SetValue(xvalue, i); // test: andersom? } for (int i = 0; i < 16; i++) { //double yvalue = ymin + ((ymax - ymin) / i); double yvalue = ymin; if (i > 0) yvalue = ymin + i * ((ymax - ymin) / (15)); y_values.SetValue(yvalue, i); // test: andersom? } for (int i = 0; i < 16; i++) { dtresult.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } // table filled double _lastX = 0; double _lastY = 0; double _lastZ = 0; //using (StreamReader sr = new StreamReader(ofd.FileName)) { //string line = string.Empty; char[] sep = new char[1]; char[] sep2 = new char[1]; //int linecount = 0; sep.SetValue('|', 0); sep2.SetValue('=', 0); //while ((line = sr.ReadLine()) != null) foreach(string line in alllines) { string[] values = line.Split(sep); if (values.Length > 0) { try { //dd/MM/yyyy HH:mm:ss //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|"; string dtstring = (string)values.GetValue(0); DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2))); if (dt > endDate) endDate = dt; if (dt < startDate) startDate = dt; for (int t = 1; t < values.Length; t++) { string subvalue = (string)values.GetValue(t); string[] subvals = subvalue.Split(sep2); if (subvals.Length == 2) { string varname = (string)subvals.GetValue(0); double value = ConvertToDouble((string)subvals.GetValue(1)); if (varname == x) { _lastX = value; } else if (varname == y) { _lastY = value; } else if (varname == z) { _lastZ = value; } } } } catch (Exception pE) { Console.WriteLine(pE.Message); } // add point to the datatable AddPointToDataTable(dtresult, _lastX, _lastY, _lastZ, xmin, xmax, ymin, ymax, zmin, zmax, type); } } } result.MaxValue = zmax; result.MinValue = zmin; result.SetXAxis(x_values); result.SetYAxis(y_values); result.SetXAxisName(x); result.SetYAxisName(y); result.SetZAxisName(z); if (m_appSettings.MapViewerType == MapviewerType.Fancy) result.UseNewMapViewer = true; result.SetTable(dtresult); string typedescr = " (Mean values)"; if (type == 1) typedescr = " (Minimum values)"; else if (type == 1) typedescr = " (Maximum values)"; result.Text = "Matrix [" + x + " : " + y + " : " + z + "]" + typedescr; //result.ShowDialog(); byte[] m_map_content = new byte[16 * 16 * 2]; int idx = 0; for (int i = 15; i >= 0; i--) { foreach (object o in dtresult.Rows[i].ItemArray) { double value = Convert.ToDouble(o); // now convert to int * 100 Int32 ivalue = 0; try { ivalue = Convert.ToInt32(value * 100); } catch (Exception E) { Console.WriteLine("Failed to convert to integer value: " + value.ToString()); } byte b1 = 0; byte b2 = 0; try { b1 = Convert.ToByte(ivalue / 256); b2 = Convert.ToByte(ivalue - (int)b1 * 256); } catch (Exception E) { Console.WriteLine("Failed to convert to byte value + " + ivalue.ToString()); } m_map_content[idx++] = b1; m_map_content[idx++] = b2; } } //<GS-28102010> for test, start a mapviewer as well result.ShowDialog(); //StartResultViewerForMatrix(x_values, y_values, x, y, z, dtresult, m_map_content); } } }
private void StartCompareToSRAMFile(string sramfilename) { Trionic5Tools.SymbolCollection scdiff = new Trionic5Tools.SymbolCollection(); foreach (Trionic5Tools.SymbolHelper sh in m_trionicFileInformation.SymbolCollection) { if (sh.Flash_start_address > 0 && sh.Start_address > 0) { // get sram content and binfile content for this symbol byte[] sramsymbol = m_trionicFile.ReadDataFromFile(sramfilename, (uint)sh.Start_address, (uint)sh.Length); byte[] flashsymbol = m_trionicFile.ReadData((uint)sh.Flash_start_address, (uint)sh.Length); int bdifferent = 0; for (int btel = 0; btel < sh.Length; btel++) { if (sramsymbol[btel] != flashsymbol[btel]) { bdifferent++; } } if (bdifferent > 0) { // symbol is not equal! scdiff.Add(sh); } } } dockManager1.BeginUpdate(); try { DevExpress.XtraBars.Docking.DockPanel dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); CompareResults tabdet = new CompareResults(); tabdet.Dock = DockStyle.Fill; tabdet.Filename = sramfilename; tabdet.onSymbolSelect += new CompareResults.NotifySelectSymbol(tabdet_onSymbolSelectRAM); dockPanel.Controls.Add(tabdet); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "SRAM <> BIN Compare results: " + Path.GetFileName(sramfilename); dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Left, 1); dockPanel.Width = 700; //CompareSymbolTable(filename, compSymbols, compAddressLookup, tabdet.gridControl1); tabdet.CompareSymbolCollection = scdiff; 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 scdiff) { float diffperc = 0; int diffabs = 0; float diffavg = 0; dt.Rows.Add(sh.Varname, sh.Start_address, sh.Flash_start_address, sh.Length, sh.Length, sh.Helptext, false, (int)sh.Category, diffperc, diffabs, diffavg, sh.Category.ToString().Replace("_", " "), sh.Subcategory.ToString().Replace("_", " ")); } tabdet.gridControl1.DataSource = dt; //tabdet.CompareAddressLookupCollection = compAddressLookup; tabdet.OpenGridViewGroups(tabdet.gridControl1, 1); } catch (Exception E) { Console.WriteLine(E.Message); } dockManager1.EndUpdate(); }
private void SaveMyMaps(string filename) { if (gridControl1.DataSource != null) { if (File.Exists(filename)) { File.Delete(filename); } DataTable dt = (DataTable)gridControl1.DataSource; XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null); doc.AppendChild(dec);// Create the root element XmlElement root = doc.CreateElement("categories"); doc.AppendChild(root); SymbolCollection sc = new SymbolCollection(); // first get all categories foreach (DataRow dr in dt.Rows) { string category = dr["category"].ToString(); bool found = false; foreach(SymbolHelper sh in sc) { if (sh.Varname == category) found = true; } if (!found) { SymbolHelper newsh = new SymbolHelper(); newsh.Varname = category; sc.Add(newsh); } } foreach (SymbolHelper sh in sc) { XmlElement title = doc.CreateElement("category"); title.SetAttribute("title", sh.Varname); foreach (DataRow dr in dt.Rows) { if (dr["category"].ToString() == sh.Varname) { XmlElement map = doc.CreateElement("map"); map.SetAttribute("symbol", dr["symbol"].ToString()); map.SetAttribute("title", dr["title"].ToString()); title.AppendChild(map); } } root.AppendChild(title); } /* foreach (DataRow dr in dt.Rows) { XmlElement title = doc.CreateElement("category"); title.SetAttribute("title", dr["category"].ToString()); XmlElement map = doc.CreateElement("map"); map.SetAttribute("symbol", dr["symbol"].ToString()); map.SetAttribute("title", dr["title"].ToString()); title.AppendChild(map); root.AppendChild(title); } * */ doc.Save(filename); } }