コード例 #1
0
        private EEGDataListener GetTrialDataListener(out BlockingQueue <IArrayView <EEGDataEntry> > trialQueue)
        {
            var entryList = new List <EEGDataEntry>();
            var queue     = new BlockingQueue <IArrayView <EEGDataEntry> >();

            trialQueue = queue;

            var invoker = new SingleThreadedInvoker();

            return(new EEGDataListener(invoker,
                                       null,
                                       entries =>
            {
                foreach (var entry in entries)
                {
                    // got a new marker, so flush!
                    if (entryList.Count > 0 && entry.Marker != entryList[0].Marker)
                    {
                        queue.Enqueue(entryList.AsIArray());
                        entryList = new List <EEGDataEntry>(entryList.Count);
                    }

                    // save stimulus entries
                    if (entry.HasStimulusMarker())
                    {
                        entryList.Add(entry);
                    }
                }
            },
                                       null,
                                       () => invoker.Dispose()));
        }
コード例 #2
0
        private EEGDataListener GetRawDataRecordingListener()
        {
            if (!this.Settings.SaveRawData)
            {
                return(null);
            }

            StreamWriter writer;

            try
            {
                writer = new StreamWriter(
                    Path.Combine(this.Settings.OutputFolder, GetFileName(RAW_DATA_BASE_NAME, this.startTime, GUIUtils.Strings.CSV_EXTENSION)),
                    false);
            }
            catch (Exception)
            {
                GUIUtils.Alert("Failed to save raw data to " + this.Settings.OutputFolder, MessageBoxIcon.Warning);
                return(null);
            }

            var invoker = new SingleThreadedInvoker();

            return(new EEGDataListener(invoker,
                                       null,
                                       data =>
            {
                try { writer.WriteLine(data.ConcatToString(Environment.NewLine)); }
                catch (Exception) { }
            },
                                       null,
                                       () => { writer.Dispose(); invoker.Dispose(); }));
        }