Communication Interface¤
Internal support package (instro.lib.cominterface).
Contains shared primitives used by instruments and drivers (types, transports, publishers, utilities).
ComInterfaceClass
¤
ComInterfaceClass(connect_config: ConnectConfig)
Bases: ComInterfaceClassBase
Parent abstract class for ComInterface.
Parameters:
-
(connect_config¤ConnectConfig) –The config for connection
ConnectConfig
dataclass
¤
ConnectConfig(
visa_resource: str = "",
visa_backend: str = "@ivi",
serial_config: SerialConfig = SerialConfig(),
terminator: TerminatorConfig = TerminatorConfig(),
timeout: TimeoutConfig = TimeoutConfig(),
network: NetworkConfig = NetworkConfig(),
interface_type: str = "visa",
)
The config data class for connection.
For non-windows user, will use the self rewrite backend to handle For Windows user, will use the NI-VISA as the backend For using socket, will use the python socket as the backend
If you are using the socket, fill out socket_host, socket_port If using visa and it's non Serial, fill out visa_resource If using visa and it's Serial, fill out visa_resource, serial_config
Attributes:
-
visa_resource(str) –The visa resource that you can find via scan
-
visa_backend(str) –The visa backend to use. Default is '@ivi'
-
serial_config(SerialConfig) –The config for connect with serial
-
terminator(TerminatorConfig) –The terminator config
-
timeout(TimeoutConfig) –The timeout config
-
network(NetworkConfig) –The network config
serial_config
class-attribute
instance-attribute
¤
serial_config: SerialConfig = field(default_factory=SerialConfig)
terminator
class-attribute
instance-attribute
¤
terminator: TerminatorConfig = field(default_factory=TerminatorConfig)
timeout
class-attribute
instance-attribute
¤
timeout: TimeoutConfig = field(default_factory=TimeoutConfig)
DataHandler
¤
DataHandler(interface: ComInterfaceClass)
Visa
¤
Visa(connect_config)
Bases: ComInterfaceClass
Child ComInterfaceClass Module of visa.
apply_timeout
¤
apply_timeout(
timeout_type: TimeoutType, timeout: int | None = None
) -> None
set_timeout
¤
send_raw
¤
recv_raw
¤
query_raw
¤
acquire_resource
¤
acquire_resource()
Context manager to acquire the VISA resource lock for complex operations.
This allows users to perform multiple operations atomically without releasing the lock between operations.
Returns:
-
–
A context manager that can be used with 'with' statement.
select
¤
select(connect_config: ConnectConfig) -> ComInterfaceClass
The select function for cominterface.
This function will auto select the right backend for user base on the input information.
Parameters:
-
(connect_config¤ConnectConfig) –The config for connection
Returns:
-
ComInterfaceClass–The built ComInterfaceClass