示例#1
0
        /// <summary>
        /// Keeps reading from device for duration.
        /// </summary>
        /// <param name="reader">reader to read from</param>
        /// <param name="second">duration to read</param>
        public TimedEmotivReader(IConnectomeReader <IEmotivState> reader, int second)
        {
            this.reader = reader;
            timer       = new Timer(1000 * second);

            timer.Elapsed += (o, e) => reader.StopReading();
        }
        /// <summary>
        /// Sets up Device, Reader, and Sampler then start interpreters coroutine
        /// </summary>
        public virtual void Setup()
        {
            Device      = GetDevice();
            Reader      = GetReader();
            Sampler     = GetSampler();
            Interpeters = GetInterpreters();

            DataRateCalculator      = GetRateCalculator();
            CalculatorConfiguration = GetCalculatorConfiguration();

            Reader.OnRead += Sampler.Register;
            Reader.OnRead += (s) => TotalStatesRead++;

            Reader.StartReading();

            StartCoroutine(InterpetationProcess());
            StartCoroutine(UpdateStatusBar());
        }
示例#3
0
        private void StartCollecting(IConnectomeReader <IEmotivState> readerPlug, int seconds)
        {
            //collect date for time
            list = new List <IEmotivState>();

            IEmotivReader reader = new TimedEmotivReader(readerPlug, seconds);

            reader.OnRead += (state) => list.Add(state);

            ToggleButton("Reading...", false);
            reader.StartReading();

            //TODO learn threading with UI
            while (reader.IsReading)
            {
                ;
            }

            ToggleButton("Exporting...", false);

            //spit into excel
            exportToExcl(list);
            ToggleButton("Exported!");
        }