Example #1
0
 private static void engine_ExpressivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState emoState = e.emoState;
     EmoExpressiv.isBlink = emoState.ExpressivIsBlink();
     EmoExpressiv.isLeftWink = emoState.ExpressivIsLeftWink();
     EmoExpressiv.isRightWink = emoState.ExpressivIsRightWink();
     EmoExpressiv.isEyesOpen = emoState.ExpressivIsEyesOpen();
     EmoExpressiv.isLookingUp = emoState.ExpressivIsLookingUp();
     EmoExpressiv.isLookingDown = emoState.ExpressivIsLookingDown();
     EmoExpressiv.isLookingLeft = emoState.ExpressivIsLookingLeft();
     EmoExpressiv.isLookingRight = emoState.ExpressivIsLookingRight();
     emoState.ExpressivGetEyelidState(out EmoExpressiv.eyelidStateLeft, out EmoExpressiv.eyelidStateRight);
     emoState.ExpressivGetEyeLocation(out EmoExpressiv.eyeLocationX, out EmoExpressiv.eyeLocationY);
     EmoExpressiv.eyebrowExtent = emoState.ExpressivGetEyebrowExtent();
     EmoExpressiv.smileExtent = emoState.ExpressivGetSmileExtent();
     EmoExpressiv.clenchExtent = emoState.ExpressivGetClenchExtent();
     EmoExpressiv.upperFaceAction = emoState.ExpressivGetUpperFaceAction();
     EmoExpressiv.upperFacePower = emoState.ExpressivGetUpperFaceActionPower();
     EmoExpressiv.lowerFaceAction = emoState.ExpressivGetLowerFaceAction();
     EmoExpressiv.lowerFacePower = emoState.ExpressivGetLowerFaceActionPower();
     for (int i = 0; i < EmoExpressiv.expAlgoList.Length; i++)
     {
         EmoExpressiv.isExpActiveList[i] = emoState.ExpressivIsActive(EmoExpressiv.expAlgoList[i]);
     }
 }
    private void onEmoStateUpdated(object sender, EmoStateUpdatedEventArgs args)
    {
        DetectHeadset(args.userId);

        EdkDll.IEE_EEG_ContactQuality_t[] cq = getContactQuality(args.emoState);
        setColor(cq);
    }
    static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState es = e.emoState;

        isBlink        = es.FacialExpressionIsBlink();
        isLeftWink     = es.FacialExpressionIsLeftWink();
        isRightWink    = es.FacialExpressionIsRightWink();
        isEyesOpen     = es.FacialExpressionIsEyesOpen();
        isLookingUp    = es.FacialExpressionIsLookingUp();
        isLookingDown  = es.FacialExpressionIsLookingDown();
        isLookingLeft  = es.FacialExpressionIsLookingLeft();
        isLookingRight = es.FacialExpressionIsLookingRight();
        es.FacialExpressionGetEyelidState(out eyelidStateLeft, out eyelidStateRight);
        es.FacialExpressionGetEyeLocation(out eyeLocationX, out eyeLocationY);
        eyebrowExtent   = es.FacialExpressionGetEyebrowExtent();
        smileExtent     = es.FacialExpressionGetSmileExtent();
        clenchExtent    = es.FacialExpressionGetClenchExtent();
        upperFaceAction = es.FacialExpressionGetUpperFaceAction();
        upperFacePower  = es.FacialExpressionGetUpperFaceActionPower();
        lowerFaceAction = es.FacialExpressionGetLowerFaceAction();
        lowerFacePower  = es.FacialExpressionGetLowerFaceActionPower();
        for (int i = 0; i < expAlgoList.Length; ++i)
        {
            isExpActiveList[i] = es.FacialExpressionIsActive(expAlgoList[i]);
        }
    }
        static void engine_FacialExpressionEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            EdkDll.IEE_FacialExpressionAlgo_t[] expAlgoList =
            {
                EdkDll.IEE_FacialExpressionAlgo_t.FE_WINK_LEFT,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_WINK_RIGHT
            };
            Boolean[] isExpActiveList = new Boolean[expAlgoList.Length];

            Boolean isLeftWink  = es.FacialExpressionIsLeftWink();
            Boolean isRightWink = es.FacialExpressionIsRightWink();

            for (int i = 0; i < expAlgoList.Length; ++i)
            {
                isExpActiveList[i] = es.FacialExpressionIsActive(expAlgoList[i]);
            }

            if (isLeftWink)
            {
                Mouse.LeftClick();
                //MessageBox.Show("Left Clicked!");
            }

            if (isRightWink)
            {
                Mouse.RightClick();
                //MessageBox.Show("Right Clicked!");
            }
        }
Example #5
0
 protected virtual void OnEmoEngineEmoStateUpdated(EmoStateUpdatedEventArgs e)
 {
     if (this.EmoEngineEmoStateUpdated != null)
     {
         this.EmoEngineEmoStateUpdated(this, e);
     }
 }
