Exemple #1
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();
        }
        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");
            }
        }
        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!");
            }
        }
        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();
        }
Exemple #5
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();
        }
Exemple #6
0
        static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();
            //Console.WriteLine("new emostate {0}", timeFromStart);
        }
        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("");
        }
Exemple #8
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();
        }
        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());
        }
        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();
        }
        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());
        }
Exemple #12
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);
        }
Exemple #13
0
        void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            if (e.userId == 0)
            {
                EmoState es = e.emoState;

                Console.WriteLine("User " + e.userId, ":  " + es.GetTimeFromStart());
            }
            else if (e.userId == 1)
            {
                EmoState es = e.emoState;
                Console.WriteLine("User " + e.userId, ":  " + es.GetTimeFromStart());
            }
        }
Exemple #14
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;
            }
        }
        public void engine_MentalCommandEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            EdkDll.IEE_MentalCommandAction_t cogAction = es.MentalCommandGetCurrentAction();
            Single  power    = es.MentalCommandGetCurrentActionPower();
            Boolean isActive = es.MentalCommandIsActive();

            _eventModel.CogAction = (int)cogAction;
            _eventModel.CogPower  = power;

            Console.WriteLine("{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive);
        }
        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();
            }
        }
Exemple #17
0
        static void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            EdkDll.EE_CognitivAction_t cogAction = es.CognitivGetCurrentAction();
            Single  power    = es.CognitivGetCurrentActionPower();
            Boolean isActive = es.CognitivIsActive();

            cogLog.WriteLine(
                "{0},{1},{2},{3}",
                timeFromStart,
                cogAction, power, isActive);
            cogLog.Flush();
        }
        private void epressiveStateUdpate(object sender, EmoStateUpdatedEventArgs e)
        {
            if (e.userId == userID)
            {
                EmoState es = e.emoState;
                ExpressivOSC.ExpressivState exprState = new ExpressivOSC.ExpressivState();

                exprState.emotivTimeStamp = es.GetTimeFromStart();

                EdkDll.EE_ExpressivAlgo_t asd;
                int abc = (int)es.ExpressivGetLowerFaceAction();

                string lower = "" + es.ExpressivGetLowerFaceAction();
                exprState.lowerFaceAction      = lower;
                exprState.lowerFaceActionPower = es.ExpressivGetLowerFaceActionPower();

                string upper = "" + es.ExpressivGetUpperFaceAction();
                exprState.upperFaceAction      = upper;
                exprState.upperFaceActionPower = es.ExpressivGetUpperFaceActionPower();

                // EYES
                float x, y;
                es.ExpressivGetEyelidState(out x, out y);
                exprState.xEyelidState = x;
                exprState.yEyelidState = y;

                float posX, posY;
                es.ExpressivGetEyeLocation(out posX, out posY);
                exprState.posXEyeLocation = posX;
                exprState.posYEyeLocation = posY;

                exprState.isBlink     = es.ExpressivIsBlink();
                exprState.areEyesOpen = es.ExpressivIsEyesOpen();

                exprState.isLeftWink  = es.ExpressivIsLeftWink();
                exprState.isRightWink = es.ExpressivIsRightWink();

                exprState.isLookingLeft  = es.ExpressivIsLookingLeft();
                exprState.isLookingRight = es.ExpressivIsLookingRight();
                exprState.isLookingDown  = es.ExpressivIsLookingDown();
                exprState.isLookingUp    = es.ExpressivIsLookingUp();

                expressivOSC.sendExpressivOSC(exprState, false);

                Console.WriteLine("Received Expressive State Update");
            }
        }
Exemple #19
0
        static void engine_MentalCommandEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            EdkDll.IEE_MentalCommandAction_t cogAction = es.MentalCommandGetCurrentAction();
            Single  power    = es.MentalCommandGetCurrentActionPower();
            Boolean isActive = es.MentalCommandIsActive();

            cogLog.WriteLine("{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive);
            cogLog.Flush();
            if (enableLoger)
            {
                Console.WriteLine("{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive);
            }
        }
        private void Engine_MentalCommandEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            if (es.MentalCommandGetCurrentAction() == EdkDll.IEE_MentalCommandAction_t.MC_LEFT)
            {
                var a  = "";
                var aa = es.MentalCommandGetCurrentActionPower();
            }
            if (es.MentalCommandGetCurrentAction() == EdkDll.IEE_MentalCommandAction_t.MC_NEUTRAL)
            {
                var a  = "";
                var aa = es.MentalCommandGetCurrentActionPower();
            }
            var facialExpressionGetUpperFaceActionPower = es.FacialExpressionGetUpperFaceActionPower();

            Console.WriteLine("User " + e.userId + "  Time :  " + es.GetTimeFromStart());
        }
