Exemple #1
0
        static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            eState = e.emoState;
            elapsed = eState.GetTimeFromStart();

            if ((elapsed > 5) && (!allow))
            {
                allow = true;
            }

            if (eState.GetWirelessSignalStatus() == EdkDll.EE_SignalStrength_t.NO_SIGNAL)
            {
                allow = false;
            }
        }
Exemple #2
0
 /// <summary>
 /// Check whether two states are with identical Expressiv state, i.e. are both state representing the same facial expression
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean FacialExpressionEqual(EmoState state)
 {
     return(EdkDll.IS_FacialExpressionEqual(GetHandle(), state.GetHandle()));
 }
Exemple #3
0
 /// <summary>
 /// Check whether two EmoStateHandles are identical
 /// </summary>
 /// <param name="a">EmoState</param>
 /// <param name="b">EmoState</param>
 /// <returns></returns>
 public Boolean Equals(EmoState a, EmoState b)
 {
     return(EdkDll.IS_Equal(a.GetHandle(), b.GetHandle()));
 }
Exemple #4
0
 public bool ExpressivEqual(EmoState state)
 {
     return(EdkDll.ES_ExpressivEqual(this.GetHandle(), state.GetHandle()));
 }
Exemple #5
0
 public bool EmoEngineEqual(EmoState state)
 {
     return(EdkDll.ES_EmoEngineEqual(this.GetHandle(), state.GetHandle()));
 }
Exemple #6
0
 public bool AffectivEqual(EmoState state)
 {
     return(EdkDll.ES_AffectivEqual(this.GetHandle(), state.GetHandle()));
 }
        //public void sendConcentrationLevelSockets(Socket handler, EmoState es)
        /// <summary>
        /// 
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="es"></param>
        public void sendConcentrationLevelSockets(EmoState es)
        {
            //// Get the socket that handles the client request.
            //Socket listener = (Socket)ar.AsyncState;
            //Socket handler = listener.EndAccept(ar);

            //int attention = (int)Math.Round(es.AffectivGetEngagementBoredomScore() * 10);
            //System.Diagnostics.Debug.WriteLine("attention: " + attention);

            //switch (attention)
            //{
            //    case 0:
            //        Send(handler, "Conc, 0 <EOF>");
            //        break;
            //    case 1:
            //        Send(handler, "Conc, 1 <EOF>");
            //        break;
            //    case 2:
            //        Send(handler, "Conc, 2 <EOF>");
            //        break;
            //    case 3:
            //        Send(handler, "Conc, 3 <EOF>");
            //        break;
            //    case 4:
            //        Send(handler, "Conc, 4 <EOF>");
            //        break;
            //    case 5:
            //        Send(handler, "Conc, 5 <EOF>");
            //        break;
            //    case 6:
            //        Send(handler, "Conc, 6 <EOF>");
            //        break;
            //    case 7:
            //        Send(handler, "Conc, 7 <EOF>");
            //        break;
            //    case 8:
            //        Send(handler, "Conc, 8 <EOF>");
            //        break;
            //    case 9:
            //        Send(handler, "Conc, 9 <EOF>");
            //        break;
            //    default:
            //        break;
            //}
        }
 /// <summary>
 /// Check whether two states are with identical Expressiv state, i.e. are both state representing the same facial expression
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean FacialExpressionEqual(EmoState state)
 {
     return EdkDll.IS_FacialExpressionEqual(GetHandle(), state.GetHandle());
 }
Exemple #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="userId">user ID</param>
 /// <param name="emoState">EmoState</param>
 public EmoStateUpdatedEventArgs(UInt32 userId, EmoState emoState)
     : base(userId)
 {
     this.emoState = emoState;
 }
Exemple #10
0
 /// <summary>
 /// Check whether two states are with identical 'emotiv' state
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean AffectivEqual(EmoState state)
 {
     return EdkDll.ES_AffectivEqual(GetHandle(), state.GetHandle());
 }
Exemple #11
0
 /// <summary>
 /// Check whether two states are with identical Expressiv state, i.e. are both state representing the same facial expression
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean ExpressivEqual(EmoState state)
 {
     return EdkDll.ES_ExpressivEqual(GetHandle(), state.GetHandle());
 }
Exemple #12
0
 /// <summary>
 /// Check whether two states are with identical Cognitiv state
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean CognitivEqual(EmoState state)
 {
     return EdkDll.ES_CognitivEqual(GetHandle(), state.GetHandle());
 }