Example #6
0
 static void engine_ExpressivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState es = e.emoState;
     isBlink = es.ExpressivIsBlink();
     isLeftWink = es.ExpressivIsLeftWink();
     isRightWink = es.ExpressivIsRightWink();
     isEyesOpen = es.ExpressivIsEyesOpen();
     isLookingUp = es.ExpressivIsLookingUp();
     isLookingDown = es.ExpressivIsLookingDown();
     isLookingLeft = es.ExpressivIsLookingLeft();
     isLookingRight = es.ExpressivIsLookingRight();
     es.ExpressivGetEyelidState(out eyelidStateLeft, out eyelidStateRight);
     es.ExpressivGetEyeLocation(out eyeLocationX, out eyeLocationY);
     eyebrowExtent = es.ExpressivGetEyebrowExtent();
     smileExtent = es.ExpressivGetSmileExtent();
     clenchExtent = es.ExpressivGetClenchExtent();
     upperFaceAction = es.ExpressivGetUpperFaceAction();
     upperFacePower = es.ExpressivGetUpperFaceActionPower();
     lowerFaceAction = es.ExpressivGetLowerFaceAction();
     lowerFacePower = es.ExpressivGetLowerFaceActionPower();
     for (int i = 0; i < expAlgoList.Length; ++i)
     {
         isExpActiveList[i] = es.ExpressivIsActive(expAlgoList[i]);
     }
 }
        void affectiveStateUpdate(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            // float lastUpdate = time;
            //float esTimeStamp = es.GetTimeFromStart();
            //string systemTimeStamp = DateTime.Now.ToString("hh.mm.ss.ffffff");

            // "Timestamp,EmoState_Timestamp,BoredomScore,ExcitementShortScore,FrustrationScore," +
            // " MediationScore,ValenceScore,ExcitementLongShort,"


            if (e.userId == userID)
            {
                AffectiveOSC.AffectiveState affectiveState = new AffectiveOSC.AffectiveState();
                affectiveState.emotivTimeStamp    = es.GetTimeFromStart();
                affectiveState.boredom            = es.AffectivGetEngagementBoredomScore();
                affectiveState.excitement         = es.AffectivGetExcitementShortTermScore();
                affectiveState.frustration        = es.AffectivGetFrustrationScore();
                affectiveState.mediation          = es.AffectivGetMeditationScore();
                affectiveState.valence            = es.AffectivGetValenceScore();
                affectiveState.excitementLongTerm = es.AffectivGetExcitementLongTermScore();
                affectiveOSC.sendAffectiveStateData(affectiveState, false);

                Console.WriteLine("Received Affective State Update");
            }
        }
Example #8
0
 void OnEmoStateUpdatedVORTICES(object sender, EmoStateUpdatedEventArgs e)
 {
     EEGManager.Instance.MentalCommandCurrentAction = e.emoState.MentalCommandGetCurrentAction();
     ActionManager.Instance.EmoStateUpdate();
     EEGManager.Instance.MentalCommandCurrentActionPower      = e.emoState.MentalCommandGetCurrentActionPower();
     EEGManager.Instance.FacialExpressionIsRightEyeWinking    = e.emoState.FacialExpressionIsRightWink();
     EEGManager.Instance.FacialExpressionIsLeftEyeWinking     = e.emoState.FacialExpressionIsLeftWink();
     EEGManager.Instance.FacialExpressionIsUserBlinking       = e.emoState.FacialExpressionIsBlink();
     EEGManager.Instance.FacialExpressionUpperFaceActionPower = e.emoState.FacialExpressionGetUpperFaceActionPower();
     EEGManager.Instance.FacialExpressionSmileExtent          = e.emoState.FacialExpressionGetSmileExtent();
     EEGManager.Instance.FacialExpressionLowerFaceActionPower = e.emoState.FacialExpressionGetLowerFaceActionPower();
     EEGManager.Instance.FacialExpressionLowerFaceAction      = e.emoState.FacialExpressionGetLowerFaceAction();
     EEGManager.Instance.FacialExpressionUpperFaceAction      = e.emoState.FacialExpressionGetUpperFaceAction();
     //All actions below are for the Log
     MOTIONSManager.Instance.AddLines(inputName, "Clench Extent: " + e.emoState.FacialExpressionGetClenchExtent().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Eyebrow Extent: " + e.emoState.FacialExpressionGetEyebrowExtent().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Lower Face Action: " + e.emoState.FacialExpressionGetLowerFaceAction().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Lower Face Action Power:  " + e.emoState.FacialExpressionGetLowerFaceActionPower().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Upper Face Action: " + e.emoState.FacialExpressionGetUpperFaceAction().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Upper Face Action Power: " + e.emoState.FacialExpressionGetUpperFaceActionPower().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Smile Extent: " + e.emoState.FacialExpressionGetSmileExtent().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Time since start: " + e.emoState.GetTimeFromStart().ToString(), "Time");
     MOTIONSManager.Instance.AddLines(inputName, " Current Action: " + e.emoState.MentalCommandGetCurrentAction().ToString(), "Mental Command");
     MOTIONSManager.Instance.AddLines(inputName, " Current Action Power: " + e.emoState.MentalCommandGetCurrentActionPower().ToString(), "Mental Command");
     MOTIONSManager.Instance.AddLines(inputName, " Is blinking? " + e.emoState.FacialExpressionIsBlink().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Are eyes open? " + e.emoState.FacialExpressionIsEyesOpen().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Is left winking? " + e.emoState.FacialExpressionIsLeftWink().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Is right winking? " + e.emoState.FacialExpressionIsRightWink().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Is looking down? " + e.emoState.FacialExpressionIsLookingDown().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Is looking left? " + e.emoState.FacialExpressionIsLookingLeft().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Is looking right? " + e.emoState.FacialExpressionIsLookingRight().ToString(), "Facial Expression");
     MOTIONSManager.Instance.AddLines(inputName, " Is looking up? " + e.emoState.FacialExpressionIsLookingUp().ToString(), "Facial Expression");
 }
Example #9
0
    static void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        //Debug.LogError("CognitivEmoStateUpdated");
        isNotResponding = false;
        EmoState es = e.emoState;

        EdkDll.EE_CognitivAction_t cogAction = es.CognitivGetCurrentAction();
        //Debug.LogError(cogAction);
        float power = (float)es.CognitivGetCurrentActionPower();

        //Debug.LogError(power + ":" +(uint)cogAction);
        //CognitivActionPower[(uint)cogAction] = power;
        for (int i = 1; i < cognitivActionList.Length; i++)
        {
            if (cogAction == cognitivActionList[i])
            {
                CognitivActionPower[i] = power;
                //Debug.LogError(CognitivActionPower[i] + "----------------------");
            }
            else
            {
                CognitivActionPower[i] = 0;
            }
        }
    }
