Component
- class ska_csp_lmc_common.component.Component(fqdn: str, name: str, weight: int = 0, logger=None)
Bases:
object
Interface class to a sub-system device.
- __init__(fqdn: str, name: str, weight: int = 0, logger=None) None
Initialize the component instance.
- Parameters:
fqdn – the sub-system FQDN
name – the component name (for ex. ‘cbf-ctrl’, ‘pss-ctrl’, ‘pst-beam-1’, etc)
name – string
weight – the sub-system ‘weight’. CBF sub-system has an higher impact on the CSP.LMC functionalities.
logger – a logger for this instance
- __hash__()
Define the __hash__() method for the Component class to use this object as a key in a python dictionary.
- __eq__(other: Component)
Define the __eq__() method for the Component class to use this object as a key in a python dictionary.
- __key()
Define the __key() method for the Component class to use this object as a key in a python dictionary.
- property event_id: List[int]
Return the list of registered events.
- Returns:
A list with the ID of the events subscribed on the component.
- property event_attrs: List[str]
Return the list of attributes subscribed for events.
- Returns:
A list with the attributes subscribed on the component.
- property fqdn
Return the FQDN of the sub-system associated to the current component.
- property proxy
Return the DeviceProxy with the CSP sub-system TANGO device if this is reachable, otherwise None.
- property state
Return the sub-system state.
- Returns:
the sub-system State if updated via events or via direct read, UNKNOWN on failure
- property health_state
Return the sub-system health_state.
- Returns:
the sub-system healthState if updated via events or via direct read, UNKNOWN on failure
- property admin_mode
Return the sub-system admin_mode.
- Returns:
the sub-system adminmode if updated via events or via direct read, UNKNOWN on failure
- property long_running_commands_in_queue
Return the sub-system longRunningCommandsInQueue.
- Returns:
the sub-system longRunningCommandsInQueue if updated via events or via direct read, UNKNOWN on failure
- property long_running_command_status
Return the sub-system longRunningCommandStatus.
- Returns:
the sub-system longRunningCommandStatus if updated via events or via direct read, UNKNOWN on failure
- _get_attribute(attr_name: str) Any
Return the value of the required attribute. If the attribute is not initialized, its value is retrieved via direct read on the sub- system.name.
- Parameters:
attr_name – the name of the attribute
- Returns:
the attribute value on success, None otherwise
- _update_component_info(recv_evt: tango.EventData, *new_evt: CspEvent) bool
Method to update the sub-system component manager internal status when an event generated by the sub-system TANGO device is caught.
- Parameters:
recv_evt – the event generated by the CSP sub-system TANGO device
new_evt – the eve/nt forwarded back to the CSP TANGO device.
- Returns:
True to forward the event value back to the CSP device.
- _handle_event_errors(recv_event, fwd_event: CspEvent)
Method to handle the error conditions on received events. Events with errors are not always propagated back to the main CSP device.
- Parameters:
recv_event – the received event
- Returns:
True if the received event is forwarded back to the CSP device, otherwise False
- _push_event(recv_event: tango.EventData, device_attr_name=None) None
Callback function invoked when an event is received. The method checks for errors: when a loss of connection is detected, the value of the attribute is set to UNKNOWN, if the attribute support this value, otherwise to None (with quality factor set to INVALID). In the first case the attribute is updated inside the component class, too. After all checks, the method invokes the callback register at subscription, if any, passing as argument an instance of the CspEvent class with the new value.
- Parameters:
recv_event – The received event data class
device_attr_name – attribute name specified by the component class. It help to manage the attribute name mismatch between component device and CSP device
- Returns:
None
- set_component_disconnected()
This method is called when the CSP TANGO Device adminMode is set to OFFLINE.
In this case the CSP Device componentManager does no longer monitor the component and its information are reported as unknown. The component admin mode is left unchanged.
- set_component_unknown(admin_mode_value: ska_control_model.AdminMode) None
This method is called when the component experiences a loss of connection. In this context, this method sets the State and healthState attribute to UNKNOWN. For the other attributes, the value is set to the default value None and quality_factor to ATTR_INVALID.
- Parameters:
args – an instance of the CspEvent class with the new values.
- Returns:
None
- set_component_offline(admin_mode_value: ska_control_model.AdminMode) None
This method is called when the received event is related to a device not registered into the DB or its admin mode is OFFLINE/NOT-FITTED In this context, this method sets the State or healthState attribute to UNKNOWN. For the other attributes, the value is set to the default value None and quality_factor to ATTR_INVALID.
- Parameters:
admin_mode_value – the value of the CSP sub-system device adminMode.
- Returns:
None
- connect() Connector | None
Establish the connection with a sub-system device. Connection retries happen with a interval configured via the device property PingConnectionTime. If the subordinate device is not registered into the TANGO DB, the CSP Controller/Subarray device tries connection up to 3 times before throwing an exception and considering the sub-system not on-line (available). This approach is related to the deployment procedure: each sub-system configures the TANGO DB independently, through a configurator process. It may happen that the CSP Controller/Subarray is already running while the configurator of one or more sub-systems is still writing the TANGO DB. In this case, the CSP would not be able to detect the sub-system because the DB is fully configured. Retry operations provide more time to wait for the end of the TANGO DB configuration.
- Returns:
The Connector on success, otherwise None
- Raise:
a DevFailed exception on connection failure.
- disconnect() None
Invalidate the connection with the CSP Sub-subsystem and report the main SKA SCM attributes accordingly to the expected values.
- read_attr(attribute: str) Any
Return the value of the requested attribute.
- Parameters:
attribute – the attribute name
- Returns:
the attribute value, if the attribute does exist on the sub-system device
- Raise:
a ValueError exception if the attribute does not exist or read failure.
- write_attr(attribute: str, value: Any) None
Set the value of the requested attribute.
- Parameters:
attribute – the attribute name
value – the value to set
- Raise:
a ValueError exception if the attribute does not exist
- force_attribute_update(attr_name: str) None
Update the attribute via a direct read. it also invokes the _push_event method to the EventManager internal attribute value.
- Parameters:
attr_name – the name of the attribute forced to read.
- run(command_name: str, async_flag: bool = True, argument: Any | None = None, callback: Callable | None = None) Any
Execute a command on the target device.
- Parameters:
command_name – the command name
async_flag – set the execution model (async/sync)
argument – the command argument, if any
callback – callable called when the command ends on the target device, if any
- read_timeout(command_name: str) int
Read the timeout configured for a command.
- Parameters:
command_name – the command name
- Returns:
the timeout configured (in secs) or 0 on failure
- is_attribute_in_list(attr_name: str) bool
Whether the specified attribute is exported by subsystem device.
- Parameters:
attr_name – the attribute name
- subscribe_attribute(attr_name: str, event_type: tango.EventType, evt_mgr_callback: Callable | None = None) bool
Subscribe to any event.
- Parameters:
attr_name – the attribute name
event_type – the event type (CHANGE_EVENT, PERIODIC, etc..)
evt_mgr_callback – the EventManager method called when the event is received.
- Returns:
True on subscription success, otherwise False.
- unsubscribe_attribute(attr_list: List[str] | None = None) None
Unsubscribe the event on the specified attributes. If the event_id dictionary is empty, the event_callback is un-registered.
- Parameters:
attr_list – the list of attributes to un-subscribe event on. If the list is empty, all the subscribed events on the sub-system are un-subscribed.
- Returns:
None (?) <=== CHECK
- on(resources: Any | None = None, callback: Callable | None = None) None
Define the behavior of the On command for a component. Override this method as required. This method has been specialized to work with CSP sub-systems Controllers devices.
- Parameters:
callback – callable object invoked when command completes on the target TANGO Device.
- standby(callback: Callable | None = None) None
Define the behavior of the Standby command for a component. Override this method as required. This method has been specialized to work with CSP sub-systems Controllers devices.
- Parameters:
callback – callable object invoked when command completes on the target TANGO Device.
- off(callback: Callable | None = None) None
Define the behavior of the Off command for a component. Override this method as required. This method has been specialized to work with CSP sub-systems Controllers devices.
- Parameters:
callback – callable object invoked when command completes on the target TANGO Device.