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"); } }
// TODO is not in synv with time yet when sending private void affectiveStateCSVParser(string path) { if (path == null || path == "") { Console.WriteLine("no path is specified"); return; } try { // TODO var reader = new StreamReader(File.OpenRead(path)); int lines = 0; int count = 0; // read two lines: one for the header one for the sep=";" line reader.ReadLine(); reader.ReadLine(); while (!reader.EndOfStream && !Console.KeyAvailable) { var line = reader.ReadLine(); string[] values = line.Split(';'); AffectiveOSC.AffectiveState stateToSend = new AffectiveOSC.AffectiveState(); // Timestamp;EmoState_Timestamp;BoredomScore;ExcitementShortScore; // FrustrationScore; MediationScore;ValenceScore;ExcitementLongShort; stateToSend.emotivTimeStamp = (float)Convert.ToDouble(values[1]); stateToSend.boredom = Convert.ToDouble(values[2]); stateToSend.excitement = Convert.ToDouble(values[3]); stateToSend.frustration = Convert.ToDouble(values[4]); stateToSend.mediation = Convert.ToDouble(values[5]); stateToSend.valence = Convert.ToDouble(values[6]); stateToSend.excitementLongTerm = Convert.ToDouble(values[7]); Console.WriteLine("Sending Package from CSV ..." + count); Console.WriteLine(line); affectiveOSC.sendAffectiveStateData(stateToSend, true); count++; } } catch (FileNotFoundException e) { Console.WriteLine("Could not open file:" + e.FileName); } }