Example #10
0
 protected virtual void OnCognitivEmoStateUpdated(EmoStateUpdatedEventArgs e)
 {
     if (this.CognitivEmoStateUpdated != null)
     {
         this.CognitivEmoStateUpdated(this, e);
     }
 }
Example #11
0
 protected virtual void OnExpressivEmoStateUpdated(EmoStateUpdatedEventArgs e)
 {
     if (this.ExpressivEmoStateUpdated != null)
     {
         this.ExpressivEmoStateUpdated(this, e);
     }
 }
Example #12
0
        private void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            Int32 headsetOn = es.GetHeadsetOn();

            EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();

            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
            textBox2.Text = chargeLevel.ToString() + '/' + maxChargeLevel.ToString();
            // HT_Signalstrt.Text = signalStrength.ToString();

            engineLog.Write(
                "{0},{1},{2},{3},{4},",
                timeFromStart,
                headsetOn, signalStrength, chargeLevel, maxChargeLevel);


            engineLog.WriteLine("");
            engineLog.Flush();
        }
Example #13
0
        static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();
            //Console.WriteLine("new emostate {0}", timeFromStart);
        }
Example #14
0
    /// <summary>
    /// Event function called when EmoEngine detects new mental command
    /// Updates current action for UI and Training Cube
    /// </summary>
    void OnMentalCommandEmoStateUpdated(object sender, EmoStateUpdatedEventArgs args)
    {
        if (training)
        {
            cube.SetAciton(cube.ACTION_RESET);
            return;
        }
        //do not update during training
        EdkDll.IEE_MentalCommandAction_t action = args.emoState.MentalCommandGetCurrentAction();
        //Move Block and Update UI text
        switch (action)
        {
        case EdkDll.IEE_MentalCommandAction_t.MC_NEUTRAL:
            cube.SetAciton(cube.ACTION_NEUTRAL);
            UI.UpdateCurrentActionText("Current Action: Neutral");
            break;

        case EdkDll.IEE_MentalCommandAction_t.MC_RIGHT:
            cube.SetAciton(cube.ACTION_RIGHT);
            UI.UpdateCurrentActionText("Current Action: Right");
            break;

        case EdkDll.IEE_MentalCommandAction_t.MC_LEFT:
            cube.SetAciton(cube.ACTION_LEFT);
            UI.UpdateCurrentActionText("Current Action: Left");
            break;
        }
    }
Example #15
0
    private static void engine_ExpressivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState emoState = e.emoState;

        EmoExpressiv.isBlink        = emoState.ExpressivIsBlink();
        EmoExpressiv.isLeftWink     = emoState.ExpressivIsLeftWink();
        EmoExpressiv.isRightWink    = emoState.ExpressivIsRightWink();
        EmoExpressiv.isEyesOpen     = emoState.ExpressivIsEyesOpen();
        EmoExpressiv.isLookingUp    = emoState.ExpressivIsLookingUp();
        EmoExpressiv.isLookingDown  = emoState.ExpressivIsLookingDown();
        EmoExpressiv.isLookingLeft  = emoState.ExpressivIsLookingLeft();
        EmoExpressiv.isLookingRight = emoState.ExpressivIsLookingRight();
        emoState.ExpressivGetEyelidState(out EmoExpressiv.eyelidStateLeft, out EmoExpressiv.eyelidStateRight);
        emoState.ExpressivGetEyeLocation(out EmoExpressiv.eyeLocationX, out EmoExpressiv.eyeLocationY);
        EmoExpressiv.eyebrowExtent   = emoState.ExpressivGetEyebrowExtent();
        EmoExpressiv.smileExtent     = emoState.ExpressivGetSmileExtent();
        EmoExpressiv.clenchExtent    = emoState.ExpressivGetClenchExtent();
        EmoExpressiv.upperFaceAction = emoState.ExpressivGetUpperFaceAction();
        EmoExpressiv.upperFacePower  = emoState.ExpressivGetUpperFaceActionPower();
        EmoExpressiv.lowerFaceAction = emoState.ExpressivGetLowerFaceAction();
        EmoExpressiv.lowerFacePower  = emoState.ExpressivGetLowerFaceActionPower();
        for (int i = 0; i < EmoExpressiv.expAlgoList.Length; i++)
        {
            EmoExpressiv.isExpActiveList[i] = emoState.ExpressivIsActive(EmoExpressiv.expAlgoList[i]);
        }
    }
