Test Mode Mixin

Mixin to provide testMode and test mode overrides for an SKA Tango device.

ska_tango_base.test_mode_mixin.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 testMode attribute.

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 doc to 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.

class ska_tango_base.test_mode_mixin.TestModeOverrideMixin[source]

Add Test Mode Attribute Overrides to a Tango device.

When testMode is TEST, clients can override the value of attributes using the test_mode_overrides attribute.

init_device() None[source]

Add our variables to the class we are extending.

_test_mode: Signal[scm.TestMode]

Signal for the test mode of the device.

Values are emitted for this signal whenever a client successfully changes to the testMode attribute.

testMode: attribute_from_signal

Test mode attribute of the device.

Either no test mode or an indication of the test mode.

read_testMode() TestMode | tuple[TestMode, float, AttrQuality][source]

Read the test mode of the device.

Subclasses can override this to change the behaviour of the testMode attribute.

write_testMode(mode: TestMode) None[source]

Write the test mode of the device.

Subclasses can override this to change the behaviour of the testMode attribute.

is_test_mode_overrides_allowed(request_type: AttReqType) bool[source]

Control access to test_mode_overrides attribute.

Writes to the attribute are allowed only if test mode is active.

Parameters:

request_type – Attribute request type

Returns:

If in test mode

read_test_mode_overrides() str | tuple[str, float, AttrQuality][source]

Read the current override configuration.

Returns:

JSON-encoded dictionary (attribute name: value)

write_test_mode_overrides(overrides: str) None[source]

Read the override configuration.

Parameters:

value_str – JSON-encoded dict of overrides (attribute name: value)

_build_state: str

Value returned by the buildState attribute.

Should be set by subclasses during device initialisation.

Typically this will include the name of the python package, the version number of that package and a brief description of that package.

_version_id: str

Value returned by the versionId attribute.

Should be set by subclasses during device initialisation.

Must be of the form "<major>.<minor>.<patch>".

ska_tango_base.test_mode_mixin.overridable(func: Callable[[Concatenate[C, P]], Any] | None = None, *, name: str | None = None) Callable[[Concatenate[C, P]], Any][source]

Decorate attribute with test mode overrides.

Parameters:

func – Tango attribute

Returns:

Overridden value or original function