/// <summary> /// Process set recording command /// </summary> private async Task <string> ProcessSetRecording(UriArgParser args) { try { var enable = bool.Parse(args.GetArg("enable")); var fileName = args.GetArg("filename"); var formatType = args.GetArg("format"); if (BrainflowBoard == null) { return($"NAK?response=Board is not reading data."); } if (enable) { if (FileWriter.IsLogging) { return($"NAK?response=You must close the current recording file before starting a new one."); } FileWriterType format = FileWriterType.Bdf; switch (formatType) { case "txt": format = FileWriterType.OpenBciTxt; break; case "bdf": format = FileWriterType.Bdf; break; } var recordingDir = ConfigurationManager.AppSettings.Get("defaultDir"); var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), recordingDir); await FileWriter.StartWritingToFileAsync(path, fileName, BrainflowBoard.BoardId, BrainflowBoard.SampleRate, format, new FileHeaderInfo() { SessionName = fileName }); return($"ACK?response=File {Path.GetFileName(FileWriter.FileName)} started."); } else { if (FileWriter != null && !FileWriter.IsLogging) { return($"NAK?response=No recording in progress."); } await FileWriter.StopWritingToFileAsync(); return($"ACK?response=Recording stopped."); } } catch (Exception) { return($"NAK?response=Invalid parameters"); } }
private string ProcessSrbSet(UriArgParser args) { try { var enable = bool.Parse(args.GetArg("enable")); var board = int.Parse(args.GetArg("board")); BrainflowBoard.RequestSetSrb1(board, enable); return($"ACK?response=Request set SRB1 {enable}"); } catch (Exception e) { Logger.AddLog(new LogEventArgs(this, "ProcessSrbSet", e, LogLevel.ERROR)); } return($"NAK?response=bad arguments"); }
/// <summary> /// Process change log level command /// </summary> private string ProcessChangeLogLevel(UriArgParser args) { Logger.LogLevelDisplay = (LogLevel)int.Parse(args.GetArg("level")); Logger.AddLog(new LogEventArgs(this, "CommandServerProcessRequest", $"Process request to set log level to {Logger.LogLevelDisplay}.", LogLevel.INFO)); if (LoggingWindow != null) { LoggingWindow.ChangeLogLevel(); } return($"ACK?response=Log level set to {Logger.LogLevelDisplay}."); }
private string ProcessStreamSet(UriArgParser args) { try { var enable = bool.Parse(args.GetArg("enable")); BrainflowBoard.RequestEnableStreaming(enable); return($"ACK?response=Request enable stream {enable}"); } catch (Exception e) { Logger.AddLog(new LogEventArgs(this, "ProcessStreamSet", e, LogLevel.ERROR)); } return($"NAK?response=bad arguments"); }