Example #16
0
        static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            Int32 headsetOn = es.GetHeadsetOn();
            Int32 numCqChan = es.GetNumContactQualityChannels();

            EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();
            for (Int32 i = 0; i < numCqChan; ++i)
            {
                if (cq[i] != es.GetContactQuality(i))
                {
                    throw new Exception();
                }
            }
            EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);

            engineLog.Write(
                "{0},{1},{2},{3},{4},",
                timeFromStart,
                headsetOn, signalStrength, chargeLevel, maxChargeLevel);

            for (int i = 0; i < cq.Length; ++i)
            {
                engineLog.Write("{0},", cq[i]);
            }
            engineLog.WriteLine("");
            engineLog.Flush();
        }
        static void affectiveStateUpdate(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es              = e.emoState;
            float    lastUpdate      = time;
            float    esTimeStamp     = es.GetTimeFromStart();
            string   systemTimeStamp = DateTime.Now.ToString("hh.mm.ss.ffffff");
            // Write the data to a file
            TextWriter file = new StreamWriter(filename, true);

            // "Timestamp,EmoState_Timestamp,BoredomScore,ExcitementShortScore,FrustrationScore," +
            // " MediationScore,ValenceScore,ExcitementLongShort,"


            if (e.userId == userID)
            {
                file.Write(systemTimeStamp + ";");
                file.Write(Convert.ToString(esTimeStamp) + ";");
                file.Write(es.AffectivGetEngagementBoredomScore() + ";");
                file.Write(es.AffectivGetExcitementShortTermScore() + ";");
                file.Write(es.AffectivGetFrustrationScore() + ";");
                file.Write(es.AffectivGetMeditationScore() + ";");
                file.Write(es.AffectivGetValenceScore() + ";");
                file.Write(es.AffectivGetExcitementLongTermScore() + ";");
                file.WriteLine("");



                Console.WriteLine("Receiveing affective update .....");
            }
            file.Close();
        }
        static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;


            float timeFromStart = es.GetTimeFromStart();

            file.Write(timeFromStart + ",");
            Console.WriteLine("Time: " + timeFromStart);

            EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
            file.Write(signalStrength + ",");

            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
            file.Write(chargeLevel + ",");

            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF3) + ",");
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T7) + ",");
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O1) + ",");   // Pz
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T8) + ",");
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF4) + ",");

            file.WriteLine("");
        }
Example #19
0
        static void emoEngine_MentalCommandEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            var   mentalCommand = e.emoState.MentalCommandGetCurrentAction();
            float power         = e.emoState.MentalCommandGetCurrentActionPower();

            Console.WriteLine("Mental command detected: {0} ({1})", mentalCommand, power);
            mainForm.FireMentalCommand(mentalCommand, power);
        }
Example #20
0
        ///////////////////////////////////////////////////////////////////////

        #region EmoEngine event handlers

        private void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            // ctor clones the EmoState object.
            EmoState emoState = new EmoState(e.emoState);

            // Notifies the client thread that the EmotivState changed.
            this._processEventsWorker.ReportProgress(0, emoState);
        }
Example #21
0
        static void emoEngine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            if (e.userId != 0)
            {
                return;
            }

            float timeFromStart = es.GetTimeFromStart();

            Console.Write(timeFromStart + ",");

            EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
            Console.Write(signalStrength + ",");
            MainForm.headsetStatus.SetSignalStrength(signalStrength);

            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
            Console.Write(chargeLevel + "," + maxChargeLevel + ",");
            if (signalStrength == EdkDll.IEE_SignalStrength_t.NO_SIG)
            {
                chargeLevel = 0;
            }
            MainForm.headsetStatus.SetBatteryLevel(chargeLevel);

            foreach (var item in new[] {
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_CMS, chStr = "CMS" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_DRL, chStr = "DRL" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FP1, chStr = "FP1" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FP2, chStr = "FP2" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F7, chStr = "F7" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F3, chStr = "F3" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F4, chStr = "F4" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F8, chStr = "F8" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FC5, chStr = "FC5" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FC6, chStr = "FC6" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_T7, chStr = "T7" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_T8, chStr = "T8" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_P7, chStr = "P7" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_P8, chStr = "P8" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_O1, chStr = "O1" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_O2, chStr = "O2" }
            })
            {
                int val = (int)es.GetContactQuality((int)item.ch);
                Console.Write(val + ",");
                if (signalStrength == EdkDll.IEE_SignalStrength_t.NO_SIG)
                {
                    val = 0;
                }
                MainForm.headsetStatus.SetSensor(item.chStr, val);
            }

            Console.WriteLine();
        }
Example #22
0
    static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState es        = e.emoState;
        Int32    numCqChan = es.GetNumContactQualityChannels();

        EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();
        nChan = numCqChan;
        int temp = 0;

        for (Int32 i = 0; i < numCqChan; ++i)
        {
            if (cq[i] != es.GetContactQuality(i))
            {
                throw new Exception();
            }

            switch (cq[i])
            {
            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL:
                Cq[i] = 0;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_VERY_BAD:
                Cq[i] = 1;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_POOR:
                Cq[i] = 2;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_FAIR:
                Cq[i] = 3;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_GOOD:
                temp++;
                Cq[i] = 4;
                break;
            }

            //---------------------
        }
        numOfGoodContacts = temp;
        //EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
        Int32 chargeLevel    = 0;
        Int32 maxChargeLevel = 0;

        es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);

        EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
        if (signalStrength == EdkDll.EE_SignalStrength_t.NO_SIGNAL)
        {
            for (Int32 i = 0; i < numCqChan; ++i)
            {
                Cq[i] = 0;
            }
        }
    }
