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
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
logger = logging.getLogger(__name__)
|
|
3
|
+
|
|
4
|
+
from tango.server import device_property, attribute
|
|
5
|
+
|
|
6
|
+
from ...tango import ControllerDS, TangoDevInfo
|
|
7
|
+
from .oceanopticshw import OceanOpticsHW
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class OceanOptics(ControllerDS):
|
|
11
|
+
serial_number = device_property(dtype=str, mandatory=False, default_value=None)
|
|
12
|
+
default_readout = device_property(dtype=float, mandatory=False, default_value=0.01)
|
|
13
|
+
|
|
14
|
+
trigger_mode = attribute(lambda self: self.control.spectro.trigger_mode.name, dtype=str)
|
|
15
|
+
serial = attribute(lambda self: self.control.spectro.serial_number, dtype=str)
|
|
16
|
+
integration_time_micros = attribute(lambda self: self.control.spectro.integration_time_micros, dtype=float)
|
|
17
|
+
integration_time_micros_limits = attribute(lambda self: self.control.spectro.integration_time_micros_limits, dtype=[float], max_dim_x=2)
|
|
18
|
+
n_points = attribute(lambda self: self.control.n_points, dtype=int)
|
|
19
|
+
buffer_capacity = attribute(lambda self: self.control.buffer_capacity, dtype=int)
|
|
20
|
+
block_size = attribute(lambda self: self.control.block_size, dtype=int)
|
|
21
|
+
buffer_capacity_maximum = attribute(lambda self: self.control.buffer_capacity_maximum, dtype=int)
|
|
22
|
+
readout_time = attribute(lambda self: self.control.readout_time, dtype=float)
|
|
23
|
+
|
|
24
|
+
def _create_control(self, *args, **kwargs):
|
|
25
|
+
oo = OceanOpticsHW(*args, serial=self.serial_number, **kwargs)
|
|
26
|
+
if self.default_readout > 0:
|
|
27
|
+
oo.readout_time = self.default_readout
|
|
28
|
+
return oo
|
|
29
|
+
|
|
30
|
+
@trigger_mode.write
|
|
31
|
+
def trigger_mode(self, trigger_mode):
|
|
32
|
+
self.control.spectro.trigger_mode = trigger_mode
|
|
33
|
+
|
|
34
|
+
@integration_time_micros.write
|
|
35
|
+
def integration_time_micros(self, integration_time_micros):
|
|
36
|
+
self.control.integration_time_micros = integration_time_micros
|
|
37
|
+
|
|
38
|
+
@n_points.write
|
|
39
|
+
def n_points(self, n_points):
|
|
40
|
+
self.control.n_points = n_points
|
|
41
|
+
|
|
42
|
+
@buffer_capacity.write
|
|
43
|
+
def buffer_capacity(self, buffer_capacity):
|
|
44
|
+
self.control.buffer_capacity = buffer_capacity
|
|
45
|
+
|
|
46
|
+
@block_size.write
|
|
47
|
+
def block_size(self, block_size):
|
|
48
|
+
self.control.block_size = block_size
|
|
49
|
+
|
|
50
|
+
@readout_time.write
|
|
51
|
+
def readout_time(self, readout_time):
|
|
52
|
+
self.control.readout_time = readout_time
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
OCEANOPTICS_DEVINFO = TangoDevInfo(
|
|
57
|
+
klass = OceanOptics,
|
|
58
|
+
properties = {"serial": "",
|
|
59
|
+
"default_readout": ""})
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
logger = logging.getLogger(__name__)
|
|
3
|
+
|
|
4
|
+
import enum
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
from ...common import to_enum, GateMode, TriggerMode
|
|
9
|
+
from ...control import Controller, PollResult, Status
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# ocean optics trigger modes:
|
|
13
|
+
# - 0: continuous integrations, gate is ignored
|
|
14
|
+
# - 1: continuous acquisitons, starts and continues as long as the gate is HIGH
|
|
15
|
+
# - 2: advertised as coming "soon"...
|
|
16
|
+
# - 3: integration starts when a rising edge is detected, and runs for the given time
|
|
17
|
+
|
|
18
|
+
class OOTriggerModes(enum.Enum):
|
|
19
|
+
FREERUN = 0
|
|
20
|
+
LEVEL = 1
|
|
21
|
+
EDGE = 3
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class OOpticsSpectro:
|
|
25
|
+
seabreeze = property(lambda self: self._seabreaze)
|
|
26
|
+
sbspec = property(lambda self: self._sbspec)
|
|
27
|
+
device = property(lambda self: self._device)
|
|
28
|
+
libver = property(lambda self: self.seabreeze.__version__)
|
|
29
|
+
model = property(lambda self: self._model)
|
|
30
|
+
|
|
31
|
+
integration_time_micros_limits = property(lambda self: self._itime_limits)
|
|
32
|
+
max_intensity = property(lambda self: self._max_intensity)
|
|
33
|
+
serial_number = property(lambda self: self._serial_number)
|
|
34
|
+
features = property(lambda self: self._features_names)
|
|
35
|
+
integration_time_micros = property(lambda self: self._integration_time_micros)
|
|
36
|
+
trigger_mode = property(lambda self: self._trigger_mode)
|
|
37
|
+
spectrum_size = property(lambda self: self._spectrum_size)
|
|
38
|
+
dark_pixels_indices = property(lambda self: self._dark_pixels_indices)
|
|
39
|
+
buffer_capacity_maximum = property(lambda self: self._data_buffer.get_buffer_capacity_maximum())
|
|
40
|
+
buffer_capacity_minimum = property(lambda self: self._data_buffer.get_buffer_capacity_minimum())
|
|
41
|
+
|
|
42
|
+
def __init__(self, *args, serial=None, **kwargs):
|
|
43
|
+
super().__init__(*args, **kwargs)
|
|
44
|
+
|
|
45
|
+
# Seabreeze library.
|
|
46
|
+
import seabreeze as sb
|
|
47
|
+
sb.use("cseabreeze")
|
|
48
|
+
from seabreeze import spectrometers as sbspec
|
|
49
|
+
|
|
50
|
+
self._seabreaze = sb
|
|
51
|
+
self._sbspec = sbspec
|
|
52
|
+
|
|
53
|
+
if serial is None:
|
|
54
|
+
logger.warning("No serial number specified, listing devices...")
|
|
55
|
+
devices = sbspec.list_devices()
|
|
56
|
+
if len(devices) == 0:
|
|
57
|
+
raise RuntimeError("No Ocean Optics devices found.")
|
|
58
|
+
msg = "\n - ".join(dev.serial_number for dev in devices)
|
|
59
|
+
logger.info("Found devices:\n - %s", msg)
|
|
60
|
+
if len(devices) > 1:
|
|
61
|
+
msg = "More than one device found, please specify a serial number."
|
|
62
|
+
logger.error(msg)
|
|
63
|
+
raise RuntimeError(msg)
|
|
64
|
+
serial = devices[0].serial_number
|
|
65
|
+
|
|
66
|
+
logger.info("Opening device using serial number %s.", serial)
|
|
67
|
+
|
|
68
|
+
dev = self._device = sbspec.Spectrometer.from_serial_number(serial)
|
|
69
|
+
|
|
70
|
+
self._itime_limits = tuple(dev.integration_time_micros_limits)
|
|
71
|
+
self._max_intensity = dev.max_intensity
|
|
72
|
+
self._model = dev.model
|
|
73
|
+
self._serial_number = dev.serial_number
|
|
74
|
+
self._features_names = tuple(key for key, value in dev.features.items() if value)
|
|
75
|
+
|
|
76
|
+
if "data_buffer" not in self.features:
|
|
77
|
+
raise RuntimeError("Only Ocean Optics devices that have the 'data_buffer' feature are supported.")
|
|
78
|
+
|
|
79
|
+
if "spectrometer" not in self.features:
|
|
80
|
+
raise RuntimeError("Only Ocean Optics devices that have the 'spectrometer' feature are supported.")
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
self._tec = self.get_feature("thermo_electric")
|
|
84
|
+
except RuntimeError:
|
|
85
|
+
self._tec = None
|
|
86
|
+
|
|
87
|
+
self._spectro = self.get_feature("spectrometer")
|
|
88
|
+
self._data_buffer = self.get_feature("data_buffer")
|
|
89
|
+
|
|
90
|
+
self._integration_time_micros = None
|
|
91
|
+
self.integration_time_micros = 1e6
|
|
92
|
+
self._trigger_mode = None
|
|
93
|
+
self.trigger_mode = 0
|
|
94
|
+
|
|
95
|
+
# TODO: making sure this is a model we know...
|
|
96
|
+
# assert self._spec.pixels == 1044
|
|
97
|
+
# assert self._spec.get_electric_dark_pixel_indices() == [0, 1, 2, 3, 1040, 1041, 1042, 1043]
|
|
98
|
+
|
|
99
|
+
self._dark_pixels_indices = self._spectro.get_electric_dark_pixel_indices()
|
|
100
|
+
self._spectrum_size = self._spectro.get_intensities().shape[0]
|
|
101
|
+
|
|
102
|
+
def get_feature(self, feature_name):
|
|
103
|
+
try:
|
|
104
|
+
return self.device.features[feature_name][0]
|
|
105
|
+
except KeyError:
|
|
106
|
+
msg = f"Unknown feature {feature_name}."
|
|
107
|
+
logger.error(msg)
|
|
108
|
+
raise ValueError(msg)
|
|
109
|
+
except IndexError:
|
|
110
|
+
msg = f"Feature {feature_name} not available on this model."
|
|
111
|
+
logger.warning(msg)
|
|
112
|
+
raise RuntimeError(msg)
|
|
113
|
+
|
|
114
|
+
@trigger_mode.setter
|
|
115
|
+
def trigger_mode(self, trigger_mode):
|
|
116
|
+
logger.info("Setting trigger_mode to %s.", trigger_mode)
|
|
117
|
+
trigger_mode = to_enum(trigger_mode, OOTriggerModes)
|
|
118
|
+
self._spectro.set_trigger_mode(trigger_mode.value)
|
|
119
|
+
self._trigger_mode = trigger_mode
|
|
120
|
+
|
|
121
|
+
@integration_time_micros.setter
|
|
122
|
+
def integration_time_micros(self, integration_time_micros):
|
|
123
|
+
logger.info("Setting integration_time_micros to %s.", integration_time_micros)
|
|
124
|
+
# TODO: check time limits?
|
|
125
|
+
self._spectro.set_integration_time_micros(integration_time_micros)
|
|
126
|
+
self._integration_time_micros = integration_time_micros
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def number_of_elements(self):
|
|
130
|
+
return self._data_buffer.get_number_of_elements()
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def buffer_capacity(self):
|
|
134
|
+
return self._data_buffer.get_buffer_capacity()
|
|
135
|
+
|
|
136
|
+
@buffer_capacity.setter
|
|
137
|
+
def buffer_capacity(self, buffer_capacity):
|
|
138
|
+
self._data_buffer.set_buffer_capacity(buffer_capacity)
|
|
139
|
+
|
|
140
|
+
def get_intensities(self, n_points=None):
|
|
141
|
+
if n_points is None:
|
|
142
|
+
n_points = 1
|
|
143
|
+
spectra = np.ndarray((n_points, self.spectrum_size), dtype=float)
|
|
144
|
+
for i in range(n_points):
|
|
145
|
+
spectra[i] = self._spectro.get_intensities()
|
|
146
|
+
return spectra
|
|
147
|
+
|
|
148
|
+
def get_wavelengths(self):
|
|
149
|
+
return self._spectro.get_wavelengths()
|
|
150
|
+
|
|
151
|
+
def clear_buffer(self):
|
|
152
|
+
logger.debug("Clearing buffer.")
|
|
153
|
+
self._data_buffer.clear()
|
|
154
|
+
|
|
155
|
+
def close(self):
|
|
156
|
+
logger.debug("Closing device.")
|
|
157
|
+
self._device.close()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def mosca_to_qepro(trigger_mode):
|
|
162
|
+
"""
|
|
163
|
+
Only supported run_mode is REALTIME.
|
|
164
|
+
QEPro modes:
|
|
165
|
+
- FREERUN = 0: gate_mode = IGNORE, start_trigger = NONE
|
|
166
|
+
- LEVEL = 1: gate_mode = HIGH, start_trigger = NONE
|
|
167
|
+
- EDGE = 3: gate_mode = IGNORE, start_trigger = RISING
|
|
168
|
+
"""
|
|
169
|
+
MoscaToQePro = {
|
|
170
|
+
TriggerMode.INT_TRIG_READOUT: OOTriggerModes.FREERUN,
|
|
171
|
+
TriggerMode.GATE: OOTriggerModes.LEVEL,
|
|
172
|
+
TriggerMode.EXT_TRIG_READOUT: OOTriggerModes.EDGE}
|
|
173
|
+
try:
|
|
174
|
+
return MoscaToQePro[trigger_mode]
|
|
175
|
+
except KeyError:
|
|
176
|
+
raise ValueError(f"Unsupported trigger mode {trigger_mode}.")
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class OceanOpticsHW(Controller):
|
|
180
|
+
"""Base class for hardware controller.
|
|
181
|
+
"""
|
|
182
|
+
name = property(lambda self: self._name)
|
|
183
|
+
spectro = property(lambda self: self._oo_spectro)
|
|
184
|
+
|
|
185
|
+
integration_time_micros = property(lambda self: self.spectro.integration_time_micros)
|
|
186
|
+
buffer_capacity_maximum = property(lambda self: self.spectro.buffer_capacity_maximum)
|
|
187
|
+
|
|
188
|
+
readout_time = property(lambda self: self._readout_time)
|
|
189
|
+
|
|
190
|
+
def __init__(self, *args, serial=None, **kwargs):
|
|
191
|
+
super().__init__(*args, **kwargs)
|
|
192
|
+
self._oo_spectro = OOpticsSpectro(serial=serial)
|
|
193
|
+
|
|
194
|
+
self._readout_time = 0.
|
|
195
|
+
self._oo_poller = None
|
|
196
|
+
self._oo_is_running = False
|
|
197
|
+
self._buffer_capacity = 0
|
|
198
|
+
# self._readout_time = 0.
|
|
199
|
+
self._nb_points = 1
|
|
200
|
+
self._block_size = 1
|
|
201
|
+
|
|
202
|
+
def unconfig(self):
|
|
203
|
+
self.spectro.close()
|
|
204
|
+
|
|
205
|
+
def unprepare(self):
|
|
206
|
+
pass
|
|
207
|
+
|
|
208
|
+
def metadata(self):
|
|
209
|
+
return {}
|
|
210
|
+
|
|
211
|
+
def apply_mosca(self,
|
|
212
|
+
acq_nb_points=None,
|
|
213
|
+
acq_realtime=None,
|
|
214
|
+
trigger_mode=None,
|
|
215
|
+
block_size=None,
|
|
216
|
+
**kwargs):
|
|
217
|
+
spectro = self.spectro
|
|
218
|
+
|
|
219
|
+
if trigger_mode is not None:
|
|
220
|
+
oo_mode = mosca_to_qepro(trigger_mode)
|
|
221
|
+
spectro.trigger_mode = oo_mode
|
|
222
|
+
|
|
223
|
+
# if the buffer capacity has been set, apply it.
|
|
224
|
+
# otherwise set it to the acq_nb_points
|
|
225
|
+
if self._buffer_capacity > 0:
|
|
226
|
+
spectro.buffer_capacity = self._buffer_capacity
|
|
227
|
+
else:
|
|
228
|
+
max_cap = spectro.buffer_capacity_maximum
|
|
229
|
+
if acq_nb_points is None or acq_nb_points <= 0:
|
|
230
|
+
spectro.buffer_capacity = max_cap
|
|
231
|
+
else:
|
|
232
|
+
spectro.buffer_capacity = min(max_cap, acq_nb_points)
|
|
233
|
+
|
|
234
|
+
if acq_realtime is not None:
|
|
235
|
+
spectro.integration_time_micros = 1e6 * acq_realtime
|
|
236
|
+
if acq_nb_points is not None:
|
|
237
|
+
self.nb_points = acq_nb_points
|
|
238
|
+
if block_size is not None:
|
|
239
|
+
self.block_size = block_size
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def block_size(self):
|
|
243
|
+
return self._block_size
|
|
244
|
+
|
|
245
|
+
@block_size.setter
|
|
246
|
+
def block_size(self, block_size):
|
|
247
|
+
self._block_size = block_size
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def buffer_capacity(self):
|
|
251
|
+
return self._oo_spectro.buffer_capacity
|
|
252
|
+
|
|
253
|
+
@readout_time.setter
|
|
254
|
+
def readout_time(self, readout_time):
|
|
255
|
+
self._readout_time = readout_time
|
|
256
|
+
|
|
257
|
+
@buffer_capacity.setter
|
|
258
|
+
def buffer_capacity(self, buffer_capacity):
|
|
259
|
+
"""
|
|
260
|
+
Manually sets the QEPro buffer capacity.
|
|
261
|
+
If set to 0, then the buffer capacity will be set to
|
|
262
|
+
min(buffer_capacity_maximum, acq_nb_points) when
|
|
263
|
+
starting an acquisition.
|
|
264
|
+
"""
|
|
265
|
+
if buffer_capacity > 0:
|
|
266
|
+
self._oo_spectro.buffer_capacity = buffer_capacity
|
|
267
|
+
self._buffer_capacity = buffer_capacity
|
|
268
|
+
|
|
269
|
+
@integration_time_micros.setter
|
|
270
|
+
def integration_time_micros(self, integration_time_micros):
|
|
271
|
+
self.spectro.integration_time_micros = integration_time_micros
|
|
272
|
+
|
|
273
|
+
@property
|
|
274
|
+
def nb_points(self):
|
|
275
|
+
return self._nb_points
|
|
276
|
+
|
|
277
|
+
@nb_points.setter
|
|
278
|
+
def nb_points(self, nb_points):
|
|
279
|
+
"""
|
|
280
|
+
Number of points required for the scan.
|
|
281
|
+
"""
|
|
282
|
+
self._nb_points = nb_points
|
|
283
|
+
|
|
284
|
+
def prepare_acq(self, resume=False):
|
|
285
|
+
# TODO: the polling can still miss points if
|
|
286
|
+
# block_size is too close to buffer capacity
|
|
287
|
+
if self.buffer_capacity < self.block_size:
|
|
288
|
+
raise RuntimeError(f"Block_size (here {self.block_size}) should be"
|
|
289
|
+
f" lower than buffer capacity (here {self.buffer_capacity})")
|
|
290
|
+
|
|
291
|
+
def start_acq(self, resume=None):
|
|
292
|
+
# the OOptics model(s) this code
|
|
293
|
+
# supports runs continuously, there is no
|
|
294
|
+
# actual start/stop
|
|
295
|
+
self._oo_poller = OOPoller(self.spectro, self.nb_points, self.block_size)
|
|
296
|
+
self.spectro.clear_buffer()
|
|
297
|
+
|
|
298
|
+
def stop_acq(self):
|
|
299
|
+
# the OOptics model(s) this code
|
|
300
|
+
# supports runs continuously, there is no
|
|
301
|
+
# actual start/stop
|
|
302
|
+
if self._oo_poller:
|
|
303
|
+
self._oo_poller.stop()
|
|
304
|
+
|
|
305
|
+
def poll_acq(self) -> PollResult:
|
|
306
|
+
return self._oo_poller()
|
|
307
|
+
|
|
308
|
+
def mca_status(self):
|
|
309
|
+
if self._oo_poller and self._oo_poller.is_running():
|
|
310
|
+
return Status.RUNNING
|
|
311
|
+
return Status.READY
|
|
312
|
+
|
|
313
|
+
def available_detectors(self) -> list[int]:
|
|
314
|
+
return (0,)
|
|
315
|
+
|
|
316
|
+
def spectrum_size(self):
|
|
317
|
+
return self.spectro.spectrum_size
|
|
318
|
+
|
|
319
|
+
def get_stats_names(self) -> list[str]:
|
|
320
|
+
return []
|
|
321
|
+
|
|
322
|
+
def get_supported_spectrum_sizes(self) -> list[int]:
|
|
323
|
+
return [self.spectro.spectrum_size]
|
|
324
|
+
|
|
325
|
+
def get_supported_trigger_modes(self) -> list[GateMode]:
|
|
326
|
+
return [TriggerMode.INT_TRIG_READOUT, TriggerMode.GATE, TriggerMode.EXT_TRIG_READOUT]
|
|
327
|
+
|
|
328
|
+
# TOODO: need more tests with the hardware to validate this
|
|
329
|
+
# def get_supported_gate_modes(self) -> list[GateMode]:
|
|
330
|
+
# return [GateMode.IGNORE, GateMode.HIGH]
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class OOPoller:
|
|
334
|
+
def __init__(self, device, n_points, block_size):
|
|
335
|
+
self._device = device
|
|
336
|
+
self._spectrum_size = device.spectrum_size
|
|
337
|
+
self._n_read = 0
|
|
338
|
+
self._n_triggered = 0
|
|
339
|
+
self._n_points = n_points
|
|
340
|
+
self._block_size = block_size
|
|
341
|
+
self._stop = False
|
|
342
|
+
self._finished = False
|
|
343
|
+
|
|
344
|
+
def stop(self):
|
|
345
|
+
logger.info("Poller: stop requested.")
|
|
346
|
+
self._stop = True
|
|
347
|
+
|
|
348
|
+
def is_running(self):
|
|
349
|
+
return not self._finished
|
|
350
|
+
|
|
351
|
+
def __call__(self):
|
|
352
|
+
n_points = self._n_points
|
|
353
|
+
device = self._device
|
|
354
|
+
finished = False
|
|
355
|
+
n_read = 0
|
|
356
|
+
spectra = None
|
|
357
|
+
stop = self._stop
|
|
358
|
+
|
|
359
|
+
if self._finished:
|
|
360
|
+
finished = True
|
|
361
|
+
# TODO: raise instead?
|
|
362
|
+
else:
|
|
363
|
+
num_elem = device.number_of_elements
|
|
364
|
+
self._n_triggered = self._n_read + num_elem
|
|
365
|
+
|
|
366
|
+
if num_elem > 0:
|
|
367
|
+
if n_points > 0:
|
|
368
|
+
n_read = min(self._block_size, num_elem, n_points - self._n_read)
|
|
369
|
+
else:
|
|
370
|
+
n_read = min(self._block_size, num_elem)
|
|
371
|
+
|
|
372
|
+
if n_read > 0:
|
|
373
|
+
self._n_read += n_read
|
|
374
|
+
finished = self._n_read == self._n_points
|
|
375
|
+
spectra = device.get_intensities(n_points=n_read).reshape(1, -1, self._spectrum_size)
|
|
376
|
+
|
|
377
|
+
self._finished = finished or stop
|
|
378
|
+
return PollResult(finished=self._finished, n_read=n_read,
|
|
379
|
+
spectra=spectra, total_triggered=self._n_triggered)
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .simdante import SimDante, SIMDANTE_DEVINFO
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
logger = logging.getLogger(__name__)
|
|
3
|
+
|
|
4
|
+
from tango.server import run, device_property, command, attribute
|
|
5
|
+
from ....tango import TangoDevInfo
|
|
6
|
+
from ...xglab.dante import Dante as DDS
|
|
7
|
+
from .simdantehw import SimDanteHW
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SimDante(DDS):
|
|
11
|
+
def _create_control(self):
|
|
12
|
+
control = SimDanteHW(
|
|
13
|
+
self.address,
|
|
14
|
+
False,
|
|
15
|
+
self.config_dir,
|
|
16
|
+
keepalive_period=self.keepalive_period,
|
|
17
|
+
max_init_time=self.max_init_time
|
|
18
|
+
)
|
|
19
|
+
logger.warning(
|
|
20
|
+
"=========================\n"
|
|
21
|
+
"==== USING SIMULATOR ====\n"
|
|
22
|
+
"=========================\n"
|
|
23
|
+
)
|
|
24
|
+
# from .simdantehw import XGL_DPP as SimXGL
|
|
25
|
+
# control.comm._xgl = SimXGL
|
|
26
|
+
return control
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
SIMDANTE_DEVINFO = TangoDevInfo(
|
|
30
|
+
klass=SimDante,
|
|
31
|
+
properties={"config_dir": "c:/blissadm/dante/config",
|
|
32
|
+
"config_file": "config.hdf",
|
|
33
|
+
"address": ""})
|