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(); }
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"); } }
/// <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; 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()); }
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(); }
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(); }
void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmotivUser = e.userId; // enable data aquisition for this user. engine.DataAcquisitionEnable(e.userId, true); // ask for up to 1 second of buffered data engine.EE_DataSetBufferSizeInSec(1); EmoState es = e.emoState; DateTime now = DateTime.Now; //int x,y; //engine.HeadsetGetGyroDelta(e.userId, out x, out y); //values["GyroDeltaX"] = (float)x; //values["GyroDeltaY"] = (float)y; Dictionary <string, float> values = new Dictionary <string, float>(); values["AffectivGetExcitementShortTermScore"] = es.AffectivGetExcitementShortTermScore(); values["AffectivGetExcitementLongTermScore"] = es.AffectivGetExcitementLongTermScore(); values["AffectivGetEngagementBoredomScore"] = es.AffectivGetEngagementBoredomScore(); values["AffectivGetMeditationScore"] = es.AffectivGetMeditationScore(); values["AffectivGetFrustrationScore"] = es.AffectivGetFrustrationScore(); float leftEye, rightEye; es.ExpressivGetEyelidState(out leftEye, out rightEye); values["ExpressivGetEyelidStateLeft"] = leftEye; values["ExpressivGetEyelidStateRight"] = rightEye; es.ExpressivGetEyeLocation(out leftEye, out rightEye); values["ExpressivGetEyeLocationLeft"] = leftEye; values["ExpressivGetEyeLocationRight"] = rightEye; values["ExpressivGetClenchExtent"] = es.ExpressivGetClenchExtent(); values["ExpressivGetEyebrowExtent"] = es.ExpressivGetEyebrowExtent(); values["ExpressivGetLowerFaceActionPower"] = es.ExpressivGetLowerFaceActionPower(); values["ExpressivGetSmileExtent"] = es.ExpressivGetSmileExtent(); values["ExpressivGetUpperFaceActionPower"] = es.ExpressivGetUpperFaceActionPower(); values["ExpressivIsBlink"] = bool2float(es.ExpressivIsBlink()); values["ExpressivIsEyesOpen"] = bool2float(es.ExpressivIsEyesOpen()); values["ExpressivIsLeftWink"] = bool2float(es.ExpressivIsLeftWink()); values["ExpressivIsLookingDown"] = bool2float(es.ExpressivIsLookingDown()); values["ExpressivIsLookingLeft"] = bool2float(es.ExpressivIsLookingLeft()); values["ExpressivIsLookingRight"] = bool2float(es.ExpressivIsLookingRight()); values["ExpressivIsLookingUp"] = bool2float(es.ExpressivIsLookingUp()); values["ExpressivIsRightWink"] = bool2float(es.ExpressivIsRightWink()); Sender.uploadEmotivEvent(user, now, values); }
/// <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); } }
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(); */ }
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(); }
//Update data void AffectivEmoStateUpdated() { if (FEmoState[0] != null) { EmoState es = FEmoState[0]; Single timeFromStart = es.GetTimeFromStart(); mLongTermExcitementScore = es.AffectivGetExcitementLongTermScore(); mShortTermExcitementScore = es.AffectivGetExcitementShortTermScore(); for (int i = 0; i < mAffAlgoList.Length; ++i) { mIsAffActiveList[i] = es.AffectivIsActive(mAffAlgoList[i]); } mMeditationScore = es.AffectivGetMeditationScore(); mFrustrationScore = es.AffectivGetFrustrationScore(); mBoredomScore = es.AffectivGetEngagementBoredomScore(); es.AffectivGetExcitementShortTermModelParams(out mRawScoreEc, out mMinScaleEc, out mMaxScaleEc); if (mMinScaleEc != mMaxScaleEc) { if (mRawScoreEc < mMinScaleEc) { mScaledScoreEc = 0; } else if (mRawScoreEc > mMaxScaleEc) { mScaledScoreEc = 1; } else { mScaledScoreEc = (mRawScoreEc - mMinScaleEc) / (mMaxScaleEc - mMinScaleEc); } } es.AffectivGetEngagementBoredomModelParams(out mRawScoreEg, out mMinScaleEg, out mMaxScaleEg); if (mMinScaleEg != mMaxScaleEg) { if (mRawScoreEg < mMinScaleEg) { mScaledScoreEg = 0; } else if (mRawScoreEg > mMaxScaleEg) { mScaledScoreEg = 1; } else { mScaledScoreEg = (mRawScoreEg - mMinScaleEg) / (mMaxScaleEg - mMinScaleEg); } } es.AffectivGetMeditationModelParams(out mRawScoreMd, out mMinScaleMd, out mMaxScaleMd); if (mMinScaleMd != mMaxScaleMd) { if (mRawScoreMd < mMinScaleMd) { mScaledScoreMd = 0; } else if (mRawScoreMd > mMaxScaleMd) { mScaledScoreMd = 1; } else { mScaledScoreMd = (mRawScoreMd - mMinScaleMd) / (mMaxScaleMd - mMinScaleMd); } } es.AffectivGetFrustrationModelParams(out mRawScoreFt, out mMinScaleFt, out mMaxScaleFt); if (mMaxScaleFt != mMinScaleFt) { if (mRawScoreFt < mMinScaleFt) { mScaledScoreFt = 0; } else if (mRawScoreFt > mMaxScaleFt) { mScaledScoreFt = 1; } else { mScaledScoreFt = (mRawScoreFt - mMinScaleFt) / (mMaxScaleFt - mMinScaleFt); } } } }