Example #23
0
        private void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            lock (emoEngine)
            {
                EmoState emoState = new EmoState(e.emoState);

                _processEventsWorker.ReportProgress(0, emoState);
            }
        }
Example #24
0
    private static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState emoState = e.emoState;
        int      numContactQualityChannels = emoState.GetNumContactQualityChannels();

        EdkDll.EE_EEG_ContactQuality_t[] contactQualityFromAllChannels = emoState.GetContactQualityFromAllChannels();
        EmoEngineInst.nChan = numContactQualityChannels;
        EdkDll.EE_SignalStrength_t wirelessSignalStatus = emoState.GetWirelessSignalStatus();
        int num = 0;

        if (wirelessSignalStatus != EdkDll.EE_SignalStrength_t.NO_SIGNAL)
        {
            for (int i = 0; i < numContactQualityChannels; i++)
            {
                if (contactQualityFromAllChannels[i] != emoState.GetContactQuality(i))
                {
                    throw new Exception();
                }
                switch (contactQualityFromAllChannels[i])
                {
                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL:
                    EmoEngineInst.Cq[i] = 0;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_VERY_BAD:
                    EmoEngineInst.Cq[i] = 1;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_POOR:
                    EmoEngineInst.Cq[i] = 2;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_FAIR:
                    EmoEngineInst.Cq[i] = 3;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_GOOD:
                    num++;
                    EmoEngineInst.Cq[i] = 4;
                    break;
                }
            }
        }
        else
        {
            for (int j = 0; j < numContactQualityChannels; j++)
            {
                EmoEngineInst.Cq[j] = 0;
            }
        }
        EmoEngineInst.numOfGoodContacts = num;
        int num2 = 0;
        int num3 = 0;

        EmoEngineInst.signalStrength = emoState.GetWirelessSignalStatus();
        emoState.GetBatteryChargeLevel(out num2, out num3);
    }
Example #25
0
        private void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;
            int      x  = 1;
            int      y  = 1;

            engine.HeadsetGetGyroDelta(e.userId, out x, out y);
            Console.WriteLine($"X: {x}, Y: {y}");
            Console.WriteLine("User " + e.userId + "  Time :  " + es.GetTimeFromStart());
        }
Example #26
0
 private void Engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     foreach (var item in e.emoState.GetContactQualityFromAllChannels())
     {
         if (item == EdkDll.IEE_EEG_ContactQuality_t.IEEG_CQ_POOR)
         {
             var a = "";
         }
     }
 }
Example #27
0
        /// <summary>
        /// Function called by the EmoEngine if the state of the BCI changes.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Arguments generated by the event.</param>
        void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            // Get the current state from the device
            EmoState es = e.emoState;

            // Read the concentration level as short term excitement
            ConcentrationLevel = es.AffectivGetExcitementShortTermScore();
            // Check whether the user is actually concentrated enough
            Concentrated = ConcentrationLevel <= CONCENTRATION_TRESHOLD;
        }
        public void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Console.WriteLine("Emostate updated: {0}", e.emoState);
            es.GetBatteryChargeLevel(out _batterChargeLevel, out _maxBatterChargeLevel);
            _eventModel.BatteryStatus  = _batterChargeLevel;
            _eventModel.WifiStatus     = es.GetWirelessSignalStatus();
            _eventModel.SessionStatus  = es.GetTimeFromStart();
            _eventModel.ContactQuality = es.GetContactQualityFromAllChannels();
        }
Example #29
0
 private void onEmoStateUpdated(object sender, EmoStateUpdatedEventArgs args)
 {
     if (allowCheckHeadset)
     {
         allowCheckHeadset = false;
         DetectHeadset(args.userId);
         ShowHeadset();
     }
     EdkDll.IEE_EEG_ContactQuality_t[] cq = getContactQuality(args.emoState);
     setColor(cq);
 }
Example #30
0
 /*
  * This method handle the EmoEngine update event,
  * if the EmoState has the PUSH action,
  * a force is applied to the ball in the direction of the camara
 */
 void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState es = e.emoState;
     if (e.userId != 0)
         return;
     Debug.Log ("Corrent action: " + es.MentalCommandGetCurrentAction().ToString());
     if (es.MentalCommandGetCurrentAction () == EdkDll.IEE_MentalCommandAction_t.MC_PUSH) {
         Vector3 movement = new Vector3(cam.transform.forward.x, cam.transform.forward.y, cam.transform.forward.z);
         rb.AddForce(movement * speed);
         Debug.Log ("Push");
     }
 }
Example #31
0
        private void Engine_FacialExpressionEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            if (es.FacialExpressionIsBlink())
            {
                var a = "";
            }
            var facialExpressionGetUpperFaceActionPower = es.FacialExpressionGetUpperFaceActionPower();

            Console.WriteLine("User " + e.userId + "  Time :  " + es.GetTimeFromStart());
        }
