ni_measurementlink_service._drivers
Shared code for interfacing with driver APIs.
Package Contents
Classes
Specifies whether to initialize a new session or attach to an existing session. |
Functions
Create a context manager that closes the session. |
|
|
A context manager that yields the session and closes it. |
Attributes
- class ni_measurementlink_service._drivers.SessionInitializationBehavior[source]
Bases:
enum.IntEnumSpecifies whether to initialize a new session or attach to an existing session.
- AUTO = 0
The NI gRPC Device Server will attach to an existing session with the specified name if it exists, otherwise the server will initialize a new session.
Note: When using the Session as a context manager and the context exits, the behavior depends on what happened when the constructor was called. If it resulted in a new session being initialized on the NI gRPC Device Server, then it will automatically close the server session. If it instead attached to an existing session, then it will detach from the server session and leave it open.
- INITIALIZE_SERVER_SESSION = 1
Initialize a new session with the specified name.
Note: When using the Session as a context manager and the context exits, it will automatically close the server session.
- ATTACH_TO_SERVER_SESSION = 2
Attach to an existing session with the specified name.
Note: When using the Session as a context manager and the context exits, it will detach from the server session and leave it open.
- INITIALIZE_SESSION_THEN_DETACH = 3
Initialize a new session.
When exiting the context manager, detach instead of closing.
Note: This initialization behavior is intended for TestStand code modules used in
Setupsteps orProcessSetupcallback sequences.
- ATTACH_TO_SESSION_THEN_CLOSE = 4
Attach to an existing session.
When exiting the context manager, automatically close the server session.
Note: This initialization behavior is intended for TestStand code modules used in
Cleanupsteps orProcessCleanupcallback sequences.
- ni_measurementlink_service._drivers.TSession
- ni_measurementlink_service._drivers.closing_session_with_ts_code_module_support(initialization_behavior, session)[source]
Create a context manager that closes the session.
Emulates the behavior of INITIALIZE_SESSION_THEN_DETACH and ATTACH_TO_SESSION_THEN_CLOSE.
- Parameters:
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) –
session (TSession) –
- Return type:
ContextManager[TSession]