Example #1
0
        public frmMain(string[] args)
        {
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
            //System.Threading.Thread.CurrentThread.CurrentUICulture
            CultureInfo tci = new CultureInfo("nl-NL");
            Thread.CurrentThread.CurrentCulture = tci;
            splash = new frmSplash();
            splash.Show();
            System.Windows.Forms.Application.DoEvents();
            InitializeComponent();
            m_AFRMap = new AFRMap();
            m_AFRMap.onCellLocked += m_AFRMap_onCellLocked;
            m_AFRMap.onFuelmapCellChanged += m_AFRMap_onFuelmapCellChanged;

            try
            {
                sndplayer = new System.Media.SoundPlayer();
            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }
            if (args.Length > 0)
            {
                if (args[0].ToUpper().EndsWith(".BIN"))
                {
                    if(File.Exists(args[0]))
                    {
                        m_commandLineFile = args[0];
                        m_startFromCommandLine = true;
                    }
                }
            }

            m_DelegateUpdateRealTimeValue = UpdateRealtimeInformationValue;
            m_DelegateUpdateBDMProgress = ReportBDMProgress;
            m_DelegateUpdateMapViewer = UpdateMapViewer;

            m_DelegateUpdateStatus = updateStatusInBox;
            m_DelegateProgressStatus = SetProgressPercentage;
            m_DelegateCanFrame = trionic7_onCanFrame;

            trionic7.onReadProgress += trionicCan_onReadProgress;
            trionic7.onWriteProgress += trionicCan_onWriteProgress;
            trionic7.onCanInfo += trionicCan_onCanInfo;
            trionic7.onCanFrame += trionicCan_onCanFrame;

            try
            {
                RegistryKey TempKeyCM = null;
                TempKeyCM = Registry.ClassesRoot.CreateSubKey(@"SystemFileAssociations\.bin\shell\Edit in T7 Suite\command");
                string StartKey = System.Windows.Forms.Application.ExecutablePath + " \"%1\"";
                TempKeyCM.SetValue("", StartKey);
                TempKeyCM.Close();
            }
            catch (Exception E)
            {
                logger.Debug(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)
            {
                logger.Debug(E.Message);
            }

            try
            {
                // should be done only once!
                this.fio_callback = this.on_fio;
                BdmAdapter_SetFIOCallback(this.fio_callback);
                logger.Debug("BDM adapter callback set!");
                // should be done only once!

            }
            catch (Exception BDMException)
            {
                logger.Debug("BDM init failed: " + BDMException.Message);
            }

            try
            {
                m_DelegateStartReleaseNotePanel = this.StartReleaseNotesViewer;

            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }
        }
Example #2
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);
            }
        }