Example #32
0
    static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState es = e.emoState;
        Int32 numCqChan = es.GetNumContactQualityChannels();
        EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();
        nChan = numCqChan;
        int temp = 0;
        for (Int32 i = 0; i < numCqChan; ++i)
        {
            if (cq[i] != es.GetContactQuality(i))
            {
                throw new Exception();
            }
           
            switch (cq[i])
            {
                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL:
                    Cq[i] = 0;
                    break;
                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_VERY_BAD:
                    Cq[i] = 1;
                    break;
                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_POOR:
                    Cq[i] = 2;
                    break;
                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_FAIR:
                    Cq[i] = 3;
                    break;
                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_GOOD:
                    temp++;
                    Cq[i] = 4;
                    break;
            }

            //---------------------
        }
        numOfGoodContacts = temp;
        //EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
        Int32 chargeLevel = 0;
        Int32 maxChargeLevel = 0;
        es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);

        EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
        if (signalStrength == EdkDll.EE_SignalStrength_t.NO_SIGNAL)
        {
            for (Int32 i = 0; i < numCqChan; ++i)
            {
                Cq[i] = 0;
            }
        }

    }
Example #33
0
 static void engine_AffectivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState es = e.emoState;
     longTermExcitementScore =(float) es.AffectivGetExcitementLongTermScore();
     shortTermExcitementScore = (float)es.AffectivGetExcitementShortTermScore();
     for (int i = 0; i < affAlgoList.Length; ++i)
     {
         isAffActiveList[i] = es.AffectivIsActive(affAlgoList[i]);
     }
     meditationScore = (float)es.AffectivGetMeditationScore();
     frustrationScore = (float)es.AffectivGetFrustrationScore();
     boredomScore = (float)es.AffectivGetEngagementBoredomScore();
 }
Example #34
0
 private static void engine_AffectivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState emoState = e.emoState;
     EmoAffectiv.longTermExcitementScore = emoState.AffectivGetExcitementLongTermScore();
     EmoAffectiv.shortTermExcitementScore = emoState.AffectivGetExcitementShortTermScore();
     for (int i = 0; i < EmoAffectiv.affAlgoList.Length; i++)
     {
         EmoAffectiv.isAffActiveList[i] = emoState.AffectivIsActive(EmoAffectiv.affAlgoList[i]);
     }
     EmoAffectiv.meditationScore = emoState.AffectivGetMeditationScore();
     EmoAffectiv.frustrationScore = emoState.AffectivGetFrustrationScore();
     EmoAffectiv.boredomScore = emoState.AffectivGetEngagementBoredomScore();
 }
Example #35
0
        public void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            scoreMedidation = es.AffectivGetMeditationScore();
            //Console.WriteLine(scoreMedidation);
            scoreExcitement = es.AffectivGetExcitementShortTermScore();
            //Console.WriteLine(scoreExcitement);
            scoreEngage = es.AffectivGetEngagementBoredomScore();
            //Console.WriteLine("meditation: " + es.AffectivGetMeditationScore());
            //Console.WriteLine("Excitement: " + es.AffectivGetExcitementShortTermScore());
            //Console.WriteLine("Frustration: " + es.AffectivGetFrustrationScore());
        }
Example #36
0
        static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            Int32 headsetOn = es.GetHeadsetOn();

            EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
        }
Example #37
0
 private static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState emoState = e.emoState;
     int numContactQualityChannels = emoState.GetNumContactQualityChannels();
     EdkDll.EE_EEG_ContactQuality_t[] contactQualityFromAllChannels = emoState.GetContactQualityFromAllChannels();
     EmoEngineInst.nChan = numContactQualityChannels;
     EdkDll.EE_SignalStrength_t wirelessSignalStatus = emoState.GetWirelessSignalStatus();
     int num = 0;
     if (wirelessSignalStatus != EdkDll.EE_SignalStrength_t.NO_SIGNAL)
     {
         for (int i = 0; i < numContactQualityChannels; i++)
         {
             if (contactQualityFromAllChannels[i] != emoState.GetContactQuality(i))
             {
                 throw new Exception();
             }
             switch (contactQualityFromAllChannels[i])
             {
             case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL:
                 EmoEngineInst.Cq[i] = 0;
                 break;
             case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_VERY_BAD:
                 EmoEngineInst.Cq[i] = 1;
                 break;
             case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_POOR:
                 EmoEngineInst.Cq[i] = 2;
                 break;
             case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_FAIR:
                 EmoEngineInst.Cq[i] = 3;
                 break;
             case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_GOOD:
                 num++;
                 EmoEngineInst.Cq[i] = 4;
                 break;
             }
         }
     }
     else
     {
         for (int j = 0; j < numContactQualityChannels; j++)
         {
             EmoEngineInst.Cq[j] = 0;
         }
     }
     EmoEngineInst.numOfGoodContacts = num;
     int num2 = 0;
     int num3 = 0;
     EmoEngineInst.signalStrength = emoState.GetWirelessSignalStatus();
     emoState.GetBatteryChargeLevel(out num2, out num3);
 }
Example #38
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;
			}
		}
	}
Example #39
0
	/// <summary>
	/// Handler for AffectivEmoStateUpated event
	/// </summary>
	/// <param name="e">Contains metadata of the event, like userID</param>
	protected virtual void OnAffectivEmoStateUpdated(EmoStateUpdatedEventArgs e)
	{
		if (AffectivEmoStateUpdated != null)
			AffectivEmoStateUpdated(this, e);
	}