Exemple #21
0
        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]);
            }

            //expLog.Write("{0},{1},",isLeftWink, isRightWink);
            //for (int i = 0; i < expAlgoList.Length; ++i)
            //{
            //    expLog.Write("{0},", isExpActiveList[i]);
            //}
            if (isLeftWink)
            {
                Mouse.LeftClick();
            }
            if (isRightWink)
            {
                Mouse.RightClick();
            }

            expLog.WriteLine("");
            expLog.Flush();
        }
        static void PerformanceMetricEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState eState = e.emoState;
            // userID = e.userId;
            string myMsg         = "";
            Single timeFromStart = eState.GetTimeFromStart();

            myMsg += $"Time:{timeFromStart},";
            Double rawScore    = 0;
            Double minScale    = 0;
            Double maxScale    = 0;
            Double scaledScore = 0;

            My_Program.myForm.textBox2.Text = $"PMetricUpdate.";
            Dictionary <string, object> myEmoState = new Dictionary <string, object>();

            //Getting Stress
            eState.PerformanceMetricGetStressModelParams(out rawScore, out minScale, out maxScale);
            if (minScale == maxScale)
            {
                scaledScore = 0;
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
            }
            Dictionary <string, double> Stress = new Dictionary <string, double>();

            Stress.Add("Raw", rawScore);
            Stress.Add("Min", minScale);
            Stress.Add("Max", maxScale);
            Stress.Add("Scaled", scaledScore);
            //myMsg += $"Stress Raw:{rawScore}, Min:{minScale}, Max:{maxScale}, Scaled:{scaledScore}";

            //Getting Engagement
            eState.PerformanceMetricGetEngagementBoredomModelParams(out rawScore, out minScale, out maxScale);
            if (minScale == maxScale)
            {
                scaledScore = 0;
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
            }
            Dictionary <string, double> Engagement = new Dictionary <string, double>();

            Engagement.Add("Raw", rawScore);
            Engagement.Add("Min", minScale);
            Engagement.Add("Max", maxScale);
            Engagement.Add("Scaled", scaledScore);
            //myMsg += $"Engagement Raw:{rawScore}, Min:{minScale}, Max:{maxScale}, Scaled:{scaledScore}";

            //Getting Relaxation
            eState.PerformanceMetricGetRelaxationModelParams(out rawScore, out minScale, out maxScale);
            if (minScale == maxScale)
            {
                scaledScore = 0;
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
            }
            Dictionary <string, double> Relaxation = new Dictionary <string, double>();

            Relaxation.Add("Raw", rawScore);
            Relaxation.Add("Min", minScale);
            Relaxation.Add("Max", maxScale);
            Relaxation.Add("Scaled", scaledScore);
            //myMsg += $"Relaxation Raw:{rawScore}, Min:{minScale}, Max:{maxScale}, Scaled:{scaledScore}";

            //Getting Excitement
            eState.PerformanceMetricGetInstantaneousExcitementModelParams(out rawScore, out minScale, out maxScale);
            if (minScale == maxScale)
            {
                scaledScore = 0;
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
            }
            Dictionary <string, double> Excitement = new Dictionary <string, double>();

            Excitement.Add("Raw", rawScore);
            Excitement.Add("Min", minScale);
            Excitement.Add("Max", maxScale);
            Excitement.Add("Scaled", scaledScore);
            //myMsg += $"Excitement Raw:{rawScore}, Min:{minScale}, Max:{maxScale}, Scaled:{scaledScore}";

            //Getting Interest
            eState.PerformanceMetricGetInterestModelParams(out rawScore, out minScale, out maxScale);
            if (minScale == maxScale)
            {
                scaledScore = 0;
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
            }
            Dictionary <string, double> Interest = new Dictionary <string, double>();

            Interest.Add("Raw", rawScore);
            Interest.Add("Min", minScale);
            Interest.Add("Max", maxScale);
            Interest.Add("Scaled", scaledScore);
            //myMsg += $"Interest Raw:{rawScore}, Min:{minScale}, Max:{maxScale}, Scaled:{scaledScore}";

            //Output of the Performance Metric 5 parameters here.
            //My_Program.myForm.richTextBox1.Text = myMsg;
            myEmoState["Stress"]     = Stress;
            myEmoState["Engagement"] = Engagement;
            myEmoState["Relaxation"] = Relaxation;
            myEmoState["Exitement"]  = Excitement;
            myEmoState["Interest"]   = Interest;

            //Harvest_EEG_Headset();
            //Harvest_Wavebands_Headset();

            outputBuffer["Emostate"] = myEmoState;

            //string json = new JavaScriptSerializer().Serialize(outputBuffer);
            // if (My_Program.SRV)
            // {
            // My_Program.myServer.Broadcast(json);
            // }
            //outputBuffer.Remove("Emostate");
        }
Exemple #23
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 Frustration : Raw Score {0:f5} Min Scale {1:f5} max Scale {2:f5} Scaled Score {3:f5}\n", rawScoreFt, minScaleFt, maxScaleFt, scaledScoreFt);
            }

            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();
        }
Exemple #24
0
        static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();
        }
Exemple #25
0
        void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Console.WriteLine("User " + e.userId + "  Time :  " + es.GetTimeFromStart());
        }
        static void engine_PerformanceMetricEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState eState = e.emoState;

            if (!writeHeader)
            {
                writeHeader = true;
                perLog.Write("Time, ");
                perLog.Write("Stress raw score, ");
                perLog.Write("Stress min score, ");
                perLog.Write("Stress max score, ");
                perLog.Write("Stress scaled score, ");
                perLog.Write("Engagement boredom raw score,");
                perLog.Write("Engagement boredom min score,");
                perLog.Write("Engagement boredom max score,");
                perLog.Write("Engagement boredom scaled score,");
                perLog.Write("Relaxation raw score,");
                perLog.Write("Relaxation min score,");
                perLog.Write("Relaxation max score,");
                perLog.Write("Relaxation scaled score,");
                perLog.Write("Excitement raw score,");
                perLog.Write("Excitement min score,");
                perLog.Write("Excitement max score,");
                perLog.Write("Excitement scaled score,");
                perLog.Write("Interest raw score,");
                perLog.Write("Interest min score,");
                perLog.Write("Interest max score,");
                perLog.Write("Interest scaled score");
                perLog.WriteLine("");
            }

            Single timeFromStart = eState.GetTimeFromStart();

            perLog.Write(timeFromStart + ",");

            Double rawScore    = 0;
            Double minScale    = 0;
            Double maxScale    = 0;
            Double scaledScore = 0;

            eState.PerformanceMetricGetStressModelParams(out rawScore, out minScale, out maxScale);
            perLog.Write(rawScore + ",");
            perLog.Write(minScale + ",");
            perLog.Write(maxScale + ",");

            if (minScale == maxScale)
            {
                perLog.Write("undefined" + ",");
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
                perLog.Write(scaledScore + ",");
            }

            eState.PerformanceMetricGetEngagementBoredomModelParams(out rawScore, out minScale, out maxScale);
            perLog.Write(rawScore + ",");
            perLog.Write(minScale + ",");
            perLog.Write(maxScale + ",");

            if (minScale == maxScale)
            {
                perLog.Write("undefined" + ",");
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
                perLog.Write(scaledScore + ",");
            }

            eState.PerformanceMetricGetRelaxationModelParams(out rawScore, out minScale, out maxScale);
            perLog.Write(rawScore + ",");
            perLog.Write(minScale + ",");
            perLog.Write(maxScale + ",");

            if (minScale == maxScale)
            {
                perLog.Write("undefined" + ",");
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
                perLog.Write(scaledScore + ",");
            }

            eState.PerformanceMetricGetInstantaneousExcitementModelParams(out rawScore, out minScale, out maxScale);
            perLog.Write(rawScore + ",");
            perLog.Write(minScale + ",");
            perLog.Write(maxScale + ",");

            if (minScale == maxScale)
            {
                perLog.Write("undefined" + ",");
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
                perLog.Write(scaledScore + ",");
            }

            eState.PerformanceMetricGetInterestModelParams(out rawScore, out minScale, out maxScale);
            perLog.Write(rawScore + ",");
            perLog.Write(minScale + ",");
            perLog.Write(maxScale + ",");

            if (minScale == maxScale)
            {
                perLog.Write("undefined" + ",");
            }
            else
            {
                CaculateScale(rawScore, maxScale, minScale, out scaledScore);
                perLog.Write(scaledScore + ",");
            }

            perLog.WriteLine("");
            perLog.Flush();
        }
Exemple #27
0
        static void engine_AffectivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            //TextWriter file = new StreamWriter(filen, true);
            AffectivValue af = new AffectivValue();
            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;


            #region Excitement
            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:f7}", rawScoreEc);
                //  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);
                af.shortTermExcitementScore = (float)rawScoreEc;
                //                file.Write("Excitement :" + rawScoreEc + " ");

                //  file.Close();
            }

            #endregion
            #region Boredom
            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);
                af.boredom = rawScoreEg;
                //file.Write("Engagement: " + rawScoreEg + " ");
            }
            #endregion

            #region Meditation
            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);
                af.meditation = rawScoreMd;
                // file.Write(" Meditation :" + rawScoreMd + "  ");
            }
            #endregion

            #region Frustration
            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 Frustration : Raw Score {0:f5} Min Scale {1:f5} max Scale {2:f5} Scaled Score {3:f5}\n", rawScoreFt, minScaleFt, maxScaleFt, scaledScoreFt);
                af.frustration = rawScoreFt;
                //file.Write("Frustration :" + rawScoreFt + "  ");
                //file.WriteLine("");
                //file.Close();
            }
            #endregion


            af.timeFromStart      = timeFromStart;
            af.longTermExcitement = longTermExcitementScore;
            af.isAffActiveList    = isAffActiveList;
            Affv.Add(af);

            /*
             *
             * 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();
             */
        }
Exemple #28
0
        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_BLINK,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_CLENCH,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_SUPRISE,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_FROWN,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_HORIEYE,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_NEUTRAL,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_SMILE,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_WINK_LEFT,
                EdkDll.IEE_FacialExpressionAlgo_t.FE_WINK_RIGHT
            };
            Boolean[] isExpActiveList = new Boolean[expAlgoList.Length];

            Boolean isBlink       = es.FacialExpressionIsBlink();
            Boolean isLeftWink    = es.FacialExpressionIsLeftWink();
            Boolean isRightWink   = es.FacialExpressionIsRightWink();
            Boolean isEyesOpen    = es.FacialExpressionIsEyesOpen();
            Boolean isLookingUp   = es.FacialExpressionIsLookingUp();
            Boolean isLookingDown = es.FacialExpressionIsLookingDown();
            Single  leftEye       = 0.0F;
            Single  rightEye      = 0.0F;
            Single  x             = 0.0F;
            Single  y             = 0.0F;

            es.FacialExpressionGetEyelidState(out leftEye, out rightEye);
            es.FacialExpressionGetEyeLocation(out x, out y);
            Single eyebrowExtent = es.FacialExpressionGetEyebrowExtent();
            Single smileExtent   = es.FacialExpressionGetSmileExtent();
            Single clenchExtent  = es.FacialExpressionGetClenchExtent();

            EdkDll.IEE_FacialExpressionAlgo_t upperFaceAction = es.FacialExpressionGetUpperFaceAction();
            Single upperFacePower = es.FacialExpressionGetUpperFaceActionPower();

            EdkDll.IEE_FacialExpressionAlgo_t lowerFaceAction = es.FacialExpressionGetLowerFaceAction();
            Single lowerFacePower = es.FacialExpressionGetLowerFaceActionPower();

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

            expLog.Write(
                "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},",
                timeFromStart,
                isBlink, isLeftWink, isRightWink, isEyesOpen, isLookingUp,
                isLookingDown, leftEye, rightEye,
                x, y, eyebrowExtent, smileExtent, upperFaceAction,
                upperFacePower, lowerFaceAction, lowerFacePower);
            for (int i = 0; i < expAlgoList.Length; ++i)
            {
                expLog.Write("{0},", isExpActiveList[i]);
            }
            expLog.WriteLine("");
            expLog.Flush();
        }
Exemple #29
0
        private static void epressiveStateUdpate(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            if (e.userId == userID)
            {
                string header = "EmoState_Timestamp;" +
                                "LowerFaceAction;LowerFaceActionPower;UpperFaceAction;UpperFaceActionPower;" +
                                " ExpressivEyelidStateX;ExpressivEyelidStateY;ExpressivEyeLocationX;ExpressivEyeLocationY;" +
                                "IsBlink;AreEyesOpen;IsLeftWink;IsRightWink;IsLookingLeft;IsLookingRight;IsLookingDown;IsLookingUp";
                // Wr;ite the data to a file
                TextWriter file = new StreamWriter(filename, true);

                file.Write(es.GetTimeFromStart());
                file.Write(";");

                EdkDll.EE_ExpressivAlgo_t lowerFaceAction = es.ExpressivGetLowerFaceAction();
                float lowerFaceActionPower = es.ExpressivGetLowerFaceActionPower();

                EdkDll.EE_ExpressivAlgo_t upperFaceAction = es.ExpressivGetUpperFaceAction();
                float upperFaceActionPower = es.ExpressivGetUpperFaceActionPower();

                file.Write(lowerFaceAction);
                file.Write(";");
                file.Write(lowerFaceActionPower);
                file.Write(";");

                file.Write(upperFaceAction);
                file.Write(";");
                file.Write(upperFaceActionPower);
                file.Write(";");

                // EYES
                float x, y;
                es.ExpressivGetEyelidState(out x, out y);

                file.Write(x);
                file.Write(";");
                file.Write(y);
                file.Write(";");



                float posX, posY;
                es.ExpressivGetEyeLocation(out posX, out posY);

                file.Write(posX);
                file.Write(";");
                file.Write(posY);
                file.Write(";");

                bool isBlink = es.ExpressivIsBlink();
                file.Write(isBlink);
                file.Write(";");

                bool areEyesOpen = es.ExpressivIsEyesOpen();
                file.Write(areEyesOpen);
                file.Write(";");

                bool isLeftWink  = es.ExpressivIsLeftWink();
                bool isRightWink = es.ExpressivIsRightWink();
                file.Write(isLeftWink);
                file.Write(";");
                file.Write(isRightWink);
                file.Write(";");



                bool isLookingLeft  = es.ExpressivIsLookingLeft();
                bool isLookingRight = es.ExpressivIsLookingRight();
                bool isLookingDown  = es.ExpressivIsLookingDown();
                bool isLookingUp    = es.ExpressivIsLookingUp();
                file.Write(isLookingLeft);
                file.Write(";");
                file.Write(isLookingRight);
                file.Write(";");
                file.Write(isLookingDown);
                file.Write(";");
                file.Write(isLookingUp);
                file.Write(";");

                file.WriteLine("");
                file.Close();
            }
        }
Exemple #30
0
        private void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState     es            = e.emoState;
            FlightWindow outer         = new FlightWindow();
            Single       timeFromStart = es.GetTimeFromStart();
            Single       power         = es.CognitivGetCurrentActionPower();      // get power

            EdkDll.EE_CognitivAction_t cogAction = es.CognitivGetCurrentAction(); // get detected command

            Boolean isActive = es.CognitivIsActive();

            textBox1.Text = "Action:" + cogAction.ToString() + "|" + "Power" + power;
            switch (cogAction)
            {
            case EdkDll.EE_CognitivAction_t.COG_NEUTRAL:
            {
                count_clear("tf");
                outer.manualHover();           //forcing manula hovering.
                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_PUSH:
            {
                count_clear("tf");
                outer.button1_Click(sender, e);                // forward command
                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_PULL:
            {
                count_clear("t");
                if (forward_count % 2 == 0)
                {
                    outer.Backwards_Click(sender, e);              // forwad backward
                }
                forward_count++;

                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_LIFT:
            {
                // if (takeoff_bool == false)
                // {
                if (takeoff_count % 3 == 0)
                {
                    outer.Takeoff_Click(sender, e);             // takeoff
                }

                //takeoff_bool = true;

                //}
                //else
                //{
                //    // already take off so rotate
                //    if (takeoff_count % 2 == 0)
                //    {
                //        outer.button7_Click(sender, e); /// more up
                //    }
                takeoff_count++;
                //}
                count_clear("f");

                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_DROP:
            {
                outer.Landing_Click(sender, e);          // landing
                count_clear("tf");
                takeoff_bool = false;
                break;
            }
            }


            // Console.Write("{0}", cogAction);
            cogLog.WriteLine("{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive);   // writing to log file
            cogLog.Flush();
        }