mosca 2.0.2__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.
- mosca/__init__.py +11 -0
- mosca/common/__init__.py +9 -0
- mosca/common/enums.py +79 -0
- mosca/common/logger.py +139 -0
- mosca/common/threads.py +199 -0
- mosca/common/utils.py +70 -0
- mosca/control/__init__.py +4 -0
- mosca/control/buffer.py +526 -0
- mosca/control/controller.py +278 -0
- mosca/control/datahandler.py +261 -0
- mosca/control/detectors.py +116 -0
- mosca/control/mosca.py +693 -0
- mosca/control/spectra.py +36 -0
- mosca/control/stats.py +43 -0
- mosca/control/tasks/__init__.py +3 -0
- mosca/control/tasks/background.py +118 -0
- mosca/control/tasks/rois.py +466 -0
- mosca/control/tasks/saving.py +391 -0
- mosca/control/tasks/spectrasums.py +185 -0
- mosca/control/tasks/task.py +201 -0
- mosca/control/tasks/taskmanager.py +133 -0
- mosca/devices/__init__.py +28 -0
- mosca/devices/hamamatsu/__init__.py +0 -0
- mosca/devices/hamamatsu/hamamatsu.py +88 -0
- mosca/devices/hamamatsu/hamamatsuhw.py +1298 -0
- mosca/devices/oceanoptics/__init__.py +0 -0
- mosca/devices/oceanoptics/oceanoptics.py +59 -0
- mosca/devices/oceanoptics/oceanopticshw.py +379 -0
- mosca/devices/simulation/__init__.py +0 -0
- mosca/devices/simulation/dante/__init__.py +1 -0
- mosca/devices/simulation/dante/simdante.py +33 -0
- mosca/devices/simulation/dante/simdantehw.py +506 -0
- mosca/devices/simulation/dummy/__init__.py +1 -0
- mosca/devices/simulation/dummy/dummy.py +299 -0
- mosca/devices/simulation/generator.py +607 -0
- mosca/devices/simulation/xia/__init__.py +1 -0
- mosca/devices/simulation/xia/iniparser.py +99 -0
- mosca/devices/simulation/xia/simfalconx.py +26 -0
- mosca/devices/simulation/xia/simfalconxhw.py +599 -0
- mosca/devices/xglab/__init__.py +0 -0
- mosca/devices/xglab/dante.py +126 -0
- mosca/devices/xglab/dantehw.py +1178 -0
- mosca/devices/xia/__init__.py +0 -0
- mosca/devices/xia/falconx.py +232 -0
- mosca/devices/xia/handel/__init__.py +14 -0
- mosca/devices/xia/handel/_cffi.py +62 -0
- mosca/devices/xia/handel/error.py +272 -0
- mosca/devices/xia/handel/handel_inc/handel_constants.h +127 -0
- mosca/devices/xia/handel/handel_inc/handel_errors.h +254 -0
- mosca/devices/xia/handel/handel_inc/handel_generic.h +66 -0
- mosca/devices/xia/handel/interface.py +1025 -0
- mosca/devices/xia/handel/mapping.py +107 -0
- mosca/devices/xia/handel/parser.py +62 -0
- mosca/devices/xia/handel/stats.py +85 -0
- mosca/devices/xia/mercury.py +160 -0
- mosca/devices/xia/utils.py +47 -0
- mosca/devices/xia/xia.py +575 -0
- mosca/devices/xia/xiads.py +161 -0
- mosca/mosca.py +0 -0
- mosca/tango/__init__.py +2 -0
- mosca/tango/controller.py +80 -0
- mosca/tango/main.py +163 -0
- mosca/tango/mosca.py +513 -0
- mosca/tango/moscav1.py +408 -0
- mosca/tango/shared.py +23 -0
- mosca/tango/tasks/__init__.py +0 -0
- mosca/tango/tasks/background.py +55 -0
- mosca/tango/utils.py +109 -0
- mosca-2.0.2.dist-info/METADATA +32 -0
- mosca-2.0.2.dist-info/RECORD +73 -0
- mosca-2.0.2.dist-info/WHEEL +4 -0
- mosca-2.0.2.dist-info/entry_points.txt +2 -0
- mosca-2.0.2.dist-info/licenses/LICENSE +166 -0
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
"""
|
|
2
|
+
XGLab Dante Simulator
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
from simu import XGL_DPP
|
|
6
|
+
XGL_DPP contains most of the functions exposed by
|
|
7
|
+
the real XGL_DPP library.
|
|
8
|
+
|
|
9
|
+
You can do software and mapping acquisition.
|
|
10
|
+
|
|
11
|
+
To set the exposure time for mapping mode:
|
|
12
|
+
XGL_DPP.internal_trig_time = <expo time in s>
|
|
13
|
+
|
|
14
|
+
In mapping mode, the simulator will update its number of
|
|
15
|
+
available points (pygetAvailableData) every 0.1s by default
|
|
16
|
+
and one last time when the total number of points has been reached.
|
|
17
|
+
The refresh rate can be changed:
|
|
18
|
+
XGL_DPP._map_refresh_t = <t in s>
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import logging
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
import os
|
|
25
|
+
import time
|
|
26
|
+
|
|
27
|
+
import typing
|
|
28
|
+
import threading
|
|
29
|
+
import queue
|
|
30
|
+
from functools import wraps
|
|
31
|
+
from dataclasses import dataclass, fields
|
|
32
|
+
|
|
33
|
+
import numpy as np
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
from ...xglab.dantehw import XGLabDante, GatingModes
|
|
37
|
+
from ..generator import DataGenerator
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass # (kw_only=True)
|
|
41
|
+
class DppConfig:
|
|
42
|
+
fast_filter_thr: int = int()
|
|
43
|
+
energy_filter_thr: int = int()
|
|
44
|
+
energy_baseline_thr: int = int()
|
|
45
|
+
max_risetime: float = float()
|
|
46
|
+
gain: float = float()
|
|
47
|
+
peaking_time: int = int()
|
|
48
|
+
max_peaking_time: int = int()
|
|
49
|
+
flat_top: int = int()
|
|
50
|
+
edge_peaking_time: int = int()
|
|
51
|
+
edge_flat_top: int = int()
|
|
52
|
+
reset_recovery_time: int = int()
|
|
53
|
+
zero_peak_freq: float = float()
|
|
54
|
+
baseline_samples: int = int()
|
|
55
|
+
inverted_input: bool = bool()
|
|
56
|
+
time_constant: float = float()
|
|
57
|
+
base_offset: int = int()
|
|
58
|
+
overflow_recovery: int = int()
|
|
59
|
+
reset_threshold: int = int()
|
|
60
|
+
tail_coefficient: float = float()
|
|
61
|
+
other_param: int = int()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass # (kw_only=True)
|
|
65
|
+
class DppConfigOffset:
|
|
66
|
+
offset_val1: int = 0
|
|
67
|
+
offset_val2: int = 0
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def check_args(init=True, has_master=True, master_id=0, chan_id=0):
|
|
71
|
+
def decorator(func):
|
|
72
|
+
@wraps(func)
|
|
73
|
+
def inner(*args, **kwargs):
|
|
74
|
+
self = args[0]
|
|
75
|
+
if init and not self._is_init:
|
|
76
|
+
raise RuntimeError("Lib is not init.")
|
|
77
|
+
if has_master and not self._master_id:
|
|
78
|
+
raise RuntimeError("No master set.")
|
|
79
|
+
if master_id > 0 and self._master_id != args[master_id]:
|
|
80
|
+
raise RuntimeError(f"Unknown master id: {args[master_id]}")
|
|
81
|
+
if chan_id > 0 and args[chan_id] not in self._dpp_config:
|
|
82
|
+
raise RuntimeError(f"Unknown detector id: {args[chan_id]}")
|
|
83
|
+
return func(*args, **kwargs)
|
|
84
|
+
|
|
85
|
+
return inner
|
|
86
|
+
|
|
87
|
+
return decorator
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def async_reply(read=True):
|
|
91
|
+
def decorator(func):
|
|
92
|
+
@wraps(func)
|
|
93
|
+
def inner(self, *args, **kwargs):
|
|
94
|
+
return self._async_reply(func, *args, read=read, **kwargs)
|
|
95
|
+
# result = func(self, *args, **kwargs)
|
|
96
|
+
# return self._async_reply(result, read=read)
|
|
97
|
+
|
|
98
|
+
return inner
|
|
99
|
+
|
|
100
|
+
return decorator
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@dataclass
|
|
104
|
+
class SoftStatistics:
|
|
105
|
+
real_time: np.uint64 = np.uint64()
|
|
106
|
+
live_time: np.uint64 = np.uint64()
|
|
107
|
+
ICR: np.double = np.double()
|
|
108
|
+
OCR: np.double = np.double()
|
|
109
|
+
last_timestam: np.uint64 = np.uint64()
|
|
110
|
+
detected: np.int64 = np.int64()
|
|
111
|
+
measured: np.int64 = np.int64()
|
|
112
|
+
edge_dt: np.uint32 = np.uint32()
|
|
113
|
+
filt1_dt: np.uint32 = np.uint32()
|
|
114
|
+
zerocounts: np.uint32 = np.uint32()
|
|
115
|
+
baselines_value: np.uint32 = np.uint32()
|
|
116
|
+
pup_value: np.uint32 = np.uint32()
|
|
117
|
+
pup_f1_value: np.uint32 = np.uint32()
|
|
118
|
+
pup_notf1_value: np.uint32 = np.uint32()
|
|
119
|
+
reset_counter_value: np.uint32 = np.uint32()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class XGPDataGenerator(DataGenerator):
|
|
123
|
+
# def __init__(self, *args, **kwargs):
|
|
124
|
+
# super().__init__(*args, **kwargs)
|
|
125
|
+
|
|
126
|
+
def prepare(self, *args, **kwargs):
|
|
127
|
+
super().prepare(*args, **kwargs)
|
|
128
|
+
self._xg_buffer = None
|
|
129
|
+
self._xg_stats = None
|
|
130
|
+
self._xg_next_read = [0] * self.n_detectors
|
|
131
|
+
self._xg_current_pixel = [0] * self._n_detectors
|
|
132
|
+
self._xg_last_data_received = [False] * self.n_detectors
|
|
133
|
+
self._block_size_factor = 100
|
|
134
|
+
|
|
135
|
+
def run(self):
|
|
136
|
+
self._xg_last_data_received = [False] * self.n_detectors
|
|
137
|
+
self._xg_next_read = [0] * self.n_detectors
|
|
138
|
+
self._xg_current_pixel = [0] * self.n_detectors
|
|
139
|
+
if self.gating_mode != GatingModes.FreeRunning:
|
|
140
|
+
self._xg_buffer = np.zeros(
|
|
141
|
+
(
|
|
142
|
+
self.n_detectors,
|
|
143
|
+
self.block_size * self._block_size_factor,
|
|
144
|
+
self.spectrum_size,
|
|
145
|
+
),
|
|
146
|
+
dtype=np.uint64,
|
|
147
|
+
)
|
|
148
|
+
self._xg_stats = np.zeros(
|
|
149
|
+
(self.n_detectors, self.block_size * self._block_size_factor, 4),
|
|
150
|
+
dtype=np.uint64,
|
|
151
|
+
)
|
|
152
|
+
else:
|
|
153
|
+
self._xg_buffer = np.zeros(
|
|
154
|
+
(self.n_detectors, self.spectrum_size), dtype=np.uint64
|
|
155
|
+
)
|
|
156
|
+
self._xg_stats = [SoftStatistics() for _ in range(self.n_detectors)]
|
|
157
|
+
super().run()
|
|
158
|
+
|
|
159
|
+
def update(self, detector, data, stats, f_pix, l_pix):
|
|
160
|
+
if self.gating_mode != GatingModes.FreeRunning:
|
|
161
|
+
pix_0 = self._xg_current_pixel[detector]
|
|
162
|
+
pix_1 = pix_0 + l_pix - f_pix + 1
|
|
163
|
+
idx = np.arange(pix_0, pix_1) % self._xg_buffer.shape[1]
|
|
164
|
+
self._xg_buffer[detector, idx] = data
|
|
165
|
+
self._xg_current_pixel[detector] = l_pix + 1
|
|
166
|
+
else:
|
|
167
|
+
# self._xg_last_data_received[detector] = True
|
|
168
|
+
self._xg_buffer[detector] = data[0]
|
|
169
|
+
# TODO: fill in with actual stats
|
|
170
|
+
self._xg_stats[detector] = SoftStatistics(real_time=stats[0][0])
|
|
171
|
+
|
|
172
|
+
# f_pix and l_pix are zero based
|
|
173
|
+
if l_pix == self.acq_nb_points - 1:
|
|
174
|
+
self._xg_last_data_received[detector] = True
|
|
175
|
+
|
|
176
|
+
def _acq_finished(self):
|
|
177
|
+
for idet in range(self.n_detectors):
|
|
178
|
+
self._xg_last_data_received[idet] = True
|
|
179
|
+
|
|
180
|
+
def step_data(self, detector):
|
|
181
|
+
result = self._xg_buffer[detector], -1, self._xg_stats[detector]
|
|
182
|
+
return result
|
|
183
|
+
|
|
184
|
+
def last_data_received(self, detector):
|
|
185
|
+
return self._xg_last_data_received[detector]# or not self.is_running()
|
|
186
|
+
|
|
187
|
+
def map_data(self, detector, spectrum_size, num_pix):
|
|
188
|
+
if spectrum_size != self.spectrum_size:
|
|
189
|
+
raise RuntimeError("Invalid spectrum_size")
|
|
190
|
+
pix_0 = self._xg_next_read[detector]
|
|
191
|
+
pix_1 = pix_0 + num_pix
|
|
192
|
+
if pix_1 > self._xg_current_pixel[detector]:
|
|
193
|
+
raise RuntimeError("Too many pixels requested")
|
|
194
|
+
self._xg_next_read[detector] = pix_1
|
|
195
|
+
idx = np.arange(pix_0, pix_1) % self._xg_buffer.shape[1]
|
|
196
|
+
|
|
197
|
+
# if pix_1 == self.acq_nb_points:
|
|
198
|
+
# self._xg_last_data_received[detector] = True
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
self._xg_buffer[detector, idx, :],
|
|
202
|
+
np.arange(pix_0, pix_1),
|
|
203
|
+
self._xg_stats[detector, idx, :].flatten(),
|
|
204
|
+
None,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
def available(self, detector):
|
|
208
|
+
# if self._xg_last_data_received[detector]:
|
|
209
|
+
# return 0
|
|
210
|
+
return self._xg_current_pixel[detector] - self._xg_next_read[detector]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class _XGL_DPP:
|
|
214
|
+
internal_trig_time = property(lambda self: self._internal_trig_time)
|
|
215
|
+
simu_data_file = property(lambda self: self._data_file)
|
|
216
|
+
gate = property(lambda self: self._gate)
|
|
217
|
+
config_time = property(lambda self: self._config_time)
|
|
218
|
+
|
|
219
|
+
def __init__(self, master_id="192.168.1.1", n_chans=16, config_time=.01):
|
|
220
|
+
super().__init__()
|
|
221
|
+
self._reply_id_lock = threading.RLock()
|
|
222
|
+
self._master_id = master_id
|
|
223
|
+
self._n_chans = n_chans
|
|
224
|
+
self._last_error = 0
|
|
225
|
+
self._is_init = False
|
|
226
|
+
self._callback = None
|
|
227
|
+
self._last_call_id = 0
|
|
228
|
+
self._gating_mode = ["Software"] * self._n_chans
|
|
229
|
+
self._map_refresh_t = 0.1
|
|
230
|
+
self._data_file = None
|
|
231
|
+
|
|
232
|
+
# (enabled, dppconfig)
|
|
233
|
+
self._dpp_config = {chan: [True, DppConfig()] for chan in range(n_chans)}
|
|
234
|
+
self._query_address = None
|
|
235
|
+
|
|
236
|
+
self._generator = XGPDataGenerator()
|
|
237
|
+
self._internal_trig_time = 1
|
|
238
|
+
self._gate = False
|
|
239
|
+
|
|
240
|
+
self._config_time = config_time
|
|
241
|
+
|
|
242
|
+
def generator(self):
|
|
243
|
+
return self._generator
|
|
244
|
+
|
|
245
|
+
@config_time.setter
|
|
246
|
+
def config_time(self, config_time):
|
|
247
|
+
self._config_time = config_time
|
|
248
|
+
|
|
249
|
+
@internal_trig_time.setter
|
|
250
|
+
def internal_trig_time(self, internal_trig_time):
|
|
251
|
+
self._internal_trig_time = internal_trig_time
|
|
252
|
+
|
|
253
|
+
@gate.setter
|
|
254
|
+
def gate(self, gate):
|
|
255
|
+
self._gate = gate
|
|
256
|
+
|
|
257
|
+
@simu_data_file.setter
|
|
258
|
+
def simu_data_file(self, simu_data_file):
|
|
259
|
+
# TODO: check file structure
|
|
260
|
+
if not simu_data_file:
|
|
261
|
+
self._data_file = None
|
|
262
|
+
logger.info("Not using a data file.")
|
|
263
|
+
elif not os.path.exists(simu_data_file):
|
|
264
|
+
raise RuntimeError(
|
|
265
|
+
f"Given simu data file doesn't exist! " f"({simu_data_file})."
|
|
266
|
+
)
|
|
267
|
+
else:
|
|
268
|
+
self._data_file = simu_data_file
|
|
269
|
+
logger.info("Using a data file: %s.", simu_data_file)
|
|
270
|
+
|
|
271
|
+
def _async_call(self, func, call_id, *args, read=True, **kwargs):
|
|
272
|
+
reply = func(self, *args, **kwargs)
|
|
273
|
+
rtype = (read and 1) or 2
|
|
274
|
+
self._callback(rtype, call_id, 0, reply)
|
|
275
|
+
# gevent.get_hub().destroy(True)
|
|
276
|
+
|
|
277
|
+
def _async_reply(self, func, *args, read=True, **kwargs):
|
|
278
|
+
if not self._callback:
|
|
279
|
+
raise RuntimeError("Calling and async command without callback.")
|
|
280
|
+
|
|
281
|
+
with self._reply_id_lock:
|
|
282
|
+
self._last_call_id += 1
|
|
283
|
+
call_id = self._last_call_id
|
|
284
|
+
|
|
285
|
+
args = (func, call_id) + args
|
|
286
|
+
kwargs["read"] = read
|
|
287
|
+
task = threading.Thread(target=self._async_call, args=args, kwargs=kwargs)
|
|
288
|
+
task.start()
|
|
289
|
+
|
|
290
|
+
return call_id
|
|
291
|
+
|
|
292
|
+
def configuration(self):
|
|
293
|
+
return DppConfig()
|
|
294
|
+
|
|
295
|
+
def configuration_offset(self):
|
|
296
|
+
return DppConfigOffset()
|
|
297
|
+
|
|
298
|
+
@check_args(init=False, has_master=False)
|
|
299
|
+
def pyCloseLibrary(self):
|
|
300
|
+
return True
|
|
301
|
+
|
|
302
|
+
@check_args(init=False, has_master=False)
|
|
303
|
+
def pygetLastError(self):
|
|
304
|
+
return True, self._last_error
|
|
305
|
+
|
|
306
|
+
def pyresetLastError(self):
|
|
307
|
+
self._last_error = 0
|
|
308
|
+
return True
|
|
309
|
+
|
|
310
|
+
@check_args(master_id=1)
|
|
311
|
+
def pyflush_local_eth_conn(self, master_id):
|
|
312
|
+
raise NotImplementedError()
|
|
313
|
+
|
|
314
|
+
@check_args(init=False, has_master=False)
|
|
315
|
+
def pyInitLibrary(self):
|
|
316
|
+
self._is_init = True
|
|
317
|
+
return True
|
|
318
|
+
|
|
319
|
+
@check_args(has_master=False)
|
|
320
|
+
def pyadd_to_query(self, address):
|
|
321
|
+
self._query_address = address
|
|
322
|
+
return True
|
|
323
|
+
|
|
324
|
+
@check_args()
|
|
325
|
+
def pyautoScanSlaves(self, enable):
|
|
326
|
+
return True
|
|
327
|
+
|
|
328
|
+
@check_args()
|
|
329
|
+
def pyget_dev_number(self):
|
|
330
|
+
return True, 1
|
|
331
|
+
|
|
332
|
+
@check_args()
|
|
333
|
+
def pyget_ids(self, nb, id_size):
|
|
334
|
+
if id_size < len(self._master_id):
|
|
335
|
+
return False, ""
|
|
336
|
+
return True, self._master_id
|
|
337
|
+
|
|
338
|
+
@check_args(master_id=1)
|
|
339
|
+
def pyget_boards_in_chain(self, master_id):
|
|
340
|
+
return True, self._n_chans
|
|
341
|
+
|
|
342
|
+
@check_args(has_master=False)
|
|
343
|
+
def pyregister_callback(self, callback):
|
|
344
|
+
self._callback = callback
|
|
345
|
+
return True
|
|
346
|
+
|
|
347
|
+
@check_args(master_id=1, chan_id=2)
|
|
348
|
+
@async_reply(read=False)
|
|
349
|
+
def pydisableBoard(self, master_id, chan_id, disable):
|
|
350
|
+
config = self._dpp_config[chan_id]
|
|
351
|
+
config[0] = disable
|
|
352
|
+
self._n_chans = sum(
|
|
353
|
+
[1 for config in self._dpp_config.values() if not config[0]]
|
|
354
|
+
)
|
|
355
|
+
return [1]
|
|
356
|
+
|
|
357
|
+
@check_args(master_id=1, chan_id=2)
|
|
358
|
+
@async_reply(read=False)
|
|
359
|
+
def pyconfigure_inputmode(self, master_id, chan_id, mode):
|
|
360
|
+
return [1]
|
|
361
|
+
|
|
362
|
+
@check_args(master_id=1, chan_id=2)
|
|
363
|
+
@async_reply(read=False)
|
|
364
|
+
def pyconfigure_offset(self, master_id, chan_id, offset):
|
|
365
|
+
return [1]
|
|
366
|
+
|
|
367
|
+
@check_args(master_id=1, chan_id=2)
|
|
368
|
+
@async_reply(read=False)
|
|
369
|
+
def pyconfigure(self, master_id, chan_id, chanconf):
|
|
370
|
+
kwargs = {fld.name: getattr(chanconf, fld.name) for fld in fields(DppConfig)}
|
|
371
|
+
new_conf = DppConfig(**kwargs)
|
|
372
|
+
self._dpp_config[chan_id][1] = new_conf
|
|
373
|
+
time.sleep(self.config_time)
|
|
374
|
+
return [1]
|
|
375
|
+
|
|
376
|
+
@check_args()
|
|
377
|
+
def pylibVersion(self, id_size):
|
|
378
|
+
return True, "DanteSimu 1.0"
|
|
379
|
+
|
|
380
|
+
@check_args(master_id=1, chan_id=2)
|
|
381
|
+
@async_reply()
|
|
382
|
+
def pygetFirmware(self, master_id, chan_id):
|
|
383
|
+
return [6, 7, 8, 9]
|
|
384
|
+
|
|
385
|
+
@check_args(master_id=1, chan_id=3)
|
|
386
|
+
@async_reply(read=False)
|
|
387
|
+
def pyconfigure_gating(self, master_id, gating_mode, chan_id):
|
|
388
|
+
self._gating_mode[chan_id] = gating_mode
|
|
389
|
+
return [1]
|
|
390
|
+
|
|
391
|
+
@check_args(master_id=1)
|
|
392
|
+
def pyclear_chain(self, master_id):
|
|
393
|
+
return True
|
|
394
|
+
|
|
395
|
+
@check_args(master_id=1)
|
|
396
|
+
@async_reply(read=False)
|
|
397
|
+
def pystart(self, master_id, expo_time, spectrum_size):
|
|
398
|
+
# TODO: check if generator running
|
|
399
|
+
generator = self.generator()
|
|
400
|
+
# generator.configure(
|
|
401
|
+
# 1,
|
|
402
|
+
# self._n_chans,
|
|
403
|
+
# spectrum_size,
|
|
404
|
+
# mapping_mode=False,
|
|
405
|
+
# data_file=self.simu_data_file,
|
|
406
|
+
# gate=False,
|
|
407
|
+
# internal_trig_time=expo_time,
|
|
408
|
+
# )
|
|
409
|
+
# self._generator.run()
|
|
410
|
+
for chan, config in self._dpp_config.items():
|
|
411
|
+
if not config[0]: # enabled
|
|
412
|
+
generator.start_detector(chan)
|
|
413
|
+
return [1]
|
|
414
|
+
|
|
415
|
+
@check_args(master_id=1, chan_id=2)
|
|
416
|
+
@async_reply()
|
|
417
|
+
def pyisRunning_system(self, master_id, chan_id):
|
|
418
|
+
generator = self.generator()
|
|
419
|
+
running = 1 if generator and generator.detector_running(chan_id) else 0
|
|
420
|
+
return [running]
|
|
421
|
+
|
|
422
|
+
@check_args(master_id=1)
|
|
423
|
+
@async_reply(read=False)
|
|
424
|
+
def pystart_map(self, master_id, x, n_points, spectrum_size):
|
|
425
|
+
# TODO: check if generator running
|
|
426
|
+
generator = self.generator()
|
|
427
|
+
# generator.configure(
|
|
428
|
+
# n_points,
|
|
429
|
+
# self._n_chans,
|
|
430
|
+
# spectrum_size,
|
|
431
|
+
# block_size=1,
|
|
432
|
+
# internal_trig_time=self.internal_trig_time,
|
|
433
|
+
# gate=self._gate,
|
|
434
|
+
# data_file=self.simu_data_file,
|
|
435
|
+
# map_refresh_t=self._map_refresh_t,
|
|
436
|
+
# )
|
|
437
|
+
# self._generator.run()
|
|
438
|
+
for chan, config in self._dpp_config.items():
|
|
439
|
+
if not config[0]: # enabled
|
|
440
|
+
generator.start_detector(chan)
|
|
441
|
+
return [1]
|
|
442
|
+
|
|
443
|
+
@check_args(master_id=1)
|
|
444
|
+
@async_reply(read=False)
|
|
445
|
+
def pystop(self, master_id):
|
|
446
|
+
self.generator().stop()
|
|
447
|
+
return [1]
|
|
448
|
+
|
|
449
|
+
@check_args(master_id=1, chan_id=2)
|
|
450
|
+
def pyisLastDataReceived(self, master_id, chan_id):
|
|
451
|
+
# TODO: more checks
|
|
452
|
+
# if not self._generator:
|
|
453
|
+
# raise RuntimeError("No acquisition running.")
|
|
454
|
+
return True, self.generator().last_data_received(chan_id)
|
|
455
|
+
|
|
456
|
+
@check_args(master_id=1, chan_id=2)
|
|
457
|
+
def pygetData(self, master_id, chan_id, spectrum_size):
|
|
458
|
+
# TODO: more checks
|
|
459
|
+
# if self.generator().last_data_received(chan_id):
|
|
460
|
+
# raise RuntimeError("All data already received.")
|
|
461
|
+
return (True,) + self.generator().step_data(chan_id)
|
|
462
|
+
|
|
463
|
+
@check_args(master_id=1, chan_id=2)
|
|
464
|
+
def pygetAvailableData(self, master, chan_id):
|
|
465
|
+
# if self.generator().last_data_received(chan_id):
|
|
466
|
+
# raise RuntimeError("All data already received.")
|
|
467
|
+
return True, self.generator().available(chan_id)
|
|
468
|
+
|
|
469
|
+
@check_args(master_id=1, chan_id=2)
|
|
470
|
+
def pygetAllData(self, master_id, chan_id, spectrum_size, num_pix):
|
|
471
|
+
# if self.generator().last_data_received(chan_id):
|
|
472
|
+
# raise RuntimeError("All data already received.")
|
|
473
|
+
return (True,) + self.generator().map_data(chan_id, spectrum_size, num_pix)
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
XGL_DPP = _XGL_DPP()
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
class SimDanteHW(XGLabDante):
|
|
480
|
+
def __init__(self, *args, **kwargs):
|
|
481
|
+
super().__init__(*args, **kwargs)
|
|
482
|
+
self.comm._xgl = XGL_DPP
|
|
483
|
+
|
|
484
|
+
def generator(self):
|
|
485
|
+
return self.comm._xgl.generator()
|
|
486
|
+
|
|
487
|
+
def stop_acq(self):
|
|
488
|
+
super().stop_acq()
|
|
489
|
+
self._is_running = False
|
|
490
|
+
|
|
491
|
+
def apply_mosca(self,
|
|
492
|
+
*args,
|
|
493
|
+
**kwargs):
|
|
494
|
+
super().apply_mosca(*args, **kwargs)
|
|
495
|
+
|
|
496
|
+
# forcing block_size to one, as the
|
|
497
|
+
# dante doesn't have an internal buffer like the XIA
|
|
498
|
+
kwargs["block_size"] = 1
|
|
499
|
+
self.generator().apply_mosca(*args, **kwargs)
|
|
500
|
+
|
|
501
|
+
def prepare_acq(self, *args, **kwargs):
|
|
502
|
+
super().prepare_acq()
|
|
503
|
+
generator = self.generator()
|
|
504
|
+
generator.start_delay = 0.015
|
|
505
|
+
generator.gating_mode = self.gating_mode
|
|
506
|
+
self.generator().prepare(self.available_detectors(), self.spectrum_size())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .dummy import Dummy, DUMMY_DEVINFO
|