public TrackForm(OBDInterface obd2) { TrackForm.thisForm = this; m_obdInterface = obd2; timeslip = new Timeslip(); timeslip.Vehicle = m_obdInterface.GetActiveProfile().Name; InitializeComponent(); CheckConnection(); }
public Timeslip CreateTimeslip(string StartTime, string EndTime, string remarks, string tag, int workBreakDownId) { // application user needs to be here Timeslip timeslip = new Timeslip() { StartTime = DateTime.Parse(StartTime), EndTime = DateTime.Parse(EndTime), Remarks = remarks, Tag = tag, UserId = "1", WorkBreakdownItemId = workBreakDownId }; _context.Timeslips.Add(timeslip); _context.SaveChanges(); return(timeslip); }
private void CalculateTimeslip() { double num1 = 0.0; double num2 = 0.0; bool flag = false; timeslip = new Timeslip(); timeslip.Vehicle = m_obdInterface.GetActiveProfile().Name; if (m_arrKphValues == null || m_arrKphValues.Count == 0) return; timeslip.Vehicle = m_obdInterface.GetActiveProfile().Name; timeslip.Date = (m_arrKphValues[0] as DatedValue).Date; int index = 1; if (1 >= m_arrKphValues.Count) return; do { DatedValue datedValue1 = m_arrKphValues[index - 1] as DatedValue; DatedValue datedValue2 = m_arrKphValues[index] as DatedValue; double num3 = (datedValue2.Value + datedValue1.Value) * 0.5 * (5.0 / 18.0); DateTime dateTime = datedValue1.Date; double totalSeconds = datedValue2.Date.Subtract(dateTime).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; } ++index; } while (index < m_arrKphValues.Count); if (!flag) return; UpdateTimeslip(); }
private void btnReset_Click(object sender, EventArgs e) { m_bCapture = false; btnStage.Enabled = true; TrackForm.StopTimer(); timeslip = new Timeslip(); timeslip.Vehicle = m_obdInterface.GetActiveProfile().Name; UpdateTimeslip(); }
private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Timeslip files (*.slp)|*.slp"; openFileDialog.FilterIndex = 0; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() != DialogResult.OK) return; XmlSerializer xmlSerializer = new XmlSerializer(timeslip.GetType()); FileStream fileStream = new FileStream(openFileDialog.FileName, FileMode.Open); timeslip = (Timeslip)xmlSerializer.Deserialize((Stream)fileStream); fileStream.Close(); UpdateTimeslip(); }