9 UDP_IP =
"192.168.30.93"
10 HOST_IP =
"192.168.30.49"
14 oneByte = struct.pack(
"@2p",
"\x02")[1:]
15 setBurst =
"\x01\x09\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
16 setBurst = struct.pack(
"@18p", setBurst)
17 setBurstOff =
"\x01\x09\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
18 setBurstOff = struct.pack(
"@18p", setBurstOff)
19 setTrigAttr =
"\x01\x00\x05\x00\x00\x00\x00\x00\x00\x96\x10\x00\x20\x00\x00\x00\x08"
20 setTrigAttr = struct.pack(
"@18p", setTrigAttr)
21 reset =
"\x01\x00\x02\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00"
22 reset = struct.pack(
"@18p", reset)
23 requestData =
"\x01\x00\x02\x00\x00\x00\x00\x00\x00\x0F\x44\x00\x00\x00\x00\x00\x00"
24 requestData = struct.pack(
"@18p", requestData)
25 erase =
"\x01\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
26 erase = struct.pack(
"@18p", erase)
28 cdUp =
"\x01\x00\x03\x00\x00\x00\x00\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00"
29 cdUp = struct.pack(
"@18p", cdUp)
30 cdDown =
"\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
31 cdDown = struct.pack(
"@18p", cdDown)
32 cdReset =
"\x01\x00\x03\x00\x00\x00\x00\x00\x00\x10\x00\x00\x01\x00\x00\x00\x00"
33 cdReset = struct.pack(
"@18p", cdReset)
35 dcmOne =
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
36 dcmOne = struct.pack(
"@18p", dcmOne)
37 dcmTwo =
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00"
38 dcmTwo = struct.pack(
"@18p", dcmTwo)
39 dcmThree =
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00"
40 dcmThree = struct.pack(
"@18p", dcmThree)
41 dcmClearOne =
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
42 dcmClearOne = struct.pack(
"@18p", dcmClearOne)
43 dcmFour =
"\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00"
44 dcmFour = struct.pack(
"@18p", dcmFour)
45 dcmClearTwo =
"\x01\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
46 dcmClearTwo = struct.pack(
"@18p", dcmClearTwo)
47 clockLockingDelay = 0.7;
53 def question (question, message):
56 response = raw_input(question)
57 if response ==
"s" or response ==
"S":
58 print "Command skipped."
59 elif response ==
"E" or response ==
"e":
61 elif response ==
"C" or response ==
"c":
62 continousMode =
not continousMode
63 elif response ==
"U" or response == "u":
65 time.sleep(clockLockingDelay)
67 time.sleep(clockLockingDelay)
69 time.sleep(clockLockingDelay)
70 elif response ==
"D" or response ==
"d":
72 time.sleep(clockLockingDelay)
74 time.sleep(clockLockingDelay)
76 time.sleep(clockLockingDelay)
77 elif response ==
"R" or response == 'r':
81 print "Command Completed."
84 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
86 sock.bind(( HOST_IP, 49387))
87 sock.sendto(message, (UDP_IP, UDP_PORT))
88 print "Command Completed."
100 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
102 sock.bind(( HOST_IP, 49387))
103 m = sock.recvfrom(2048)
108 header = struct.unpack(
"<B",m[0][0])[0]
109 counter = struct.unpack(
"<B",m[0][1])[0]
110 print "Counter Number: " + str(counter)
111 print "Packet Length: " + str(length)
112 print "From port: " + str(port)
113 print "From IP address: " + str(ipAddress)
115 d0 = struct.unpack(
"<Q",m[0][2:10])[0]
116 line =
"%10s %5d %s %3s %3s %10s"%(ipAddress, port, length, hex(header), hex(counter), hex(d0))
127 d = struct.unpack(
"<B", relData[place])[0]
130 if place == len(relData):
131 dataPoints = (dataPoints + len(relData))
134 print "Number of Data Points: " + str(dataPoints)
135 now = calendar.timegm(time.gmtime());
136 difference = now - Last
137 print "Time since last pulse: " + str(difference)
148 print "Creating Socket:"
149 print "UDP target IP:", UDP_IP
150 print "UDP target port:", UDP_PORT
156 time.sleep(clockLockingDelay)
158 time.sleep(clockLockingDelay)
160 time.sleep(clockLockingDelay)
162 time.sleep(clockLockingDelay)
164 time.sleep(clockLockingDelay)
166 time.sleep(clockLockingDelay)
177 elif not continousMode:
178 question(
"Turn off burst mode? ", setBurstOff)