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; } } }
/// <summary> /// Verifica si el evento recibido es del tipo eye /// </summary> /// <param name="emoState">Evento recibido </param> /// <returns></returns> private bool CheckEyeEvent(EmoState emoState) { //Se pone en true en caso de que el evento fue del tipo de los ojos var wasEyes = false; if (emoState.FacialExpressionIsBlink()) { wasEyes = true; _facialExpressionDto.Eyes.Change(EyeExpressionEnum.Blink); } else if (emoState.FacialExpressionIsLeftWink()) { wasEyes = true; _facialExpressionDto.Eyes.Change(EyeExpressionEnum.WinkLeft); } else if (emoState.FacialExpressionIsRightWink()) { wasEyes = true; _facialExpressionDto.Eyes.Change(EyeExpressionEnum.WinkRight); } else if (emoState.FacialExpressionIsLookingLeft() == 1) { wasEyes = true; _facialExpressionDto.Eyes.Change(EyeExpressionEnum.LookLeft); } else if (emoState.FacialExpressionIsLookingRight() == 1) { wasEyes = true; _facialExpressionDto.Eyes.Change(EyeExpressionEnum.LookRight); } return(wasEyes); }
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 engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { EmoState es = e.emoState; Single timeFromStart = es.GetTimeFromStart(); //Console.WriteLine("new emostate {0}", timeFromStart); }
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(); }
//Event handler for Expressiv event void ExpressivEmoStateUpdated() { if (FEmoState[0] != null) { EmoState es = FEmoState[0]; mIsBlink = es.ExpressivIsBlink(); mIsLeftWink = es.ExpressivIsLeftWink(); mIsRightWink = es.ExpressivIsRightWink(); mIsEyesOpen = es.ExpressivIsEyesOpen(); mIsLookingUp = es.ExpressivIsLookingUp(); mIsLookingDown = es.ExpressivIsLookingDown(); mIsLookingLeft = es.ExpressivIsLookingLeft(); mIsLookingRight = es.ExpressivIsLookingRight(); mLeftEyelid = 0.0F; mRightEyelid = 0.0F; mX = 0.0F; mY = 0.0F; es.ExpressivGetEyelidState(out mLeftEyelid, out mRightEyelid); es.ExpressivGetEyeLocation(out mX, out mY); mEyebrowExtent = es.ExpressivGetEyebrowExtent(); mSmileExtent = es.ExpressivGetSmileExtent(); mClenchExtent = es.ExpressivGetClenchExtent(); mUpperFaceAction = es.ExpressivGetUpperFaceAction(); mUpperFacePower = es.ExpressivGetUpperFaceActionPower(); mLowerFaceAction = es.ExpressivGetLowerFaceAction(); mLowerFacePower = es.ExpressivGetLowerFaceActionPower(); for (int i = 0; i < mExpAlgoList.Length; ++i) { mIsExpActiveList[i] = es.ExpressivIsActive(mExpAlgoList[i]); } } }
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]); } }
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(""); }
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(); }
/// <summary> /// Chequea si el evento que recibe es de alguno de los del tipo face /// en caso de serlo setea la propiedad del objeto _facialExpressionDto /// </summary> /// <param name="emoState">Evento recibido</param> /// <returns></returns> private bool CheckLowerFaceExpression(EmoState emoState) { var wasLowerExpression = false; var power = emoState.FacialExpressionGetLowerFaceActionPower(); if (emoState.FacialExpressionGetLowerFaceAction() == EdkDll.IEE_FacialExpressionAlgo_t.FE_SMILE) { wasLowerExpression = _facialExpressionDto.LowerFace.IsTheSameThanPrevious(_facialExpressionDto.LowerFace.Type, power); _facialExpressionDto.LowerFace.Change(LowerFaceEnum.Smile, power); } if (emoState.FacialExpressionGetLowerFaceAction() == EdkDll.IEE_FacialExpressionAlgo_t.FE_CLENCH) { wasLowerExpression = _facialExpressionDto.LowerFace.IsTheSameThanPrevious(_facialExpressionDto.LowerFace.Type, power);; _facialExpressionDto.LowerFace.Change(LowerFaceEnum.Clench, power); } if (emoState.FacialExpressionGetLowerFaceAction() == EdkDll.IEE_FacialExpressionAlgo_t.FE_LAUGH) { wasLowerExpression = _facialExpressionDto.LowerFace.IsTheSameThanPrevious(_facialExpressionDto.LowerFace.Type, power);; _facialExpressionDto.LowerFace.Change(LowerFaceEnum.Laugh, power); } if (emoState.FacialExpressionGetLowerFaceAction() == EdkDll.IEE_FacialExpressionAlgo_t.FE_SMIRK_LEFT) { wasLowerExpression = _facialExpressionDto.LowerFace.IsTheSameThanPrevious(_facialExpressionDto.LowerFace.Type, power);; _facialExpressionDto.LowerFace.Change(LowerFaceEnum.SmirkLeft, power); } if (emoState.FacialExpressionGetLowerFaceAction() == EdkDll.IEE_FacialExpressionAlgo_t.FE_SMIRK_RIGHT) { wasLowerExpression = _facialExpressionDto.LowerFace.IsTheSameThanPrevious(_facialExpressionDto.LowerFace.Type, power);; _facialExpressionDto.LowerFace.Change(LowerFaceEnum.SmirkRight, power); } return(wasLowerExpression); }
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"); } }
// --------------------------------------------------------------------------------------------- public DistractorDTO KickTheStudent(int userId, List <Pad> lastEmoStates) { //// TODO usunąć mock *************************************************** //Random rnd = new Random(); //Func<EmoState> losuj = () => { // var los = rnd.Next(1, 4); // if (los == 1) return EmoState.BORED; // if (los == 2) return EmoState.OK; // if (los == 3) return EmoState.FRUSTRATED; // return EmoState.UNDEFINED; //}; //List<Pad> mockEmoStates = new List<Pad>(5); //string mocki = ""; //for (int i = 0; i < 5; i++) { // mockEmoStates.Add(new Pad("", losuj())); // mocki += " " + i + ". " + mockEmoStates[mockEmoStates.Count() - 1].state.ToString(); //} //lastEmoStates = mockEmoStates; //// ******************************************************************** if (lastEmoStates.Count() < 5) { _logger.Debug("User: "******"|" + "Not providing a distractor as not enough (" + lastEmoStates.Count() + ") emotional states gathered yet"); return(null); } EmoState emoStateNow = GetCurrentEmoState(lastEmoStates); // wybór DYSTRAKTORA ...................................................... if (emoStateNow == EmoState.UNDEFINED || emoStateNow == EmoState.OK) { return(null); } DistractorType distrType; if (emoStateNow == EmoState.BORED) { distrType = DistractorType.KICK; } else { distrType = DistractorType.REWARD; } var distractor = _distractorService.NextDistractor(userId, distrType); // logging current emo-states string states = ""; lastEmoStates.ForEach(delegate(Pad pad) { states += pad.state + ","; }); _logger.Info("User: "******"|" + "Providing a \"" + distrType + "\" distractor for user with last emotional states: " + states); return(DistractorMapper.GetDTO(distractor)); }
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]); } }
void engine_UserAdded_Event(object sender, EmoEngineEventArgs e) { //Thread t = Thread.CurrentThread; //Debug.Log(t.Name + t.ThreadState); // t.Suspend(); //t.Yield();// Suspend(); Debug.Log("Dongle Plugged!!!!!!!"); userID = (int)e.userId; try { int errorCode = EdkDll.EE_DataAcquisitionEnable((uint)userID, true); //engine.DataAcquisitionEnable((uint)userID, true); EmoEngine.errorHandler((Int32)errorCode); Debug.Log("errorCode = " + errorCode); //enable the data aquisition for this user //[DllImport("edk.dll", EntryPoint = "EE_DataAcquisitionEnable")] // static extern Int32 Unmanaged_EE_DataAcquisitionEnable(UInt32 userId, Boolean enable); } catch (Exception exp) { Debug.Log("error"); Debug.Log(exp); } try { bool result; int err2 = EdkDll.EE_DataAcquisitionIsEnabled((uint)userID, out result); Debug.Log(err2); EmoEngine.errorHandler((Int32)err2); } catch (Exception exp) { Debug.Log("error"); Debug.Log(exp); } EmoState emoState = new EmoState(); EdkDll.EE_EEG_ContactQuality_t[] qualities = emoState.GetContactQualityFromAllChannels(); int i; for (i = 0; i < qualities.Length; i++) { Debug.Log(qualities[i]); } // EE_DataAcquisitionIsEnabled(uint userId, out bool pEnableOut); //engine.DataAcquisitionEnable((uint)userID, true); uint sampleRate = engine.DataGetSamplingRate((uint)userID); Debug.Log(sampleRate); //ask for up to 1s of buffered data engine.EE_DataSetBufferSizeInSec(1); int num = (int)engine.EngineGetNumUser(); Debug.Log("user number = " + num); }
/////////////////////////////////////////////////////////////////////// #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); }
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(); }
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; } } }
private void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e) { lock (emoEngine) { EmoState emoState = new EmoState(e.emoState); _processEventsWorker.ReportProgress(0, emoState); } }
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); }
/// <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; }
/// <summary> /// Chequea si el evento que recibe es del tipo typeToCompare, en caso de serlo setea las propiedades del MentalCommand /// </summary> /// <param name="emoState">Evento contra el cual se comparara</param> /// <param name="typeToCompare">Tipo de evento sobre el cual se intenta comparar</param> /// <param name="powerToSet">Si la comparación de tipo de eventos fue exitosá se setea este power</param> /// <param name="typeToSet">Si la comparación de tipo de eventos fue exitosá se setea este type</param> public static bool IsToSetType(this MentalCommand mentalCommand, EmoState emoState, IEE_MentalCommandAction_t typeToCompare, float powerToSet, MentalCommandEnum typeToSet) { if (emoState.MentalCommandGetCurrentAction() == typeToCompare) { //wasLowerExpression = _facialExpressionDto.LowerFace.IsTheSameThanPrevious(_facialExpressionDto.LowerFace.Type, power); mentalCommand.Change(typeToSet, powerToSet); return(true); } return(false); }
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()); }
/*--------------------------------------------------------------------*/ #region Construction /// <summary> /// Initializes a new instance of EmoStateWrapper class. /// </summary> /// <param name="emoState">An <see cref="EmoState"/> for the <see cref="EmoStateWrapper"/> properties.</param> public EmoStateWrapper(EmoState emoState) { if (emoState != null) { _emoState = emoState.Clone() as EmoState; } else { throw new ArgumentNullException("emoState", "must be assigned"); } }
//Update fields when Emo state updated void CognitivEmoStateUpdated() { if (FEmoState[0] != null) { EmoState es = FEmoState[0]; mCogAction = es.CognitivGetCurrentAction(); mPower = es.CognitivGetCurrentActionPower(); mIsActive = es.CognitivIsActive(); } }
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()); }
/// <summary> /// Initializes a new instance of the <see cref="EmotivState"/> class. /// </summary> /// <param name="emoState">An <see cref="EmoState"/> to back the <see cref="EmotivState"/> properties.</param> public EmotivState(EmoState emoState) { if (emoState != null) { // Cache a copy. this._emoState = emoState.Clone() as EmoState; } else { throw new ArgumentNullException("emoState", "must be assigned"); } }
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_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); }
public bool ExpressivEqual(EmoState state) { return EdkDll.ES_ExpressivEqual(this.GetHandle(), state.GetHandle()); }
public bool AffectivEqual(EmoState state) { return EdkDll.ES_AffectivEqual(this.GetHandle(), state.GetHandle()); }
public bool CognitivEqual(EmoState state) { return EdkDll.ES_CognitivEqual(this.GetHandle(), state.GetHandle()); }
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); } } }
/// <summary> /// Copy constructor /// </summary> /// <param name="es">EmoState to be copied</param> public EmoState(EmoState es) { this.hEmoState = EdkDll.ES_Create(); EdkDll.ES_Copy(this.hEmoState, es.GetHandle()); }
/// <summary> /// Check whether two states are with identical 'emotiv' state /// </summary> /// <param name="state">EmoState</param> /// <returns>true: Equal, false: Different</returns> public Boolean AffectivEqual(EmoState state) { return EdkDll.ES_AffectivEqual(GetHandle(), state.GetHandle()); }
/// <summary> /// Check whether two states are with identical Expressiv state, i.e. are both state representing the same facial expression /// </summary> /// <param name="state">EmoState</param> /// <returns>true: Equal, false: Different</returns> public Boolean ExpressivEqual(EmoState state) { return EdkDll.ES_ExpressivEqual(GetHandle(), state.GetHandle()); }
/// <summary> /// Check whether two states are with identical Cognitiv state /// </summary> /// <param name="state">EmoState</param> /// <returns>true: Equal, false: Different</returns> public Boolean CognitivEqual(EmoState state) { return EdkDll.ES_CognitivEqual(GetHandle(), state.GetHandle()); }
/// <summary> /// Check whether two states are with identical EmoEngine state. /// </summary> /// <remarks> /// This function is comparing the time since EmoEngine start, /// the wireless signal strength and the signal quality of different channels /// </remarks> /// <param name="state">EmoState</param> /// <returns>true: Equal, false: Different</returns> public Boolean EmoEngineEqual(EmoState state) { return EdkDll.ES_EmoEngineEqual(GetHandle(), state.GetHandle()); }
/// <summary> /// Constructor /// </summary> /// <param name="userId">user ID</param> /// <param name="emoState">EmoState</param> public EmoStateUpdatedEventArgs(UInt32 userId, EmoState emoState) : base(userId) { this.emoState = emoState; }
/// <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; } } }
public bool EmoEngineEqual(EmoState state) { return EdkDll.ES_EmoEngineEqual(this.GetHandle(), state.GetHandle()); }
/// <summary> /// Check whether two EmoStateHandles are identical /// </summary> /// <param name="a">EmoState</param> /// <param name="b">EmoState</param> /// <returns></returns> public Boolean Equals (EmoState a, EmoState b) { return EdkDll.ES_Equal(a.GetHandle(), b.GetHandle()); }
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); } }