This commit is contained in:
Erik Frojdh
2019-06-12 10:41:50 +02:00
parent 1fed3553b9
commit 55229f77a3
7 changed files with 14 additions and 64 deletions

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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)