// private UpdateBadReads private void tmrUpdate_Tick(object sender, EventArgs e) { bool status; if (cbConnect.Checked) { status = JeepECUData.ReadECUData(ref ECUVars, lblCurrentGateWay.Text); if (status) { ConnectionState = ConnectionStateEnums.eConnected; fails = 0; ++SuccessfulReads; tsStatLblSuccess.Text = SuccessfulReads.ToString(); ECUVars.LogTime = DateTime.Now; //Timestamp record //Handle Logging if (cbLog.Checked) { CsvRecord cr = new CsvRecord(); //Get a new CSV Record List <String> dataStringList = ECUVars.GetDataValueStringList(); foreach (String item in dataStringList) { cr.Fields.Add(item); } LogFile.Records.Add(cr); needSave = true; } } else { ConnectionState = ConnectionStateEnums.eConnecting; ++fails; if (fails > 5) { status = CheckConnection(lblCurrentGateWay.Text); if (!status) { tmrUpdate.Enabled = false; //Disable timer since it runs asynchroniously and will continue to run this //method while MessageBox is up. MessageBox.Show("Lost Connection. Still Connected to SSID RenixECU?", "Error", MessageBoxButtons.OK); cbConnect.Checked = false; } } } } }
private void SaveparsedCSVFile() { List <ECUData> ECUDataRecords = new List <ECUData>(); DialogResult result = dlgCSVSave.ShowDialog(); JeepECUData ecu = new JeepECUData(); if (result == DialogResult.OK) { //parse all data from raw Readings into Data Frames //Parse Data One Byte at a time into frames for (int x = 0; x < rawEngineData.Count; x++) { ecu.ReceiveDataFrame(rawEngineData[x].data); if (ecu.bufferError == 1) { ++BadFrameErrors; } if (ecu.FrameCompleteFlag) { //Note Reading the frame Buffer resets the complete flag and allows parsing //to continue ECUData rec = ecu.ParseFrame(ecu.frameBuffer); if (ecu.bufferCount >= 27) { //Get a date/time stamp for this //use last byte in frame. Add to recors and //save the record rec.LogTime = rawEngineData[x].timeStamp; ECUDataRecords.Add(rec); } else { ++ShortFrameErrors; } } } JeepECUData.SaveECUData(dlgCSVSave.FileName, ECUDataRecords); } }