private void CSV_PutLine(IMUData data) { if (isInCSVTitle == true) { csvFileWriter.WriteCSVline(imuData.CSVHeaders.ToArray()); isInCSVTitle = false; } csvFileWriter.WriteCSVline(imuData.CSVData.ToArray()); }
private void DataSave() { if (csvFileWriter != null) { ms++; if (timeremain == 0) { csvFileWriter.CloseFile(); csvFileWriter = null; MessageBox.Show("Chưa lưu"); } string stringDataToWrite = String.Concat(DateTime.Now.Second.ToString(), "," + channel[5].ToString(), "," + channel[4].ToString(), "," + channel[3].ToString(), "," + channel[2].ToString()); csvFileWriter.WriteCSVline(stringListDataToWrite); stringListDataToWrite.Clear(); stringListDataToWrite.Add(stringDataToWrite); if (ms == timeremain) { csvFileWriter.CloseFile(); csvFileWriter = null; MessageBox.Show("Dữ liệu đã được lưu"); } } #endregion }
static void xIMUserial_SaveFile(object sender, CalInertialAndMagneticData e) { channels[0] = e.Accelerometer[0]; channels[1] = e.Accelerometer[1]; channels[2] = e.Accelerometer[2]; channels[3] = e.Gyroscope[0]; channels[4] = e.Gyroscope[1]; channels[5] = e.Gyroscope[2]; channels[6] = e.Magnetometer[0]; channels[7] = e.Magnetometer[1]; channels[8] = e.Magnetometer[2]; if (csvFileWriter != null && isSaving) { csvFileWriter.WriteCSVline(channels); } }
//function data save private void DataSave() { if (csvFileWriter != null) { string stringDataToWrite = String.Concat(DateTime.Now.ToString(), "," + channel[5].ToString(), "," + channel[4].ToString(), "," + channel[3].ToString(), "," + channel[2].ToString()); csvFileWriter.WriteCSVline(stringListDataToWrite); stringListDataToWrite.Clear(); stringListDataToWrite.Add(stringDataToWrite); if (DateTime.Compare(DateTime.Now, timeCountSaveData) >= 0) { csvFileWriter.CloseFile(); csvFileWriter = null; MessageBox.Show("Dữ liệu đã được lưu"); } } #endregion }
//function data save private void DataSave() { if (csvFileWriter != null) { ms++; string stringDataToWrite = String.Concat(ms.ToString(), "," + channel[5].ToString(), "," + channel[4].ToString(), "," + channel[3].ToString(), "," + channel[2].ToString()); csvFileWriter.WriteCSVline(stringListDataToWrite); stringListDataToWrite.Clear(); stringListDataToWrite.Add(stringDataToWrite); if (timeremain == 0) { csvFileWriter.CloseFile(); csvFileWriter = null; MessageBox.Show("Chưa lưu"); } if (ms >= timeremain + 1) { csvFileWriter.CloseFile(); csvFileWriter = null; MessageBox.Show("Đã lưu"); } } }
private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) { try { int bytesToRead = Com.BytesToRead; byte[] readbuff = new byte[bytesToRead]; Com.Read(readbuff, 0, bytesToRead); foreach (byte b in readbuff) { if (b == '*') { startBit_isTrue = true; } else { if ((startBit_isTrue == true) && (b != '#')) { asciiBuf += (char)b; } if ((startBit_isTrue == true) && (b == '#')) { startBit_isTrue = false; if (asciiBuf != "" && asciiBuf != null) { string[] data = asciiBuf.Split(','); int channelIndex = 0; for (int i = 0; i < data.Length; i++) { if (data[i] != "" && channelIndex < 4) { channels[channelIndex] = float.Parse(data[i]); channelIndex++; } } asciiBuf = ""; if (channelIndex > 0) { Sample_Received++; Data_list_ADC1.Add(channels[0]); Data_list_ADC2.Add(channels[1]); Data_list_ADC3.Add(channels[2]); Data_list_ADC4.Add(channels[3]); if (csvFileWriter != null) { realtime = DateTime.Now; string stringDataToWrite = String.Concat(realtime.ToLongTimeString(), "," + channels[0].ToString(), "," + channels[1].ToString(), "," + channels[2].ToString(), "," + channels[3].ToString()); csvFileWriter.WriteCSVline(stringListDataToWrite); stringListDataToWrite.Clear(); stringListDataToWrite.Add(stringDataToWrite); } count++; //data_enough_IsTrue = true; if (count == count_max) { count = 0; data_enough_IsTrue = true; } } } } } } } catch (Exception) { DisplayValue(asciiBuf); } }