Future Base Interface
Base interfaces for SKA Tango devices.
- class ska_tango_base.future._base_interface.OpStateEmitMixin[source]
Bases:
_BaseOpStateEmitMixinA mixin class for a SKA base device or its component manager.
It provides helper methods for managing the Operational State of the device.
- class ska_tango_base.future._base_interface.OpStateSignal[source]
-
Special signal for Operational State.
Ensures that only valid enumerants from
DevStatefor the SKA Operational State are emitted for the signal.
- class ska_tango_base.future._base_interface.BaseInterface[source]
Bases:
OpStateEmitMixin,SignalBusMixin,SKADeviceProvides the Tango interface for a base SKA device with an Operational State.
This class only provides the Tango interface required for SKA Tango devices which support an Operational State. It is up to subclasses to override various abstract methods to provide the appropriate behaviour and set the Operational State as appropriate, except for the initial state that is set in
init_device().The Operational State of an SKA Tango device is exposed as the built-in Tango device state via
set_state(). Subclasses are not expected to callset_state()themselves. Instead, the state is driven automatically by calling_update_op_state()withinitialisingorfaultkeyword arguments, which will additionally ensure that change and archive events are sent.The Operational State of the
BaseInterfaceonly supports a subset of theDevStateenumeration, with the following interpretations:INIT: The device is initialising. Mandatory initial state for all devices.
ON: The Tango device is communicating with the system under control. Mandatory default state after initialisation has finished.
FAULT: The Tango device encountered a software fault/exception. Optional.
BaseInterfacealso provides the signals_admin_modeand_health_stateas well as the corresponding Tango attributesadminModeandhealthState, as well ashealthInfo.The
adminModeTango attribute is writable and should not be set by subclasses of this interface.The
healthStateandhealthInforead-only attributes should be set by subclasses by callingreport_health(). It is intended to provide information of the overall health of the device, based on the state of the component(s) it is monitoring.- _admin_mode: Signal[AdminMode]
Signal for the admin mode of the device.
Values are emitted for this signal whenever a client successfully changes to the adminMode attribute.
- admin_mode_model: AdminModeModel
State model used to ensure that admin mode transitions are allowed.
- adminMode: attribute_from_signal
Admin mode attribute of the device.
- _op_state: OpStateSignal
Signal for the Operational State of the device.
Write to this signal to set the state of the Tango device.
- _status: Signal[str]
Signal for the status of the device.
Write to this signal to set the status of the Tango device.
- _health_state
Signal for the health state of the device.
This signal cannot be written to directly. Use the
report_health()method instead.
- healthState
Health state attribute of the device.
This should be set by subclasses of this interface by calling
report_health().
- healthInfo
A list of reasons why the device has a particular health state.
Should be an empty list when the
healthStateisHealthState.OK.This should be set by subclasses of this interface by calling
report_health().
- init_device() None[source]
Initialise the tango device after startup.
Subclasses overriding
init_device()must callinit_completed()once initialisation has finished.Example
class MyDevice(BaseInterface): def init_device(self) -> None: super().init_device() ... self.init_completed()
- init_completed() None[source]
Update operational state to reflect that initialisation has completed.
Must be called from your
init_device()method.Example
class MyDevice(BaseInterface): def init_device(self) -> None: super().init_device() ... self.init_completed()
Enable manual event pushing for state and status.
- _update_admin_mode(admin_mode: AdminMode) None[source]
Update the admin mode of the device.
This helper method is passed to the admin mode model as a callback, so that the model can trigger actions in the Tango device.
- Parameters:
admin_mode – the new admin mode value
- read_adminMode() AdminMode | tuple[AdminMode, float, AttrQuality][source]
Read the admin mode of the device.
Subclasses can override this to change the behaviour of the
adminModeattribute.
- write_adminMode(mode: AdminMode) None[source]
Set the Admin Mode of the device.
Subclasses can override this to change the behaviour of the
adminModeattribute.- Parameters:
mode – Admin Mode of the device.
- Raises:
ValueError – for unknown adminMode
StateModelError – for a disallowed transition
- is_adminMode_allowed(request_type: AttReqType) bool[source]
Check if the adminMode can be read/written currently.
This can be overridden by subclasses to restrict when clients can access the attribute.
- is_healthState_allowed(request_type: AttReqType) bool[source]
Check if the healthState can be read currently.
This can be overridden by subclasses to restrict when clients can access the attribute.
- read_healthState() HealthState | tuple[HealthState, float, AttrQuality][source]
Read the health state of the device.
Subclasses can override this to change the behaviour of the
healthStateattribute.
- is_healthInfo_allowed(request_type: AttReqType) bool[source]
Check if the healthInfo can be read currently.
This can be overridden by subclasses to restrict when clients can access the attribute.
- read_healthInfo() list[str] | tuple[list[str], float, AttrQuality][source]
Read the health info of the device.
Subclasses can override this to change the behaviour of the
healthInfoattribute.
- report_health(health_state: HealthState, health_info: list[str]) None[source]
Report the health of the device.
The
health_infoshould include all the reasons that the current device is reporting aDEGRADEDorFAILEDhealth_state. Each element should be a separate reason and should be as brief as possible, while still providing enough information to aid in diagnosis.If the
health_state == OK, then thehealth_infomust be an empty list.health_state == UNKNOWNis not supported from this interface. Usehealth_state == FAILEDwith a descriptivehealth_infoinstead, e.g. “component <x> is unreachable”.- Parameters:
health_state – The overall health state of the device
health_info – A list of reasons for the current overall health state
- Raises:
ValueError – If
health_state==OKandhealth_info != []ValueError – If
health_state==UNKNOWN
- ska_tango_base.future._base_interface.standard_control_mode(doc: str | None = None, **kwargs: Any) tuple[Signal[ControlMode], attribute_from_signal][source]
Return a signal and attribute pair for the optional
controlModeattribute.When set to
ControlMode.LOCAL, the Tango device accepts commands only from a local client and ignores commands and queries received from TM or any other remote clients. The local client must release LOCAL control before remote clients can take control again. The returned tuple should be unpacked into class-level signal and attribute declarations, for example:_control_mode, controlMode = standard_control_mode()
The attribute is writable and memorized. Override
docto provide a device-specific description.- Parameters:
doc – Optional override for the Tango attribute description.
kwargs – Additional keyword arguments forwarded to
attribute_from_signal().
- Returns:
A
(signal, attribute)tuple.
- ska_tango_base.future._base_interface.standard_simulation_mode(doc: str | None = None, **kwargs: Any) tuple[Signal[SimulationMode], attribute_from_signal][source]
Return a signal and attribute pair for the optional
simulationModeattribute.When
SimulationMode.TRUE, the device is using a simulator instead of real hardware. The returned tuple should be unpacked into class-level signal and attribute declarations, for example:_simulation_mode, simulationMode = standard_simulation_mode()
The attribute is writable and memorized. Override
docto provide a device-specific description.- Parameters:
doc – Optional override for the Tango attribute description.
kwargs – Additional keyword arguments forwarded to
attribute_from_signal().
- Returns:
A
(signal, attribute)tuple.
- ska_tango_base.future._base_interface.standard_test_mode(doc: str | None = None, **kwargs: Any) tuple[Signal[TestMode], attribute_from_signal][source]
Return a signal and attribute pair for the optional
testModeattribute.When
TestMode.TEST, the device substitutes its normal operating logic with testing/stub logic, which is useful for integration testing without real hardware. The returned tuple should be unpacked into class-level signal and attribute declarations, for example:_test_mode, testMode = standard_test_mode()
The attribute is writable and memorized. Override
docto provide a device-specific description.- Parameters:
doc – Optional override for the Tango attribute description.
kwargs – Additional keyword arguments forwarded to
attribute_from_signal().
- Returns:
A
(signal, attribute)tuple.