static void Engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            hsOn = es.GetHeadsetOn();
            My_Program.myForm.textBox2.Text = $"ESUpdate.";


            My_Program.myForm.textBox7.Text = "";
            //If HS is swiched OFF during run, it does not changes, so it only reacts
            //on switching HS ON for the first time After UserAdded Event only. Useless.
            My_Program.myForm.textBox7.Text = $"{hsOn}";
            //Getting events is useless or impossible. None of the below doesn't work as promised!
            // es.GetHandle() returns the State of the event.
            EdkDll.IEE_Event_t thisEvent = EdkDll.IEE_EmoEngineEventGetType(es.GetHandle());

            //My_Program.myForm.textBox7.Text = $"{EdkDll.IEE_EmoEngineEventGetType(myEvent)}";
            //My_Program.myForm.textBox7.Text = $"{EdkDll.IEE_EngineGetNextEvent(myEvent)}";
            //My_Program.myForm.textBox7.Text = $"{EdkDll.IEE_EngineGetNextEvent(es.GetHandle())}";
            //EdkDll.IEE_Event_t eventType = EdkDll.IEE_EmoEngineEventGetType(hEvent);
            //My_Program.myForm.textBox1.Text = $"State:{myState};Now:{thisEvent.GetTypeCode()}";

            float timeFromStart = es.GetTimeFromStart();

            My_Program.myForm.textBox6.Text = $"{timeFromStart}";

            //When USB dongle plugged in, WiFi for some reason jumps to 2, even if HeadSet if OFF.
            //but if HS if off later, this doesn't change.
            if (hsOn != 0)
            {
                EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
                WiFi = (int)signalStrength;
                //My_Program.myForm.textBox4.Text = $"{WiFi}";
                //The only way to reset headset ON switch if headset is OFF!!!
                if (WiFi == 0)
                {
                    hsOn = 0;
                    My_Program.myForm.textBox7.Text = $"{hsOn}";
                }
                else
                {
                    My_Program.myForm.textBox7.Text = $"{hsOn}";
                    Int32 chargeLevel    = 0;
                    Int32 maxChargeLevel = 0;
                    es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
                    My_Program.myForm.textBox5.Text = $"{chargeLevel}";
                    //string myStr = "";
                    //EdkDll.IEE_InputChannels_t myChannelsList = new EdkDll.IEE_InputChannels_t();
                    //Get EEG Electrode Contact Quality and change the electrode image on the Form.
                    Dictionary <string, int> electrodeQuality = new Dictionary <string, int>();
                    foreach (EdkDll.IEE_InputChannels_t chan in Enum.GetValues(typeof(EdkDll.IEE_InputChannels_t)))
                    {
                        electrodeQuality.Add($"{chan}", (int)es.GetContactQuality((int)chan));
                        foreach (var myElectrode in My_Program.myElectrodes)
                        {
                            // myStr += chan;
                            if (myElectrode.Name == $"{chan}")
                            {
                                string newImage = $@"{My_Program.myEpoc.myPath}";
                                if (myElectrode.Name == "IEE_CHAN_CMS" || myElectrode.Name == "IEE_CHAN_DRL")
                                {
                                    newImage += $@"\relectrode_q{(int)es.GetContactQuality((int)chan)}.png";
                                }
                                else
                                {
                                    newImage += $@"\electrode_q{(int)es.GetContactQuality((int)chan)}.png";
                                }

                                myElectrode.Image = System.Drawing.Image.FromFile(newImage);
                                //myStr += chan + "WILL BE:" + (int)es.GetContactQuality((int)chan) + " | ";
                                //myStr += newImage;
                            }
                        }
                        //myStr += $"{(int)chan}";
                        // myStr += chan + ":" + (int)es.GetContactQuality((int)chan) + " | ";
                    }
                    //Individual electrode signal quality output
                    //EdkDll.IEE_WindowingTypes myWType = new EdkDll.IEE_WindowingTypes();
                    //My_Program.myForm.textBox1.Text = $"{EdkDll.IEE_FFTGetWindowingType((uint)userID, myWType)}";
                    //My_Program.myEpoc.myEngine.IEE_FFTGetWindowingType((uint)userID, myWType);
                    //My_Program.myForm.textBox1.Text = $"{myWType}";
                    outputBuffer["Type"] = "EpocRawBuffer";
                    Harvest_EEG_Headset();
                    Harvest_Wavebands_Headset();
                    outputBuffer["EQ"] = electrodeQuality;

                    //string json = new JavaScriptSerializer().Serialize(outputBuffer);
                    //if (My_Program.SRV)
                    //{
                    //    My_Program.myServer.Broadcast(json);
                    // }
                }
            }
        }
