private void Calculate() { m_dTQMax = 0.0; m_dHPMax = 0.0; double[] numArray1 = new double[m_arrRpmValues.Count - 1]; numArray1.Initialize(); HPValue = numArray1; double[] numArray2 = new double[m_arrRpmValues.Count - 1]; numArray2.Initialize(); TQValue = numArray2; double[] numArray3 = new double[m_arrRpmValues.Count - 1]; numArray3.Initialize(); SampleRPM = numArray3; int index1 = 0; if (0 < m_arrRpmValues.Count - 1) { do { double num1 = (m_arrRpmValues[index1] as DatedValue).Value; int index2 = index1 + 1; double num2 = (m_arrRpmValues[index2] as DatedValue).Value; DateTime dateTime1 = (m_arrRpmValues[index1] as DatedValue).Date; TimeSpan timeSpan = (m_arrRpmValues[index2] as DatedValue).Date.Subtract(dateTime1); dateTime1.AddSeconds(timeSpan.TotalSeconds * 0.5); double num3 = (m_arrKphValues[index1] as DatedValue).Value; double num4 = (m_arrKphValues[index2] as DatedValue).Value; DateTime dateTime2 = (m_arrKphValues[index1] as DatedValue).Date; DateTime dateTime3 = (m_arrKphValues[index2] as DatedValue).Date; SampleRPM[index1] = (num2 + num1) * 0.5 * 0.001; double num5 = (num4 + num3) * 0.5 * 0.621371192 * 0.44704; double num6 = m_dVehicleWeight * 0.45359237 * num5 * num5 * 0.5 / dateTime3.Subtract(dateTime2).TotalSeconds; HPValue[index1] = num6 * 0.00134102209; if (HPValue[index1] > m_dHPMax) { m_dHPMax = HPValue[index1]; } TQValue[index1] = HPValue[index1] * 5252.0 / (SampleRPM[index1] * 1000.0); if (TQValue[index1] > m_dTQMax) { m_dTQMax = TQValue[index1]; } index1 = index2; }while (index1 < m_arrRpmValues.Count - 1); } dyno.XData1 = SampleRPM; dyno.YData1 = HPValue; dyno.XData2 = SampleRPM; dyno.YData2 = TQValue; dyno.YRangeEnd = m_dHPMax < m_dTQMax ? m_dTQMax : m_dHPMax; dyno.YRangeEnd = (double)Convert.ToInt32(dyno.YRangeEnd + 0.5); if (Convert.ToInt32(dyno.YRangeEnd) % Convert.ToInt32(dyno.YGrid) != 0) { do { dyno.YRangeEnd = dyno.YRangeEnd + 1.0; }while (Convert.ToInt32(dyno.YRangeEnd) % Convert.ToInt32(dyno.YGrid) != 0); } dyno.ShowData1 = true; dyno.ShowData2 = true; dyno.Refresh(); }
private void Calculate() { m_TQMax = 0.0; m_HPMax = 0.0; m_HPValue = new double[m_RpmValues.Count - 1]; m_TQValue = new double[m_RpmValues.Count - 1]; m_SampleRPM = new double[m_RpmValues.Count - 1]; int idx = 0; if ((m_RpmValues.Count - 1) > 0) { do { double rpm_value_0 = m_RpmValues[idx].Value; int next = idx + 1; double rpm_value_1 = m_RpmValues[next].Value; DateTime rpm_date_0 = m_RpmValues[idx].Date; TimeSpan delta_time = m_RpmValues[next].Date.Subtract(rpm_date_0); rpm_date_0.AddSeconds(delta_time.TotalSeconds * 0.5); double kph_value_0 = m_KphValues[idx].Value; double kph_value_1 = m_KphValues[next].Value; DateTime kph_date_0 = m_KphValues[idx].Date; DateTime kph_date_1 = m_KphValues[next].Date; m_SampleRPM[idx] = (rpm_value_1 + rpm_value_0) * 0.5 * 0.001; double num5 = (kph_value_1 + kph_value_0) * 0.5 * 0.621371192 * 0.44704; double kw_value = m_dVehicleWeight * 0.45359237 * num5 * num5 * 0.5 / kph_date_1.Subtract(kph_date_0).TotalSeconds; m_HPValue[idx] = kw_value * 0.00134102209; if (m_HPValue[idx] > m_HPMax) { m_HPMax = m_HPValue[idx]; } m_TQValue[idx] = m_HPValue[idx] * 5252.0 / (m_SampleRPM[idx] * 1000.0); if (m_TQValue[idx] > m_TQMax) { m_TQMax = m_TQValue[idx]; } idx = next; }while (idx < m_RpmValues.Count - 1); } dyno.XData1 = m_SampleRPM; dyno.YData1 = m_HPValue; dyno.XData2 = m_SampleRPM; dyno.YData2 = m_TQValue; dyno.YRangeEnd = m_HPMax < m_TQMax ? m_TQMax : m_HPMax; dyno.YRangeEnd = (double)Convert.ToInt32(dyno.YRangeEnd + 0.5); if (Convert.ToInt32(dyno.YRangeEnd) % Convert.ToInt32(dyno.YGrid) != 0) { do { dyno.YRangeEnd = dyno.YRangeEnd + 1.0; }while (Convert.ToInt32(dyno.YRangeEnd) % Convert.ToInt32(dyno.YGrid) != 0); } dyno.ShowData1 = true; dyno.ShowData2 = true; dyno.Refresh(); }