ni_measurementlink_service
releases/1.4
  • API Reference
ni_measurementlink_service
  • ni_measurementlink_service._drivers
  • Edit on GitHub

ni_measurementlink_service._drivers

Shared code for interfacing with driver APIs.

Package Contents

Classes

SessionInitializationBehavior

Specifies whether to initialize a new session or attach to an existing session.

Functions

closing_session_with_ts_code_module_support(...)

Create a context manager that closes the session.

closing_session(session)

A context manager that yields the session and closes it.

Attributes

TSession

class ni_measurementlink_service._drivers.SessionInitializationBehavior[source]

Bases: enum.IntEnum

Specifies 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 Setup steps or ProcessSetup callback 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 Cleanup steps or ProcessCleanup callback 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]

ni_measurementlink_service._drivers.closing_session(session)[source]

A context manager that yields the session and closes it.

Parameters:

session (TSession) –

Return type:

ContextManager[TSession]


© Copyright 2024, National Instruments. Revision 2ba12c60.

Built with Sphinx using a theme provided by Read the Docs.