Пример #2
0
	/// <summary>
	/// Copy constructor
	/// </summary>
	/// <param name="es">EmoState to be copied</param>
	public EmoState(EmoState es)
	{
		this.hEmoState = EdkDll.ES_Create();
		EdkDll.ES_Copy(this.hEmoState, es.GetHandle());
	}
Пример #3
0
    /// <summary>
    /// Get the level of charge remaining in the headset battery
    /// </summary>
    /// <param name="chargeLevel">the current level of charge in the headset battery</param>
    /// <param name="maxChargeLevel">the maximum level of charge in the battery</param>
    //public void GetBatteryChargeLevel(out Int32 chargeLevel, out Int32 maxChargeLevel)
    //{
    //    EdkDll.Plugin_IS_GetBatteryChargeLevel(hEmoState, out chargeLevel, out maxChargeLevel);
    //}

    /// <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.Plugin_IS_EmoEngineEqual(GetHandle(), state.GetHandle()));
    }
Пример #4
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="es">EmoState to be copied</param>
 public EmoState(EmoState es)
 {
     this.hEmoState = EdkDll.Plugin_IS_Create();
     EdkDll.Plugin_IS_Copy(this.hEmoState, es.GetHandle());
 }
Пример #5
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.ES_Equal(a.GetHandle(), b.GetHandle());
	}
