scope
¶
Base Scope device driver module.
Scope
¶
Scope(config_entry: DeviceConfigEntry, verbose: bool)
Base Scope device driver.
| Parameters: |
|
|---|
address
property
¶
address: str
Return the device address as defined in the config_entry.
This could be an IP address, hostname, or USB device address.
all_channel_names_list
property
¶
Return a tuple containing all the channel names.
command_argument_constants
cached
property
¶
command_argument_constants: Any
Return the device command argument constants.
command_syntax_enabled
property
¶
command_syntax_enabled: bool
Return a string containing the syntax of the command being accessed.
This property indicates when the syntax should be returned instead of writing/querying the device and returning the result.
command_verification_enabled
property
¶
command_verification_enabled: bool
Indicate if command verification is enabled.
This property only applies to commands sent using the .commands property of the
device.
Notes
- If
.enable_verificationis set toFalse, then no verification will happen at all. - If
.enable_verificationis set toTrueand this property isTrue, then verification will happen for commands sent using the.commandsproperty of the device. - If
.enable_verificationis set toTrueand this property isFalse, then verification will not happen for commands sent using the.commandsproperty of the device.
device_number
property
¶
device_number: int
Return the device number, if it was not created by the DeviceManager it will be -1.
enable_verification
property
writable
¶
enable_verification: bool
Return the boolean which indicates if verification checks should happen.
This can be disabled after developing a script in order to increase the speed of the script.
Notes
- If
.enable_verificationis set toFalse, then no verification of any commands sent using the.set_and_check()method will occur (the “check” portion of “set” and “check” will be skipped). - If
.enable_verificationis set toTrue, then verification will happen for commands sent using the.set_and_check()method (both the “set” and “check” portions will be executed).
hostname
cached
property
¶
hostname: str
Return the hostname of the device or an empty string if unable to fetch that.
ip_address
cached
property
¶
ip_address: str
Return the IPv4 address of the device or an empty string if unable to fetch that.
manufacturer
abstractmethod
cached
property
¶
manufacturer: str
Return the manufacturer of the device.
name_and_alias
cached
property
¶
name_and_alias: str
Return string for easy ID of device in console output prints.
series
cached
property
¶
series: str
Return the series of the device.
| Returns: |
|
|---|
sw_version
abstractmethod
cached
property
¶
sw_version: Version
Return the software version of the device.
total_channels
abstractmethod
cached
property
¶
total_channels: int
Return the total number of channels (all types).
add_method
classmethod
¶
add_method(method: Callable[Concatenate[Self, _P], _T]) -> None
Add a method to the class.
This class method is best used as a decorator on functions in order to add them to a class.
Examples:
>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_method
... def print_hello(self: Device, var: str):
... print("Hello World!")
... print(f"I am a {self.__class__.__name__}!")
... print(f"My var is {var}")
| Parameters: |
|
|---|
add_property
classmethod
¶
add_property(method: Callable[Concatenate[_EM, _P], _T]) -> None
add_property(
method: None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[Concatenate[_EM, _P], _T]], None]
add_property(
method: Callable[[Self], _T] | None = None, /, *, is_cached: bool = False
) -> Callable[[Callable[[Self], _T]], None] | None
Add a property to the class.
This class method is best used as a decorator on functions in order to add them to a class.
Examples:
>>> from tm_devices.drivers.device import Device
>>>
>>> @Device.add_property
... def foo(self: Device):
... return "bar"
>>>
>>> @Device.add_property(is_cached=True)
... def foo(self: Device):
... return self.name + self.address
| Parameters: |
|---|
check_network_connection
¶
Check the network connection to the device using an external ping command.
Wrapper function for
check_network_connection.
| Returns: |
|---|
check_port_connection
¶
Check if the given port is open on the device.
Wrapper function for check_port_connection.
| Parameters: |
|---|
| Returns: |
|
|---|
cleanup
¶
cleanup(verbose: bool = True) -> None
Perform the cleanup defined for the device.
| Parameters: |
|
|---|
command_syntax
¶
command_syntax() -> Generator[None, None, None]
Enable command syntax for the duration of this context manager.
This method is designed to be used as a context manager (with device.command_syntax():)
around any blocks of code where the literal syntax of commands accessed using the
.commands property is desired.
This is accomplished by setting the .command_syntax_enabled property to True for the
duration of the context manager.
command_verification
¶
command_verification() -> Generator[None, None, None]
Enable command verification for the duration of this context manager.
This method is designed to be used as a context manager (with
device.command_verification():) around any blocks of code where verification of commands
sent using the .commands property is desired.
This is accomplished by setting the .command_verification_enabled property to True
for the duration of the context manager.
get_errors
¶
has_errors
¶
has_errors() -> bool
Check if the device has any errors.
Note
This method will clear out the error queue after reading the current errors.
| Returns: |
|
|---|
reboot
¶
temporary_enable_verification
¶
Enable (or disable) all verification of communication for the duration of the context.
This will temporarily set the
Device.enable_verification
property to the specified value, and then reset it to the previous value
when the context exits.
| Parameters: |
|
|---|
temporary_verbose
¶
Set a temporary console output verbosity for the duration of the context.
This will reset the verbosity to the previous value when the context exits.
| Parameters: |
|
|---|
wait_for_network_connection
¶
wait_for_network_connection(
wait_time: float, sleep_seconds: int = 2, accept_immediate_connection: bool = False
) -> bool
Wait for a network connection to the device.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
wait_for_port_connection
¶
wait_for_port_connection(
port: int, wait_time: float, sleep_seconds: int = 5, accept_immediate_connection: bool = False
) -> bool
Wait for a connection to be made to the given port on the device.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|