Ejemplo n.º 1
0
 private void UpdateThread(object state)
 {
     if (!bRunThread)
     {
         return;
     }
     do
     {
         if (m_obdInterface.getConnectedStatus() && bLogging)
         {
             IEnumerator enumerator = panelDisplay.Controls.GetEnumerator();
             if (enumerator.MoveNext())
             {
                 do
                 {
                     SensorDisplayControl sensorDisplayControl = (SensorDisplayControl)enumerator.Current;
                     OBDParameter         obdParameter         = (OBDParameter)sensorDisplayControl.Tag;
                     OBDParameterValue    obdParameterValue    = m_obdInterface.getValue(obdParameter, radioDisplayEnglish.Checked);
                     if (!obdParameterValue.ErrorDetected)
                     {
                         string str = obdParameter.EnglishUnitLabel;
                         if (!radioDisplayEnglish.Checked)
                         {
                             str = obdParameter.MetricUnitLabel;
                         }
                         double        num1          = obdParameterValue.DoubleValue;
                         double        num2          = obdParameterValue.DoubleValue;
                         SensorLogItem sensorLogItem = new SensorLogItem(obdParameter.Name, num2.ToString(), str, num1.ToString(), str);
                         SensorMonitorForm.m_arrayListLog.Add((object)sensorLogItem);
                         scrollTime.Maximum = SensorMonitorForm.m_arrayListLog.Count - 1;
                         scrollTime.Value   = scrollTime.Maximum;
                         DateTime dateTime = new DateTime();
                         dateTime = new DateTime(0L);
                         TimeSpan timeSpan = sensorLogItem.Time.Subtract(m_dtStartTime);
                         lblTimeElapsed.Text = dateTime.Add(timeSpan).ToString("mm:ss.fff", DateTimeFormatInfo.InvariantInfo);
                         if (radioDisplayEnglish.Checked)
                         {
                             double num3 = obdParameterValue.DoubleValue;
                             sensorDisplayControl.EnglishDisplay = num3.ToString() + " " + obdParameter.EnglishUnitLabel;
                         }
                         else
                         {
                             double num3 = obdParameterValue.DoubleValue;
                             sensorDisplayControl.MetricDisplay = num3.ToString() + " " + obdParameter.MetricUnitLabel;
                         }
                     }
                 }while (enumerator.MoveNext());
             }
         }
         else
         {
             Thread.Sleep(300);
         }
     }while (bRunThread);
 }
Ejemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (m_ListLog.Count != 0)
     {
         SaveFileDialog dialog = new SaveFileDialog();
         dialog.Title            = "Save Logged Data As";
         dialog.Filter           = "Comma-separated values (*.csv)|*.csv|XML (*.xml)|*.xml";
         dialog.FilterIndex      = 0;
         dialog.RestoreDirectory = true;
         dialog.ShowDialog();
         if (dialog.FileName != "")
         {
             if (dialog.FileName.EndsWith(".xml"))
             {
                 Type[] typeArray = new Type[] { typeof(SensorLogItem), typeof(Sensor) };
                 using (TextWriter writer = new StreamWriter(dialog.FileName))
                 {
                     new XmlSerializer(typeof(List <SensorLogItem>), typeArray).Serialize(writer, m_ListLog);
                     writer.Close();
                 }
             }
             else
             {
                 List <string> list = new List <string>();
                 int           num2 = 0;
                 while (num2 < m_ListLog.Count)
                 {
                     SensorLogItem item = m_ListLog[num2];
                     string        str  =
                         item.Time.ToString("MM-dd-yyyy hh:mm:ss.fff", DateTimeFormatInfo.InvariantInfo) + ", "
                         + item.Name + ", "
                         + item.EnglishDisplay + ", "
                         + item.EnglishUnits + ", "
                         + item.MetricDisplay + ", "
                         + item.MetricUnits;
                     list.Add(str);
                     num2++;
                 }
                 FileStream   stream = new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write);
                 StreamWriter writer = new StreamWriter(stream);
                 int          num    = 0;
                 while (num < list.Count)
                 {
                     writer.WriteLine(list[num]);
                     num++;
                 }
                 writer.Close();
                 stream.Close();
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void UpdateThread(object state)
        {
            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);
                            scrollTime.Maximum = m_ListLog.Count - 1;
                            scrollTime.Value   = scrollTime.Maximum;

                            DateTime dateTime = new DateTime(0L);
                            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);
                }
            }
        }
Ejemplo n.º 4
0
        private void scrollTime_Scroll(object sender, ScrollEventArgs e)
        {
            int index1 = scrollTime.Value;

            if (index1 < 0 || scrollTime.Value >= m_ListLog.Count)
            {
                return;
            }

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

            lblTimeElapsed.Text = dateTime.Add(timeSpan).ToString("mm:ss.fff", DateTimeFormatInfo.InvariantInfo);
            int num = 0;

            if (0 >= SensorMonitorForm.m_ListSensors.Count)
            {
                return;
            }
            int index2 = index1;

            do
            {
                if (index2 >= 0)
                {
                    SensorLogItem sensorLogItem2 = m_ListLog[index2];
                    int           index3         = 0;
                    if (0 < panelDisplay.Controls.Count)
                    {
                        do
                        {
                            SensorDisplayControl sensorDisplayControl = (SensorDisplayControl)panelDisplay.Controls[index3];
                            if (string.Compare(sensorDisplayControl.Title, sensorLogItem2.Name) == 0)
                            {
                                sensorDisplayControl.EnglishDisplay = sensorLogItem2.EnglishDisplay + " " + sensorLogItem2.EnglishUnits;
                                sensorDisplayControl.MetricDisplay  = sensorLogItem2.MetricDisplay + " " + sensorLogItem2.MetricUnits;
                            }
                            ++index3;
                        }while (index3 < panelDisplay.Controls.Count);
                    }
                }
                ++num;
                --index2;
            }while (num < SensorMonitorForm.m_ListSensors.Count);
        }