Пример #6
0
    public void ProcessEvents(int maxTimeMilliseconds)
    {
        Stopwatch stopwatch = new Stopwatch();

        stopwatch.Start();
        while (EdkDll.EE_EngineGetNextEvent(this.hEvent) == 0)
        {
            if (maxTimeMilliseconds != 0 && stopwatch.ElapsedMilliseconds >= (long)maxTimeMilliseconds)
            {
                break;
            }
            uint num = 0u;
            EdkDll.EE_EmoEngineEventGetUserId(this.hEvent, out num);
            EmoEngineEventArgs e           = new EmoEngineEventArgs(num);
            EdkDll.EE_Event_t  eE_Event_t  = EdkDll.EE_EmoEngineEventGetType(this.hEvent);
            EdkDll.EE_Event_t  eE_Event_t2 = eE_Event_t;
            if (eE_Event_t2 != EdkDll.EE_Event_t.EE_UserAdded)
            {
                if (eE_Event_t2 != EdkDll.EE_Event_t.EE_UserRemoved)
                {
                    if (eE_Event_t2 != EdkDll.EE_Event_t.EE_EmoStateUpdated)
                    {
                        if (eE_Event_t2 != EdkDll.EE_Event_t.EE_CognitivEvent)
                        {
                            if (eE_Event_t2 != EdkDll.EE_Event_t.EE_ExpressivEvent)
                            {
                                if (eE_Event_t2 == EdkDll.EE_Event_t.EE_InternalStateChanged)
                                {
                                    this.OnInternalStateChanged(e);
                                }
                            }
                            else
                            {
                                switch (EdkDll.EE_ExpressivEventGetType(this.hEvent))
                                {
                                case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingStarted:
                                    this.OnExpressivTrainingStarted(e);
                                    break;

                                case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingSucceeded:
                                    this.OnExpressivTrainingSucceeded(e);
                                    break;

                                case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingFailed:
                                    this.OnExpressivTrainingFailed(e);
                                    break;

                                case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingCompleted:
                                    this.OnExpressivTrainingCompleted(e);
                                    break;

                                case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingDataErased:
                                    this.OnExpressivTrainingDataErased(e);
                                    break;

                                case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingRejected:
                                    this.OnExpressivTrainingRejected(e);
                                    break;

                                case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingReset:
                                    this.OnExpressivTrainingReset(e);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            switch (EdkDll.EE_CognitivEventGetType(this.hEvent))
                            {
                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingStarted:
                                this.OnCognitivTrainingStarted(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingSucceeded:
                                this.OnCognitivTrainingSucceeded(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingFailed:
                                this.OnCognitivTrainingFailed(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingCompleted:
                                this.OnCognitivTrainingCompleted(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingDataErased:
                                this.OnCognitivTrainingDataErased(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingRejected:
                                this.OnCognitivTrainingRejected(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingReset:
                                this.OnCognitivTrainingReset(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivAutoSamplingNeutralCompleted:
                                this.OnCognitivAutoSamplingNeutralCompleted(e);
                                break;

                            case EdkDll.EE_CognitivEvent_t.EE_CognitivSignatureUpdated:
                                this.OnCognitivSignatureUpdated(e);
                                break;
                            }
                        }
                    }
                    else
                    {
                        EmoState emoState = new EmoState();
                        EmoEngine.errorHandler(EdkDll.EE_EmoEngineEventGetEmoState(this.hEvent, emoState.GetHandle()));
                        EmoStateUpdatedEventArgs e2 = new EmoStateUpdatedEventArgs(num, emoState);
                        this.OnEmoStateUpdated(e2);
                        if (!emoState.EmoEngineEqual(this.lastEmoState[num]))
                        {
                            e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                            this.OnEmoEngineEmoStateUpdated(e2);
                        }
                        if (!emoState.AffectivEqual(this.lastEmoState[num]))
                        {
                            e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                            this.OnAffectivEmoStateUpdated(e2);
                        }
                        if (!emoState.CognitivEqual(this.lastEmoState[num]))
                        {
                            e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                            this.OnCognitivEmoStateUpdated(e2);
                        }
                        if (!emoState.ExpressivEqual(this.lastEmoState[num]))
                        {
                            e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                            this.OnExpressivEmoStateUpdated(e2);
                        }
                        this.lastEmoState[num] = (EmoState)emoState.Clone();
                    }
                }
                else
                {
                    this.OnUserRemoved(e);
                }
            }
            else
            {
                this.OnUserAdded(e);
            }
        }
    }
Пример #7
0
 public bool ExpressivEqual(EmoState state)
 {
     return(EdkDll.ES_ExpressivEqual(this.GetHandle(), state.GetHandle()));
 }
Пример #8
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());
	}
Пример #9
0
 public bool EmoEngineEqual(EmoState state)
 {
     return EdkDll.ES_EmoEngineEqual(this.GetHandle(), state.GetHandle());
 }
Пример #10
0
 public bool AffectivEqual(EmoState state)
 {
     return(EdkDll.ES_AffectivEqual(this.GetHandle(), state.GetHandle()));
 }
Пример #11
0
 public bool CognitivEqual(EmoState state)
 {
     return EdkDll.ES_CognitivEqual(this.GetHandle(), state.GetHandle());
 }
Пример #12
0
 public bool AffectivEqual(EmoState state)
 {
     return EdkDll.ES_AffectivEqual(this.GetHandle(), state.GetHandle());
 }
Пример #13
0
 public bool ExpressivEqual(EmoState state)
 {
     return EdkDll.ES_ExpressivEqual(this.GetHandle(), state.GetHandle());
 }
Пример #14
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());
	}
Пример #15
0
 public bool CognitivEqual(EmoState state)
 {
     return(EdkDll.ES_CognitivEqual(this.GetHandle(), state.GetHandle()));
 }
Пример #16
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());
	}
Пример #17
0
 public bool EmoEngineEqual(EmoState state)
 {
     return(EdkDll.ES_EmoEngineEqual(this.GetHandle(), state.GetHandle()));
 }
Пример #18
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.ES_EmoEngineEqual(GetHandle(), state.GetHandle());
	}
Пример #19
0
 public bool Equals(EmoState a, EmoState b)
 {
     return(EdkDll.ES_Equal(a.GetHandle(), b.GetHandle()));
 }
Пример #20
0
 public void ProcessEvents(int maxTimeMilliseconds)
 {
     Stopwatch stopwatch = new Stopwatch();
     stopwatch.Start();
     while (EdkDll.EE_EngineGetNextEvent(this.hEvent) == 0)
     {
         if (maxTimeMilliseconds != 0 && stopwatch.ElapsedMilliseconds >= (long)maxTimeMilliseconds)
         {
             break;
         }
         uint num = 0u;
         EdkDll.EE_EmoEngineEventGetUserId(this.hEvent, out num);
         EmoEngineEventArgs e = new EmoEngineEventArgs(num);
         EdkDll.EE_Event_t eE_Event_t = EdkDll.EE_EmoEngineEventGetType(this.hEvent);
         EdkDll.EE_Event_t eE_Event_t2 = eE_Event_t;
         if (eE_Event_t2 != EdkDll.EE_Event_t.EE_UserAdded)
         {
             if (eE_Event_t2 != EdkDll.EE_Event_t.EE_UserRemoved)
             {
                 if (eE_Event_t2 != EdkDll.EE_Event_t.EE_EmoStateUpdated)
                 {
                     if (eE_Event_t2 != EdkDll.EE_Event_t.EE_CognitivEvent)
                     {
                         if (eE_Event_t2 != EdkDll.EE_Event_t.EE_ExpressivEvent)
                         {
                             if (eE_Event_t2 == EdkDll.EE_Event_t.EE_InternalStateChanged)
                             {
                                 this.OnInternalStateChanged(e);
                             }
                         }
                         else
                         {
                             switch (EdkDll.EE_ExpressivEventGetType(this.hEvent))
                             {
                             case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingStarted:
                                 this.OnExpressivTrainingStarted(e);
                                 break;
                             case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingSucceeded:
                                 this.OnExpressivTrainingSucceeded(e);
                                 break;
                             case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingFailed:
                                 this.OnExpressivTrainingFailed(e);
                                 break;
                             case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingCompleted:
                                 this.OnExpressivTrainingCompleted(e);
                                 break;
                             case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingDataErased:
                                 this.OnExpressivTrainingDataErased(e);
                                 break;
                             case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingRejected:
                                 this.OnExpressivTrainingRejected(e);
                                 break;
                             case EdkDll.EE_ExpressivEvent_t.EE_ExpressivTrainingReset:
                                 this.OnExpressivTrainingReset(e);
                                 break;
                             }
                         }
                     }
                     else
                     {
                         switch (EdkDll.EE_CognitivEventGetType(this.hEvent))
                         {
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingStarted:
                             this.OnCognitivTrainingStarted(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingSucceeded:
                             this.OnCognitivTrainingSucceeded(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingFailed:
                             this.OnCognitivTrainingFailed(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingCompleted:
                             this.OnCognitivTrainingCompleted(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingDataErased:
                             this.OnCognitivTrainingDataErased(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingRejected:
                             this.OnCognitivTrainingRejected(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivTrainingReset:
                             this.OnCognitivTrainingReset(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivAutoSamplingNeutralCompleted:
                             this.OnCognitivAutoSamplingNeutralCompleted(e);
                             break;
                         case EdkDll.EE_CognitivEvent_t.EE_CognitivSignatureUpdated:
                             this.OnCognitivSignatureUpdated(e);
                             break;
                         }
                     }
                 }
                 else
                 {
                     EmoState emoState = new EmoState();
                     EmoEngine.errorHandler(EdkDll.EE_EmoEngineEventGetEmoState(this.hEvent, emoState.GetHandle()));
                     EmoStateUpdatedEventArgs e2 = new EmoStateUpdatedEventArgs(num, emoState);
                     this.OnEmoStateUpdated(e2);
                     if (!emoState.EmoEngineEqual(this.lastEmoState[num]))
                     {
                         e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                         this.OnEmoEngineEmoStateUpdated(e2);
                     }
                     if (!emoState.AffectivEqual(this.lastEmoState[num]))
                     {
                         e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                         this.OnAffectivEmoStateUpdated(e2);
                     }
                     if (!emoState.CognitivEqual(this.lastEmoState[num]))
                     {
                         e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                         this.OnCognitivEmoStateUpdated(e2);
                     }
                     if (!emoState.ExpressivEqual(this.lastEmoState[num]))
                     {
                         e2 = new EmoStateUpdatedEventArgs(num, new EmoState(emoState));
                         this.OnExpressivEmoStateUpdated(e2);
                     }
                     this.lastEmoState[num] = (EmoState)emoState.Clone();
                 }
             }
             else
             {
                 this.OnUserRemoved(e);
             }
         }
         else
         {
             this.OnUserAdded(e);
         }
     }
 }
Пример #21
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()));
 }
 /// <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()));
 }
Пример #23
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()));
 }
Пример #24
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.Plugin_IS_Equal(a.GetHandle(), b.GetHandle()));
 }
Пример #25
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()));
 }
Пример #26
0
    /// <summary>
    /// Returns the detected Cognitiv action power of the user
    /// </summary>
    /// <returns>Cognitiv action power (0.0 to 1.0)</returns>
    //public Single MentalCommandGetCurrentActionPower()
    //{
    //    return EdkDll.Plugin_IS_MentalCommandGetCurrentActionPower(hEmoState);
    //}

    /// <summary>
    /// Query whether the signal is too noisy for Cognitiv detection to be active
    /// </summary>
    /// <returns>detection state (false: Not Active, true: Active)</returns>
    //public Boolean MentalCommandIsActive()
    //{
    //    return EdkDll.Plugin_IS_MentalCommandIsActive(hEmoState);
    //}

    /// <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.Plugin_IS_FacialExpressionEqual(GetHandle(), state.GetHandle());
    //}

    /// <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.Plugin_IS_MentalCommandEqual(GetHandle(), state.GetHandle()));
    }
Пример #27
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;
			}
		}
	}