-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExpRecord.py
76 lines (42 loc) · 1.51 KB
/
ExpRecord.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Experimentally Record Data
# System Libraries
import subprocess
import time
from time import localtime,strftime
import sys
#import winsound
#import pythoncom
# Zeo Libraries
from ZeoRawData import BaseLink, Parser
from ZeoRawData.Utility import *
# ActiveHome Libraries (Windows COM)
# from win32com.client import Dispatch
# User customizable variables
port = '/dev/tty.usbserial'
f = open('Darwin_dream', 'w')
class ExpData:
def updateSlice(self, slice):
if not slice['Waveform'] == []:
wave = slice['Waveform']
waveS = str(wave)[1:-1] #take the brackets off the end
timestamp = slice['ZeoTimestamp']
timeS = time.strptime(timestamp, "%m/%d/%Y %H:%M:%S")
timeS2=str(time.mktime(timeS))
#save the data
f.write("%s, %s\n" % (timeS2, waveS))
#def updateEvent(self, event):
if __name__ == "__main__":
# Initialize Serial Link
link = BaseLink.BaseLink(port)
parser = Parser.Parser()
cue = ExpData()
#time.sleep(20000) #why is this here?
# Add Callbacks and Start the Link
link.addCallback(parser.update)
parser.addSliceCallback(cue.updateSlice)
#parser.addEventCallback(cue.updateEvent)
link.start()
# Infinitely loop to allow the script to run continuously
while(True):
time.sleep(5) #why is this here?
#end of program