mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 12:27:14 +02:00
python
This commit is contained in:
@ -7,49 +7,3 @@ from .errors import DetectorError
|
||||
import functools
|
||||
|
||||
|
||||
def error_handling(func):
|
||||
"""
|
||||
Check for errors registered by the slsDetectorSoftware
|
||||
"""
|
||||
@functools.wraps(func)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
|
||||
# remove any previous errors
|
||||
self._api.clearErrorMask()
|
||||
|
||||
# call function
|
||||
result = func(self, *args, **kwargs)
|
||||
|
||||
# check for new errors
|
||||
m = self.error_mask
|
||||
if m != 0:
|
||||
msg = self.error_message
|
||||
self._api.clearErrorMask()
|
||||
raise DetectorError(msg)
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def property_error_handling(func):
|
||||
"""
|
||||
Check for errors registered by the slsDetectorSoftware
|
||||
"""
|
||||
|
||||
@functools.wraps(func)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
# remove any previous errors
|
||||
self._detector._api.clearErrorMask()
|
||||
|
||||
# call function
|
||||
result = func(self, *args, **kwargs)
|
||||
|
||||
# check for new errors
|
||||
m = self._detector.error_mask
|
||||
if m != 0:
|
||||
msg = self._detector.error_message
|
||||
self._detector._api.clearErrorMask()
|
||||
raise DetectorError(msg)
|
||||
return result
|
||||
|
||||
return wrapper
|
@ -10,7 +10,6 @@ from collections.abc import Iterable
|
||||
from collections import namedtuple
|
||||
|
||||
from _sls_detector import DetectorApi
|
||||
from .decorators import error_handling
|
||||
from .detector_property import DetectorProperty
|
||||
from .errors import DetectorError, DetectorValueError
|
||||
from .registers import Register
|
||||
@ -97,9 +96,6 @@ class Detector:
|
||||
def busy(self, value):
|
||||
self._api.setAcquiringFlag(value)
|
||||
|
||||
def clear_errors(self):
|
||||
"""Clear the error mask for the detector. Used to reset after checking."""
|
||||
self._api.clearErrorMask()
|
||||
|
||||
@property
|
||||
def client_version(self):
|
||||
|
@ -13,7 +13,6 @@ from functools import partial
|
||||
|
||||
from .adcs import Adc, DetectorAdcs
|
||||
from .dacs import DetectorDacs
|
||||
from .decorators import error_handling
|
||||
from .detector import Detector
|
||||
from .detector_property import DetectorProperty
|
||||
from .utils import element_if_equal
|
||||
|
@ -5,7 +5,6 @@ Jungfrau detector class and support functions.
|
||||
Inherits from Detector.
|
||||
"""
|
||||
from .adcs import Adc, DetectorAdcs
|
||||
from .decorators import error_handling
|
||||
from .detector import Detector
|
||||
from .dacs import DetectorDacs
|
||||
from .utils import element_if_equal
|
||||
|
@ -8,7 +8,6 @@ from .utils import element_if_equal
|
||||
from .adcs import DetectorAdcs, Adc
|
||||
from .dacs import DetectorDacs
|
||||
from .detector_property import DetectorProperty
|
||||
from .decorators import error_handling
|
||||
from .registers import Register, Adc_register
|
||||
|
||||
class JungfrauCTBDacs(DetectorDacs):
|
||||
|
@ -1,9 +1,7 @@
|
||||
from .decorators import error_handling, property_error_handling
|
||||
class Register:
|
||||
def __init__(self, detector):
|
||||
self._detector = detector
|
||||
|
||||
@property_error_handling
|
||||
def __getitem__(self, key):
|
||||
return self._detector._api.readRegister(key)
|
||||
|
||||
|
Reference in New Issue
Block a user