Changeset 344
- Timestamp:
- 03/27/12 18:58:09 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/project/PuzzleboxSynapseEmotiv/PuzzleboxSynapseEmotiv/main.cpp
r343 r344 14 14 #define USE_COMPOSER = True; 15 15 16 typedef struct emotivData_struct { 17 // Headset Status 18 float time_from_start; 19 int emotiv_userid; 20 int wireless_signal_status; 21 int headset_on; 22 // Affectiv Suite results 23 float excitement; 24 float excitement_long_term; 25 float meditation; 26 float frustration; 27 float engagement_boredom; 28 // Cognitiv Suite results 29 int cognitiv_action; 30 float cognitive_power; 31 } emotivDataStruct; 32 16 33 bool print_to_console = 1; 17 34 … … 21 38 22 39 void printHeaders(); 23 voidprocessEmotivUpdate();40 emotivDataStruct processEmotivUpdate(); 24 41 //void logEmotivUpdate(unsigned int userID, EmoStateHandle eState, bool withHeader = false); 25 42 void logEmotivUpdate(bool withHeader = false); … … 36 53 int state = 0; 37 54 std::string input; 55 emotivDataStruct emotivData; 38 56 39 57 try { … … 44 62 } 45 63 46 printHeaders(); 64 if (print_to_console) { 65 printHeaders(); 66 } 47 67 48 68 while (1) { 49 processEmotivUpdate();69 emotivData = processEmotivUpdate(); 50 70 } 51 71 52 53 //std::cout << "Start receiving EmoState! Press any key to stop logging...\n" << std::endl; 54 55 //bool writeHeader = true; 56 // 57 //while (!_kbhit()) { 58 59 // state = EE_EngineGetNextEvent(eEvent); 60 61 // // New event needs to be handled 62 // if (state == EDK_OK) { 63 64 // EE_Event_t eventType = EE_EmoEngineEventGetType(eEvent); 65 // EE_EmoEngineEventGetUserId(eEvent, &userID); 66 67 // // Log the EmoState if it has been updated 68 // if (eventType == EE_EmoStateUpdated) { 69 70 // EE_EmoEngineEventGetEmoState(eEvent, eState); 71 // const float timestamp = ES_GetTimeFromStart(eState); 72 73 // //printf("%10.3fs : New EmoState from user %d ...\r", timestamp, userID); 74 // 75 // //logEmotivUpdate(userID, eState, writeHeader); 76 // logEmotivUpdate(writeHeader); 77 // writeHeader = false; 78 // } 79 // } 80 // else if (state != EDK_NO_EVENT) { 81 // std::cout << "Internal error in Emotiv Engine!" << std::endl; 82 // break; 83 // } 84 85 // Sleep(1); 86 //} 87 88 } 72 } // try 89 73 catch (const std::exception& e) { 90 74 std::cerr << e.what() << std::endl; 91 75 std::cout << "Press any key to exit..." << std::endl; 92 76 getchar(); 93 } 77 } // catch 94 78 95 79 EE_EngineDisconnect(); … … 98 82 99 83 return 0; 100 } 84 85 } // main 101 86 102 87 … … 106 91 std::cout << "Wireless Signal Status,"; 107 92 std::cout << "Headset On,"; 108 109 93 std::cout << "Short Term Excitement,"; 110 94 std::cout << "Long Term Excitement,"; … … 115 99 std::cout << "Cognitiv Power"; 116 100 std::cout << std::endl; 117 } 118 119 //void processEmotivUpdate(unsigned int userID, EmoStateHandle eState, bool withHeader) { 120 void processEmotivUpdate() { 101 } // printHeaders 102 103 104 void printEmotivData(emotivDataStruct emotivData) { 105 std::cout << emotivData.time_from_start << ","; 106 std::cout << emotivData.emotiv_userid << ","; 107 std::cout << emotivData.wireless_signal_status << ","; 108 std::cout << emotivData.headset_on << ","; 109 std::cout << emotivData.excitement << ","; 110 std::cout << emotivData.meditation << ","; 111 std::cout << emotivData.frustration << ","; 112 std::cout << emotivData.engagement_boredom << ","; 113 std::cout << emotivData.cognitiv_action << ","; 114 std::cout << emotivData.cognitive_power; 115 std::cout << std::endl; 116 } // printEmotivData 117 118 emotivDataStruct processEmotivUpdate() { 119 120 emotivDataStruct emotivData; 121 122 emotivData.time_from_start = -1.0; 123 emotivData.emotiv_userid = 0; 124 emotivData.wireless_signal_status = 0; 125 emotivData.headset_on = 0; 126 emotivData.excitement = 0.0; 127 emotivData.excitement_long_term = 0.0; 128 emotivData.meditation = 0.0; 129 emotivData.frustration = 0.0; 130 emotivData.engagement_boredom = 0.0; 131 emotivData.cognitiv_action = 0; 132 emotivData.cognitive_power = 0.0; 121 133 122 134 int state = EE_EngineGetNextEvent(eEvent); … … 133 145 EE_EmoEngineEventGetEmoState(eEvent, eState); 134 146 135 //if (print_to_console) { 136 // std::cout << "Time,"; 137 // std::cout << "Emotiv UserID,"; 138 // std::cout << "Wireless Signal Status,"; 139 // std::cout << "Headset On,"; 140 141 // std::cout << "Short Term Excitement,"; 142 // std::cout << "Long Term Excitement,"; 143 // std::cout << "Meditation,"; 144 // std::cout << "Frustration,"; 145 // std::cout << "Engagement/Boredom,"; 146 // std::cout << "Cognitiv Action,"; 147 // std::cout << "Cognitiv Power,"; 148 // std::cout << std::endl; 149 //} // DEBUG 150 151 152 153 // Log the time stamp and user ID 147 // Headset Status 154 148 float time_from_start = ES_GetTimeFromStart(eState); 155 //std::cout << userID << ",";156 149 int wireless_signal_status = static_cast<int>(ES_GetWirelessSignalStatus(eState)); 157 150 int headset_on = static_cast<int>(ES_GetHeadsetOn(eState)); … … 162 155 float meditation = ES_AffectivGetMeditationScore(eState); 163 156 float frustration = ES_AffectivGetFrustrationScore(eState); 164 float engagement_boredom e= ES_AffectivGetEngagementBoredomScore(eState);157 float engagement_boredom = ES_AffectivGetEngagementBoredomScore(eState); 165 158 166 159 // Cognitiv Suite results … … 168 161 float cognitive_power = ES_CognitivGetCurrentActionPower(eState); 169 162 163 164 emotivData.time_from_start = time_from_start; 165 emotivData.emotiv_userid = userID; 166 emotivData.wireless_signal_status = wireless_signal_status; 167 emotivData.headset_on = headset_on; 168 emotivData.excitement = excitement; 169 emotivData.excitement_long_term = excitement_long_term; 170 emotivData.meditation = meditation; 171 emotivData.frustration = frustration; 172 emotivData.engagement_boredom = engagement_boredom; 173 emotivData.cognitiv_action = cognitiv_action; 174 emotivData.cognitive_power = cognitive_power; 175 176 170 177 if (print_to_console) { 171 // Log the time stamp and user ID 172 std::cout << time_from_start << ","; 173 std::cout << userID << ","; 174 std::cout << wireless_signal_status << ","; 175 std::cout << headset_on << ","; 176 std::cout << excitement << ","; 177 std::cout << meditation << ","; 178 std::cout << frustration << ","; 179 std::cout << engagement_boredome << ","; 180 std::cout << cognitiv_action << ","; 181 std::cout << cognitive_power; 182 std::cout << std::endl; 183 } // DEBUG 184 185 } 186 } 187 } 178 printEmotivData(emotivData); 179 } 180 181 182 } // if (eventType == EE_EmoStateUpdated) 183 184 } // if (state == EDK_OK) 185 186 187 return(emotivData); 188 189 190 } // processEmotivUpdate 188 191 189 192 … … 269 272 270 273 std::cout << std::endl; 271 } 272 274 275 } // logEmotivUpdate 276
Note: See TracChangeset
for help on using the changeset viewer.