Пример #1
0
        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);
            }
        }
Пример #2
0
 void _ftdiAdapterMonitor_onAdapterPresent(object sender, FTDIAdapterMonitor.AdapterEventArgs e)
 {
     if (e.Present)
     {
         //Console.WriteLine(e.Type.ToString() + " connected");
         barItemCombiAdapter.Caption = e.Type.ToString() + " connected";
         if (e.Type == AdapterType.LAWICEL && m_appSettings.CanDevice != "Lawicel")
         {
             frmInfoBox info = new frmInfoBox("You have connected a Lawicel CANUSB adapter but the settings show that this is not the currently selected canusb device!");
         }
     }
     else
     {
         barItemCombiAdapter.Caption = "";
     }
     Application.DoEvents();
 }