Beispiel #1
0
        /**
         * Handler function for raw event emitter.
         * Converts EEG events into lines of CSV and writes data to the rawLogFile
         */

        internal void OnRawEEGData(EEGEvent evt)
        {
            var csv = new StringBuilder();

            csv.Append(evt.timestamp.ToString("o"));
            csv.Append(",");
            csv.Append(evt.type.ToString());
            if (evt.extra != null)
            {
                csv.Append(evt.extra.ToString());
            }
            csv.Append(",");
            for (int i = 0; i < evt.data.Length; i++)
            {
                csv.Append(",");
                csv.Append(evt.data[i].ToString());
            }
            if (file == null)
            {
                file = new AsyncStreamWriter(rawLogFile, true);
            }
            var writableCsv = csv.ToString();

            file.WriteLine(writableCsv);
        }
Beispiel #2
0
        /**
         * Records the raw data for the current session to the filename/filepath specified
         * @throws ArgumentException if dataType is null
         */

        public void LogRawData(EEGDataType dataType, String fileName)
        {
            if (fileName == null)
            {
                fileName = DateTime.Now.ToString("MM-dd-yyyy HH-mm-ss");
                fileName = fileName + ".csv";
            }

            if (file == null)
            {
                file = new AsyncStreamWriter(fileName, true);
                var csv = new StringBuilder();
                csv.Append("Timestamp,Data Type,Extra,Data");
                var writableCsv = csv.ToString();
                file.WriteLine(writableCsv);
            }
            this.AddRawHandler(dataType, OnRawEEGData);
        }
Beispiel #3
0
 public FileLogger(string logName)
 {
     outputStream = new AsyncStreamWriter(logName, true);
     outputStream.WriteLine("\n\n\n");
 }