Changeset 336
- Timestamp:
- 03/25/12 11:12:16 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Puzzlebox/Synapse/Emotiv/Protocol.py
r335 r336 82 82 self.EmotivEngine.ES_Init(self.statehandle) 83 83 84 self.connectToEmotivEPOC() 85 84 86 87 ################################################################## 88 89 def connectToEmotivEPOC(self): 90 91 # Connect 92 if self.choice == "a": 93 if self.EmotivEngine.EE_EngineRemoteConnect("127.0.0.1", 1726) != PyEpoc.PyEpoc.ERRCODE['EDK_OK']: 94 print "Could not connect!" 95 quit() 96 else: print "Connected to EmoComposer!" 97 98 elif self.choice == "b": 99 if self.EmotivEngine.EE_EngineConnect() != PyEpoc.PyEpoc.ERRCODE['EDK_OK']: 100 print "Could not connect!" 101 quit() 102 else: print "Connected to Headset!" 103 104 print """Engine Event handle at: %s""" %(self.engineeventhandle) 105 print """Emo State handle at: %s""" % (self.statehandle) 106 107 108 ################################################################## 109 110 def processEmotivState(self, state): 111 112 if state == PyEpoc.PyEpoc.ERRCODE['EDK_OK']: 113 event = self.EmotivEngine.EE_EmoEngineEventGetType(self.engineeventhandle) 114 user = self.EmotivEngine.EE_EmoEngineEventGetUserId(self.engineeventhandle)[1] 115 if (event == PyEpoc.PyEpoc.EVENT['EE_EmoStateUpdated']): 116 self.EmotivEngine.EE_EmoEngineEventGetEmoState(self.engineeventhandle, self.statehandle) 117 #status 118 battery = self.EmotivEngine.ES_GetBatteryChargeLevel(self.statehandle) 119 wireless = self.EmotivEngine.ES_GetWirelessSignalStatus(self.statehandle) 120 timestamp = self.EmotivEngine.ES_GetTimeFromStart(self.statehandle) 121 #emo 122 meditation = self.EmotivEngine.ES_AffectivGetMeditationScore(self.statehandle) 123 shortexcitement = self.EmotivEngine.ES_AffectivGetExcitementShortTermScore(self.statehandle) 124 longexcitement = self.EmotivEngine.ES_AffectivGetExcitementLongTermScore(self.statehandle) 125 frustration = self.EmotivEngine.ES_AffectivGetFrustrationScore(self.statehandle) 126 #cognitiv 127 currentaction = self.EmotivEngine.ES_CognitivGetCurrentAction(self.statehandle) 128 currentactionpower = self.EmotivEngine.ES_CognitivGetCurrentActionPower(self.statehandle) 129 print """--------------------------------------------------------------------------------""" 130 print """Timestamp: %s\tUser: %s\tEvent: %s\tW.Signal: %s\tBattery: %s""" % (timestamp,user,hex(event), wireless, battery) 131 print """S.Excite: %s\tL.Excite: %s\tMeditation: %s\tFrustr: %s""" % (shortexcitement, longexcitement, meditation, frustration) 132 print """Curr.Action: %s\tAction Pwr: %s""" % (hex(currentaction), currentactionpower) 133 134 85 135 ################################################################## 86 136 … … 93 143 ## if choice == "q": 94 144 ## quit() 95 96 # Connect 97 if self.choice == "a": 98 if self.EmotivEngine.EE_EngineRemoteConnect("127.0.0.1", 1726) != PyEpoc.PyEpoc.ERRCODE['EDK_OK']: 99 print "Could not connect!" 100 quit() 101 else: print "Connected to EmoComposer!" 102 elif self.choice == "b": 103 if self.EmotivEngine.EE_EngineConnect() != PyEpoc.PyEpoc.ERRCODE['EDK_OK']: 104 print "Could not connect!" 105 quit() 106 else: print "Connected to Headset!" 107 108 print """Engine Event handle at: %s""" %(self.engineeventhandle) 109 print """Emo State handle at: %s""" % (self.statehandle) 110 145 111 146 # Start 112 147 while True: 113 148 state = self.EmotivEngine.EE_EngineGetNextEvent(self.engineeventhandle) 114 149 115 if state == PyEpoc.PyEpoc.ERRCODE['EDK_OK']: 116 event = self.EmotivEngine.EE_EmoEngineEventGetType(self.engineeventhandle) 117 user = self.EmotivEngine.EE_EmoEngineEventGetUserId(self.engineeventhandle)[1] 118 if (event == PyEpoc.PyEpoc.EVENT['EE_EmoStateUpdated']): 119 self.EmotivEngine.EE_EmoEngineEventGetEmoState(self.engineeventhandle, self.statehandle) 120 #status 121 battery = self.EmotivEngine.ES_GetBatteryChargeLevel(self.statehandle) 122 wireless = self.EmotivEngine.ES_GetWirelessSignalStatus(self.statehandle) 123 timestamp = self.EmotivEngine.ES_GetTimeFromStart(self.statehandle) 124 #emo 125 meditation = self.EmotivEngine.ES_AffectivGetMeditationScore(self.statehandle) 126 shortexcitement = self.EmotivEngine.ES_AffectivGetExcitementShortTermScore(self.statehandle) 127 longexcitement = self.EmotivEngine.ES_AffectivGetExcitementLongTermScore(self.statehandle) 128 frustration = self.EmotivEngine.ES_AffectivGetFrustrationScore(self.statehandle) 129 #cognitiv 130 currentaction = self.EmotivEngine.ES_CognitivGetCurrentAction(self.statehandle) 131 currentactionpower = self.EmotivEngine.ES_CognitivGetCurrentActionPower(self.statehandle) 132 print """--------------------------------------------------------------------------------""" 133 print """Timestamp: %s\tUser: %s\tEvent: %s\tW.Signal: %s\tBattery: %s""" % (timestamp,user,hex(event), wireless, battery) 134 print """S.Excite: %s\tL.Excite: %s\tMeditation: %s\tFrustr: %s""" % (shortexcitement, longexcitement, meditation, frustration) 135 print """Curr.Action: %s\tAction Pwr: %s""" % (hex(currentaction), currentactionpower) 150 self.processEmotivState(state) 136 151
Note: See TracChangeset
for help on using the changeset viewer.