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,232 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
logger = logging.getLogger(__name__)
|
|
3
|
+
|
|
4
|
+
import tempfile
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
from tango.server import device_property, attribute, command
|
|
9
|
+
|
|
10
|
+
from ...tango import TangoDevInfo
|
|
11
|
+
from .xiads import XiaDS
|
|
12
|
+
from .xia import Xia, TrigPoller, hi
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FxTrigPoller(TrigPoller):
|
|
17
|
+
def _parse_map_buffer(self, master, channels, ini_channels, bf, spectra, stats, module_index):
|
|
18
|
+
# TODO: use handel.mapping.parse_mapping_buffer
|
|
19
|
+
# modified to use np array instead of dictionaries
|
|
20
|
+
|
|
21
|
+
CLOCK_TICK = self._handel.CLOCK_TICK
|
|
22
|
+
|
|
23
|
+
ptr = 0
|
|
24
|
+
|
|
25
|
+
header = bf[:128]
|
|
26
|
+
header.dtype = np.uint16
|
|
27
|
+
h0, h1 = header[0:2]
|
|
28
|
+
|
|
29
|
+
if h0 != 0x55AA or h1 != 0xAA55:
|
|
30
|
+
raise ValueError(f"Invalid mapping buffer header magic number ({h0:#x}, {h1:#x}).")
|
|
31
|
+
|
|
32
|
+
nb_pixels = header[8]
|
|
33
|
+
|
|
34
|
+
# advance header
|
|
35
|
+
ptr += 128
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
chan_idx = channels.index(master)
|
|
39
|
+
except ValueError:
|
|
40
|
+
raise RuntimeError(
|
|
41
|
+
f"Master channel {master} is not among the enabled channels {channels}. "
|
|
42
|
+
"This can happen if a master channel was disabled after the acquisition "
|
|
43
|
+
"was set up (see the TODO in xia.py about only reading enabled channels)."
|
|
44
|
+
) from None
|
|
45
|
+
|
|
46
|
+
# attention to logic with pointers
|
|
47
|
+
# to avoid multiple casting
|
|
48
|
+
# ptr works in 32bit
|
|
49
|
+
# pixel_header works in 16bit on same data
|
|
50
|
+
|
|
51
|
+
for pixno in range(nb_pixels):
|
|
52
|
+
# pxh = pixel header (is 128 32bits) but we
|
|
53
|
+
# only use 20
|
|
54
|
+
pxh = bf[ptr : ptr + 20]
|
|
55
|
+
pxh.dtype = np.uint16
|
|
56
|
+
# pxno = self.map_read_pixel + pixno
|
|
57
|
+
|
|
58
|
+
if pxh[0] != 0x33CC or pxh[1] != 0xCC33:
|
|
59
|
+
raise ValueError(f"Invalid pixel header magic number ({pxh[0]:#x}, {pxh[1]:#x}).")
|
|
60
|
+
if pxh[2] != 0x100:
|
|
61
|
+
raise ValueError(f"Unsupported pixel header version ({pxh[2]:#x}).")
|
|
62
|
+
|
|
63
|
+
spectrum_size = pxh[8]
|
|
64
|
+
|
|
65
|
+
# operations with stats could be
|
|
66
|
+
realtime = bf[ptr + 16] * CLOCK_TICK# pxh[32 and 33]
|
|
67
|
+
trigger_livetime = bf[ptr + 17] * CLOCK_TICK # pxh[34 and 35]
|
|
68
|
+
triggers = bf[ptr + 18] # pxh[36 and 37]
|
|
69
|
+
events = bf[ptr + 19] # pxh[38 and 39]
|
|
70
|
+
|
|
71
|
+
# ICR/OCR computation
|
|
72
|
+
icr = triggers / trigger_livetime if trigger_livetime != 0 else 0.0
|
|
73
|
+
ocr = events / realtime if realtime != 0 else 0.0
|
|
74
|
+
# Deadtime computation
|
|
75
|
+
# It's unclear whether icr=ocr=0 should result in a 0.0 or 1.0 deadtime
|
|
76
|
+
# Prospect uses 0% so 0. it is.
|
|
77
|
+
deadtime = 1 - float(ocr) / icr if icr != 0 else 0.0
|
|
78
|
+
|
|
79
|
+
# no icr -> 0 ?
|
|
80
|
+
energy_livetime = events / icr if icr != 0 else 0.0
|
|
81
|
+
|
|
82
|
+
stats[chan_idx, pixno, 0:] = (realtime,
|
|
83
|
+
trigger_livetime,
|
|
84
|
+
energy_livetime,
|
|
85
|
+
triggers,
|
|
86
|
+
events,
|
|
87
|
+
icr,
|
|
88
|
+
ocr,
|
|
89
|
+
deadtime)
|
|
90
|
+
|
|
91
|
+
# advance pixel header
|
|
92
|
+
ptr += 128
|
|
93
|
+
if spectrum_size % 2 != 0:
|
|
94
|
+
raise ValueError(
|
|
95
|
+
f"Unexpected odd spectrum_size ({spectrum_size}) in mapping buffer pixel header."
|
|
96
|
+
)
|
|
97
|
+
end_ptr = ptr + spectrum_size // 2
|
|
98
|
+
spectra[chan_idx, pixno, :] = bf[ptr:end_ptr]
|
|
99
|
+
ptr = end_ptr
|
|
100
|
+
|
|
101
|
+
return nb_pixels
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class FalconX(XiaDS):
|
|
105
|
+
def _create_control(self, *args, **kwargs):
|
|
106
|
+
lib_path = self.lib_path
|
|
107
|
+
if lib_path is None:
|
|
108
|
+
logger.warning("Property lib_path not set. Will use system wide handel.dll, if found.")
|
|
109
|
+
else:
|
|
110
|
+
logger.info("Looking for handel.dll in [%s].", lib_path)
|
|
111
|
+
return FalconXHW(*args, lib_path=lib_path, **kwargs)
|
|
112
|
+
|
|
113
|
+
@attribute(dtype=float)
|
|
114
|
+
def mca_refresh(self):
|
|
115
|
+
return self.control.mca_refresh
|
|
116
|
+
|
|
117
|
+
@mca_refresh.write
|
|
118
|
+
def mca_refresh(self, mca_refresh):
|
|
119
|
+
self.control.mca_refresh = mca_refresh
|
|
120
|
+
|
|
121
|
+
# NOT a property, otherwise autocomplete
|
|
122
|
+
# will call it
|
|
123
|
+
@command
|
|
124
|
+
def reset_hardware(self):
|
|
125
|
+
# TODO:
|
|
126
|
+
self.control.reset_hardware()
|
|
127
|
+
|
|
128
|
+
# NOT a property, otherwise autocomplete
|
|
129
|
+
# will call it
|
|
130
|
+
@command(dtype_out=[str])
|
|
131
|
+
def firmwares(self):
|
|
132
|
+
return self.control.firmwares
|
|
133
|
+
|
|
134
|
+
# @command(dtype_int=[str])
|
|
135
|
+
# def set_credentials(self, argins):
|
|
136
|
+
# module, login, password = argins
|
|
137
|
+
# return self.control.set_credentials(module, login, password)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def http_post(url, cmd, login, password):
|
|
141
|
+
import requests
|
|
142
|
+
auth = requests.auth.HTTPDigestAuth(login, password)
|
|
143
|
+
requests.post(f"http://{url}/{cmd}", auth=auth)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class FxHttpGetError(Exception):
|
|
147
|
+
pass
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def http_get(url, cmd, login, password):
|
|
151
|
+
import requests
|
|
152
|
+
auth = requests.auth.HTTPDigestAuth(login, password)
|
|
153
|
+
req = requests.get(f"http://{url}/{cmd}", auth=auth)
|
|
154
|
+
if req.status_code != 200:
|
|
155
|
+
raise FxHttpGetError(f"Failed to GET from {url}/{cmd}.")
|
|
156
|
+
return req.json()
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class FalconXHW(Xia):
|
|
160
|
+
TrigPollerCls = FxTrigPoller
|
|
161
|
+
|
|
162
|
+
# def __init__(self, *args, **kwargs):
|
|
163
|
+
# self._modules_infos = {}
|
|
164
|
+
# super().__init__(*args, **kwargs)
|
|
165
|
+
|
|
166
|
+
# def _post_ini(self):
|
|
167
|
+
# super()._post_ini()
|
|
168
|
+
# hi = self.hi
|
|
169
|
+
# self._modules_infos = {}
|
|
170
|
+
# modules = hi.get_modules()
|
|
171
|
+
# for module in modules:
|
|
172
|
+
# url = hi.get_module_url(module)
|
|
173
|
+
# infos = {}
|
|
174
|
+
# infos['url'] = url
|
|
175
|
+
# self._modules_infos[module] = infos
|
|
176
|
+
# self.set_credentials(module, "user", "password")
|
|
177
|
+
|
|
178
|
+
# def set_credentials(self, module, login, password):
|
|
179
|
+
# infos= self._modules_infos[module]
|
|
180
|
+
# infos['credentials'] = login, password
|
|
181
|
+
# try:
|
|
182
|
+
# mib = self._mib(module)
|
|
183
|
+
# except FxHttpGetError:
|
|
184
|
+
# # TODO: specificaly check for credentials error
|
|
185
|
+
# del infos['credentials']
|
|
186
|
+
# logger.error("Wrong credentials for module %s (%s).", module, infos["url"])
|
|
187
|
+
# firmware = "wrong credentials"
|
|
188
|
+
# else:
|
|
189
|
+
# firmware = mib['versions.version'][0]
|
|
190
|
+
# infos['firmware'] = firmware
|
|
191
|
+
|
|
192
|
+
@property
|
|
193
|
+
def mca_refresh(self):
|
|
194
|
+
return self.hi.get_acquisition_value("mca_refresh")
|
|
195
|
+
|
|
196
|
+
@mca_refresh.setter
|
|
197
|
+
def mca_refresh(self, mca_refresh):
|
|
198
|
+
logger.info("Setting mca_refresh to %s.", mca_refresh)
|
|
199
|
+
self.hi.set_acquisition_value("mca_refresh", mca_refresh)
|
|
200
|
+
self.hi.apply_acquisition_values()
|
|
201
|
+
|
|
202
|
+
# def reset_hardware(self):
|
|
203
|
+
# # TODO:
|
|
204
|
+
# hi = self.hi
|
|
205
|
+
# for alias in hi.get_modules():
|
|
206
|
+
# infos = self._modules_infos[alias]
|
|
207
|
+
# url = infos['url']
|
|
208
|
+
# login, pwd = infos.get('credentials', (None, None))
|
|
209
|
+
# if login is None:
|
|
210
|
+
# raise RuntimeError("Credentials for module {alias} not set. Can't reset module.")
|
|
211
|
+
# logger.info("Resettig module %s, url=%s.", alias, url)
|
|
212
|
+
# http_post(url, "reset", login, pwd)
|
|
213
|
+
|
|
214
|
+
# def _mib(self, module):
|
|
215
|
+
# # TODO:
|
|
216
|
+
# infos = self._modules_infos[module]
|
|
217
|
+
# url = infos['url']
|
|
218
|
+
# login, pwd = infos['credentials']
|
|
219
|
+
# req = http_get(url, "mib?", login, pwd)
|
|
220
|
+
# return {val[0]:val[1:] for val in req['data']}
|
|
221
|
+
|
|
222
|
+
# @property
|
|
223
|
+
# def firmwares(self):
|
|
224
|
+
# return [info.get('firmware', "?") for info in self._modules_infos.values()]
|
|
225
|
+
# # return [info['firmware'] for info in self._modules_infos.values()]
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
FALCONX_DEVINFO = TangoDevInfo(
|
|
229
|
+
klass=FalconX,
|
|
230
|
+
properties={"default_ini_dir": "",
|
|
231
|
+
"default_ini_file": "",
|
|
232
|
+
"lib_path": ""})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""CFFI binding."""
|
|
2
|
+
|
|
3
|
+
import cffi
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
_logger = logging.getLogger(__name__)
|
|
7
|
+
ffi = cffi.FFI()
|
|
8
|
+
|
|
9
|
+
ffi.cdef(
|
|
10
|
+
"""
|
|
11
|
+
typedef unsigned char byte_t;
|
|
12
|
+
typedef unsigned char boolean_t;
|
|
13
|
+
typedef unsigned short parameter_t;
|
|
14
|
+
typedef unsigned short flag_t;
|
|
15
|
+
int xiaInit(char *iniFile);
|
|
16
|
+
int xiaInitHandel(void);
|
|
17
|
+
int xiaGetDetectorItem(char *alias, char *name, void *value);
|
|
18
|
+
int xiaGetNumDetectors(unsigned int *numDet);
|
|
19
|
+
int xiaGetDetectors(char *detectors[]);
|
|
20
|
+
int xiaGetDetectors_VB(unsigned int index, char *alias);
|
|
21
|
+
int xiaDetectorFromDetChan(int detChan, char *alias);
|
|
22
|
+
int xiaGetFirmwareItem(char *alias, unsigned short decimation, char *name, void *value);
|
|
23
|
+
int xiaGetNumFirmwareSets(unsigned int *numFirmware);
|
|
24
|
+
int xiaGetFirmwareSets(char *firmware[]);
|
|
25
|
+
int xiaGetFirmwareSets_VB(unsigned int index, char *alias);
|
|
26
|
+
int xiaGetNumPTRRs(char *alias, unsigned int *numPTRR);
|
|
27
|
+
int xiaModifyModuleItem(const char *alias, const char *name, void *value);
|
|
28
|
+
int xiaGetModuleItem(char *alias, char *name, void *value);
|
|
29
|
+
int xiaGetNumModules(unsigned int *numModules);
|
|
30
|
+
int xiaGetModules(char *modules[]);
|
|
31
|
+
int xiaGetModules_VB(unsigned int index, char *alias);
|
|
32
|
+
int xiaModuleFromDetChan(int detChan, char *alias);
|
|
33
|
+
int xiaStartSystem(void);
|
|
34
|
+
int xiaSetAcquisitionValues(int detChan, char *name, void *value);
|
|
35
|
+
int xiaGetAcquisitionValues(int detChan, char *name, void *value);
|
|
36
|
+
int xiaRemoveAcquisitionValues(int detChan, char *name);
|
|
37
|
+
int xiaGainOperation(int detChan, char *name, void *value);
|
|
38
|
+
int xiaGainCalibrate(int detChan, double deltaGain);
|
|
39
|
+
int xiaStartRun(int detChan, unsigned short resume);
|
|
40
|
+
int xiaStopRun(int detChan);
|
|
41
|
+
int xiaGetRunData(int detChan, char *name, void *value);
|
|
42
|
+
int xiaDoSpecialRun(int detChan, char *name, void *info);
|
|
43
|
+
int xiaGetSpecialRunData(int detChan, char *name, void *value);
|
|
44
|
+
int xiaLoadSystem(char *type, char *filename);
|
|
45
|
+
int xiaSaveSystem(char *type, char *filename);
|
|
46
|
+
int xiaBoardOperation(int detChan, char *name, void *value);
|
|
47
|
+
int xiaExit(void);
|
|
48
|
+
int xiaEnableLogOutput(void);
|
|
49
|
+
int xiaSuppressLogOutput(void);
|
|
50
|
+
int xiaSetLogLevel(int level);
|
|
51
|
+
int xiaSetLogOutput(char *fileName);
|
|
52
|
+
void xiaGetVersionInfo(int *rel, int *min, int *maj, char *pretty);
|
|
53
|
+
"""
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def get_handel(lib_path="handel.dll"):
|
|
57
|
+
if lib_path is None:
|
|
58
|
+
raise RuntimeError("No handel library path configured.")
|
|
59
|
+
try:
|
|
60
|
+
return ffi.dlopen(lib_path)
|
|
61
|
+
except Exception as ex:
|
|
62
|
+
raise RuntimeError("Error while loading handel.dll") from ex
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"""Error handling."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
ERROR_DICT = {
|
|
5
|
+
0: ("SUCCESS", None),
|
|
6
|
+
1: ("OPEN_FILE", None),
|
|
7
|
+
2: ("FILEERR", None),
|
|
8
|
+
3: ("NOSECTION", None),
|
|
9
|
+
4: ("FORMAT_ERROR", None),
|
|
10
|
+
5: ("ILLEGAL_OPERATION", "Attempted to configure options in an illegal order"),
|
|
11
|
+
6: ("FILE_RA", "File random access unable to find name-value pair"),
|
|
12
|
+
7: ("SET_POS", "Error getting file position."),
|
|
13
|
+
201: (
|
|
14
|
+
"UNKNOWN_DECIMATION",
|
|
15
|
+
"The decimation read from the hardware does not match a known value",
|
|
16
|
+
),
|
|
17
|
+
202: ("SLOWLEN_OOR", "Calculated SLOWLEN value is out-of-range"),
|
|
18
|
+
203: ("SLOWGAP_OOR", "Calculated SLOWGAP value is out-of-range"),
|
|
19
|
+
204: ("SLOWFILTER_OOR", "Attempt to set the Peaking or Gap time s.t. P+G>31"),
|
|
20
|
+
205: ("FASTLEN_OOR", "Calculated FASTLEN value is out-of-range"),
|
|
21
|
+
206: ("FASTGAP_OOR", "Calculated FASTGAP value is out-of-range"),
|
|
22
|
+
207: ("FASTFILTER_OOR", "Attempt to set the Peaking or Gap time s.t. P+G>31"),
|
|
23
|
+
208: ("BASELINE_OOR", "Baseline filter length is out-of-range"),
|
|
24
|
+
301: ("INITIALIZE", None),
|
|
25
|
+
302: ("NO_ALIAS", None),
|
|
26
|
+
303: ("ALIAS_EXISTS", None),
|
|
27
|
+
304: ("BAD_VALUE", None),
|
|
28
|
+
305: ("INFINITE_LOOP", None),
|
|
29
|
+
306: ("BAD_NAME", "Specified name is not valid"),
|
|
30
|
+
307: ("BAD_PTRR", "Specified PTRR is not valid for this alias"),
|
|
31
|
+
308: ("ALIAS_SIZE", "Alias name has too many characters"),
|
|
32
|
+
309: ("NO_MODULE", "Must define at least one module before"),
|
|
33
|
+
310: ("BAD_INTERFACE", "The specified interface does not exist"),
|
|
34
|
+
311: (
|
|
35
|
+
"NO_INTERFACE",
|
|
36
|
+
"An interface must defined before more information is specified",
|
|
37
|
+
),
|
|
38
|
+
312: ("WRONG_INTERFACE", "Specified information doesn't apply to this interface"),
|
|
39
|
+
313: ("NO_CHANNELS", "Number of channels for this module is set to 0"),
|
|
40
|
+
314: ("BAD_CHANNEL", "Specified channel index is invalid or out-of-range"),
|
|
41
|
+
315: ("NO_MODIFY", "Specified name cannot be modified once set"),
|
|
42
|
+
316: ("INVALID_DETCHAN", "Specified detChan value is invalid"),
|
|
43
|
+
317: ("BAD_TYPE", "The DetChanElement type specified is invalid"),
|
|
44
|
+
318: ("WRONG_TYPE", "This routine only operates on detChans that are sets"),
|
|
45
|
+
319: ("UNKNOWN_BOARD", "Board type is unknown"),
|
|
46
|
+
320: ("NO_DETCHANS", "No detChans are currently defined"),
|
|
47
|
+
321: ("NOT_FOUND", "Unable to locate the Acquisition value requested"),
|
|
48
|
+
322: ("PTR_CHECK", "Pointer is out of synch when it should be valid"),
|
|
49
|
+
323: (
|
|
50
|
+
"LOOKING_PTRR",
|
|
51
|
+
"FirmwareSet has a FDD file defined and this only works with PTRRs",
|
|
52
|
+
),
|
|
53
|
+
324: ("NO_FILENAME", "Requested filename information is set to NULL"),
|
|
54
|
+
325: ("BAD_INDEX", "User specified an alias index that doesn't exist"),
|
|
55
|
+
326: ("NULL_ALIAS", "Null alias passed into function"),
|
|
56
|
+
327: ("NULL_NAME", "Null name passed into function"),
|
|
57
|
+
328: ("NULL_VALUE", "Null value passed into function"),
|
|
58
|
+
329: ("NEEDS_BOARD_TYPE", "Module needs board_type"),
|
|
59
|
+
330: ("UNKNOWN_ITEM", "Unknown item"),
|
|
60
|
+
331: ("TYPE_REDIRECT", "Module type can not be redefined once set"),
|
|
61
|
+
332: ("NO_TMP_PATH", "No FDD temporary path defined for this firmware."),
|
|
62
|
+
333: ("NULL_PATH", "Specified path was NULL."),
|
|
63
|
+
350: (
|
|
64
|
+
"FIRM_BOTH",
|
|
65
|
+
"A FirmwareSet may not contain both an FDD and seperate Firmware "
|
|
66
|
+
"definitions",
|
|
67
|
+
),
|
|
68
|
+
351: (
|
|
69
|
+
"PTR_OVERLAP",
|
|
70
|
+
"Peaking time ranges in the Firmware definitions may not overlap",
|
|
71
|
+
),
|
|
72
|
+
352: (
|
|
73
|
+
"MISSING_FIRM",
|
|
74
|
+
"Either the FiPPI or DSP file is missing from a Firmware element",
|
|
75
|
+
),
|
|
76
|
+
353: ("MISSING_POL", "A polarity value is missing from a Detector element"),
|
|
77
|
+
354: ("MISSING_GAIN", "A gain value is missing from a Detector element"),
|
|
78
|
+
355: ("MISSING_INTERFACE", "The interface this channel requires is missing"),
|
|
79
|
+
356: ("MISSING_ADDRESS", "The epp_address information is missing for this channel"),
|
|
80
|
+
357: (
|
|
81
|
+
"INVALID_NUMCHANS",
|
|
82
|
+
"The wrong number of channels are assigned to this module",
|
|
83
|
+
),
|
|
84
|
+
358: ("INCOMPLETE_DEFAULTS", "Some of the required defaults are missing"),
|
|
85
|
+
359: ("BINS_OOR", "There are too many or too few bins for this module type"),
|
|
86
|
+
360: (
|
|
87
|
+
"MISSING_TYPE",
|
|
88
|
+
"The type for the current detector is not specified properly",
|
|
89
|
+
),
|
|
90
|
+
361: ("NO_MMU", "No MMU defined and/or required for this module"),
|
|
91
|
+
362: ("NULL_FIRMWARE", "No firmware set defined"),
|
|
92
|
+
363: ("NO_FDD", "No FDD defined in the firmware set"),
|
|
93
|
+
364: ("WRONG_DET_TYPE", "The detector type is wrong for the requested operation"),
|
|
94
|
+
401: ("NOMEM", "Unable to allocate memory"),
|
|
95
|
+
402: ("XERXES", "XerXes returned an error"),
|
|
96
|
+
403: ("MD", "MD layer returned an error"),
|
|
97
|
+
404: ("EOF", "EOF encountered"),
|
|
98
|
+
405: ("XERXES_NORMAL_RUN_ACTIVE", "XerXes says a normal run is still active"),
|
|
99
|
+
406: ("HARDWARE_RUN_ACTIVE", "The hardware says a control run is still active"),
|
|
100
|
+
501: ("UNKNOWN", None),
|
|
101
|
+
507: ("FILE_TYPE", "Improper file type specified"),
|
|
102
|
+
508: ("END", "There are no more instances of the name specified. Pos set to end"),
|
|
103
|
+
509: ("INVALID_STR", "Invalid string format"),
|
|
104
|
+
510: ("UNIMPLEMENTED", "The routine is unimplemented in this version"),
|
|
105
|
+
511: (
|
|
106
|
+
"PARAM_DEBUG_MISMATCH",
|
|
107
|
+
"A parameter mismatch was found with XIA_PARAM_DEBUG enabled.",
|
|
108
|
+
),
|
|
109
|
+
601: (
|
|
110
|
+
"NOSUPPORT_FIRM",
|
|
111
|
+
"The specified firmware is not supported by this board type",
|
|
112
|
+
),
|
|
113
|
+
602: ("UNKNOWN_FIRM", "The specified firmware type is unknown"),
|
|
114
|
+
603: ("NOSUPPORT_VALUE", "The specified acquisition value is not supported"),
|
|
115
|
+
604: ("UNKNOWN_VALUE", "The specified acquisition value is unknown"),
|
|
116
|
+
605: (
|
|
117
|
+
"PEAKINGTIME_OOR",
|
|
118
|
+
"The specified peaking time is out-of-range for this product",
|
|
119
|
+
),
|
|
120
|
+
606: (
|
|
121
|
+
"NODEFINE_PTRR",
|
|
122
|
+
"The specified peaking time does not have a PTRR associated with it",
|
|
123
|
+
),
|
|
124
|
+
607: ("THRESH_OOR", "The specified treshold is out-of-range"),
|
|
125
|
+
608: ("ERROR_CACHE", "The data in the values cache is out-of-sync"),
|
|
126
|
+
609: ("GAIN_OOR", "The specified gain is out-of-range for this produce"),
|
|
127
|
+
610: ("TIMEOUT", "Timeout waiting for BUSY"),
|
|
128
|
+
611: ("BAD_SPECIAL", "The specified special run is not supported for this module"),
|
|
129
|
+
612: ("TRACE_OOR", "The specified value of tracewait (in ns) is out-of-range"),
|
|
130
|
+
613: ("DEFAULTS", "The PSL layer encountered an error creating a Defaults element"),
|
|
131
|
+
614: (
|
|
132
|
+
"BAD_FILTER",
|
|
133
|
+
"Error loading filter info from either a FDD file or the Firmware "
|
|
134
|
+
"configuration",
|
|
135
|
+
),
|
|
136
|
+
615: (
|
|
137
|
+
"NO_REMOVE",
|
|
138
|
+
"Specified acquisition value is required for this product and can't be "
|
|
139
|
+
"removed",
|
|
140
|
+
),
|
|
141
|
+
616: ("NO_GAIN_FOUND", "Handel was unable to converge on a stable gain value"),
|
|
142
|
+
617: ("UNDEFINED_RUN_TYPE", "Handel does not recognize this run type"),
|
|
143
|
+
618: (
|
|
144
|
+
"INTERNAL_BUFFER_OVERRUN",
|
|
145
|
+
"Handel attempted to overrun an internal buffer boundry",
|
|
146
|
+
),
|
|
147
|
+
619: (
|
|
148
|
+
"EVENT_BUFFER_OVERRUN",
|
|
149
|
+
"Handel attempted to overrun the event buffer boundry",
|
|
150
|
+
),
|
|
151
|
+
620: (
|
|
152
|
+
"BAD_DATA_LENGTH",
|
|
153
|
+
"Handel was asked to set a Data length to zero for readout",
|
|
154
|
+
),
|
|
155
|
+
621: ("NO_LINEAR_FIT", "Handel was unable to perform a linear fit to some data"),
|
|
156
|
+
622: ("MISSING_PTRR", "Required PTRR is missing"),
|
|
157
|
+
623: ("PARSE_DSP", "Error parsing DSP"),
|
|
158
|
+
624: ("UDXPS", None),
|
|
159
|
+
625: ("BIN_WIDTH", "Specified bin width is out-of-range"),
|
|
160
|
+
626: (
|
|
161
|
+
"NO_VGA",
|
|
162
|
+
"An attempt was made to set the gaindac on a board that doesn't have a " "VGA",
|
|
163
|
+
),
|
|
164
|
+
627: ("TYPEVAL_OOR", "Specified detector type value is out-of-range"),
|
|
165
|
+
628: ("LOW_LIMIT_OOR", "Specified low MCA limit is out-of-range"),
|
|
166
|
+
629: ("BPB_OOR", "bytes_per_bin is out-of-range"),
|
|
167
|
+
630: ("FIP_OOR", "Specified FiPPI is out-fo-range"),
|
|
168
|
+
631: ("MISSING_PARAM", "Unable to find DSP parameter in list"),
|
|
169
|
+
632: ("OPEN_XW", "Error opening a handle in the XW library"),
|
|
170
|
+
633: ("ADD_XW", "Error adding to a handle in the XW library"),
|
|
171
|
+
634: ("WRITE_XW", "Error writing out a handle in the XW library"),
|
|
172
|
+
635: ("VALUE_VERIFY", "Returned value inconsistent with sent value"),
|
|
173
|
+
636: ("POL_OOR", "Specifed polarity is out-of-range"),
|
|
174
|
+
637: ("SCA_OOR", "Specified SCA number is out-of-range"),
|
|
175
|
+
638: ("BIN_MISMATCH", "Specified SCA bin is either too high or too low"),
|
|
176
|
+
639: ("WIDTH_OOR", "MCA bin width is out-of-range"),
|
|
177
|
+
640: ("UNKNOWN_PRESET", "Unknown PRESET run type specified"),
|
|
178
|
+
641: ("GAIN_TRIM_OOR", "Gain trim out-of-range"),
|
|
179
|
+
642: ("GENSET_MISMATCH", "Returned GENSET doesn't match the set GENSET"),
|
|
180
|
+
643: ("NUM_MCA_OOR", "The specified number of MCA bins is out of range"),
|
|
181
|
+
644: ("PEAKINT_OOR", None),
|
|
182
|
+
645: ("PEAKSAM_OOR", None),
|
|
183
|
+
646: ("MAXWIDTH_OOR", None),
|
|
184
|
+
647: ("NULL_TYPE", "A NULL file type was specified"),
|
|
185
|
+
648: ("GAIN_SCALE", "Gain scale factor is not valid"),
|
|
186
|
+
649: ("NULL_INFO", "The specified info array is NULL"),
|
|
187
|
+
650: ("UNKNOWN_PARAM_DATA", "Unknown parameter data type"),
|
|
188
|
+
651: ("MAX_SCAS", "The specified number of SCAs is more then the maximum allowed"),
|
|
189
|
+
652: ("UNKNOWN_BUFFER", "Requested buffer is unknown"),
|
|
190
|
+
653: ("NO_MAPPING", "Mapping mode is currently not installed/enabled"),
|
|
191
|
+
654: ("MAPPING_PT_CTL", "Wrong mapping point control for operation"),
|
|
192
|
+
655: ("UNKNOWN_PT_CTL", "Unknown mapping point control."),
|
|
193
|
+
656: ("CLOCK_SPEED", "The hardware is reporting an invalid clock speed."),
|
|
194
|
+
657: ("BAD_DECIMATION", "Passed in decimation is invalid."),
|
|
195
|
+
658: ("BAD_SYNCH_RUN", "Specified value for synchronous run is bad."),
|
|
196
|
+
659: ("PRESET_VALUE_OOR", "Requested preset value is out-of-range."),
|
|
197
|
+
660: ("MEMORY_LENGTH", "Memory length is invalid."),
|
|
198
|
+
661: ("UNKNOWN_PREAMP_TYPE", "Preamp type is unknown."),
|
|
199
|
+
662: ("DAC_TARGET_OOR", "The specified DAC target is out of range."),
|
|
200
|
+
663: ("DAC_TOL_OOR", "The specified DAC tolerance is out of range."),
|
|
201
|
+
664: ("BAD_TRIGGER", "Specified trigger setting is invalid."),
|
|
202
|
+
665: ("EVENT_LEN_OOR", "The specified event length is out of range."),
|
|
203
|
+
666: ("PRE_BUF_LEN_OOR", "The specified pre-buffer length is out of range."),
|
|
204
|
+
667: ("HV_OOR", "The specified high voltage value is out of range."),
|
|
205
|
+
668: ("PEAKMODE_OOR", "The specified peak mode is out of range."),
|
|
206
|
+
669: (
|
|
207
|
+
"NOSUPPORTED_PREAMP_TYPE",
|
|
208
|
+
"The specified preamp type is not supported by current firmware.",
|
|
209
|
+
),
|
|
210
|
+
670: (
|
|
211
|
+
"ENERGYCOEF_OOR",
|
|
212
|
+
"The calculated energy coefficient values are out of range.",
|
|
213
|
+
),
|
|
214
|
+
671: (
|
|
215
|
+
"VETO_PULSE_STEP",
|
|
216
|
+
"The specified step value is too large for the Alpha pulser veto " "pulse.",
|
|
217
|
+
),
|
|
218
|
+
672: ("TRIGOUTPUT_OOR", "The specified trigger signal output is out of range."),
|
|
219
|
+
673: ("LIVEOUTPUT_OOR", "The specified livetime signal output is out of range."),
|
|
220
|
+
674: ("UNKNOWN_MAPPING", "Unknown mapping mode value specified."),
|
|
221
|
+
675: ("UNKNOWN_LIST_MODE_VARIANT", "Illegal list mode variant."),
|
|
222
|
+
676: ("MALFORMED_LENGTH", "List mode upper length word is malformed."),
|
|
223
|
+
677: ("CLRBUFSIZE_LENGTH", "Clear Buffer Size length is too large."),
|
|
224
|
+
678: ("BAD_ELECTRODE_SIZE", "UltraLo electrode size is invalid."),
|
|
225
|
+
679: ("TILT_THRESHOLD_OOR", "Specified threshold is out-of-range."),
|
|
226
|
+
680: ("USB_BUSY", "Direct USB command failed due to busy USB."),
|
|
227
|
+
681: ("MALFORMED_MM_RESPONSE", "UltraLo moisture meter response is malformed."),
|
|
228
|
+
682: ("MALFORMED_MM_STATUS", "UltraLo moisture meter status is invalid."),
|
|
229
|
+
683: ("MALFORMED_MM_VALUE", "UltraLo moisture meter value is invalid."),
|
|
230
|
+
684: ("NO_EVENTS", "No events to retrieve from the event buffer."),
|
|
231
|
+
701: ("XUP_VERSION", "XUP version is not supported"),
|
|
232
|
+
702: ("CHKSUM", "checksum mismatch in the XUP"),
|
|
233
|
+
703: ("BAK_MISSING", "Requested BAK file cannot be opened"),
|
|
234
|
+
704: ("SIZE_MISMATCH", "Size read from file is incorrect"),
|
|
235
|
+
705: ("NO_ACCESS", "Specified access file isn't valid"),
|
|
236
|
+
706: (
|
|
237
|
+
"N_FILTER_BAD",
|
|
238
|
+
"The number of filter parameters in the FDD doesn't match the number "
|
|
239
|
+
"requires for the hardware",
|
|
240
|
+
),
|
|
241
|
+
801: ("UNIT_TEST", None),
|
|
242
|
+
13009: (
|
|
243
|
+
"LOW_REFRESH_RATE",
|
|
244
|
+
"Histogram fixed time target is less than refresh rate",
|
|
245
|
+
),
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
DEFAULT_ERROR = "UNKNOWN_ERROR_CODE", None
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class HandelError(IOError):
|
|
252
|
+
def __init__(self, errno, strerror, description=None):
|
|
253
|
+
self.errno = errno
|
|
254
|
+
self.strerror = strerror
|
|
255
|
+
self.description = description
|
|
256
|
+
self.args = errno, strerror, description
|
|
257
|
+
|
|
258
|
+
def __str__(self):
|
|
259
|
+
s = "[HandelError {}] {}".format(self.errno, self.strerror)
|
|
260
|
+
if self.description:
|
|
261
|
+
s += ": {}".format(self.description)
|
|
262
|
+
return s
|
|
263
|
+
|
|
264
|
+
@classmethod
|
|
265
|
+
def from_errno(cls, errno):
|
|
266
|
+
strerror, description = ERROR_DICT.get(errno, DEFAULT_ERROR)
|
|
267
|
+
return cls(errno, strerror, description)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def check_error(errno):
|
|
271
|
+
if errno != 0:
|
|
272
|
+
raise HandelError.from_errno(errno)
|