public void StartRecording(DataLogger dataLoggerConfig) { if (dataLoggerConfig != null) { currentDataLoggerConfig = dataLoggerConfig; currentLogFile = LogFileName(); StreamWriter fileStream = new System.IO.StreamWriter(System.IO.Path.Combine(dataLoggerConfig.LocalDirectory, currentLogFile)); recordStream = fileStream ?? throw new FileNotFoundException(); recordStream.WriteLine("Recv time , Packet num, ID , flags, data , float[1] , float[0] , sender addr"); isRecording = true; packetNumber = 0; recordStatus = "Waiting for Message"; StartReceivingCan(); if (dataLoggerConfig.IsRotateByMin()) { StartFileRollTimer(dataLoggerConfig.RotateMinutes); } } else { throw (new FileNotFoundException()); } }
private void LoadConfigButton_Click(object sender, EventArgs e) { Stream ioStream; this.openFileDialog = new OpenFileDialog { RestoreDirectory = true, Filter = "DataLogger config files (*.dlconf)|*.dlconf|All files (*.*)|*.*", FilterIndex = 1 }; if (openFileDialog.ShowDialog() == DialogResult.OK) { if ((ioStream = openFileDialog.OpenFile()) != null) { recordReplayService.StopRecording(); UpdateButtons(); // Not using the instance here DataLogger dataLoggerConfig = CanRecordReplayDebugService.LoadConfig(ioStream); if (dataLoggerConfig.IsLogToLocalDisk()) { logLocally.Checked = true; } else if (dataLoggerConfig.IsLogToFTP()) { logViaFTP.Checked = true; } else if (dataLoggerConfig.IsLogToSFTP()) { logViaSFTP.Checked = true; } if (dataLoggerConfig.ArchiveLogs) { archive.Checked = true; } if (dataLoggerConfig.CompressLogs) { compress.Checked = true; } if (dataLoggerConfig.LimitArchive) { limitArchive.Checked = true; ArchiveLimitTextBox.Text = dataLoggerConfig.LimitArchiveFileNum.ToString(); } if (dataLoggerConfig.IsRotateByMin()) { timeRotate.Checked = true; } else if (dataLoggerConfig.IsRotateByMB()) { sizeRotate.Checked = true; } minutesTextBox.Text = dataLoggerConfig.RotateMinutes.ToString(); MBtextBox.Text = dataLoggerConfig.RotateMB.ToString(); localDirTextBox.Text = dataLoggerConfig.LocalDirectory; archiveDirTextBox.Text = dataLoggerConfig.ArchiveDirectory; remoteHostTextBox.Text = dataLoggerConfig.RemoteHost; remotePortTextBox.Text = dataLoggerConfig.RemotePort.ToString(); remoteDirTextBox.Text = dataLoggerConfig.RemoteDirectory; usernameTextBox.Text = dataLoggerConfig.Username; passwordTextBox.Text = dataLoggerConfig.Password; } } UpdatePanels(); }