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.
Files changed (73) hide show
  1. mosca/__init__.py +11 -0
  2. mosca/common/__init__.py +9 -0
  3. mosca/common/enums.py +79 -0
  4. mosca/common/logger.py +139 -0
  5. mosca/common/threads.py +199 -0
  6. mosca/common/utils.py +70 -0
  7. mosca/control/__init__.py +4 -0
  8. mosca/control/buffer.py +526 -0
  9. mosca/control/controller.py +278 -0
  10. mosca/control/datahandler.py +261 -0
  11. mosca/control/detectors.py +116 -0
  12. mosca/control/mosca.py +693 -0
  13. mosca/control/spectra.py +36 -0
  14. mosca/control/stats.py +43 -0
  15. mosca/control/tasks/__init__.py +3 -0
  16. mosca/control/tasks/background.py +118 -0
  17. mosca/control/tasks/rois.py +466 -0
  18. mosca/control/tasks/saving.py +391 -0
  19. mosca/control/tasks/spectrasums.py +185 -0
  20. mosca/control/tasks/task.py +201 -0
  21. mosca/control/tasks/taskmanager.py +133 -0
  22. mosca/devices/__init__.py +28 -0
  23. mosca/devices/hamamatsu/__init__.py +0 -0
  24. mosca/devices/hamamatsu/hamamatsu.py +88 -0
  25. mosca/devices/hamamatsu/hamamatsuhw.py +1298 -0
  26. mosca/devices/oceanoptics/__init__.py +0 -0
  27. mosca/devices/oceanoptics/oceanoptics.py +59 -0
  28. mosca/devices/oceanoptics/oceanopticshw.py +379 -0
  29. mosca/devices/simulation/__init__.py +0 -0
  30. mosca/devices/simulation/dante/__init__.py +1 -0
  31. mosca/devices/simulation/dante/simdante.py +33 -0
  32. mosca/devices/simulation/dante/simdantehw.py +506 -0
  33. mosca/devices/simulation/dummy/__init__.py +1 -0
  34. mosca/devices/simulation/dummy/dummy.py +299 -0
  35. mosca/devices/simulation/generator.py +607 -0
  36. mosca/devices/simulation/xia/__init__.py +1 -0
  37. mosca/devices/simulation/xia/iniparser.py +99 -0
  38. mosca/devices/simulation/xia/simfalconx.py +26 -0
  39. mosca/devices/simulation/xia/simfalconxhw.py +599 -0
  40. mosca/devices/xglab/__init__.py +0 -0
  41. mosca/devices/xglab/dante.py +126 -0
  42. mosca/devices/xglab/dantehw.py +1178 -0
  43. mosca/devices/xia/__init__.py +0 -0
  44. mosca/devices/xia/falconx.py +232 -0
  45. mosca/devices/xia/handel/__init__.py +14 -0
  46. mosca/devices/xia/handel/_cffi.py +62 -0
  47. mosca/devices/xia/handel/error.py +272 -0
  48. mosca/devices/xia/handel/handel_inc/handel_constants.h +127 -0
  49. mosca/devices/xia/handel/handel_inc/handel_errors.h +254 -0
  50. mosca/devices/xia/handel/handel_inc/handel_generic.h +66 -0
  51. mosca/devices/xia/handel/interface.py +1025 -0
  52. mosca/devices/xia/handel/mapping.py +107 -0
  53. mosca/devices/xia/handel/parser.py +62 -0
  54. mosca/devices/xia/handel/stats.py +85 -0
  55. mosca/devices/xia/mercury.py +160 -0
  56. mosca/devices/xia/utils.py +47 -0
  57. mosca/devices/xia/xia.py +575 -0
  58. mosca/devices/xia/xiads.py +161 -0
  59. mosca/mosca.py +0 -0
  60. mosca/tango/__init__.py +2 -0
  61. mosca/tango/controller.py +80 -0
  62. mosca/tango/main.py +163 -0
  63. mosca/tango/mosca.py +513 -0
  64. mosca/tango/moscav1.py +408 -0
  65. mosca/tango/shared.py +23 -0
  66. mosca/tango/tasks/__init__.py +0 -0
  67. mosca/tango/tasks/background.py +55 -0
  68. mosca/tango/utils.py +109 -0
  69. mosca-2.0.2.dist-info/METADATA +32 -0
  70. mosca-2.0.2.dist-info/RECORD +73 -0
  71. mosca-2.0.2.dist-info/WHEEL +4 -0
  72. mosca-2.0.2.dist-info/entry_points.txt +2 -0
  73. mosca-2.0.2.dist-info/licenses/LICENSE +166 -0
