mxcubecore.BaseHardwareObjects#
Classes
|
Superclass for classes that take configuration from YAML files |
|
Placeholder enumeration for HardwareObject-specific states |
|
Old superclass for devices |
Device ocntainer class - old style |
|
|
Class serves solely to provide a single supercalss combining HardwareObjectNode and DeviceContaine |
|
Equipment class -old style |
|
Xml-configured hardware object |
Functionality for either xml- or yaml-configured HardwareObjects |
|
|
Hardware Object Node |
|
Enumeration of common states, shared between all HardwareObjects |
|
Yaml-configured hardware object. |
|
This class ignores all parameters passed when constructing or calling instances and traps all attribute and method requests. |
|
|
Property Set |
- class mxcubecore.BaseHardwareObjects.ConfiguredObject(name: str)[source]#
Bases:
object
Superclass for classes that take configuration from YAML files
- Parameters:
name (str) –
- property all_objects_by_role: OrderedDict[str, Self | None]#
All contained Objects mapped by role (in specification order).
Includes objects defined in subclasses.
- Returns:
Contained objects mapped by role.
- Return type:
OrderedDict[str, Union[Self, None]]
- property all_roles: Tuple[str]#
Tuple of all content object roles, in definition and loading order
- Returns:
Content object roles
- Return type:
Tuple[str]
- property procedures: OrderedDict[str, Self]#
Procedures attached to this object mapped by name (in specification order).
- Returns:
Object procedures.
- Return type:
OrderedDict[str, Self]
- class mxcubecore.BaseHardwareObjects.DefaultSpecificState(value)[source]#
Bases:
Enum
Placeholder enumeration for HardwareObject-specific states
- class mxcubecore.BaseHardwareObjects.Device(name)[source]#
Bases:
HardwareObject
Old superclass for devices
Signals:
“deviceReady”
“deviceNotReady”
NB Deprecated - should be replaced by AbstractActuator
- class mxcubecore.BaseHardwareObjects.DeviceContainer[source]#
Bases:
object
Device ocntainer class - old style
NB Deprecated. Once DeviceContainerNode is removed, this clould be merged into Equipment
- class mxcubecore.BaseHardwareObjects.DeviceContainerNode(node_name: str)[source]#
Bases:
HardwareObjectNode
,DeviceContainer
Class serves solely to provide a single supercalss combining HardwareObjectNode and DeviceContaine
TODO.This class is Deprecated.
it is only used once, in HardwareObjectFileParser.HardwareObjectHandler.startElement And that use looks like it could be replaced by something else
- Parameters:
node_name (str) –
- class mxcubecore.BaseHardwareObjects.Equipment(name)[source]#
Bases:
HardwareObject
,DeviceContainer
Equipment class -old style
Signals:
equipmentReady”
“equipmentNotReady”
- NB This class needs refactoring. Since many (soon: all??) contained
objects are no longer of class Device, the code in here is unlikely to work.
- class mxcubecore.BaseHardwareObjects.HardwareObject(rootName: str)[source]#
Bases:
HardwareObjectNode
,HardwareObjectMixin
Xml-configured hardware object
- Parameters:
rootName (str) –
- property exported_attributes: Dict[str, Any]#
Get exported attributes.
- Returns:
Exported attributes.
- Return type:
Dict[str, Any]
- class mxcubecore.BaseHardwareObjects.HardwareObjectMixin[source]#
Bases:
CommandContainer
Functionality for either xml- or yaml-configured HardwareObjects
Signals emited:
stateChanged
specificStateChanged
- SPECIFIC_STATES#
enum.Enum: Placeholder for HardwareObject-specific states. To be overridden
alias of
DefaultSpecificState
- STATES#
enum.Enum: General states, shared between all HardwareObjects. Do not overridde
alias of
HardwareObjectState
- abort() None [source]#
Immediately terminate HardwareObject action.
Should not happen in state READY.
- Return type:
None
- clear_gevent() None [source]#
Clear gevent tasks, called when disconnecting a HardwareObject.
Override in subclasses as needed.
- Return type:
None
- connect(sender: str | object | Any, signal: str | Any, slot: Callable | None = None) None [source]#
Connect a signal sent by self to a slot.
The functions provides syntactic sugar ; Instead of
`python self.connect(self, "signal", slot) `
it is possible to do`python self.connect("signal", slot) `
TODO: This would be much nicer if refactored as
`python def connect(self, signal, slot, sender=None) `
- Parameters:
- Raises:
ValueError – If slot is None and “sender” parameter is not a string.
- Return type:
None
- disconnect(sender: str | object | Any, signal: str | Any, slot: Callable | None = None) None [source]#
Disconnect a signal sent by self to a slot.
The functions provides syntactic sugar ; Instead of
`python self.connect(self, "signal", slot) `
it is possible to do`python self.connect("signal", slot) `
TODO: This would be much nicer if refactored as
`python def disconnect(self, signal, slot, sender=None): ... `
- Parameters:
- Raises:
ValueError – If slot is None and “sender” parameter is not a string.
- Return type:
None
- emit(signal: str | object | Any, *args) None [source]#
Emit signal. Accepts both multiple args and a single tuple of args.
TODO: This function would be unnecessary if all callers used
`python dispatcher.send(signal, self, *argtuple) `
- execute_exported_command(cmd_name: str, args: Dict[str, Any]) Any [source]#
Execute exported command.
- force_emit_signals() None [source]#
Emits all hardware object signals
The method is called from the gui via beamline object to ensure that bricks have values after the initialization. Problem arrise when a hardware object is used by several bricks. If first brick connects to some signal emited by a brick then other bricks connecting to the same signal will not receive the values on the startup. The easiest solution is to call force_emit_signals method directly after the initialization of the beamline object
- Return type:
None
- get_specific_state() Any | None [source]#
Getter for specific_state attribute. Override if needed.
- Returns:
Specific state enum or None.
- Return type:
Union[Any, None]
- get_state() HardwareObjectState [source]#
Getter for state attribute.
Implementations must query the hardware directly, to ensure current results.
- Returns:
Current state.
- Return type:
- init() None [source]#
‘public’ post-initialization method. Override as needed.
For ConfiguredObjects called after loading contained objects.
- Return type:
None
- is_ready() bool [source]#
Convenience function: Check if the object state is READY.
The same effect could be achieved with
`python self.get_state() == self.STATES.READY `
- Returns:
True if ready, otherwise False.
- Return type:
- property pydantic_model: Dict[str, Type[BaseModel]]#
Get object Pydantic models.
- Returns:
Pydantic models for object.
- Return type:
Dict[str, Type[BaseModel]]
- re_emit_values() None [source]#
Update values for all internal attributes
Should be expanded in subclasse with more updatable attributes (e.g. value, limits)
- Return type:
None
- stop() None [source]#
Gentler (?) alternative to abort.
Override as necessary to implement.
- Return type:
None
- update_specific_state(state: Any | None = None) None [source]#
Update self._specific_state, and emit specificStateChanged if appropriate.
- Parameters:
state (Optional[Any], optional) – Specific state - the enumeration will be
None. (specific for each HardwareObject class. Defaults to) –
- Raises:
ValueError – If state specified is invalid.
- Return type:
None
- update_state(state: HardwareObjectState | None = None) None [source]#
Update self._state, and emit signal stateChanged if the state has changed.
- Parameters:
state (Optional[HardwareObjectState], optional) – State. Defaults to None.
- Raises:
ValueError – If state specified is invalid.
- Return type:
None
- class mxcubecore.BaseHardwareObjects.HardwareObjectNode(node_name: str)[source]#
Bases:
object
Hardware Object Node
- Parameters:
node_name (str) –
- add_object(name: str, hw_object: HardwareObject | None, role: str | None = None) None [source]#
Add hardware object mapped by name.
- Parameters:
name (str) – Name.
hw_object (Union[HardwareObject, None]) – Hardware object.
role (Optional[str], optional) – Role. Defaults to None.
- Return type:
None
- add_reference(name: str, reference: str, role: str | None = None) None [source]#
Add hardware object reference.
- get_object_by_role(role: str) HardwareObject | None [source]#
Get hardware object by role.
- Parameters:
role (str) – Role.
- Returns:
Hardware object.
- Return type:
Union[HardwareObject, None]
- get_objects(object_name: str) Generator[HardwareObject | None, None, None] [source]#
Get hardware objects by name.
- Parameters:
object_name (str) – Name.
- Yields:
Union[HardwareObject, None] – Hardware object.
- Return type:
Generator[HardwareObject | None, None, None]
- get_properties() PropertySet [source]#
Get properties.
- Returns:
Properties.
- Return type:
- get_property(name: str, default_value: Any | None = None) Any [source]#
Get property value.
- Parameters:
name (str) – Name
default_value (Optional[Any], optional) – Default value. Defaults to None.
- Returns:
Property value.
- Return type:
Any
- get_roles() List[str] [source]#
Get hardware object roles.
- Returns:
List of hardware object roles.
- Return type:
List[str]
- get_xml_path() str | None [source]#
Get XML file path.
- Returns:
XML file path.
- Return type:
Union[str, None]
- objects_names() List[str | None] [source]#
Return hardware object names.
- Returns:
List of hardware object names.
- Return type:
List[Union[str, None]]
- print_log(log_type: str = 'HWR', level: str = 'debug', msg: str = '') None [source]#
Print message to logger.
- resolve_references() None [source]#
Resolve hardware objects from defined references.
- Return type:
None
- set_name(name: str) None [source]#
Set node name
- Parameters:
name (str) – Name to set.
- Return type:
None
- set_path(path: str) None [source]#
Set the ‘path’ of the Hardware Object in the XML file describing it (the path follows the XPath syntax)
- Parameters:
path (str) – String representing the path of the Hardware Object in its file
- Return type:
None
- class mxcubecore.BaseHardwareObjects.HardwareObjectState(value)[source]#
Bases:
Enum
Enumeration of common states, shared between all HardwareObjects
- class mxcubecore.BaseHardwareObjects.HardwareObjectYaml(name: str)[source]#
Bases:
ConfiguredObject
,HardwareObjectMixin
Yaml-configured hardware object.
For use when we move configuration out of xml and into yaml.
The class is needed only to provide a single superclass that combines ConfiguredObject and HardwareObjectMixin
- Parameters:
name (str) –
- class mxcubecore.BaseHardwareObjects.Null(*args, **kwargs)[source]#
Bases:
object
This class ignores all parameters passed when constructing or calling instances and traps all attribute and method requests. Instances of it always (and reliably) do ‘nothing’.
The code might benefit from implementing some further special Python methods depending on the context in which its instances are used. Especially when comparing and coercing Null objects the respective methods’ iimplementation will depend very much on the environment and, hence, these special methods are not provided here.
- class mxcubecore.BaseHardwareObjects.Procedure(name: str)[source]#
Bases:
HardwareObject
- Parameters:
name (str) –
- class mxcubecore.BaseHardwareObjects.PropertySet[source]#
Bases:
dict
Property Set
- get_changes() Generator[tuple, None, None] [source]#
Get property changes since the last time checked.