/// <summary> /// Main update event for AFFECTION data /// </summary> private void engine_AffectivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; 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; // Short 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); } } // Short Engagaement 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); } // 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); } // 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); } // If recording is enabled... if (this._recording) { //Append SCALED affectiv values _ondra.AppendAffectivData(_stopwatch.Elapsed.TotalSeconds, scaledScoreEc, scaledScoreEg, scaledScoreMd, scaledScoreFt); } }