Пример #1
0
        public static void startLog()
        {
            Console.WriteLine("EEG LOGGER");
            Console.WriteLine("Please wear a headset with good signal!!!");

            // Delete Output file if existed
            if (File.Exists(OutFilePath))
            {
                File.Delete(OutFilePath);
            }

            // initialize filestreams for data recording
            SignalProcessor.OutFileStream = new FileStream(OutFilePath, FileMode.Append, FileAccess.Write);
            /*SignalProcessor.TrainFileStream = new FileStream(TrainFilePath, FileMode.Append, FileAccess.Write);*/


            DataStream dse = new DataStream();

            dse.AddStreams("eeg");     // You can add more streams to subscribe multiple streams
            dse.AddStreams("pow");
            dse.OnSubscribed            += SignalProcessor.SetHeaderAll;
            dse.OnEEGDataReceived       += SignalProcessor.OnEEGDataReceived;
            dse.OnBandPowerDataReceived += SignalProcessor.OnBandPowerRecieved;


            // Need a valid license key and activeSession when subscribe eeg data
            dse.Start(licenseID, true);
            IsConnected = true;
            Utils.UserMessage("EEG is connected.", messageType: Globals.MessageTypes.Status);
            Console.WriteLine("Click STOP RECORD to flush data to file and exit");
            // form thread
            Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
            // keep recording eeg data until class prop is changed to false
            new Thread(() =>
            {
                while (KeepRecording)
                {
                }

                // Unsubcribe stream
                dse.UnSubscribe();
                Thread.Sleep(5000);

                // Close Session
                dse.CloseSession();
                Thread.Sleep(5000);
                // Close Out Stream
                SignalProcessor.OutFileStream.Dispose();
                Utils.UserMessage("Headset successfully disconnected. Data flushed to file.", messageType: Globals.MessageTypes.Status);
            })
            {
                IsBackground = true
            }.Start();
        }
Пример #2
0
        public void StartHeadsetCommunications()
        {
            DataStream dataStream = new DataStream();

            dataStream.AddStreams("com");
            dataStream.OnSubscribed      += SubscribedOK;
            dataStream.OnComDataReceived += ComDataReceived;

            // Need a valid license key and activeSession when subscribe com data
            stopwatch.Start();
            dataStream.Start("", true);

            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
            }

            // Unsubcribe stream
            dataStream.UnSubscribe();
            stopwatch.Stop();
            Thread.Sleep(5000);

            // Close Session
            dataStream.CloseSession();
            Thread.Sleep(5000);
        }
Пример #3
0
        public static void StartLogger()
        {
            Console.WriteLine("BAND POWER LOGGER");
            Console.WriteLine("Please wear Headset with good signal!!!");


            OutFileStream = new FileStream(OutFilePath, FileMode.Append, FileAccess.Write);

            DataStream dse = new DataStream();

            dse.AddStreams("pow");
            dse.OnSubscribed            += SubscribedOK;
            dse.OnBandPowerDataReceived += OnBandPowerOK;
            dse.Start();

            Console.WriteLine("Press Esc to flush data to file and exit");

            /*   while (Console.ReadKey().Key != ConsoleKey.Escape) { }
             *
             * // Unsubcribe stream
             * dse.UnSubscribe();
             * Thread.Sleep(5000);
             *
             * // Close Session
             * dse.CloseSession();
             * Thread.Sleep(5000);
             * // Close Out Stream
             * OutFileStream.Dispose();*/
        }