Changeset 411 for trunk/Puzzlebox/Synapse/ThinkGear/Protocol.py
- Timestamp:
- 01/27/16 01:10:35 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Puzzlebox/Synapse/ThinkGear/Protocol.py
r390 r411 86 86 import signal 87 87 import serial 88 import copy 88 89 89 90 if ((sys.platform != 'win32') and \ … … 154 155 DEBUG_PACKET_COUNT = 1024 155 156 157 158 #CURRENT_SIGNAL = 0 159 #CURRENT_ATTENTION = 0 160 #CURRENT_MEDITATION = 0 161 156 162 ##################################################################### 157 163 # Classes … … 185 191 self.data_packet['eegPower'] = {} 186 192 self.data_packet['eSense'] = {} 193 194 self.current_signal = 200 195 self.current_attention = 0 196 self.current_meditaiton = 0 197 self.detection_threshold = 70 198 self.current_detection = 0 187 199 188 200 #self.packet_count = 0 … … 367 379 if (raw >= 32768): 368 380 raw = raw - 65536 381 382 383 384 #print "%s,%s,%s,%s,%s" % (time.time(), 385 #CURRENT_SIGNAL, 386 #CURRENT_ATTENTION, 387 #CURRENT_MEDITATION, 388 #raw) 389 390 if (self.current_signal == 0): 391 print "%s,%i,%i,%i,%s,%i" % (time.time(), 392 self.current_signal, 393 self.current_attention, 394 self.current_meditaiton, 395 raw, 396 self.current_detection) 369 397 370 398 … … 477 505 print poor_signal_quality 478 506 507 self.current_signal = copy.copy(poor_signal_quality) 508 479 509 packet_update['poorSignalLevel'] = poor_signal_quality 510 511 self.current_signal = poor_signal_quality 480 512 481 513 … … 486 518 print attention 487 519 520 self.current_attention = copy.copy(attention) 521 522 if (attention > self.detection_threshold): 523 self.current_detection = 1 524 else: 525 self.current_detection = 0 526 488 527 packet_update['eSense'] = {} 489 528 packet_update['eSense']['attention'] = attention … … 495 534 print "meditation:", 496 535 print meditation 536 537 self.current_meditaiton = copy.copy(meditation) 497 538 498 539 packet_update['eSense'] = {} … … 521 562 522 563 packet_update['rawEeg'] = raw_eeg_value 564 565 #print "%s,%i,%i,%i,%s" % (time.time(), 566 #self.current_signal, 567 #self.current_attention, 568 #self.current_meditaiton, 569 #raw_eeg_value) 523 570 524 571 … … 892 939 def run(self): 893 940 894 self.resetSession() 941 try: 942 self.resetSession() 943 except Exception, e: 944 if self.DEBUG: 945 print "ERROR: self.resetSession():", 946 print e 895 947 896 948 if self.device != None and self.device.device != None: … … 1234 1286 self.buffer += byte 1235 1287 1236 except :1288 except Exception, e: 1237 1289 if self.DEBUG: 1238 print "ERROR: failed to read from serial device" 1290 print "ERROR: failed to read from serial device:", 1291 print e 1239 1292 break 1240 1293
Note: See TracChangeset
for help on using the changeset viewer.