Example #1
0
 private void thinkGear_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
 {
     int signal = 100 - (int)e.ThinkGearState.PoorSignal;
     if (signal != lastSignal)
     {
         SignalChangedEventArgs signalArgs = new SignalChangedEventArgs();
         signalArgs.NewSignal = signal;
         signalArgs.OldSignal = lastSignal;
         lastSignal = signal;
         OnSignalChanged(signalArgs);
     }
     ThinkGearStateEventArgs args = new ThinkGearStateEventArgs();
     args.Data = new EEGState(e.ThinkGearState);
     args.Timestamp = sw.ElapsedMilliseconds;
     OnDataReceived(args);
     if (IsLogging && logWriter != null)
     {
         string line = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}",
             sw.ElapsedMilliseconds, e.ThinkGearState.Alpha1, e.ThinkGearState.Alpha2, e.ThinkGearState.Beta1, e.ThinkGearState.Beta2,
             e.ThinkGearState.Delta, e.ThinkGearState.Gamma1, e.ThinkGearState.Gamma2, e.ThinkGearState.Theta, e.ThinkGearState.Meditation,
             e.ThinkGearState.Attention, e.ThinkGearState.Raw, 100 - e.ThinkGearState.PoorSignal);
         logWriter.WriteLine(line);
     }
     Thread.Sleep(sleepTime);
 }
Example #2
0
 protected virtual void OnSignalChanged(SignalChangedEventArgs e)
 {
     EventHandler<SignalChangedEventArgs> handler = SignalChanged;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Example #3
0
 private void ReplayLogAsync(object obj)
 {
     SortedDictionary<int, EEGState> log = ((Tuple<SortedDictionary<int, EEGState>,int>)obj).Item1;
     int interval = ((Tuple<SortedDictionary<int, EEGState>, int>)obj).Item2;
     foreach (KeyValuePair<int, EEGState> item in log)
     {
         if (!IsReplaying)
             break;
         ThinkGearStateEventArgs args = new ThinkGearStateEventArgs();
         args.Data = item.Value;
         args.Timestamp = item.Key;
         OnDataReceived(args);
         if (!string.IsNullOrWhiteSpace(args.Data.Comment))
             OnLogCommentFound(new CommentEventArgs(item.Key, args.Data.Comment));
         if ((int)item.Value.Signal != lastSignal)
         {
             SignalChangedEventArgs signalArgs = new SignalChangedEventArgs();
             signalArgs.NewSignal = (int)item.Value.Signal;
             signalArgs.OldSignal = lastSignal;
             lastSignal = (int)item.Value.Signal;
             OnSignalChanged(signalArgs);
         }
         lastSignal = (int)item.Value.Signal;
         Thread.Sleep(interval);
     }
     OnLogReplayFinished(null);
 }
 // --------------------------------------------------------------------------------------------------------------------
 void core_SignalChanged(object sender, SignalChangedEventArgs e)
 {
     if (e.NewSignal >= 0)
     {
         Invoke(new Action(() => progressBarEEGSignalStrength.Value = e.NewSignal));
         Invoke(new Action(() => labelConnectionStrength.Text = e.NewSignal.ToString()));
     }
 }