public Form1(string[] args) { _splash.Show(); Application.DoEvents(); _splash.SetProgressText("Initializing..."); /*HWID _id = new HWID(); string computerID = _id.GetUniqueIdentifier(Application.StartupPath); //_splash.SetProgressText("ID: " + computerID); Trionic5Immo immo = new Trionic5Immo(); //Console.WriteLine("ID: " + computerID); if (immo.ImmoValid(computerID)) { _immoValid = true; } else { // show license input window // _splash.SetProgressText("License is NOT valid"); // only for testing purposes: always on //_immoValid = true; }*/ _immoValid = true; _splash.SetProgressText("Loading components..."); InitializeComponent(); try { m_DelegateUpdateRealtimeValue = new DelegateUpdateRealtimeValue(this.UpdateRealtimeValue); m_DelegateFeedInfoToAFRMaps = new DelegateFeedInfoToAFRMaps(this.FeedInfoIntoAFRMaps); m_DelegateUpdateMapViewer = new DelegateUpdateMapViewer(this.UpdateMapViewer); m_DelegateUpdateBDMProgress = new DelegateUpdateBDMProgress(this.ReportBDMProgress); m_DelegateStartReleaseNotePanel = new DelegateStartReleaseNotePanel(this.StartReleaseNotesViewer); } catch (Exception E) { Console.WriteLine(E.Message); } _splash.SetProgressText("Loading settings..."); m_appSettings = new AppSettings(); try { sndplayer = new SoundPlayer(); } catch (Exception sndE) { Console.WriteLine(sndE.Message); } // reload last file? _splash.SetProgressText("Starting desktop..."); _ecuConnection = new ECUConnection(); _ecuConnection.CanusbDevice = m_appSettings.CanDevice; _ecuConnection.SetWidebandvalues(m_appSettings.WidebandLowVoltage, m_appSettings.WidebandHighVoltage, m_appSettings.WidebandLowAFR, m_appSettings.WidebandHighAFR); _ecuConnection.onSymbolDataReceived += new ECUConnection.SymbolDataReceived(_ecuConnection_onSymbolDataReceived); _ecuConnection.onCycleCompleted += new ECUConnection.CycleCompleted(_ecuConnection_onCycleCompleted); _ecuConnection.onWriteDataToECU += new ECUConnection.WriteDataToECU(_ecuConnection_onWriteDataToECU); _ecuConnection.onCanBusInfo += new ECUConnection.CanBusInfo(_ecuConnection_onCanBusInfo); _ecuConnection.onReadDataFromECU += new ECUConnection.ReadDataFromECU(_ecuConnection_onReadDataFromECU); //_ecuConnection.RunInEmulationMode = m_appSettings.DebugMode; // <GS-17032011> if debugging, run emulator in stead of real connection try { RegistryKey TempKeyCM = null; TempKeyCM = Registry.ClassesRoot.CreateSubKey(@"SystemFileAssociations\.bin\shell\Edit in T5Suite 2.0\command"); string StartKey = System.Windows.Forms.Application.ExecutablePath + " \"%1\""; TempKeyCM.SetValue("", StartKey); TempKeyCM.Close(); } catch (Exception E) { Console.WriteLine(E.Message); } try { RegistryKey TempKeyCM = null; TempKeyCM = Registry.ClassesRoot.CreateSubKey(@"SystemFileAssociations\.bin\shell\Auto detect Trionic file type\command"); string StartKey = System.Windows.Forms.Application.StartupPath + "\\SuiteLauncher.exe" + " \"%1\""; TempKeyCM.SetValue("", StartKey); TempKeyCM.Close(); } catch (Exception E) { Console.WriteLine(E.Message); } try { // should be done only once! this.fio_callback = new FIOCallback(this.on_fio); BdmAdapter_SetFIOCallback(this.fio_callback); Console.WriteLine("BDM adapter callback set!"); // should be done only once! } catch (Exception BDMException) { Console.WriteLine("BDM init failed: " + BDMException.Message); } if (args.Length > 0) { if (args[0].ToString().ToUpper().EndsWith(".BIN")) { // open the bin file m_startFromCommandLine = true; m_commandLineFile = args[0].ToUpper(); } } try { _adapterMonitor = new CombiAdapterMonitor(); _adapterMonitor.onAdapterPresent += new CombiAdapterMonitor.AdapterPresent(_adapterMonitor_onAdapterPresent); _adapterMonitor.Start(); _ftdiAdapterMonitor = new FTDIAdapterMonitor(); _ftdiAdapterMonitor.onAdapterPresent += new FTDIAdapterMonitor.AdapterPresent(_ftdiAdapterMonitor_onAdapterPresent); _ftdiAdapterMonitor.Start(); } catch (Exception E) { Console.WriteLine("Failed to instantiate the combiadapter monitor: " + E.Message); } }
void _ecuConnection_onWriteDataToECU(object sender, ECUConnection.ProgressEventArgs e) { // show progress bar! SetTaskProgress(e.Percentage, true); }
void _ecuConnection_onReadDataFromECU(object sender, ECUConnection.ProgressEventArgs e) { // signal progress! SetTaskProgress(e.Percentage, true); if (e.Percentage == 100) SetTaskProgress(0, false); }
void _ecuConnection_onSymbolDataReceived(object sender, ECUConnection.RealtimeDataEventArgs e) { // process received symboldata into the application // invoke method because data is coming from another thread! if (!this.IsDisposed) { try { this.Invoke(m_DelegateUpdateRealtimeValue, e.Symbol, e.Value); } catch (Exception E) { Console.WriteLine(E.Message); } } }
void _ecuConnection_onCanBusInfo(object sender, ECUConnection.CanInfoEventArgs e) { SetStatusText(e.Info); Console.WriteLine(DateTime.Now.ToString("HH:mm:ss:fff") + " " + e.Info); }