-
Notifications
You must be signed in to change notification settings - Fork 2
/
acq400_checkramp.py
executable file
·110 lines (87 loc) · 3.11 KB
/
acq400_checkramp.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
""" capture upload test
acq1001_capplot UUT1 [UUT2 ..]
where UUT1 is the ip-address or host name of first uut
example test client runs captures in a loop on one or more uuts
pre-requisite: UUT's are configured and ready to make a transient
capture
eg clk is running. soft trg enabled
eg transient length set.
runs one capture, uploads the data and plots with matplotlib
tested with 2 x 8 channels UUT's (ACQ1014)
matplot will get very congested with more channels.
this is really meant as a demonstration of capture, load to numpy,
it's not really intended as a scope UI.
"""
import sys
import acq400_hapi
import numpy as np
import matplotlib.pyplot as plt
import os
import time
SOFT_TRIGGER=int(os.getenv("SOFT_TRIGGER", "1"))
TRACE_UPLOAD=int(os.getenv("TRACE_UPLOAD", "0"))
SAVEDATA=os.getenv("SAVEDATA", None)
PLOTDATA=int(os.getenv("PLOTDATA", "1"))
CAPTURE=int(os.getenv("CAPTURE", "1"))
PLOTTO=int(os.getenv("PLOTTO", "0"))
def run_main():
global SOFT_TRIGGER,TRACE_UPLOAD, SAVEDATA, PLOTDATA, PLOTTO
uuts = [ ]
if len(sys.argv) > 1:
for addr in sys.argv[1:]:
uuts.append(acq400_hapi.Acq400(addr))
else:
print("USAGE: acq1001_caploop UUT1 [UUT2 ..]")
sys.exit(1)
acq400_hapi.cleanup.init()
shot_controller = acq400_hapi.ShotController(uuts)
try:
if CAPTURE:
shot_controller.run_shot(soft_trigger=SOFT_TRIGGER)
if SAVEDATA:
for u in uuts:
u.save_data = SAVEDATA
if TRACE_UPLOAD:
for u in uuts:
u.trace = 1
chx, ncol, nchan, nsam = shot_controller.read_channels((1,33))
# plot ex: 2 x 8 ncol=2 nchan=8
# U1 U2 FIG
# 11 21 1 2
# 12 22 3 4
# 13 23
# ...
# 18 28 15 16
plt.ion()
checks = []
if PLOTDATA:
for col in range(ncol):
for chn in range(0,nchan):
fignum = 1 + col + chn*ncol
plt.subplot(nchan+1, ncol, fignum)
plt.title("{} {}".format(uuts[col].uut, chn))
plt.plot(chx[col][chn])
checkramp = chx[col][nchan-1];
ll = len(checkramp)
plt.subplot(nchan+1, ncol, fignum+3)
checkramp = checkramp[1:ll-1] - checkramp[0:ll-2]
plt.plot(checkramp)
checks.append((np.amax(checkramp), np.amin(checkramp)))
plt.draw()
print("stats {}".format(checks))
if PLOTTO > 0:
while PLOTTO > 0:
time.sleep(1)
PLOTTO -= 1
else:
print("hit return to quit")
sys.stdin.readline()
plt.close()
except acq400_hapi.cleanup.ExitCommand:
print("ExitCommand raised and caught")
finally:
print("Finally, going down")
# execution starts here
if __name__ == '__main__':
run_main()