-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tango fixes and update core and tango tests to match structure of epi…
…cs tests (#723) Run Tango test context in subprocess to get around forking, support Tango tests on Windows Add converters for DevState and DevEnum Tango signals Add example one of everything Tango server providing every attribute and command type Fix Tango trls for children provided by remote tango servers with #dbase=no Add DevStateEnum StrictEnum for use with TangoSignals Use MonitorQueue from ophyd_async.testing in soft, epics and tango signal tests Remove ability to create Tango signal, backend or device from existing DeviceProxy, require trl Make assert_reading diff output cleaner when alarm_severity or timestamp not given
- Loading branch information
Showing
27 changed files
with
1,412 additions
and
943 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from typing import Any, Generic | ||
|
||
import numpy as np | ||
from numpy.typing import NDArray | ||
|
||
from ophyd_async.core import ( | ||
SignalDatatypeT, | ||
) | ||
from tango import ( | ||
DevState, | ||
) | ||
|
||
from ._utils import DevStateEnum | ||
|
||
|
||
class TangoConverter(Generic[SignalDatatypeT]): | ||
def write_value(self, value: Any) -> Any: | ||
return value | ||
|
||
def value(self, value: Any) -> Any: | ||
return value | ||
|
||
|
||
class TangoEnumConverter(TangoConverter): | ||
def __init__(self, labels: list[str]): | ||
self._labels = labels | ||
|
||
def write_value(self, value: str): | ||
if not isinstance(value, str): | ||
raise TypeError("TangoEnumConverter expects str value") | ||
return self._labels.index(value) | ||
|
||
def value(self, value: int): | ||
return self._labels[value] | ||
|
||
|
||
class TangoEnumArrayConverter(TangoConverter): | ||
def __init__(self, labels: list[str]): | ||
self._labels = labels | ||
|
||
def write_value(self, value: NDArray[np.str_]) -> NDArray[np.integer]: | ||
vfunc = np.vectorize(self._labels.index) | ||
new_array = vfunc(value) | ||
return new_array | ||
|
||
def value(self, value: NDArray[np.integer]) -> NDArray[np.str_]: | ||
vfunc = np.vectorize(self._labels.__getitem__) | ||
new_array = vfunc(value) | ||
return new_array | ||
|
||
|
||
class TangoDevStateConverter(TangoConverter): | ||
_labels = [e.value for e in DevStateEnum] | ||
|
||
def write_value(self, value: str) -> DevState: | ||
idx = self._labels.index(value) | ||
return DevState(idx) | ||
|
||
def value(self, value: DevState) -> str: | ||
idx = int(value) | ||
return self._labels[idx] | ||
|
||
|
||
class TangoDevStateArrayConverter(TangoConverter): | ||
_labels = [e.value for e in DevStateEnum] | ||
|
||
def _write_convert(self, value): | ||
return DevState(self._labels.index(value)) | ||
|
||
def _convert(self, value): | ||
return self._labels[int(value)] | ||
|
||
def write_value(self, value: NDArray[np.str_]) -> NDArray[DevState]: | ||
vfunc = np.vectorize(self._write_convert, otypes=[DevState]) | ||
new_array = vfunc(value) | ||
return new_array | ||
|
||
def value(self, value: NDArray[DevState]) -> NDArray[np.str_]: | ||
vfunc = np.vectorize(self._convert) | ||
new_array = vfunc(value) | ||
return new_array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.