1717try :
1818 showPlot = concore .params ['plot' ]
1919except :
20- showPlot = False
20+ showPlot = 0
2121
2222try :
2323 tsamp = concore .params ['tsamp' ]
2626except :
2727 tsamp = 1
2828
29+ def validseq (t ):
30+ for i in range (0 ,len (t )- 1 ):
31+ if t [i ] >= t [i + 1 ]:
32+ print ('i=' + str (i )+ ': ' + str (t [i ])+ '>=' + str (t [i + 1 ]))
33+
2934def extract (amplifierData ):
3035 s = 0.0
3136 for data in amplifierData :
@@ -51,6 +56,16 @@ def readUint16(array, arrayIndex):
5156 arrayIndex = arrayIndex + 2
5257 return variable , arrayIndex
5358
59+ def clearall ():
60+ # Clear TCP data output to ensure no TCP channels are enabled
61+ scommand .sendall (b'execute clearalldataoutputs' )
62+ time .sleep (0.1 )
63+ # Send TCP commands to set up TCP Data Output Enabled for wide
64+ # band of channel A-010
65+ scommand .sendall (b'set a-010.tcpdataoutputenabled true' )
66+ time .sleep (0.1 )
67+
68+
5469def acq ():
5570 # Run controller for tsamp second
5671 scommand .sendall (b'set runmode run' )
@@ -127,14 +142,6 @@ def acq():
127142# Calculate timestep from sample rate
128143timestep = 1 / sampleRate
129144
130- # Clear TCP data output to ensure no TCP channels are enabled
131- scommand .sendall (b'execute clearalldataoutputs' )
132- time .sleep (0.1 )
133-
134- # Send TCP commands to set up TCP Data Output Enabled for wide
135- # band of channel A-010
136- scommand .sendall (b'set a-010.tcpdataoutputenabled true' )
137- time .sleep (0.1 )
138145
139146# Calculations for accurate parsing
140147# At 30 kHz with 1 channel, 1 second of wideband waveform data (including magic number, timestamps, and amplifier data) is 181,420 bytes
@@ -148,6 +155,7 @@ def acq():
148155waveformBytesPerFrame = 4 + 2
149156waveformBytesPerBlock = framesPerBlock * waveformBytesPerFrame + 4
150157
158+ clearall ()
151159
152160concore .delay = 0.01
153161init_simtime_u = "[0.0, 0.0, 0.0]"
@@ -169,16 +177,23 @@ def acq():
169177 oldAmpD = amplifierData
170178 amplifierTimestamps = []
171179 amplifierData = []
172- acq_thread .start ()
173- nxtacq_thread = threading .Thread (target = acq , daemon = True )
174- ym [0 ] = extract (oldAmpD )
175- print ("ym=" + str (ym [0 ]))
176- if showPlot :
180+ if showPlot & 1 == 1 :
177181 plt .plot (oldAmpT ,oldAmpD )
178- plt .title ("ym=" + str (ym [ 0 ] ))
182+ plt .title ("ym=" + str (extract ( oldAmpD ))
179183 plt .xlabel ('Time (s)' )
180184 plt .ylabel ('Voltage (uV)' )
181185 plt .show ()
186+ if showPlot & 2 == 2 :
187+ plt .plot (range (0 ,len (oldAmpD )),oldAmpD )
188+ plt .title ("ym=" + str (extract (oldAmpD ))
189+ plt .xlabel ('index' )
190+ plt .ylabel ('Voltage (uV)' )
191+ plt .show ()
192+ acq_thread .start ()
193+ nxtacq_thread = threading .Thread (target = acq , daemon = True )
194+ ym [0 ] = extract (oldAmpD )
195+ validseq (oldAmpT )
196+ print ("ym=" + str (ym [0 ]))
182197 concore .write (1 ,"ym" ,ym )
183198acq_thread .join ()
184199print ("retry=" + str (concore .retrycount ))
0 commit comments