Example #40
0
	/// <summary>
	/// Handler for EmoStateUpdated event
	/// </summary>
	/// <param name="e">Contains metadata of the event, like userID</param>
	protected virtual void OnEmoStateUpdated(EmoStateUpdatedEventArgs e)
	{
		if (EmoStateUpdated != null)
			EmoStateUpdated(this, e);
	}
Example #41
0
    void engine_CognitiveEmoStateUpdated(object sender, EmoStateUpdatedEventArgs args)
    {
        cogState = args.emoState;
        EmoState emoState = args.emoState;

        if (emoState.CognitivGetCurrentAction() == EdkDll.EE_CognitivAction_t.COG_DISAPPEAR)
        {
            CognitvEventManager.TriggerCognitivDisappear(sender, emoState.CognitivGetCurrentActionPower() * 10);
        }
        else if (emoState.CognitivGetCurrentAction() == EdkDll.EE_CognitivAction_t.COG_LIFT)
        {
            Debug.Log("EmoHandler sent Lift of " + emoState.CognitivGetCurrentActionPower() * 10);
            CognitvEventManager.TriggerCognitivLift(sender, emoState.CognitivGetCurrentActionPower() * 10);
        }
        else if (emoState.CognitivGetCurrentAction() == EdkDll.EE_CognitivAction_t.COG_LEFT)
        {
            CognitvEventManager.TriggerCognitivLeft(sender, emoState.CognitivGetCurrentActionPower() * 10);
        }
        else if (emoState.CognitivGetCurrentAction() == EdkDll.EE_CognitivAction_t.COG_PUSH)
        {
            Debug.Log("EmoHandler sent Push of " + emoState.CognitivGetCurrentActionPower() * 10);
            CognitvEventManager.TriggerCognitivPush(sender, emoState.CognitivGetCurrentActionPower() * 10);
        }
    }
Example #42
0
 static void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     //Debug.LogError("CognitivEmoStateUpdated");
     isNotResponding = false;
     EmoState es = e.emoState;
     cogAction = es.CognitivGetCurrentAction();
     //Debug.LogError(cogAction);
     power = (float)es.CognitivGetCurrentActionPower();
     //Debug.LogError(power + ":" +(uint)cogAction);
     //CognitivActionPower[(uint)cogAction] = power;
     for (int i = 1; i < cognitivActionList.Length; i++)
     {
         if (cogAction == cognitivActionList[i])
         {
             CognitivActionPower[i] = power;
             //Debug.LogError(CognitivActionPower[i] + "----------------------");
         }
         else CognitivActionPower[i] = 0;
     }
 }
Example #43
0
    static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState es = e.emoState;

        Single timeFromStart = es.GetTimeFromStart();
        // Console.WriteLine("new emostate {0}", timeFromStart);
    }
Example #44
0
    void engine_AffectivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs args)
    {
        EmoState emoState = args.emoState;

        CognitvEventManager.TriggerCognitivEmotion(sender, emoState.AffectivGetMeditationScore());
    }
Example #45
0
 private static void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState emoState = e.emoState;
     EdkDll.EE_CognitivAction_t eE_CognitivAction_t = emoState.CognitivGetCurrentAction();
     float num = emoState.CognitivGetCurrentActionPower();
     for (int i = 1; i < EmoCognitiv.cognitivActionList.Length; i++)
     {
         if (eE_CognitivAction_t == EmoCognitiv.cognitivActionList[i])
         {
             EmoCognitiv.CognitivActionPower[i] = num;
         }
     }
 }
Example #46
0
 protected virtual void OnCognitivEmoStateUpdated(EmoStateUpdatedEventArgs e)
 {
     if (this.CognitivEmoStateUpdated != null)
     {
         this.CognitivEmoStateUpdated(this, e);
     }
 }
Example #47
0
 protected virtual void OnEmoEngineEmoStateUpdated(EmoStateUpdatedEventArgs e)
 {
     if (this.EmoEngineEmoStateUpdated != null)
     {
         this.EmoEngineEmoStateUpdated(this, e);
     }
 }
Example #48
0
 protected virtual void OnExpressivEmoStateUpdated(EmoStateUpdatedEventArgs e)
 {
     if (this.ExpressivEmoStateUpdated != null)
     {
         this.ExpressivEmoStateUpdated(this, e);
     }
 }
Example #49
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);
         }
     }
 }
Example #50
0
    static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState es = e.emoState;

        Single timeFromStart = es.GetTimeFromStart();

        Int32 headsetOn = es.GetHeadsetOn();
        Int32 numCqChan = es.GetNumContactQualityChannels();
        EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();
        for (Int32 i = 0; i < numCqChan; ++i)
        {
            if (cq[i] != es.GetContactQuality(i))
            {
                throw new Exception();
            }
        }
        EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
        Int32 chargeLevel = 0;
        Int32 maxChargeLevel = 0;
        es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);

        /*
        engineLog.Write(
            "{0},{1},{2},{3},{4},",
            timeFromStart,
            headsetOn, signalStrength, chargeLevel, maxChargeLevel);

        for (int i = 0; i < cq.Length; ++i)
        {
            engineLog.Write("{0},", cq[i]);
        }
        engineLog.WriteLine("");
        engineLog.Flush();
        */
    }