Exemple #13
0
 public EmoStateUpdatedEventArgs(uint userId, EmoState emoState) : base(userId)
 {
     this.emoState = emoState;
 }
		/// <summary>
		/// Update Sensor Data Contact Quality
		/// </summary>
		/// <param name="es">EmoState</param>
		private void UpdateSensorContactQuality(EmoState es)
		{
			EdkDll.EE_EEG_ContactQuality_t[] contactQualityArray = es.GetContactQualityFromAllChannels();
			AF3Contact.Fill = AF3ContactMain.Fill = getContactQualityColor(contactQualityArray[3].ToString());
			AF4Contact.Fill = AF4ContactMain.Fill = getContactQualityColor(contactQualityArray[16].ToString());
			F7Contact.Fill = F7ContactMain.Fill = getContactQualityColor(contactQualityArray[4].ToString());
			F3Contact.Fill = F3ContactMain.Fill = getContactQualityColor(contactQualityArray[5].ToString());
			F4Contact.Fill = F4ContactMain.Fill = getContactQualityColor(contactQualityArray[14].ToString());
			F8Contact.Fill = F8ContactMain.Fill = getContactQualityColor(contactQualityArray[15].ToString());
			FC5Contact.Fill = FC5ContactMain.Fill = getContactQualityColor(contactQualityArray[6].ToString());
			FC6Contact.Fill = FC6ContactMain.Fill = getContactQualityColor(contactQualityArray[13].ToString());
			T7Contact.Fill = T7ContactMain.Fill = getContactQualityColor(contactQualityArray[7].ToString());
			T8Contact.Fill = T8ContactMain.Fill = getContactQualityColor(contactQualityArray[12].ToString());
			CMSContact.Fill = CMSContactMain.Fill = getContactQualityColor(contactQualityArray[0].ToString());
			DRLContact.Fill = DRLContactMain.Fill = getContactQualityColor(contactQualityArray[1].ToString());
			P7Contact.Fill = P7ContactMain.Fill = getContactQualityColor(contactQualityArray[8].ToString());
			P8Contact.Fill = P8ContactMain.Fill = getContactQualityColor(contactQualityArray[11].ToString());
			O1Contact.Fill = O1ContactMain.Fill = getContactQualityColor(contactQualityArray[9].ToString());
			O2Contact.Fill = O2ContactMain.Fill = getContactQualityColor(contactQualityArray[10].ToString());
		}
		void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
		{
			es = e.emoState;
			elapsed = es.GetTimeFromStart();
			UpdateSensorContactQuality(es);

			SignalStatus = es.GetWirelessSignalStatus().ToString();
            MainUptime.Content = ConvertToTime(es.GetTimeFromStart());
			Uptime.Content = ConvertToTime(es.GetTimeFromStart());
			es.GetBatteryChargeLevel(out BatteryLevel, out MaxBatteryLevel);
			SamplingRate.Content = samplingRate.ToString();
			BufferSize.Content = bufferSize.ToString();
			EdkDll.EE_DataGetBufferSizeInSec(out bufferSize);
			EdkDll.EE_DataGetSamplingRate(userID, out samplingRate);

			EdkDll.EE_ExpressivAlgo_t lowerFaceAction, upperFaceAction;
			bool expressivIsBlink, expressivIsEyesOpen, expressivIsLeftWink, expressivIsLookingDown, expressivIsLookingLeft, expressivIsLookingRight, expressivIsLookingUp, expressivIsRightWink;
			float lowerFaceActionPower, upperFaceActionPower;
			float leftEye, rightEye;

			#region Expressiv

			#region Lower Face Action

			lowerFaceAction = es.ExpressivGetLowerFaceAction();
			lowerFaceActionPower = es.ExpressivGetLowerFaceActionPower();

			switch (lowerFaceAction)
			{
				case EdkDll.EE_ExpressivAlgo_t.EXP_CLENCH:
					ClearExpressivLowerFaceCircles();
					break;
				case EdkDll.EE_ExpressivAlgo_t.EXP_LAUGH:
					ClearExpressivLowerFaceCircles();
					LaughRect.Fill = Brushes.Green;
					LaughRect1.Fill = Brushes.Green;
					break;
				case EdkDll.EE_ExpressivAlgo_t.EXP_NEUTRAL:
					ClearExpressivLowerFaceCircles();
					break;
				case EdkDll.EE_ExpressivAlgo_t.EXP_SMILE:
					ClearExpressivLowerFaceCircles();
					SmileRect.Fill = Brushes.Green;
					SmileRect1.Fill = Brushes.Green;
					break;
				case EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_LEFT:
					ClearExpressivLowerFaceCircles();
					SmirkLeftRect.Fill = Brushes.Green;
					SmirkLeftRect1.Fill = Brushes.Green;
					break;
				case EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_RIGHT:
					ClearExpressivLowerFaceCircles();
					SmirkRightRect.Fill = Brushes.Green;
					SmirkRightRect1.Fill = Brushes.Green;
					break;
				default:
					break;
			}

			#region Clench Extent

			float clenchExtent = es.ExpressivGetClenchExtent();
			Clench.Content = toPercentString(clenchExtent);
			Clench1.Content = toPercentString(clenchExtent);

			if (clenchExtent < 0.20)
			{
				ClenchRect.Fill = Brushes.Black;
			}
			else if (clenchExtent < 0.40)
			{
				ClenchRect.Fill = Brushes.Red;
			}
			else if (clenchExtent < 0.60)
			{
				ClenchRect.Fill = Brushes.Orange;
			}
			else if (clenchExtent < 0.80)
			{
				ClenchRect.Fill = Brushes.Yellow;
			}
			else
			{
				ClenchRect.Fill = Brushes.Green;
			}

			#endregion Clench Extent

			#region Smile Extent

			float smileExtent = es.ExpressivGetSmileExtent();
			Smile.Content = toPercentString(smileExtent);
			Smile1.Content = toPercentString(smileExtent);

			if (smileExtent < 0.20)
			{
				SmileRect.Fill = Brushes.Black;
			}
			else if (smileExtent < 0.40)
			{
				SmileRect.Fill = Brushes.Red;
			}
			else if (smileExtent < 0.60)
			{
				SmileRect.Fill = Brushes.Orange;
			}
			else if (smileExtent < 0.80)
			{
				SmileRect.Fill = Brushes.Yellow;
			}
			else
			{
				SmileRect.Fill = Brushes.Green;
			}

			#endregion Smile Extent

			//LowerFaceAction.Content = lowerFaceAction.ToString();

			#endregion Lower Face Action

			#region Middle Face Action

			es.ExpressivGetEyelidState(out leftEye, out rightEye);
			expressivIsBlink = es.ExpressivIsBlink();
			if (expressivIsBlink)
			{
				ClearExpressivUpperFaceCircles();
				BlinkRect.Fill = Brushes.Green;
				BlinkRect1.Fill = Brushes.Green;
			}
			expressivIsEyesOpen = es.ExpressivIsEyesOpen();
			if (expressivIsEyesOpen)
			{
				//MiddleFaceAction.Content = "Eyes Open";
				BlinkRect.Fill = Brushes.Black;
				BlinkRect1.Fill = Brushes.Black;
			}
			else
			{
				BlinkRect.Fill = Brushes.Green;
				BlinkRect1.Fill = Brushes.Green;
				//MiddleFaceAction.Content = "Eyes Closed";
			}
			expressivIsLeftWink = es.ExpressivIsLeftWink();
			if (expressivIsLeftWink)
			{
				ClearExpressivUpperFaceCircles();
				WinkLeftRect.Fill = Brushes.Green;
				WinkLeftRect1.Fill = Brushes.Green;
			}
			expressivIsRightWink = es.ExpressivIsRightWink();
			if (expressivIsRightWink)
			{
				ClearExpressivUpperFaceCircles();
				WinkRightRect.Fill = Brushes.Green;
				WinkRightRect1.Fill = Brushes.Green;
			}
			expressivIsLookingDown = es.ExpressivIsLookingDown();
			if (expressivIsLookingDown)
			{
				//MessageBox.Show("I am looking down");
			}
			expressivIsLookingLeft = es.ExpressivIsLookingLeft();
			if (expressivIsLookingLeft)
			{
				//MessageBox.Show("I am looking left"); // Emotiv SDK is wrong
			}
			expressivIsLookingRight = es.ExpressivIsLookingRight();
			if (expressivIsLookingRight)
			{
				//MessageBox.Show("I am looking right"); // Emotiv SDK is wrong
			}
			expressivIsLookingUp = es.ExpressivIsLookingUp();
			if (expressivIsLookingUp)
			{
				//MessageBox.Show("I am looking up");
			}
			float eyeXCoordinate, eyeYCoordinate;
			es.ExpressivGetEyeLocation(out eyeXCoordinate, out eyeYCoordinate);
			if (eyeXCoordinate > 0)
			{
				//MessageBox.Show("Looking Right");
			}
			else if (eyeXCoordinate<0)
			{
				//MessageBox.Show("Looking Left"); // sometimes it works
			}
			if (eyeYCoordinate > 0)
			{
				MessageBox.Show("Looking Up"); // not working
			}
			else if (eyeYCoordinate < 0)
			{
				MessageBox.Show("Looking Down"); // not working
			}

			#endregion Middle Face Action

			#region Upper Face Action

			upperFaceAction = es.ExpressivGetUpperFaceAction();
			upperFaceActionPower = es.ExpressivGetUpperFaceActionPower();

			switch (upperFaceAction)
			{
				case EdkDll.EE_ExpressivAlgo_t.EXP_EYEBROW:
					ClearExpressivUpperFaceCircles();
					break;
				case EdkDll.EE_ExpressivAlgo_t.EXP_FURROW:
					ClearExpressivUpperFaceCircles();
					FurrowRect.Fill = Brushes.Green;
					FurrowRect1.Fill = Brushes.Green;
					break;
				case EdkDll.EE_ExpressivAlgo_t.EXP_NEUTRAL:
					ClearExpressivUpperFaceCircles();
					break;
				default:
					break;
			}

			#region Eyebrow Extent

			float eyebrowExtent = es.ExpressivGetEyebrowExtent();
			Eyebrow.Content = toPercentString(eyebrowExtent);
			Eyebrow1.Content = toPercentString(eyebrowExtent);

			if (eyebrowExtent < 0.20)
			{
				EyebrowRect.Fill = Brushes.Black;
				EyebrowRect1.Fill = Brushes.Black;
			}
			else if (eyebrowExtent < 0.40)
			{
				EyebrowRect.Fill = Brushes.Red;
				EyebrowRect1.Fill = Brushes.Red;
			}
			else if (eyebrowExtent < 0.60)
			{
				EyebrowRect.Fill = Brushes.Orange;
				EyebrowRect1.Fill = Brushes.Orange;
			}
			else if (eyebrowExtent < 0.80)
			{
				EyebrowRect.Fill = Brushes.Yellow;
				EyebrowRect1.Fill = Brushes.Yellow;
			}
			else
			{
				EyebrowRect.Fill = Brushes.Green;
				EyebrowRect1.Fill = Brushes.Green;
			}

			#endregion Eyebrow Extent
						
			//UpperFaceAction.Content = upperFaceAction.ToString();

			#endregion Upper Face Action

			// Must be removed
			#region Robots

			#region OWI535 Robotic Arm

			//if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_CLENCH)
			//{
			//    OWI535RoboticArm.GrippersClose(1000);
			//}
			//else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_LEFT)
			//{
			//    OWI535RoboticArm.ArmRotateLeft(1000);
			//}
			//else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_RIGHT)
			//{
			//    OWI535RoboticArm.ArmRotateRight(1000);
			//}

			//else if (es.ExpressivGetEyebrowExtent() > 0.10)
			//{
			//    OWI535RoboticArm.ArmStop();
			//}
			//else if (es.ExpressivIsRightWink())
			//{
			//    OWI535RoboticArm.GrippersOpen(1000);
			//}

			#endregion OWI535 Robotic Arm

			#region R2D2

			if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_CLENCH)
			{
				//R2D2.MoveForward();
                int iRobotVelocity = getiRobotVelocity();
                iRobotMoveForward(iRobotVelocity);
                
			}
			else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_LEFT)
			{
				//R2D2.MoveLeft();
                int iRobotVelocity = getiRobotVelocity();
                iRobotTurnLeft(iRobotVelocity);
			}
			else if (lowerFaceAction == EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_RIGHT)
			{
				//R2D2.MoveRight();
                int iRobotVelocity = getiRobotVelocity();
                iRobotTurnRight(iRobotVelocity);
			}
			else if (es.ExpressivGetEyebrowExtent() > 0.10)
			{
				//R2D2.Stop();
                iRobotStop();
			}
			
			#endregion R2D2

			#endregion Robots

			#endregion Expressiv

			#region Affectiv
			
			AffectiveEngagementBoredom = es.AffectivGetEngagementBoredomScore();    // Get Engagement/Boredom Score.
			AffectivExcitementLong = es.AffectivGetExcitementLongTermScore();       // Get Excitement Long Term Score.
			AffectivExcitementShort = es.AffectivGetExcitementShortTermScore();     // Get Excitement Short Term Score.
			AffectivFrustration = es.AffectivGetFrustrationScore();                 // Get Frustration Score.
			AffectivMeditation = es.AffectivGetMeditationScore();                   // Get Meditation Score.

			#endregion Affectiv

			#region Cognitiv

			EdkDll.EE_CognitivAction_t EEGAction;
			EEGAction = es.CognitivGetCurrentAction();
			double cognitivpower = es.CognitivGetCurrentActionPower();
			double cognitivpowerPercent = cognitivpower * 100;
			UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(CognitivPowerProgressBar.SetValue);
			Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, cognitivpowerPercent });

			cognitivPower.Content = (Convert.ToInt32(cognitivpowerPercent)).ToString() + " %";
			bool cognitivIsNoisy;
			cognitivIsNoisy = es.CognitivIsActive();
			if (cognitivIsNoisy)
			{
				cognitivIsActive.Content = "Noisy";
			}
			else
			{
				cognitivIsActive.Content = "Ok";
			}

			// Get Cognitiv Action
			switch (EEGAction)
			{
				case EdkDll.EE_CognitivAction_t.COG_DISAPPEAR:
					cognitivIsState.Content = "Dissapear";
					break;
				case EdkDll.EE_CognitivAction_t.COG_DROP:
					MessageBox.Show("Drop");
					cognitivIsState.Content = "Drop";
					break;
				case EdkDll.EE_CognitivAction_t.COG_LEFT:
					cognitivIsState.Content = "Left";
					break;
				case EdkDll.EE_CognitivAction_t.COG_LIFT:
					cognitivIsState.Content = "Lift";
					break;
				case EdkDll.EE_CognitivAction_t.COG_NEUTRAL:
					cognitivIsState.Content = "Neutral";
					break;
				case EdkDll.EE_CognitivAction_t.COG_PULL:
					cognitivIsState.Content = "Pull";
					break;
				case EdkDll.EE_CognitivAction_t.COG_PUSH:
					cognitivIsState.Content = "Push";
					if (cognitivpower > 0.2)
					{
						//R2D2.MoveBack();
                        int iRobotVelocity = getiRobotVelocity();
                        iRobotMoveForward(iRobotVelocity);
						//OWI535RoboticArm.Handshake();
					}
					break;
				case EdkDll.EE_CognitivAction_t.COG_RIGHT:
					cognitivIsState.Content = "Right";
					break;
				case EdkDll.EE_CognitivAction_t.COG_ROTATE_CLOCKWISE:
					cognitivIsState.Content = "Rotate Clockwise";
					break;
				case EdkDll.EE_CognitivAction_t.COG_ROTATE_COUNTER_CLOCKWISE:
					cognitivIsState.Content = "Rotate Counter Clockwise";
					break;
				case EdkDll.EE_CognitivAction_t.COG_ROTATE_FORWARDS:
					cognitivIsState.Content = "Rotate Forwards";
					break;
				case EdkDll.EE_CognitivAction_t.COG_ROTATE_LEFT:
					cognitivIsState.Content = "Rotate Left";
					break;
				case EdkDll.EE_CognitivAction_t.COG_ROTATE_REVERSE:
					cognitivIsState.Content = "Rotate Reverse";
					break;
				case EdkDll.EE_CognitivAction_t.COG_ROTATE_RIGHT:
					cognitivIsState.Content = "Rotate Right";
					break;
				default:
					break;
			}

			#endregion Cognitiv

		}
