etho-python 1.2__py3-none-any.whl → 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- etho/services/daq/IOTask.py +66 -51
- etho/utils/sound.py +1 -1
- {etho_python-1.2.dist-info → etho_python-1.2.1.dist-info}/METADATA +1 -1
- {etho_python-1.2.dist-info → etho_python-1.2.1.dist-info}/RECORD +7 -7
- {etho_python-1.2.dist-info → etho_python-1.2.1.dist-info}/WHEEL +0 -0
- {etho_python-1.2.dist-info → etho_python-1.2.1.dist-info}/entry_points.txt +0 -0
- {etho_python-1.2.dist-info → etho_python-1.2.1.dist-info}/licenses/LICENSE +0 -0
etho/services/daq/IOTask.py
CHANGED
|
@@ -27,7 +27,7 @@ class IOTask(daq.Task):
|
|
|
27
27
|
dev_name="Dev1",
|
|
28
28
|
cha_name=["ai0"],
|
|
29
29
|
limits=None,
|
|
30
|
-
rate=10000.0,
|
|
30
|
+
rate: float = 10000.0,
|
|
31
31
|
nb_inputsamples_per_cycle=None,
|
|
32
32
|
clock_source=None,
|
|
33
33
|
terminals: Optional[List[str]] = None,
|
|
@@ -63,7 +63,8 @@ class IOTask(daq.Task):
|
|
|
63
63
|
raise TypeError(f"`cha_name` is {type(cha_name)}. Should be `list` or `tuple`")
|
|
64
64
|
|
|
65
65
|
self.samples_read = daq.int32()
|
|
66
|
-
|
|
66
|
+
self.samples_written = daq.int32()
|
|
67
|
+
self.rate = rate
|
|
67
68
|
# channels
|
|
68
69
|
cha_types = {
|
|
69
70
|
"ai": "analog_input",
|
|
@@ -80,7 +81,7 @@ class IOTask(daq.Task):
|
|
|
80
81
|
self.cha_string = ", ".join(self.cha_names)
|
|
81
82
|
self.num_channels = len(self.cha_names)
|
|
82
83
|
if nb_inputsamples_per_cycle is None:
|
|
83
|
-
nb_inputsamples_per_cycle = int(rate)
|
|
84
|
+
nb_inputsamples_per_cycle = int(self.rate)
|
|
84
85
|
|
|
85
86
|
# terminals
|
|
86
87
|
terminal_types = {
|
|
@@ -111,21 +112,30 @@ class IOTask(daq.Task):
|
|
|
111
112
|
self.data_gen = None # called at start of callback
|
|
112
113
|
self.data_rec = None # called at end of callback
|
|
113
114
|
|
|
115
|
+
self.buffer_seconds = 100
|
|
116
|
+
self.refresh_seconds = 0.1
|
|
117
|
+
self.num_samples_per_chan = int(rate * self.buffer_seconds)
|
|
118
|
+
self.num_samples_per_event = int(rate * self.refresh_seconds)
|
|
119
|
+
|
|
114
120
|
if len(set(self.cha_type)) != 1:
|
|
115
121
|
raise ValueError("Mixed channel types (AI, AO, DI, DO).")
|
|
116
122
|
|
|
117
123
|
if self.cha_type[0] == "analog_input":
|
|
118
124
|
# add all channels
|
|
119
125
|
for name, terminal, limit in zip(self.cha_names, self.cha_terminals, self.cha_limits):
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
try:
|
|
127
|
+
self.CreateAIVoltageChan(
|
|
128
|
+
name,
|
|
129
|
+
"",
|
|
130
|
+
terminal,
|
|
131
|
+
limit[0],
|
|
132
|
+
limit[1],
|
|
133
|
+
daq.DAQmx_Val_Volts,
|
|
134
|
+
None,
|
|
135
|
+
)
|
|
136
|
+
except DAQError as e:
|
|
137
|
+
logging.exception(f"Failed creating AO {name}: %s", e)
|
|
138
|
+
raise
|
|
129
139
|
self.num_samples_per_chan = nb_inputsamples_per_cycle
|
|
130
140
|
self.num_samples_per_event = nb_inputsamples_per_cycle # self.num_samples_per_chan*self.num_channels
|
|
131
141
|
self.AutoRegisterEveryNSamplesEvent(daq.DAQmx_Val_Acquired_Into_Buffer, self.num_samples_per_event, 0)
|
|
@@ -140,19 +150,16 @@ class IOTask(daq.Task):
|
|
|
140
150
|
daq.DAQmx_Val_Volts,
|
|
141
151
|
None,
|
|
142
152
|
)
|
|
143
|
-
|
|
144
|
-
self.num_samples_per_event = 1000 # determines shortest interval at which new data can be generated
|
|
153
|
+
|
|
145
154
|
self.AutoRegisterEveryNSamplesEvent(daq.DAQmx_Val_Transferred_From_Buffer, self.num_samples_per_event, 0)
|
|
146
|
-
self.CfgOutputBuffer(self.num_samples_per_chan
|
|
155
|
+
self.CfgOutputBuffer(self.num_samples_per_chan)
|
|
147
156
|
# ensures continuous output and avoids collision of old and new data in buffer
|
|
148
157
|
self.SetWriteRegenMode(daq.DAQmx_Val_DoNotAllowRegen)
|
|
149
158
|
elif self.cha_type[0] == "digital_output":
|
|
150
159
|
for name in self.cha_names:
|
|
151
160
|
self.CreateDOChan(name, "", daq.DAQmx_Val_ChanPerLine)
|
|
152
|
-
self.num_samples_per_chan = 5000
|
|
153
|
-
self.num_samples_per_event = 1000 # determines shortest interval at which new data can be generated
|
|
154
161
|
self.AutoRegisterEveryNSamplesEvent(daq.DAQmx_Val_Transferred_From_Buffer, self.num_samples_per_event, 0)
|
|
155
|
-
self.CfgOutputBuffer(self.num_samples_per_chan
|
|
162
|
+
self.CfgOutputBuffer(self.num_samples_per_chan)
|
|
156
163
|
# ensures continuous output and avoids collision of old and new data in buffer
|
|
157
164
|
self.SetWriteRegenMode(daq.DAQmx_Val_DoNotAllowRegen)
|
|
158
165
|
|
|
@@ -174,7 +181,7 @@ class IOTask(daq.Task):
|
|
|
174
181
|
|
|
175
182
|
self.CfgSampClkTiming(
|
|
176
183
|
clock_source,
|
|
177
|
-
rate,
|
|
184
|
+
self.rate,
|
|
178
185
|
daq.DAQmx_Val_Rising,
|
|
179
186
|
daq.DAQmx_Val_ContSamps,
|
|
180
187
|
self.num_samples_per_chan,
|
|
@@ -210,50 +217,58 @@ class IOTask(daq.Task):
|
|
|
210
217
|
if self.data_gen is not None:
|
|
211
218
|
try:
|
|
212
219
|
self._data = next(self.data_gen) # get data from data generator
|
|
213
|
-
self.log.warning(f"datagen {self.data_gen}")
|
|
214
220
|
except StopIteration as e:
|
|
215
|
-
self.log.warning(f"
|
|
221
|
+
self.log.warning(f"Generator out of data - stopping iteration. This is okay!")
|
|
216
222
|
self._data = None
|
|
217
223
|
|
|
218
224
|
if self.cha_type[0] == "analog_input":
|
|
219
225
|
# should only read self.num_samples_per_event!! otherwise recordings will be zeropadded for each chunk
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
try:
|
|
227
|
+
self.ReadAnalogF64(
|
|
228
|
+
daq.DAQmx_Val_Auto,
|
|
229
|
+
1.0,
|
|
230
|
+
daq.DAQmx_Val_GroupByScanNumber,
|
|
231
|
+
self._data,
|
|
232
|
+
self.num_samples_per_chan * self.num_channels,
|
|
233
|
+
daq.byref(self.samples_read),
|
|
234
|
+
None,
|
|
235
|
+
)
|
|
236
|
+
# only keep samples that were actually read, .value converts c_long to int
|
|
237
|
+
self._data = self._data[: self.samples_read.value, :]
|
|
238
|
+
except daq.DAQError as e:
|
|
239
|
+
logging.exception("Error Reading Analog %d: %s", e.error, e)
|
|
231
240
|
|
|
232
241
|
elif self.cha_type[0] == "analog_output" and self._data is not None:
|
|
233
|
-
|
|
234
|
-
self.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
try:
|
|
243
|
+
self.WriteAnalogF64(
|
|
244
|
+
self._data.shape[0],
|
|
245
|
+
0,
|
|
246
|
+
daq.DAQmx_Val_WaitInfinitely,
|
|
247
|
+
daq.DAQmx_Val_GroupByScanNumber,
|
|
248
|
+
self._data,
|
|
249
|
+
daq.byref(self.samples_written),
|
|
250
|
+
None,
|
|
251
|
+
)
|
|
252
|
+
except daq.DAQError as e:
|
|
253
|
+
logging.exception("Error Writing Analog %d: %s", e.error, e)
|
|
254
|
+
|
|
242
255
|
elif self.cha_type[0] == "digital_output" and self._data is not None:
|
|
243
|
-
|
|
244
|
-
self.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
256
|
+
try:
|
|
257
|
+
self.WriteDigitalLines(
|
|
258
|
+
self._data.shape[0],
|
|
259
|
+
0,
|
|
260
|
+
daq.DAQmx_Val_WaitInfinitely,
|
|
261
|
+
daq.DAQmx_Val_GroupByScanNumber,
|
|
262
|
+
self._data,
|
|
263
|
+
daq.byref(self.samples_read),
|
|
264
|
+
None,
|
|
265
|
+
)
|
|
266
|
+
except daq.DAQError as e:
|
|
267
|
+
logging.exception("Error Writing Digital %d: %s", e.error, e)
|
|
252
268
|
|
|
253
269
|
if self.data_rec is not None:
|
|
254
270
|
for data_rec in self.data_rec:
|
|
255
271
|
if self._data is not None:
|
|
256
|
-
self.log.warning(f"{data_rec} {systemtime}")
|
|
257
272
|
data_rec.send((self._data, systemtime))
|
|
258
273
|
self._newdata_event.set()
|
|
259
274
|
|
etho/utils/sound.py
CHANGED
|
@@ -16,7 +16,7 @@ def parse_cell(cell, dtype: Callable = None) -> List:
|
|
|
16
16
|
if isinstance(cell, str):
|
|
17
17
|
cell = cell.strip()
|
|
18
18
|
token = cell.lstrip("[").rstrip("]").split(",")
|
|
19
|
-
token = [tok.strip() for tok in token]
|
|
19
|
+
token = [tok.strip().strip("'\"") for tok in token]
|
|
20
20
|
if dtype:
|
|
21
21
|
token = [dtype(tok) for tok in token]
|
|
22
22
|
else:
|
|
@@ -28,7 +28,7 @@ etho/services/camera/dummy.py,sha256=rwYfQvm_3sxR8gtqw2-J9isULxurV8lCDJgSYehBq8k
|
|
|
28
28
|
etho/services/camera/hamamatsu.py,sha256=M6zVEgpUlGCcszVNSBrnjyRdexzA0ZivI4G_GpqMAP4,3690
|
|
29
29
|
etho/services/camera/spinnaker.py,sha256=4QewxZlNm0CSRyfXK-9300QthD4egCX1ulyEg_qPsi0,11961
|
|
30
30
|
etho/services/camera/ximea.py,sha256=qNPMC49j_WH3xkRfv0sZF20HVu4W4FTA6-lsFqy8OOc,5306
|
|
31
|
-
etho/services/daq/IOTask.py,sha256=
|
|
31
|
+
etho/services/daq/IOTask.py,sha256=brMxfx8NRXxbdZ6lcK7rGm-1-mcRsFSIP9I4fJd_IUg,13210
|
|
32
32
|
etho/services/daq/ai.py,sha256=JNDbhtZbmuO-LbKtybmWIPGpMYuFw41xGJg63ZPTgCw,6561
|
|
33
33
|
etho/services/dlp/dlp_make_warpfiles.py,sha256=YL9rBmryb_mwDpwc6QlXTf7jqANyFg8XVcAVt0dM2S8,5995
|
|
34
34
|
etho/services/dlp/dlp_runners.py,sha256=Bk34jyyGOCsYpJpPEkG7szirtPfagPHiqNTtiJU3xKc,8730
|
|
@@ -40,11 +40,11 @@ etho/utils/calibration.py,sha256=-FMABMS-ReJ4XXR0wUAiAqGizXX5Vlj2NYH4ofiBnpA,314
|
|
|
40
40
|
etho/utils/config.py,sha256=Tp8nxFfrRC6ujU3L6dDRXmh-JQF630jCEoxg63PIzF0,1314
|
|
41
41
|
etho/utils/runner.py,sha256=XiUWQp0ua1DYwHUdgBr5Z_lz5ZVxBVCidPBgjckEaH8,4171
|
|
42
42
|
etho/utils/shuffled_cycle.py,sha256=WvBbNQP-iK7fVoCgHGTDjmT0wJhZm8Rb7IDXIbBcE5Q,1481
|
|
43
|
-
etho/utils/sound.py,sha256=
|
|
43
|
+
etho/utils/sound.py,sha256=UUN8AReClsNX6aBtluwWWjNuztk-Xh8m9PsiNmA1cAQ,11704
|
|
44
44
|
etho/utils/tui.py,sha256=zPaV5ItzOa3QuC3DGMNcTWM4N3El87hnAnTy51lacHs,3777
|
|
45
45
|
etho/utils/zeroclient.py,sha256=3wHR9rtHlESLu9UR1hZRsVisGNpLJKYv2m0sIJUbT08,3498
|
|
46
|
-
etho_python-1.2.dist-info/entry_points.txt,sha256=Y9LGGC-42Xm1bv62a_IiLYVq8T2HoPO5fLypuFfqamo,38
|
|
47
|
-
etho_python-1.2.dist-info/licenses/LICENSE,sha256=DpD3ghQH7qR9cJdLW41cPartvauhOgGI0CeEXtoWNyI,1068
|
|
48
|
-
etho_python-1.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
49
|
-
etho_python-1.2.dist-info/METADATA,sha256=
|
|
50
|
-
etho_python-1.2.dist-info/RECORD,,
|
|
46
|
+
etho_python-1.2.1.dist-info/entry_points.txt,sha256=Y9LGGC-42Xm1bv62a_IiLYVq8T2HoPO5fLypuFfqamo,38
|
|
47
|
+
etho_python-1.2.1.dist-info/licenses/LICENSE,sha256=DpD3ghQH7qR9cJdLW41cPartvauhOgGI0CeEXtoWNyI,1068
|
|
48
|
+
etho_python-1.2.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
49
|
+
etho_python-1.2.1.dist-info/METADATA,sha256=j80oKFjgghWyvp7C7YaATu0xWP1aSogIVaIGWx41ZgI,5928
|
|
50
|
+
etho_python-1.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|