mosca/tango/moscav1.py ADDED
@@ -0,0 +1,408 @@
1
+ import re
2
+ import logging
3
+ logger = logging.getLogger(__name__)
4
+
5
+
6
+ from ruamel.yaml import YAML
7
+ import tango
8
+ from tango import DevState, DevError
9
+ from tango.server import Device, command, attribute
10
+
11
+ from ..control.datahandler import SPECTRA_DTYPE, STATS_DTYPE, ROIS_DTYPE, SPECTRASUM_DTYPE
12
+ from ..common import Status, TriggerMode, GateMode
13
+ from .shared import get_controller, get_mosca
14
+ from .utils import get_device_instance, get_server_name
15
+
16
+ # class Status(enum.Enum):
17
+ # UNKNOWN = enum.auto()
18
+ # IDLE = enum.auto()
19
+ # RUNNING = enum.auto()
20
+ # ERROR = enum.auto()
21
+
22
+ # TODO:
23
+ MAGIC_NUMBER = 0x02
24
+
25
+
26
+ class MoscaV1(Device):
27
+ """
28
+ MOSCA Tango device server.
29
+ """
30
+
31
+ _lazy_init = False
32
+
33
+ multichannel = attribute(lambda self: True, dtype=bool)
34
+
35
+ timeout_start = attribute(lambda self: self._mosca_ds.timeout_start, dtype=float)
36
+ timeout_stop = attribute(lambda self: self._mosca_ds.timeout_stop, dtype=float)
37
+ timeout_setup = attribute(lambda self: self._mosca_ds.timeout_setup, dtype=float)
38
+ timeout_prepare = attribute(lambda self: self._mosca_ds.timeout_prepare, dtype=float)
39
+
40
+ def __init__(self, *args, **kwargs):
41
+ logger.info("Mosca __init__")
42
+ self._controller = None
43
+ self._mca_ds = None
44
+ self._mosca = None
45
+ self._mosca_ds = None
46
+ self._preset_value = None
47
+ self._preset_mode = None
48
+ Device.__init__(self, *args, **kwargs)
49
+
50
+ def init_device(self):
51
+ logger.info("in init_device() (lazy=%s)", self._lazy_init)
52
+ try:
53
+ Device.init_device(self)
54
+ if not self._lazy_init:
55
+ _ = self.mosca_ds
56
+ _ = self.mosca
57
+ _ = self.mca_ds
58
+ _ = self.controller
59
+ self.set_state(DevState.ON)
60
+ except:
61
+ self.set_state(DevState.FAULT)
62
+ logger.error("Failed init.")
63
+ raise
64
+ logger.info("out init_device()")
65
+
66
+ @property
67
+ def mosca(self):
68
+ if self._mosca is None:
69
+ self._mosca = get_mosca()
70
+ return self._mosca
71
+
72
+ @property
73
+ def mosca_ds(self):
74
+ if self._mosca_ds is None:
75
+ self._mosca_ds = get_device_instance("Mosca")
76
+ return self._mosca_ds
77
+
78
+ @attribute(dtype=str)
79
+ def mosca_name(self):
80
+ return self.mosca_ds.name()
81
+
82
+ @property
83
+ def mca_ds(self):
84
+ if self._mca_ds is None:
85
+ self._mca_ds = tango.DeviceProxy(self.mosca_ds.controller_name)
86
+ return self._mca_ds
87
+
88
+ @property
89
+ def controller(self):
90
+ if self._controller is None:
91
+ self._controller = self.mosca.controller#get_controller(self.mca_ds.name())
92
+ return self._controller
93
+
94
+ @attribute(dtype=str)
95
+ def controller_name(self):
96
+ return self.mca_ds.name()
97
+
98
+ @attribute(dtype=str)
99
+ def detector_name(self):
100
+ metadata = self.mosca_ds.metadata()
101
+ md_dict = YAML().load(metadata)
102
+ return md_dict.get("tango", {}).get("name", "unknown")
103
+
104
+ @attribute(dtype=str)
105
+ def detector_model(self):
106
+ metadata = self.mosca_ds.metadata()
107
+ md_dict = YAML().load(metadata)
108
+ return md_dict.get("tango", {}).get("mca_type", "unknown")
109
+
110
+ @attribute(dtype=int)
111
+ def number_channels(self):
112
+ return len(self.mosca.detectors.detectors)
113
+
114
+ @attribute(dtype=int)
115
+ def spectrum_size(self):
116
+ return self.mosca.spectrum_size
117
+
118
+ @spectrum_size.write
119
+ def spectrum_size(self, spectrum_size):
120
+ self.mosca.spectrum_size = spectrum_size
121
+
122
+ @attribute(dtype=[str], max_dim_x=100)
123
+ def metadata_labels(self):
124
+ return self.mosca.stats_names
125
+
126
+ @attribute(dtype=int)
127
+ def number_points(self):
128
+ return self.mosca.acq_nb_points
129
+
130
+ @number_points.write
131
+ def number_points(self, number_points):
132
+ self.mosca.acq_nb_points = number_points
133
+
134
+ @attribute(dtype=float)
135
+ def preset_value(self):
136
+ # WARNING! MoscaV1 only supports two preset modes:
137
+ # REALTIME and NONE
138
+ # Don't forget to manage preset_value if you add any
139
+ # of the other modes.
140
+ return self.mosca.acq_realtime * 1000.
141
+
142
+ @preset_value.write
143
+ def preset_value(self, preset_value):
144
+ # WARNING! MoscaV1 only supports two preset modes:
145
+ # REALTIME and NONE
146
+ # Don't forget to manage preset_value if you add any
147
+ # of the other modes.
148
+ self.mosca.acq_realtime = preset_value / 1000.
149
+
150
+ @attribute(dtype=str)
151
+ def trigger_mode(self):
152
+ trigger_mode = self.mosca.trigger_mode
153
+ if trigger_mode == TriggerMode.GATE:
154
+ return "GATE"
155
+ elif trigger_mode == TriggerMode.EXT_TRIG:
156
+ return "SYNC"
157
+ return "SOFTWARE"
158
+
159
+ @trigger_mode.write
160
+ def trigger_mode(self, trigger_mode):
161
+ # This isn't the way it should be done,
162
+ # but this is the way Mosca V1 was designed, so...
163
+ # gate mode and trigger mode should be set separately,
164
+ # like it's done in Mosca V2.
165
+ logger.info("trigger_mode called with %s.", trigger_mode)
166
+ gate_mode = self.mosca.gate_mode
167
+
168
+ if trigger_mode == "SOFTWARE":
169
+ trigger_mode = TriggerMode.INT_TRIG_READOUT
170
+ gate_mode = GateMode.IGNORE
171
+ elif trigger_mode == "GATE":
172
+ trigger_mode = TriggerMode.GATE
173
+ gate_mode = GateMode.HIGH
174
+ elif trigger_mode == "SYNC":
175
+ trigger_mode = TriggerMode.EXT_TRIG
176
+ gate_mode = GateMode.HIGH
177
+ else:
178
+ raise ValueError(f"Unknown trigger_mode: {trigger_mode}.")
179
+
180
+ logger.info("trigger_mode to mosca: trig=%s, gate=%s", trigger_mode, gate_mode)
181
+ self.mosca.trigger_mode = trigger_mode
182
+ self.mosca.gate_mode = gate_mode
183
+
184
+ @attribute(dtype=str)
185
+ def preset_mode(self):
186
+ if self.mosca.trigger_mode == TriggerMode.INT_TRIG_READOUT:
187
+ return "REALTIME"
188
+ return "NONE"
189
+
190
+ @preset_mode.write
191
+ def preset_mode(self, preset_mode):
192
+ # WARNING! MoscaV1 only supports two preset modes:
193
+ # REALTIME and NONE
194
+ # Don't forget to manage preset_value if you add any
195
+ # of the other modes.
196
+ preset_mode = preset_mode.casefold()
197
+ if preset_mode =="none":
198
+ pass
199
+ elif preset_mode =="realtime":
200
+ self.mosca.trigger_mode = TriggerMode.INT_TRIG_READOUT
201
+ else:
202
+ raise NotImplementedError(f"Unsupported preset_mode: {preset_mode}.")
203
+
204
+ # @attribute(dtype=int)
205
+ # def block_size(self):
206
+ # return self.mosca.block_size
207
+
208
+ # @block_size.write
209
+ # def block_size(self, block_size):
210
+ # self.mosca.block_size = block_size
211
+
212
+ @command
213
+ def prepareAcq(self):
214
+ self.mosca.apply_mosca()
215
+ self.mosca.prepare()
216
+
217
+ @command
218
+ def startAcq(self):
219
+ # for consistency with mosca v2
220
+ mca_status = self.controller.mca_status()
221
+ if mca_status != Status.READY:
222
+ raise RuntimeError(f"Can't call startAcq while MCA state is {mca_status.name}.")
223
+ # self.mosca.data.prepare()
224
+ self.mosca.prepare()
225
+ self.mosca.start_acq()
226
+
227
+ @command
228
+ def stopAcq(self):
229
+ self.mosca.stop_acq()
230
+
231
+ @command(dtype_in=[int], dtype_out=[SPECTRA_DTYPE])
232
+ def getData(self, args):
233
+ # we get an error when array exceed 2**26-30 elements.
234
+ first, last = args
235
+ data = self.mosca.data.spectra.flatten[first:last + 1]
236
+ return data
237
+
238
+ @command(dtype_in=[int], dtype_out=[ROIS_DTYPE])
239
+ def getCounterValues(self, args):
240
+ first, last = args
241
+ # "[first:last]" is not consistent with getData
242
+ # but this can't be fixed because we have to keep
243
+ # compatibility with the client.
244
+ # This is not a bug per se, it must be kept like
245
+ # that for historical reasons.
246
+ return self.mosca.data.rois.flatten[first:last]
247
+
248
+ @command(dtype_in=[int], dtype_out=[STATS_DTYPE])
249
+ def getMetadataValues(self, args):
250
+ first, last = args
251
+ return self.mosca.data.stats.flatten[first:last + 1]
252
+
253
+ @command(dtype_in=None, dtype_out=[int])
254
+ def getAcqStatus(self):
255
+ status = self.mosca.status
256
+ if status == Status.RUNNING:
257
+ status = 1
258
+ elif status in (Status.PREPARED, Status.READY):
259
+ status = 0
260
+ else:
261
+ status = 2
262
+
263
+ data = self.mosca.data
264
+ n_read_pix = data.n_available_points
265
+ n_acq_pix = self.mosca.n_triggered_points
266
+ n_saved_pix = 0
267
+
268
+ return [status, n_read_pix, n_saved_pix, n_acq_pix]
269
+
270
+ @command(dtype_in=[str])
271
+ def addCounter(self, args):
272
+ rois = self.mosca.data.rois
273
+ roi_name, channel, start, stop = args[0:4]
274
+
275
+ start = int(start)
276
+ stop = int(stop)
277
+
278
+ # matches:
279
+ # -1 OR m-n OR m
280
+ # but not:
281
+ # -m-n OR -m with m != 1
282
+ match = re.match(r"^(?P<det0>[0-9]+|\-1)((?<!\-1)\-(?P<det1>(?<!\-1)[0-9]+))*$",
283
+ channel)
284
+
285
+ if not match:
286
+ raise RuntimeError(f"Invalid channel definition: {channel}.")
287
+
288
+ gdict = match.groupdict()
289
+ det0 = gdict["det0"]
290
+ det1 = gdict["det1"]
291
+
292
+ det0 = int(det0)
293
+
294
+ if det0 == -1:
295
+ rois.add_roi_sum(roi_name,
296
+ start,
297
+ stop)
298
+ elif det1 is not None:
299
+ det1 = int(det1)
300
+ detectors = list(range(det0, det1 + 1))
301
+ rois.add_roi_sum(roi_name,
302
+ start,
303
+ stop,
304
+ *detectors)
305
+ else:
306
+ rois.add_roi(roi_name,
307
+ start,
308
+ stop,
309
+ int(channel))
310
+
311
+ @command
312
+ def resetCounters(self):
313
+ self.mosca.data.rois.clear_definitions()
314
+
315
+ # @command(dtype_in=[str])
316
+ # def addSpectraSum(self, args):
317
+ # sums = self.mosca.data.spectra_sums
318
+ # sums_name = args[0]
319
+ # detectors = [int(arg) for arg in args[1:]]
320
+ # sums.add_sum(name=sums_name,
321
+ # detectors=detectors)
322
+
323
+ # @command(dtype_in=[int], dtype_out=[SPECTRASUM_DTYPE])
324
+ # def getSpectraSums(self, args):
325
+ # first = 0
326
+ # last = None
327
+ # try:
328
+ # first = args[0]
329
+ # last = args[1]
330
+ # except IndexError:
331
+ # pass
332
+ # return self.mosca.data.spectra_sums.flatten[first:last]
333
+
334
+ ##############
335
+ # XIA specific
336
+ ##############
337
+
338
+ @command(dtype_out=[str])
339
+ def DevXiaGetConfigList(self):
340
+ return self.mca_ds.available_ini_files()
341
+
342
+
343
+ @attribute(dtype=str)
344
+ def config_path(self):
345
+ return self.mca_ds.ini_dir
346
+
347
+ @config_path.write
348
+ def config_path(self, config_path):
349
+ self.mca_ds.ini_dir = config_path
350
+
351
+ @attribute(dtype=str)
352
+ def config(self):
353
+ return self.mca_ds.ini_file
354
+
355
+ @config.write
356
+ def config(self, config):
357
+ self.mca_ds.set_timeout_millis(20000)
358
+ self.mca_ds.ini_file = config
359
+
360
+ @attribute(dtype=str)
361
+ def detector_mode(self):
362
+ if self.mosca.trigger_mode in (TriggerMode.FREERUN, TriggerMode.INT_TRIG_READOUT):
363
+ return "MCA"
364
+ return "MAP"
365
+
366
+ # @detector_mode.write
367
+ # def detector_mode(self, detector_mode):
368
+ # logger.info("Setting detector mode to %s.", detector_mode)
369
+ # detector_mode = detector_mode.lower()
370
+ # if detector_mode == "MCA":
371
+ # self.mosca.run_mode = RunModes.REALTIME
372
+ # # self.mosca.gate_mode = GateMode.HIGH
373
+ # self.mosca.stop_trigger = ControlTriggers.NONE
374
+ # elif detector_mode == "MAP":
375
+ # self.mosca.run_mode = RunModes.REALTIME
376
+ # self.mosca.gate_mode = GateMode.HIGH
377
+ # self.mosca.stop_trigger = ControlTriggers.FALLING
378
+ # else:
379
+ # raise NotImplementedError(
380
+ # f"detector_mode not implemented: {detector_mode}")
381
+
382
+ @attribute(dtype=[str], max_dim_x=100)
383
+ def channels_module_and_index(self):
384
+ raise NotImplementedError
385
+
386
+ # @channels_module_and_index.write
387
+ # def channels_module_and_index(self, channels_module_and_index):
388
+ # raise NotImplementedError
389
+
390
+ @attribute(dtype=float)
391
+ def refresh_rate(self):
392
+ return self.controller.mca_refresh
393
+
394
+ @refresh_rate.write
395
+ def refresh_rate(self, refresh_rate):
396
+ self.controller.mca_refresh = refresh_rate
397
+
398
+ @attribute(dtype=[int], max_dim_x=100)
399
+ def channels_alias(self):
400
+ return self.mosca.detectors.detectors
401
+
402
+ @attribute(dtype=int)
403
+ def map_pixels_per_buffer(self):
404
+ return self.mosca.block_size
405
+
406
+ @map_pixels_per_buffer.write
407
+ def map_pixels_per_buffer(self, map_pixels_per_buffer):
408
+ self.mosca.block_size = map_pixels_per_buffer
mosca/tango/shared.py ADDED
@@ -0,0 +1,23 @@
1
+ _CONTROLLER = None
2
+ _MOSCA = None
3
+
4
+ def _set_controller(controller):
5
+ global _CONTROLLER
6
+ if _CONTROLLER is not None:
7
+ raise RuntimeError("Controller instance already set.")
8
+ _CONTROLLER = controller
9
+
10
+
11
+ def get_controller():
12
+ return _CONTROLLER
13
+
14
+
15
+ def _set_mosca(mosca):
16
+ # TODO: weakref?
17
+ global _MOSCA
18
+ if _MOSCA is not None:
19
+ raise RuntimeError("Mosca instance already set.")
20
+ _MOSCA = mosca
21
+
22
+ def get_mosca():
23
+ return _MOSCA
File without changes
@@ -0,0 +1,55 @@
1
+ import logging
2
+ logger = logging.getLogger(__name__)
3
+
4
+ from tango.server import Device, command, attribute
5
+
6
+ from ..shared import get_mosca
7
+
8
+
9
+ # Do better
10
+ from mosca.control.datahandler import SPECTRA_DTYPE, STATS_DTYPE
11
+
12
+
13
+ class Background(Device):
14
+ """ MOSCA Tango device server. Wraps the Mosca instance. """
15
+
16
+ def __init__(self, *args, **kwargs):
17
+ self._mosca = None
18
+ self._background_task = None
19
+ Device.__init__(self, *args, **kwargs)
20
+
21
+ @property
22
+ def mosca(self):
23
+ if self._mosca is None:
24
+ self._mosca = get_mosca()
25
+ return self._mosca
26
+
27
+ @property
28
+ def background_task(self):
29
+ if self._background_task is None:
30
+ self._background_task = self.mosca.data.get_task("background")
31
+ return self._background_task
32
+
33
+ @command
34
+ def store_background(self):
35
+ self.background_task.store_background()
36
+
37
+ @attribute(dtype=bool)
38
+ def is_background_applied(self):
39
+ return self.background_task.is_background_applied
40
+
41
+ @is_background_applied.write
42
+ def is_background_applied(self, applied):
43
+ self.background_task.is_background_applied = applied
44
+
45
+ @command(dtype_out=[SPECTRA_DTYPE])
46
+ def background_spectra(self):
47
+ return self.background_task.background_spectra()
48
+
49
+ @command(dtype_out=[STATS_DTYPE])
50
+ def background_stats(self):
51
+ return self.background_task.background_stats()
52
+
53
+ @command(dtype_out=[int])
54
+ def background_detectors(self):
55
+ return list(self.background_task.background_detectors())
mosca/tango/utils.py ADDED
@@ -0,0 +1,109 @@
1
+ import logging
2
+ logger = logging.getLogger(__name__)
3
+
4
+ import sys
5
+ import tango
6
+ import typing
7
+ import argparse
8
+
9
+
10
+ def _import(name):
11
+ __import__(name)
12
+ return sys.modules[name]
13
+
14
+
15
+ class TangoDevInfo(typing.NamedTuple):
16
+ klass: str
17
+ properties: typing.Optional[dict] = {}
18
+
19
+
20
+ def get_device_instance(klass_name):
21
+ util = tango.Util.instance()
22
+ class_dict = {c.get_name().casefold():c for c in util.get_class_list()}
23
+ klass = class_dict[klass_name.casefold()]
24
+ return tango.DeviceProxy(util.get_device_list_by_class(klass.get_name())[0].get_name())
25
+
26
+
27
+ def get_server_name():
28
+ return tango.Util.instance().get_ds_name()
29
+
30
+
31
+ def get_device_class_dict(server_instance):
32
+ db = tango.Database()
33
+ class_list = db.get_device_class_list(server_instance)
34
+ class_dict = {n.casefold():c for (n, c) in zip(class_list[1::2], class_list[::2])}
35
+ return class_dict
36
+
37
+
38
+ def register_device(instance, prefix, mca_type, overwrite=False):
39
+ from ..devices import get_tango_classinfo
40
+
41
+ tg_info = get_tango_classinfo(mca_type)
42
+
43
+ mca_type = mca_type.lower()
44
+
45
+ server_name = f"Mosca/{instance}"
46
+ mosca_name = f"{prefix}/mosca/{instance}"
47
+ moscav1_name = f"{prefix}/moscav1/{instance}"
48
+
49
+ klass_name = tg_info.klass.__name__
50
+ mca_name = f"{prefix}/{mca_type}/{instance}"
51
+
52
+ db = tango.Database()
53
+
54
+ if not overwrite:
55
+ try:
56
+ _ = tango.DeviceProxy(mosca_name)
57
+ print(f"Device {mosca_name} already exists!")
58
+ return
59
+ except tango.DevFailed:
60
+ # OK
61
+ pass
62
+
63
+ try:
64
+ _ = tango.DeviceProxy(moscav1_name)
65
+ print(f"Device {moscav1_name} already exists!")
66
+ return
67
+ except tango.DevFailed:
68
+ # OK
69
+ pass
70
+
71
+ try:
72
+ _ = tango.DeviceProxy(mca_name)
73
+ print(f"Device {mca_name} already exists!")
74
+ return
75
+ except tango.DevFailed:
76
+ # OK
77
+ pass
78
+
79
+ # Mosca
80
+ dbi = tango.DbDevInfo()
81
+ dbi.name = mosca_name
82
+ dbi._class = "Mosca"
83
+ dbi.server = server_name
84
+ db.add_device(dbi)
85
+ mosca = tango.DeviceProxy(mosca_name)
86
+ mosca.put_property({"mca_type": mca_type})
87
+
88
+ # MoscaV1
89
+ dbi = tango.DbDevInfo()
90
+ dbi.name = moscav1_name
91
+ dbi._class = "MoscaV1"
92
+ dbi.server = server_name
93
+ db.add_device(dbi)
94
+
95
+ # MCA
96
+ dbi = tango.DbDevInfo()
97
+ dbi.name = mca_name
98
+ dbi._class = klass_name
99
+ dbi.server = server_name
100
+ db.add_device(dbi)
101
+ props = tg_info.properties
102
+ if props:
103
+ mca = tango.DeviceProxy(mca_name)
104
+ mca.put_property(props)
105
+
106
+ # for key, value in props:
107
+ print(f"Added the following properties to {mca_name}:")
108
+ print(" - " + "\n - ".join([f"{key} = {value or '?'}" for key, value in props.items() ]))
109
+ print("You will probably need to edit them.")
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.5
2
+ Name: mosca
3
+ Version: 2.0.2
4
+ Summary: A library for the unified control of MCA detectors
5
+ Project-URL: Homepage, https://gitlab.esrf.fr/bliss/mosca
6
+ Project-URL: Bug Tracker, https://gitlab.esrf.fr/bliss/mosca/issues
7
+ Author-email: BCU Team <bliss@esrf.fr>
8
+ License-File: LICENSE
9
+ Keywords: ESRF,MCA
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: <3.13,>=3.9
16
+ Requires-Dist: cffi
17
+ Requires-Dist: h5py
18
+ Requires-Dist: hdf5plugin
19
+ Requires-Dist: lark
20
+ Requires-Dist: numpy
21
+ Requires-Dist: pytango
22
+ Requires-Dist: ruamel-yaml
23
+ Description-Content-Type: text/x-rst
24
+
25
+ Mosca 2
26
+
27
+ Documentation: https://bliss.gitlab-pages.esrf.fr/mosca/
28
+
29
+ Tests coverage: https://bliss.gitlab-pages.esrf.fr/mosca/htmlcov/
30
+
31
+ .. image:: https://gitlab.esrf.fr/bliss/mosca/badges/11-split-mosca-ds-and-hardware-specific-ds/coverage.svg
32
+