示例#1
0
        private void scrollTime_Scroll(object sender, ScrollEventArgs e)
        {
            if (scrollTime.Value < 0 || scrollTime.Value >= m_ListLog.Count)
            {
                return;
            }

            int           index    = scrollTime.Value;
            SensorLogItem log_item = m_ListLog[index];
            DateTime      dateTime = new DateTime(0L);
            TimeSpan      timeSpan = log_item.Time.Subtract(m_dtStartTime);

            lblTimeElapsed.Text = dateTime.Add(timeSpan).ToString("mm:ss.fff", DateTimeFormatInfo.InvariantInfo);
            for (int i = 0; i < m_ListSensors.Count && index >= 0; i++, --index)
            {
                SensorLogItem sensorLogItem2 = m_ListLog[index];
                for (int j = 0; j < panelDisplay.Controls.Count; j++)
                {
                    SensorDisplayControl sensorDisplayControl = (SensorDisplayControl)panelDisplay.Controls[j];
                    if (string.Compare(sensorDisplayControl.Title, sensorLogItem2.Name) == 0)
                    {
                        sensorDisplayControl.EnglishDisplay = sensorLogItem2.EnglishDisplay + " " + sensorLogItem2.EnglishUnits;
                        sensorDisplayControl.MetricDisplay  = sensorLogItem2.MetricDisplay + " " + sensorLogItem2.MetricUnits;
                    }
                }
            }
        }
示例#2
0
        private void UpdateThread()
        {
            while (IsRunThread)
            {
                if (m_obdInterface.ConnectedStatus && IsLogging)
                {
                    foreach (SensorDisplayControl control in panelDisplay.Controls)
                    {
                        OBDParameter      param = (OBDParameter)control.Tag;
                        OBDParameterValue value = m_obdInterface.GetValue(param, radioDisplayEnglish.Checked);
                        if (!value.ErrorDetected)
                        {
                            string text = param.EnglishUnitLabel;
                            if (!radioDisplayEnglish.Checked)
                            {
                                text = param.MetricUnitLabel;
                            }

                            SensorLogItem sensorLogItem = new SensorLogItem(
                                param.Name,
                                value.DoubleValue.ToString(),
                                text,
                                value.DoubleValue.ToString(),
                                text);
                            m_ListLog.Add(sensorLogItem);
                            this.Invoke((EventHandler) delegate {
                                scrollTime.Maximum = m_ListLog.Count - 1;
                                scrollTime.Value   = scrollTime.Maximum;
                            });

                            DateTime dateTime = new DateTime(0L);
                            this.Invoke((EventHandler) delegate {
                                lblTimeElapsed.Text = dateTime.Add(sensorLogItem.Time.Subtract(m_dtStartTime)).ToString("mm:ss.fff", DateTimeFormatInfo.InvariantInfo);
                            });

                            text = value.DoubleValue.ToString();
                            if (radioDisplayEnglish.Checked)
                            {
                                control.EnglishDisplay = text + " " + param.EnglishUnitLabel;
                            }
                            else
                            {
                                control.MetricDisplay = text + " " + param.MetricUnitLabel;
                            }
                        }
                    }
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }