Beispiel #1
0
        private void EmoUpdate_Tick(object sender, EventArgs e)
        {
            if (dataReader.getEmoCount() > 0)
            {
                AffectivValue affv = dataReader.getEmoData();

                textBox_boredom.Text         = affv.boredom.ToString();
                textBox_frustration.Text     = affv.frustration.ToString();
                textBox_longExcitement.Text  = affv.longTermExcitement.ToString();
                textBox_ShortExcitement.Text = affv.shortTermExcitementScore.ToString();
            }
        }
Beispiel #2
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();
             */
        }