Example #1
0
 public void UpdateChart(int index, DGChartControl chart)
 {
     if (index < 0 || index > 3)
     {
         return;
     }
     if (0 < m_arraySensorValues[index].Count)
     {
         for (int i = 0; i < m_arraySensorValues[index].Count; i++)
         {
             if (DateTime.Now.Subtract(m_arraySensorValues[index][i].Date).TotalSeconds > Convert.ToInt32(numHistory.Value))
             {
                 m_arraySensorValues[index].RemoveAt(i);
                 i--;
             }
         }
     }
     if (m_arraySensorValues[index].Count == 0)
     {
         return;
     }
     double[] numArray1 = new double[m_arraySensorValues[index].Count];
     numArray1.Initialize();
     dSensorValues[index] = numArray1;
     double[] numArray2 = new double[m_arraySensorValues[index].Count];
     numArray2.Initialize();
     dSensorTimes[index] = numArray2;
     m_dSensorMax[index] = m_arraySensorValues[index][0].Value;
     m_dSensorMin[index] = m_arraySensorValues[index][0].Value;
     for (int i = 0; i < m_arraySensorValues[index].Count; i++)
     {
         DatedValue datedValue = m_arraySensorValues[index][i];
         if (datedValue.Value > m_dSensorMax[index])
         {
             m_dSensorMax[index] = datedValue.Value;
         }
         if (datedValue.Value < m_dSensorMin[index])
         {
             m_dSensorMin[index] = datedValue.Value;
         }
         dSensorValues[index][i] = datedValue.Value;
         TimeSpan timeSpan = DateTime.Now.Subtract(datedValue.Date);
         dSensorTimes[index][i] = timeSpan.TotalSeconds * -1.0;
     }
     if (chart.YRangeEnd < m_dSensorMax[index])
     {
         chart.YRangeEnd = Math.Ceiling(m_dSensorMax[index]);
         chart.YGrid     = (chart.YRangeEnd - chart.YRangeStart) * 0.1;
     }
     if (chart.YRangeStart > m_dSensorMin[index])
     {
         chart.YRangeStart = Math.Floor(m_dSensorMin[index]);
         chart.YGrid       = (chart.YRangeEnd - chart.YRangeStart) * 0.1;
     }
     chart.XData1 = dSensorTimes[index];
     chart.YData1 = dSensorValues[index];
 }
Example #2
0
        private void CalculateTimeslip()
        {
            double num1 = 0.0;
            double num2 = 0.0;
            bool   flag = false;

            timeslip = new Timeslip();
            if (m_KphValues == null || m_KphValues.Count == 0)
            {
                return;
            }
            timeslip.Vehicle = m_obdInterface.ActiveProfile.Name;
            timeslip.Date    = m_KphValues[0].Date;
            if (m_KphValues.Count <= 1)
            {
                return;
            }

            for (int i = 1; i < m_KphValues.Count; i++)
            {
                DatedValue datedValue1  = m_KphValues[i - 1];
                DatedValue datedValue2  = m_KphValues[i];
                double     num3         = (datedValue2.Value + datedValue1.Value) * 0.5 * (5.0 / 18.0);
                double     totalSeconds = datedValue2.Date.Subtract(datedValue1.Date).TotalSeconds;
                num1 += totalSeconds;
                double num4 = totalSeconds * num3;
                num2 += num4;
                if (num2 >= 18.288 && timeslip.SixtyFootTime == 0.0)
                {
                    timeslip.SixtyFootTime = num1 - (num2 - 18.288) / num3;
                    flag = true;
                }
                if (datedValue2.Value >= 96.56064 && timeslip.SixtyMphTime == 0.0)
                {
                    timeslip.SixtyMphTime = num1 - (datedValue2.Value - 96.56064) / ((datedValue2.Value - datedValue1.Value) / totalSeconds);
                    flag = true;
                }
                if (num2 >= 201.168 && timeslip.EighthMileTime == 0.0)
                {
                    double num5 = num2 - 201.168;
                    timeslip.EighthMileTime  = num1 - num5 / num3;
                    timeslip.EighthMileSpeed = ((datedValue2.Value - datedValue1.Value) * ((num4 - num5) / num4) + datedValue1.Value) * 0.621371192;
                    flag = true;
                }
                if (num2 >= 304.8 && timeslip.ThousandFootTime == 0.0)
                {
                    timeslip.ThousandFootTime = num1 - (num2 - 304.8) / num3;
                    flag = true;
                }
                if (num2 >= 402.336 && timeslip.QuarterMileTime == 0.0)
                {
                    double num5 = num2 - 402.336;
                    timeslip.QuarterMileTime  = num1 - num5 / num3;
                    timeslip.QuarterMileSpeed = ((datedValue2.Value - datedValue1.Value) * ((num4 - num5) / num4) + datedValue1.Value) * 0.621371192;
                    flag       = true;
                    m_bCapture = false;
                }
            }
            if (!flag)
            {
                return;
            }
            this.BeginInvoke((EventHandler) delegate {
                UpdateTimeslip();
            });
        }