Esempio n. 1
0
        private static void BrainChanged(object sender, ThinkGearChangedEventArgs e)
        {
            // get attention level as a percentage
            float attentionPercentage = e.ThinkGearState.Attention / 100.0f;

            // calculate the thrust of the crazyflie (10001 - 60000)
            Thrust = (ushort)(MIN_THRUST + (ushort)((MAX_THRUST - MIN_THRUST) * attentionPercentage));

            Console.WriteLine(attentionPercentage);
        }
Esempio n. 2
0
		void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
		{
			// update the textbox and sleep for a tiny bit
			BeginInvoke(new MethodInvoker(delegate 
				{
					lblAttention.Text = "Attention: " + e.ThinkGearState.Attention;
					lblMeditation.Text = "Meditation: " + e.ThinkGearState.Meditation;
					txtState.Text = e.ThinkGearState.ToString();
				}));
			Thread.Sleep(10);
		}
        static void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
        {
            m_dblLastAttention = e.ThinkGearState.Attention * 10;
              m_dblBlinkStrength = e.ThinkGearState.BlinkStrength * 10;
              m_dblLastMeditation = e.ThinkGearState.Meditation * 10;
              m_dblLastAlpha = ((e.ThinkGearState.Alpha1 / 100) + (e.ThinkGearState.Alpha2 / 100)) / 2;
              m_dblLastBeta = ((e.ThinkGearState.Beta1 / 100) + (e.ThinkGearState.Beta2 / 100)) / 2;
              m_dblLastDelta = e.ThinkGearState.Delta / 10000;
              m_dblLastGamma = ((e.ThinkGearState.Gamma1 / 100) + (e.ThinkGearState.Gamma2 / 100)) / 2;
              m_dblLastTheta = e.ThinkGearState.Theta / 1000;

              if (ClearDisplay)
              {
            ClearDisplay = false;
            DisplayValue = 0;
              }

              if (ClearHighscore)
              {
            ClearHighscore = false;
            DisplayValue = 0;
              }

              m_dblRaw += e.ThinkGearState.Raw;

              if (e.ThinkGearState.Raw >= HighscoreValue)
              {
            HighscoreValue = e.ThinkGearState.Raw;
              }

              if (e.ThinkGearState.Raw >= DisplayValue)
              {
            DisplayValue = e.ThinkGearState.Raw;
              }

              if (ThinkGearChanged != null)
              {
            ThinkGearChanged(sender, e);
              }
        }
      public void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
      {
        if (ClearTicks)
        {
          ClearTicks = false;
          TickCount = "";
        }
        TickCount += e.ThinkGearState.Raw + ",";

        if (ClearBuffer)
        {
          ClearBuffer = false;
          BufferData = "";
        }
        BufferData += e.ThinkGearState.Raw + ",";
      }
Esempio n. 5
0
 private void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
     {
         attentionValue = e.ThinkGearState.Attention;
         attentionTextBlock.Text = "Att Value: " + attentionValue;
         poorSignalTextBlock.Text = "Poor Signal: " + e.ThinkGearState.PoorSignal;
         Attention.Text = attentionValue.ToString();
         attentionValuesCollection.Add(new Data(attentionValue, DateTime.Now));
         attentionValueSum += (int)attentionValue;
         attentionComingCounter += 1;
         try
         {
             byte[] data = BitConverter.GetBytes(attentionValue);
             uSender.SendData(data);
             Console.WriteLine("AV: " + attentionValue + " T: " + DateTime.UtcNow.ToString());
         }
         catch (UException exc)
         {
             Console.WriteLine(exc.Message);
         }
     }));
     Thread.Sleep(1000);
 }
Esempio n. 6
0
        void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
        {
            // Zbieranie danych
            BeginInvoke(new MethodInvoker(delegate
            {
                //Poziom sygnału
                if (e.ThinkGearState.PoorSignal == 200)
                {
                    pbSignal.Value = 0;
                    lblSignal.Text = "NO SIGNAL! : ";
                    lblSignal.ForeColor = Color.Red;
                }
                else if ((e.ThinkGearState.PoorSignal < 200) && (e.ThinkGearState.PoorSignal > 100))
                {
                    pbSignal.Value = 1;
                    lblSignal.Text = "POOR SIGNAL : ";
                    lblSignal.ForeColor = Color.Yellow;

                }
                else if ((e.ThinkGearState.PoorSignal < 100) && (e.ThinkGearState.PoorSignal > 50))
                {
                    pbSignal.Value = 2;
                    lblSignal.Text = "POOR SIGNAL : ";
                    lblSignal.ForeColor = Color.Yellow;
                }
                else if
                    ((e.ThinkGearState.PoorSignal < 50) && (e.ThinkGearState.PoorSignal > 0))
                {
                    pbSignal.Value = 3;
                    lblSignal.Text = "POOR SIGNAL : ";
                    lblSignal.ForeColor = Color.Yellow;
                }
                else
                {
                    pbSignal.Value = 4;
                    lblSignal.Text = "FINE SIGNAL : ";
                    lblSignal.ForeColor = Color.Green;
                }

                //Pomiary
                lblAttention.Text = "Attention: " + e.ThinkGearState.Attention + "%";
                lblMeditation.Text = "Meditation: " + e.ThinkGearState.Meditation + "%";
                txtState.Text = e.ThinkGearState.ToString();

                //Obrazki
                pbAttention.Value = (int)e.ThinkGearState.Attention;
                pbMeditation.Value = (int)e.ThinkGearState.Meditation;
                if (e.ThinkGearState.Attention < AttWanted)
                {
                    pictureBox1.Visible = false;
                    piB1.Visible = true;
                }
                else
                {
                    piB1.Visible = false;
                    pictureBox1.Visible = true;
                }
                if (e.ThinkGearState.Meditation > MeditWanted)
                {
                    piMedit.Visible = true;
                    timer1.Start();
                    timer2.Stop();
                }
                else
                {
                    piMedit.Visible = false;
                    timer2.Start();
                    timer1.Stop();
                }

            }));
            Thread.Sleep(1);
        }
        void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
        {
            value = myThinkGear.ThinkGearState.Attention;

            System.Threading.Thread.Sleep(10);
        }
Esempio n. 8
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);
 }
        void tw_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
        {
            //throw new NotImplementedException();
            val = (double) e.ThinkGearState.Raw;

            SetTextTime(e.ThinkGearState.BlinkStrength.ToString());
        }