mosca 2.0.7__tar.gz → 2.0.8__tar.gz
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-2.0.7 → mosca-2.0.8}/PKG-INFO +1 -1
- {mosca-2.0.7 → mosca-2.0.8}/pyproject.toml +2 -3
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/xia/simfalconxhw.py +19 -3
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/_cffi.py +1 -1
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/interface.py +33 -10
- {mosca-2.0.7 → mosca-2.0.8}/.gitignore +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/LICENSE +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/README.rst +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/common/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/common/enums.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/common/logger.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/common/threads.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/common/utils.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/buffer.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/controller.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/datahandler.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/detectors.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/mosca.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/shared.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/spectra.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/stats.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/tasks/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/tasks/background.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/tasks/rois.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/tasks/saving.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/tasks/task.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/control/tasks/taskmanager.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/hamamatsu/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/hamamatsu/hamamatsu.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/hamamatsu/hamamatsuhw.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/oceanoptics/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/oceanoptics/oceanoptics.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/oceanoptics/oceanopticshw.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/dante/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/dante/simdante.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/dante/simdantehw.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/dummy/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/dummy/dummy.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/generator.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/xia/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/xia/iniparser.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/simulation/xia/simfalconx.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xglab/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xglab/dante.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xglab/dantehw.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/falconx.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/error.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/handel_inc/handel_constants.h +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/handel_inc/handel_errors.h +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/handel_inc/handel_generic.h +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/mapping.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/handel/stats.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/mercury.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/xia.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/xiads.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/devices/xia/xmap.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/mosca.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/devices.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/main.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/mosca.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/server.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/tasks/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/tasks/background.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/tasks/saving.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/rpc/utils.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/controller.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/main.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/mosca.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/moscav1.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/tasks/__init__.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/tasks/background.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/tasks/saving.py +0 -0
- {mosca-2.0.7 → mosca-2.0.8}/src/mosca/tango/utils.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mosca"
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.8"
|
|
8
8
|
description = "A library for the unified control of MCA detectors"
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
authors = [
|
|
@@ -150,8 +150,7 @@ flint = { git = "https://gitlab.esrf.fr/bliss/bliss.git", branch="4921-mosca-cli
|
|
|
150
150
|
#s3fs = "*"
|
|
151
151
|
|
|
152
152
|
[tool.pixi.feature.blisswriter.pypi-dependencies]
|
|
153
|
-
blisswriter = {
|
|
154
|
-
#blisswriter = { version = "*", extras = ["tango"] }
|
|
153
|
+
blisswriter = { version = "*", extras = ["tango"] }
|
|
155
154
|
mosca_client = { path = "packages/mosca_client", editable = true }
|
|
156
155
|
blissdata_mosca = { path = "packages/blissdata_mosca", editable = true }
|
|
157
156
|
|
|
@@ -20,6 +20,8 @@ ffi = cffi.FFI()
|
|
|
20
20
|
|
|
21
21
|
class XIA_CODES:
|
|
22
22
|
XIA_SUCCESS = 0
|
|
23
|
+
XIA_NULL_ALIAS = 326
|
|
24
|
+
XIA_INVALID_DETCHAN = 316
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
def map_buffer(
|
|
@@ -248,7 +250,6 @@ class XiaDataGenerator(DataGenerator):
|
|
|
248
250
|
# https://numpy.org/doc/stable/user/basics.types.html
|
|
249
251
|
CTYPES2NP = {
|
|
250
252
|
"char *": np.byte,
|
|
251
|
-
"char[]": np.byte,
|
|
252
253
|
"short *": np.short,
|
|
253
254
|
"unsigned short *": np.ushort,
|
|
254
255
|
"int16_t *": np.int16,
|
|
@@ -266,8 +267,9 @@ def value_to_cffi(dst, src, desc, repointer=False):
|
|
|
266
267
|
# expecting np array if src is an array
|
|
267
268
|
|
|
268
269
|
v_type = ffi.typeof(dst).cname
|
|
269
|
-
if v_type
|
|
270
|
-
|
|
270
|
+
if v_type.endswith("[]"):
|
|
271
|
+
# arrays allocated with ffi.new("T[]", n): same as "T *"
|
|
272
|
+
v_type = v_type[:-2] + " *"
|
|
271
273
|
|
|
272
274
|
try:
|
|
273
275
|
dtype = CTYPES2NP[v_type]
|
|
@@ -354,6 +356,20 @@ class Handel:
|
|
|
354
356
|
arg[i][0:len(mod)] = mod
|
|
355
357
|
return XIA_CODES.XIA_SUCCESS
|
|
356
358
|
|
|
359
|
+
def xiaModuleFromDetChan(self, detChan, alias):
|
|
360
|
+
# Same as handel: alias of the module owning detChan
|
|
361
|
+
# (channelN_alias in the ini file).
|
|
362
|
+
if alias == ffi.NULL:
|
|
363
|
+
return XIA_CODES.XIA_NULL_ALIAS
|
|
364
|
+
for module in self._hardware.modules.values():
|
|
365
|
+
for ichan in range(module["number_of_channels"]):
|
|
366
|
+
if module[f"channel{ichan}_alias"] == detChan:
|
|
367
|
+
mod_alias = module["alias"].encode()
|
|
368
|
+
alias[0 : len(mod_alias)] = mod_alias
|
|
369
|
+
alias[len(mod_alias)] = b"\0"
|
|
370
|
+
return XIA_CODES.XIA_SUCCESS
|
|
371
|
+
return XIA_CODES.XIA_INVALID_DETCHAN
|
|
372
|
+
|
|
357
373
|
def xiaGetModuleItem(self, modalias, item, value):
|
|
358
374
|
module = self._hardware.module(modalias.decode())
|
|
359
375
|
item_value = module[item.decode()]
|
|
@@ -76,7 +76,11 @@ __all__ = [
|
|
|
76
76
|
"get_handel_version",
|
|
77
77
|
]
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
# Size of the string buffers handed to Handel. Handel's own limit is
|
|
80
|
+
# MAXALIAS_LEN / MAXITEM_LEN = 200 (handel_generic.h), and xiaModuleFromDetChan
|
|
81
|
+
# always writes that many bytes (strncpy pads with zeros): a smaller buffer is
|
|
82
|
+
# overrun on every call ("free(): invalid size").
|
|
83
|
+
MAX_STRING_LENGTH = 200
|
|
80
84
|
|
|
81
85
|
LOGGER = logging.getLogger("HANDEL")
|
|
82
86
|
|
|
@@ -211,13 +215,33 @@ def get_spectrum_length(channel):
|
|
|
211
215
|
return length[0]
|
|
212
216
|
|
|
213
217
|
|
|
218
|
+
def _run_data_word_type(channel):
|
|
219
|
+
"""C element type Handel uses for array run data ("mca", "buffer_a/b").
|
|
220
|
+
|
|
221
|
+
The xerxes-based products (Mercury, xMAP) write `unsigned long` (4 bytes
|
|
222
|
+
on Windows, 8 bytes on 64-bit Linux); FalconX writes `uint32_t`.
|
|
223
|
+
Allocating uint32 for an `unsigned long` array lets Handel write past its
|
|
224
|
+
end on Linux (heap corruption, "free(): invalid size").
|
|
225
|
+
"""
|
|
226
|
+
if get_module_type(get_module_from_channel(channel)).startswith("falconx"):
|
|
227
|
+
return "uint32_t"
|
|
228
|
+
return "unsigned long"
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def _read_word_array(channel, name, length):
|
|
232
|
+
"""xiaGetRunData for an array run data item of `length` words,
|
|
233
|
+
returned as uint32 (all values fit in 32 bits)."""
|
|
234
|
+
ctype = _run_data_word_type(channel)
|
|
235
|
+
data = ffi.new(f"{ctype}[]", max(int(length), 1))
|
|
236
|
+
code = handel.xiaGetRunData(channel, name, data)
|
|
237
|
+
check_error(code)
|
|
238
|
+
raw = numpy.frombuffer(ffi.buffer(data), dtype=f"u{ffi.sizeof(ctype)}")
|
|
239
|
+
return raw[:length].astype("uint32")
|
|
240
|
+
|
|
241
|
+
|
|
214
242
|
def get_spectrum(channel):
|
|
215
243
|
length = get_spectrum_length(channel)
|
|
216
|
-
|
|
217
|
-
data = ffi.cast("uint32_t *", array.ctypes.data)
|
|
218
|
-
code = handel.xiaGetRunData(channel, b"mca", data)
|
|
219
|
-
check_error(code)
|
|
220
|
-
return array
|
|
244
|
+
return _read_word_array(channel, b"mca", length)
|
|
221
245
|
|
|
222
246
|
|
|
223
247
|
def get_spectrums():
|
|
@@ -387,10 +411,9 @@ def get_raw_buffer(master, buffer_id):
|
|
|
387
411
|
length = get_buffer_length(master)
|
|
388
412
|
LOGGER.debug(f"get_raw_buffer(master={master} buff id={buffer_id}) (len={length})")
|
|
389
413
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
check_error(code)
|
|
414
|
+
# Handel fills one 32-bit word per element (low 16 bits = first word);
|
|
415
|
+
# viewed as little-endian uint16 pairs, this is the raw buffer layout.
|
|
416
|
+
array = _read_word_array(master, command, length).astype("<u4").view("<u2")
|
|
394
417
|
# Check magic number
|
|
395
418
|
if array[0] == 0:
|
|
396
419
|
raise RuntimeError(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|