Beispiel #1
0
        private void ToggleRealtimePanel()
        {
            if (dockRealtime.Visibility == DockVisibility.Visible)
            {
                dockRealtime.Visibility = DockVisibility.Hidden;
                tmrRealtime.Enabled = false;
                m_enableRealtimeTimer = false;
                trionic7.ResumeAlivePolling();

                if (m_appSettings.UseDigitalWidebandLambda)
                {
                    if (wbReader != null)
                    {
                        wbReader.Stop();
                    }
                    wbFactory = null;
                    wbReader = null;
                }
            }
            else
            {
                trionic7.SuspendAlivePolling();
                m_enableRealtimeTimer = true;
                bool _start_Timer = false;
                if (m_appSettings.ResetRealtimeSymbolOnTabPageSwitch)
                {
                    FillRealtimeTable(MonitorType.Dashboard); // default
                }
                // check for Performance.Mode presence
                if (PerformanceModePresent())
                {
                    btnEconomyMode.Visible = true;
                    btnNormalMode.Visible = true;
                    btnSportMode.Visible = true;
                }
                else
                {
                    btnEconomyMode.Visible = false;
                    btnNormalMode.Visible = false;
                    btnSportMode.Visible = false;

                }
                if (CheckCANConnectivity())
                {
                        tmrRealtime.Enabled = m_enableRealtimeTimer;
                }
                dockRealtime.Visibility = DockVisibility.Visible;
                int width = dockManager1.Form.ClientSize.Width - dockSymbols.Width;
                int height = dockManager1.Form.ClientSize.Height;
                if (width > 660) width = 660;

                dockRealtime.Dock = DockingStyle.Left;
                dockRealtime.Width = width;

                if(m_appSettings.UseDigitalWidebandLambda)
                {
                    try
                    {
                        wbFactory = new WidebandFactory(m_appSettings.WidebandDevice, m_appSettings.WbPort, false);
                        wbReader = wbFactory.CreateInstance();
                        wbReader.Start();
                    }
                    catch (Exception ex)
                    {
                        wbFactory = null;
                        wbReader = null;
                        MessageBox.Show(ex.Message, "Wideband error", MessageBoxButtons.OK);
                    }
                }

                // set default skin
                SwitchRealtimePanelMode(m_appSettings.Panelmode);
            }
        }
Beispiel #2
0
        private void btnToggleRealtime_ItemClick(object sender, ItemClickEventArgs e)
        {
            // start realtime mode
            if (dockRealtime.Visibility == DockVisibility.Visible)
            {
                dockRealtime.Visibility = DockVisibility.Hidden;
                tmrRealtime.Enabled = false;
                m_enableRealtimeTimer = false;
                barConnectedECUName.Caption = string.Empty;
                if (t8can.isOpen())
                {
                    t8can.Cleanup();
                }

                if (m_appSettings.UseDigitalWidebandLambda)
                {
                    if (wbReader != null)
                    {
                        wbReader.Stop();
                    }
                    wbFactory = null;
                    wbReader = null;
                }
            }
            else
            {
                SetCanAdapter();
                if (!t8can.isOpen())
                {
                    t8can.openDevice(true);
                }
                if (t8can.isOpen())
                {
                    // whatever
                    // get the software version from the ECU
                    if (m_swversion == string.Empty) // not yet connected
                    {
                        m_realtimeAddresses = new System.Data.DataTable();
                        m_realtimeAddresses.Columns.Add("SymbolName");
                        m_realtimeAddresses.Columns.Add("SymbolNumber", System.Type.GetType("System.Int32"));
                        m_realtimeAddresses.Columns.Add("VarName");

                        m_swversion = t8can.GetSoftwareVersion();
                        //logger.Debug("Version: " + m_swversion);
                        logger.Debug("***");
                        for (int i = 0; i < m_swversion.Length; i++)
                        {
                            Console.Write(Convert.ToByte(m_swversion[i]).ToString("X2") + " ");
                        }
                        logger.Debug("***");
                        barConnectedECUName.Caption = m_swversion;

                        // fill realtime table
                    }
                    if (m_appSettings.ResetRealtimeSymbolOnTabPageSwitch)
                    {
                        FillRealtimeTable(MonitorType.Dashboard); // default
                    }
                    dockRealtime.Visibility = DockVisibility.Visible;
                    int width = dockManager1.Form.ClientSize.Width - dockSymbols.Width;
                    int height = dockManager1.Form.ClientSize.Height;
                    if (width > 660) width = 660;

                    dockRealtime.Dock = DockingStyle.Left;
                    dockRealtime.Width = width;

                    if (m_appSettings.UseDigitalWidebandLambda)
                    {
                        try
                        {
                            wbFactory = new WidebandFactory(m_appSettings.WidebandDevice, m_appSettings.WbPort, false);
                            wbReader = wbFactory.CreateInstance();
                            wbReader.Start();
                        }
                        catch (Exception ex)
                        {
                            wbFactory = null;
                            wbReader = null;
                            MessageBox.Show(ex.Message, "Wideband error", MessageBoxButtons.OK);
                        }
                    }

                    // set default skin
                    SwitchRealtimePanelMode(m_appSettings.Panelmode);
                    m_connectedToECU = true;
                    tmrRealtime.Enabled = true;
                    m_enableRealtimeTimer = true;
                }
            }
        }