Example #51
0
    static void engine_AffectivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState es = e.emoState;

        Single timeFromStart = es.GetTimeFromStart();

        EdkDll.EE_AffectivAlgo_t[] affAlgoList = {
            EdkDll.EE_AffectivAlgo_t.AFF_ENGAGEMENT_BOREDOM,
            EdkDll.EE_AffectivAlgo_t.AFF_EXCITEMENT,
            EdkDll.EE_AffectivAlgo_t.AFF_FRUSTRATION,
            EdkDll.EE_AffectivAlgo_t.AFF_MEDITATION,
        };

        Boolean[] isAffActiveList = new Boolean[affAlgoList.Length];

        Single longTermExcitementScore = es.AffectivGetExcitementLongTermScore();
        Single shortTermExcitementScore = es.AffectivGetExcitementShortTermScore();
        for (int i = 0; i < affAlgoList.Length; ++i)
        {
            isAffActiveList[i] = es.AffectivIsActive(affAlgoList[i]);
        }
        Single meditationScore = es.AffectivGetMeditationScore();
        Single frustrationScore = es.AffectivGetFrustrationScore();
        Single boredomScore = es.AffectivGetEngagementBoredomScore();

        double rawScoreEc = 0, rawScoreMd = 0, rawScoreFt = 0, rawScoreEg = 0;
        double minScaleEc = 0, minScaleMd = 0, minScaleFt = 0, minScaleEg = 0;
        double maxScaleEc = 0, maxScaleMd = 0, maxScaleFt = 0, maxScaleEg = 0;
        double scaledScoreEc = 0, scaledScoreMd = 0, scaledScoreFt = 0, scaledScoreEg = 0;

        es.AffectivGetExcitementShortTermModelParams(out rawScoreEc, out minScaleEc, out maxScaleEc);
        if (minScaleEc != maxScaleEc)
        {
            if (rawScoreEc < minScaleEc)
            {
                scaledScoreEc = 0;
            }
            else if (rawScoreEc > maxScaleEc)
            {
                scaledScoreEc = 1;
            }
            else
            {
                scaledScoreEc = (rawScoreEc - minScaleEc) / (maxScaleEc - minScaleEc);
            }
            Console.WriteLine("Affectiv Short Excitement: Raw Score {0:f5} Min Scale {1:f5} max Scale {2:f5} Scaled Score {3:f5}\n", rawScoreEc, minScaleEc, maxScaleEc, scaledScoreEc);
        }

        es.AffectivGetEngagementBoredomModelParams(out rawScoreEg, out minScaleEg, out maxScaleEg);
        if (minScaleEg != maxScaleEg)
        {
            if (rawScoreEg < minScaleEg)
            {
                scaledScoreEg = 0;
            }
            else if (rawScoreEg > maxScaleEg)
            {
                scaledScoreEg = 1;
            }
            else
            {
                scaledScoreEg = (rawScoreEg - minScaleEg) / (maxScaleEg - minScaleEg);
            }
            Console.WriteLine("Affectiv Engagement : Raw Score {0:f5}  Min Scale {1:f5} max Scale {2:f5} Scaled Score {3:f5}\n", rawScoreEg, minScaleEg, maxScaleEg, scaledScoreEg);
        }
        es.AffectivGetMeditationModelParams(out rawScoreMd, out minScaleMd, out maxScaleMd);
        if (minScaleMd != maxScaleMd)
        {
            if (rawScoreMd < minScaleMd)
            {
                scaledScoreMd = 0;
            }
            else if (rawScoreMd > maxScaleMd)
            {
                scaledScoreMd = 1;
            }
            else
            {
                scaledScoreMd = (rawScoreMd - minScaleMd) / (maxScaleMd - minScaleMd);
            }
            Console.WriteLine("Affectiv Meditation : Raw Score {0:f5} Min Scale {1:f5} max Scale {2:f5} Scaled Score {3:f5}\n", rawScoreMd, minScaleMd, maxScaleMd, scaledScoreMd);
        }
        es.AffectivGetFrustrationModelParams(out rawScoreFt, out minScaleFt, out maxScaleFt);
        if (maxScaleFt != minScaleFt)
        {
            if (rawScoreFt < minScaleFt)
            {
                scaledScoreFt = 0;
            }
            else if (rawScoreFt > maxScaleFt)
            {
                scaledScoreFt = 1;
            }
            else
            {
                scaledScoreFt = (rawScoreFt - minScaleFt) / (maxScaleFt - minScaleFt);
            }
            Console.WriteLine("Affectiv Frustation : Raw Score {0:f5} Min Scale {1:f5} max Scale {2:f5} Scaled Score {3:f5}\n", rawScoreFt, minScaleFt, maxScaleFt, scaledScoreFt);
        }

        shortTerm = (double) shortTermExcitementScore;
        longTerm = (double) longTermExcitementScore;
        meditation = (double) meditationScore;
        frustration = (double) frustrationScore;
        boredom = (double) boredomScore;

        //Debug.Log ("Long term excitation: "+longTermExcitementScore.ToString());
        //Debug.Log ("Frustration score: "+frustrationScore.ToString());
        /*
        affLog.Write(
            "{0},{1},{2},{3},{4},{5},",
            timeFromStart,
            longTermExcitementScore, shortTermExcitementScore, meditationScore, frustrationScore, boredomScore);

        for (int i = 0; i < affAlgoList.Length; ++i)
        {
            affLog.Write("{0},", isAffActiveList[i]);
        }
        affLog.WriteLine("");
        affLog.Flush();
        */
    }