21"""Imagine Optic Mirao 52-e deformable mirror.
23The Mirao 52-e deformable mirror is not capable of receiving hardware
24triggers. It is only capable of sending hardware triggers. That
25sending of hardware triggers
is not implemented on this module because
28The Mirao 52-e deformable mirror has a limitation on valid patterns.
29From the vendor documentation (the command is the pattern to be
32 [...] the sum of the absolute values defining the command must be
33 lower than
or equal to 24
and each value must be comprised between
36In microscope, a pattern must be specified
in the [0 1] range.
37However, the limit of 24, after rescaling to [-1 1] range, still
48import microscope._utils
62 """Imagine Optic Mirao 52e deformable mirror.
64 The Mirao 52e deformable mirrors only support software trigger.
68 def __init__(self, **kwargs) -> None:
69 super().__init__(**kwargs)
74 self.
_status = ctypes.pointer(ctypes.c_int(mro.OK))
77 "failed to open mirao mirror (error code %d)"
82 def n_actuators(self) -> int:
83 return mro.NB_COMMAND_VALUES
86 def _normalize_patterns(patterns: numpy.ndarray) -> numpy.ndarray:
88 mirao52e SDK expects values in the [-1 1] range, so we normalize
89 them
from the [0 1] range we expect
in our interface.
91 patterns = (patterns * 2) - 1
94 def _do_apply_pattern(self, pattern: numpy.ndarray) ->
None:
96 command = pattern.ctypes.data_as(mro.Command)
97 if not mro.applyCommand(command, mro.FALSE, self.
_status):
100 def _raise_status(self, func: typing.Callable) ->
None:
101 error_code = self.
_status.contents.value
103 "mro_%s() failed (error code %d)" % (func.__name__, error_code)
106 def _do_shutdown(self) -> None:
107 if not mro.close(self.
_status):
numpy.ndarray _normalize_patterns(numpy.ndarray patterns)
None _raise_status(self, typing.Callable func)