Interfaces¶
Getting Started¶
Interfaces are responsible for discovering and instantiating resource objects. They may also handle low-level operating system interactions. This may include calls to hardware via driver stacks, or calls to other Python libraries. Resources do not have an inherent dependency on the interface that instantiates it.
All interfaces are subclasses of labtronyx.InterfaceBase:
import labtronyx
class INTERFACE_CLASS_NAME(labtronyx.InterfaceBase):
pass
Required Attributes¶
Interfaces require some attributes to be defined
- interfaceName - str that names the interface.
- enumerable - True if the interface supports resource enumeration. If False, the interface should implement the
openResource()method to manually open a resource given a string identifier.
-
class
labtronyx.bases.interface.InterfaceBase(manager, **kwargs)[source]¶ Interface Base Class
Parameters: - manager (labtronyx.manager.InstrumentManager) – InstrumentManager instance
- logger (logging.Logger) – Logger instance
-
close()[source]¶ Destroy all resource objects owned by the interface.
May be extended by subclasses if any additional work is necessary to clean-up interface operations.
Returns: True if successful, False otherwise Return type: bool
-
enumerate()[source]¶ Refreshes the resource list by enumerating all of the available devices on the interface.
-
getResource(resID)[source]¶ Get a resource that may not be previously known to the interface. Attempts to open the resource using the given identifier. A ResourceUnavailable exception will be raised if the resource could not be located or opened.
Parameters: resID (str) – Resource Identifier Returns: object Raises: ResourceUnavailable
-
open()[source]¶ Make any system driver calls necessary to initialize communication. This method must not raise any exceptions.
This function is meant to be implemented by subclasses.
Returns: True if ready, False if error occurred Return type: bool
-
refresh()[source]¶ Macro for interfaces that support enumeration. Calls enumerate then prune to get an updated list of resources available to the interface
-
resources¶ Dictionary of resource objects by UUID
Return type: dict{str: labtronyx.bases.resource.ResourceBase}