Exemple #16
0
        /// <summary>
        /// Processes EmoEngine events until there is no more events or maximum processing time has elapsed
        /// </summary>
        /// <param name="maxTimeMilliseconds">maximum processing time in milliseconds</param>
        public void ProcessEvents(Int32 maxTimeMilliseconds)
        {
            Stopwatch st = new Stopwatch();

            st.Start();
            while (EdkDll.EE_EngineGetNextEvent(hEvent) == EdkDll.EDK_OK)
            {
                if (maxTimeMilliseconds != 0)
                {
                    if (st.ElapsedMilliseconds >= maxTimeMilliseconds)
                        break;
                }
                UInt32 userId = 0;
                EdkDll.EE_EmoEngineEventGetUserId(hEvent, out userId);
                EmoEngineEventArgs args = new EmoEngineEventArgs(userId);
                EdkDll.EE_Event_t eventType = EdkDll.EE_EmoEngineEventGetType(hEvent);
                switch (eventType)
                {
                    case EdkDll.EE_Event_t.EE_UserAdded:
                        OnUserAdded(args);
                        break;
                    case EdkDll.EE_Event_t.EE_UserRemoved:
                        OnUserRemoved(args);
                        break;
                    case EdkDll.EE_Event_t.EE_EmoStateUpdated:
                        EmoState curEmoState = new EmoState();
                        errorHandler(EdkDll.EE_EmoEngineEventGetEmoState(hEvent, curEmoState.GetHandle()));
                        EmoStateUpdatedEventArgs emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, curEmoState);
                        OnEmoStateUpdated(emoStateUpdatedEventArgs);
                        if (!curEmoState.EmoEngineEqual(lastEmoState[userId]))
                        {
                            emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState));
                            OnEmoEngineEmoStateUpdated(emoStateUpdatedEventArgs);
                        }
                        if (!curEmoState.AffectivEqual(lastEmoState[userId]))
                        {
                            emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState));
                            OnAffectivEmoStateUpdated(emoStateUpdatedEventArgs);
                        }
                        if (!curEmoState.CognitivEqual(lastEmoState[userId]))
                        {
                            emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState));
                            OnCognitivEmoStateUpdated(emoStateUpdatedEventArgs);
                        }
                        if (!curEmoState.ExpressivEqual(lastEmoState[userId]))
                        {
                            emoStateUpdatedEventArgs = new EmoStateUpdatedEventArgs(userId, new EmoState(curEmoState));
                            OnExpressivEmoStateUpdated(emoStateUpdatedEventArgs);
                        }
                        lastEmoState[userId] = (EmoState)curEmoState.Clone();
                        break;
                    case EdkDll.EE_Event_t.EE_CognitivEvent:
                        EdkDll.EE_CognitivEvent_t cogType = EdkDll.EE_CognitivEventGetType(hEvent);
                        switch(cogType){
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingStarted:
                                OnCognitivTrainingStarted(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingSucceeded:
                                OnCognitivTrainingSucceeded(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingFailed:
                                OnCognitivTrainingFailed(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingCompleted:
                                OnCognitivTrainingCompleted(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingDataErased:
                                OnCognitivTrainingDataErased(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingRejected:
                                OnCognitivTrainingRejected(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingReset:
                                OnCognitivTrainingReset(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivAutoSamplingNeutralCompleted:
                                OnCognitivAutoSamplingNeutralCompleted(args);
                                break;
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivSignatureUpdated:
                                OnCognitivSignatureUpdated(args);
                                break;
                            default:
                                break;
                        }
                        break;
                    case EdkDll.EE_Event_t.EE_ExpressivEvent:
                        EdkDll.EE_ExpressivEvent_t expEvent = EdkDll.EE_ExpressivEventGetType(hEvent);
                        switch (expEvent)
                        {
                            case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingStarted:
                                OnExpressivTrainingStarted(args);
                                break;
                            case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingSucceeded:
                                OnExpressivTrainingSucceeded(args);
                                break;
                            case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingFailed:
                                OnExpressivTrainingFailed(args);
                                break;
                            case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingCompleted:
                                OnExpressivTrainingCompleted(args);
                                break;
                            case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingDataErased:
                                OnExpressivTrainingDataErased(args);
                                break;
                            case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingRejected:
                                OnExpressivTrainingRejected(args);
                                break;
                            case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingReset:
                                OnExpressivTrainingReset(args);
                                break;
                            default:
                                break;
                        }
                        break;
                    case EdkDll.EE_Event_t.EE_InternalStateChanged:
                        OnInternalStateChanged(args);
                        break;
                    default:
                        break;
                }
            }
        }
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="es">EmoState to be copied</param>
 public EmoState(EmoState es)
 {
     this.hEmoState = EdkDll.IS_Create();
     EdkDll.IS_Copy(this.hEmoState, es.GetHandle());
 }
        protected void EmoEngineEmoStateUpdatedCB(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            //Update connexion status
            lock(syncLock)
            {
                mEmoState = es;
                mIsHeadsetOn = es.GetHeadsetOn() != 0;
                mCQ = es.GetContactQualityFromAllChannels();
                mSignalStrength = es.GetWirelessSignalStatus();
                es.GetBatteryChargeLevel(out mBatteryCharge, out mBatteryMaxCharge);
                mTimeFromStart = es.GetTimeFromStart();
            }
        }
 /// <summary>
 /// Check whether two states are with identical Cognitiv state
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean MentalCommandEqual(EmoState state)
 {
     return EdkDll.IS_MentalCommandEqual(GetHandle(), state.GetHandle());
 }
Exemple #20
0
 /// <summary>
 /// Check whether two states are with identical 'emotiv' state
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean AffectivEqual(EmoState state)
 {
     return(EdkDll.ES_AffectivEqual(GetHandle(), state.GetHandle()));
 }
        void sendConcentrationLevel(EmoState es)
        {
            int attention = (int)Math.Round( es.AffectivGetEngagementBoredomScore() * 10);
            System.Diagnostics.Debug.WriteLine("attention: " + attention);

            switch (attention)
            {
                case 0:
                    virtual_keys.sendZero();
                    break;
                case 1:
                    virtual_keys.sendOne();
                    break;
                case 2:
                    virtual_keys.sendTwo();
                    break;
                case 3:
                    virtual_keys.sendThree();
                    break;
                case 4:
                    virtual_keys.sendFour();
                    break;
                case 5:
                    virtual_keys.sendFive();
                    break;
                case 6:
                    virtual_keys.sendSix();
                    break;
                case 7:
                    virtual_keys.sendSeven();
                    break;
                case 8:
                    virtual_keys.sendEight();
                    break;
                case 9:
                    virtual_keys.sendNine();
                    break;
                default:
                    break;
            }

            // might need this:  http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/2d38d219-b6ea-42d8-92fe-5af344ea820e
        }
Exemple #22
0
 /// <summary>
 /// Check whether two states are with identical Expressiv state, i.e. are both state representing the same facial expression
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean ExpressivEqual(EmoState state)
 {
     return(EdkDll.ES_ExpressivEqual(GetHandle(), state.GetHandle()));
 }
Exemple #23
0
 public bool CognitivEqual(EmoState state)
 {
     return(EdkDll.ES_CognitivEqual(this.GetHandle(), state.GetHandle()));
 }
Exemple #24
0
 /// <summary>
 /// Check whether two states are with identical Cognitiv state
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean CognitivEqual(EmoState state)
 {
     return(EdkDll.ES_CognitivEqual(GetHandle(), state.GetHandle()));
 }
Exemple #25
0
 public bool Equals(EmoState a, EmoState b)
 {
     return(EdkDll.ES_Equal(a.GetHandle(), b.GetHandle()));
 }
Exemple #26
0
 /// <summary>
 /// Check whether two states are with identical 'emotiv' state
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean PerformanceMetricEqual(EmoState state)
 {
     return(PerformanceMetric.IS_PerformanceMetricEqual(GetHandle(), state.GetHandle()));
 }
Exemple #27
0
 /// <summary>
 /// Check whether two states are with identical EmoEngine state.
 /// </summary>
 /// <remarks>
 /// This function is comparing the time since EmoEngine start,
 /// the wireless signal strength and the signal quality of different channels
 /// </remarks>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean EmoEngineEqual(EmoState state)
 {
     return(EdkDll.IS_EmoEngineEqual(GetHandle(), state.GetHandle()));
 }
                /// <summary>
        /// Check whether two states are with identical EmoEngine state.
        /// </summary>
        /// <remarks>
        /// This function is comparing the time since EmoEngine start,
		/// the wireless signal strength and the signal quality of different channels
        /// </remarks>
        /// <param name="state">EmoState</param>
        /// <returns>true: Equal, false: Different</returns>
        public Boolean EmoEngineEqual(EmoState state)
        {
            return EdkDll.IS_EmoEngineEqual(GetHandle(), state.GetHandle());
        }
Exemple #29
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="es">EmoState to be copied</param>
 public EmoState(EmoState es)
 {
     this.hEmoState = EdkDll.IS_Create();
     EdkDll.IS_Copy(this.hEmoState, es.GetHandle());
 }
 /// <summary>
 /// Check whether two EmoStateHandles are identical
 /// </summary>
 /// <param name="a">EmoState</param>
 /// <param name="b">EmoState</param>
 /// <returns></returns>
 public Boolean Equals (EmoState a, EmoState b)
 {
     return EdkDll.IS_Equal(a.GetHandle(), b.GetHandle());
 }
Exemple #31
0
 /// <summary>
 /// Check whether two states are with identical Cognitiv state
 /// </summary>
 /// <param name="state">EmoState</param>
 /// <returns>true: Equal, false: Different</returns>
 public Boolean MentalCommandEqual(EmoState state)
 {
     return(EdkDll.IS_MentalCommandEqual(GetHandle(), state.GetHandle()));
 }
Exemple #32
0
        public void ProcessEvents(int maxTimeMilliseconds)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            while (EdkDll.EE_EngineGetNextEvent(this.hEvent) == 0)
            {
                if ((maxTimeMilliseconds != 0) && (stopwatch.ElapsedMilliseconds >= maxTimeMilliseconds))
                {
                    return;
                }
                uint pUserIdOut = 0;
                EdkDll.EE_EmoEngineEventGetUserId(this.hEvent, out pUserIdOut);
                EmoEngineEventArgs e = new EmoEngineEventArgs(pUserIdOut);
                switch (EdkDll.EE_EmoEngineEventGetType(this.hEvent))
                {
                case EdkDll.EE_Event_t.EE_CognitivEvent:
                {
                    switch (EdkDll.EE_CognitivEventGetType(this.hEvent))
                    {
                    case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingStarted:
                    {
                        this.OnCognitivTrainingStarted(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingSucceeded:
                    {
                        this.OnCognitivTrainingSucceeded(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingFailed:
                    {
                        this.OnCognitivTrainingFailed(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingCompleted:
                    {
                        this.OnCognitivTrainingCompleted(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingDataErased:
                    {
                        this.OnCognitivTrainingDataErased(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingRejected:
                    {
                        this.OnCognitivTrainingRejected(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingReset:
                    {
                        this.OnCognitivTrainingReset(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivAutoSamplingNeutralCompleted:
                    {
                        this.OnCognitivAutoSamplingNeutralCompleted(e);
                        continue;
                    }

                    case EdkDll.EE_CognitivEvent_t.EE_CognitivSignatureUpdated:
                    {
                        this.OnCognitivSignatureUpdated(e);
                        continue;
                    }
                    }
                    continue;
                }

                case EdkDll.EE_Event_t.EE_ExpressivEvent:
                {
                    switch (EdkDll.EE_ExpressivEventGetType(this.hEvent))
                    {
                    case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingStarted:
                    {
                        this.OnExpressivTrainingStarted(e);
                        continue;
                    }

                    case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingSucceeded:
                    {
                        this.OnExpressivTrainingSucceeded(e);
                        continue;
                    }

                    case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingFailed:
                    {
                        this.OnExpressivTrainingFailed(e);
                        continue;
                    }

                    case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingCompleted:
                    {
                        this.OnExpressivTrainingCompleted(e);
                        continue;
                    }

                    case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingDataErased:
                    {
                        this.OnExpressivTrainingDataErased(e);
                        continue;
                    }

                    case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingRejected:
                    {
                        this.OnExpressivTrainingRejected(e);
                        continue;
                    }

                    case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingReset:
                    {
                        this.OnExpressivTrainingReset(e);
                        continue;
                    }
                    }
                    continue;
                }

                case EdkDll.EE_Event_t.EE_InternalStateChanged:
                    break;

                case EdkDll.EE_Event_t.EE_UserAdded:
                {
                    this.OnUserAdded(e);
                    continue;
                }

                case EdkDll.EE_Event_t.EE_UserRemoved:
                {
                    this.OnUserRemoved(e);
                    continue;
                }

                case EdkDll.EE_Event_t.EE_EmoStateUpdated:
                {
                    EmoState emoState = new EmoState();
                    errorHandler(EdkDll.EE_EmoEngineEventGetEmoState(this.hEvent, emoState.GetHandle()));
                    EmoStateUpdatedEventArgs args2 = new EmoStateUpdatedEventArgs(pUserIdOut, emoState);
                    this.OnEmoStateUpdated(args2);
                    if (!emoState.EmoEngineEqual(this.lastEmoState[pUserIdOut]))
                    {
                        args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState));
                        this.OnEmoEngineEmoStateUpdated(args2);
                    }
                    if (!emoState.AffectivEqual(this.lastEmoState[pUserIdOut]))
                    {
                        args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState));
                        this.OnAffectivEmoStateUpdated(args2);
                    }
                    if (!emoState.CognitivEqual(this.lastEmoState[pUserIdOut]))
                    {
                        args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState));
                        this.OnCognitivEmoStateUpdated(args2);
                    }
                    if (!emoState.ExpressivEqual(this.lastEmoState[pUserIdOut]))
                    {
                        args2 = new EmoStateUpdatedEventArgs(pUserIdOut, new EmoState(emoState));
                        this.OnExpressivEmoStateUpdated(args2);
                    }
                    this.lastEmoState[pUserIdOut] = (EmoState)emoState.Clone();
                    continue;
                }

                default:
                {
                    continue;
                }
                }
                this.OnInternalStateChanged(e);
            }
        }