ni_measurementlink_service.session_management
Public API for accessing the MeasurementLink session management service.
Package Contents
Classes
Client for accessing the MeasurementLink session management service. |
|
Manages session reservation. |
|
Manages multiplexer session information. |
|
Manages reservation for multiple sessions. |
|
Manages reservation for a single session. |
|
Mapping of each channel to the pin and site it is connected to. |
|
Describes the connection between an instance of a pin and an instrument channel. |
|
Container for the pin map and sites. |
|
Container for the multiplexer session information. |
|
Container for the session information. |
|
Specifies whether to initialize a new session or attach to an existing session. |
|
Generic version of |
|
Generic version of Connection that preserves the instrument and multiplexer session type. |
|
Generic version of |
|
Generic version of |
Attributes
Site number used to identify and filter by system pins. |
|
Alias for compatibility with code that uses session_management.Client. |
- class ni_measurementlink_service.session_management.SessionManagementClient(*, discovery_client=None, grpc_channel=None, grpc_channel_pool=None)[source]
Bases:
objectClient for accessing the MeasurementLink session management service.
- Parameters:
discovery_client (Optional[ni_measurementlink_service.discovery.DiscoveryClient]) –
grpc_channel (Optional[grpc.Channel]) –
grpc_channel_pool (Optional[ni_measurementlink_service.grpc.channelpool.GrpcChannelPool]) –
- reserve_session(context, pin_or_relay_names=None, instrument_type_id=None, timeout=0.0)[source]
Reserve a single session.
Reserve the session matching the given pins, sites, and instrument type ID and return the information needed to create or access the session.
- Parameters:
context (ni_measurementlink_service.session_management._types.PinMapContext) – Includes the pin map ID for the pin map in the Pin Map Service, as well as the list of sites for the measurement.
pin_or_relay_names (Union[str, Iterable[str], None]) –
One or multiple pins, pin groups, relays, or relay groups to use for the measurement.
If unspecified, reserve sessions for all pins and relays in the registered pin map resource.
instrument_type_id (Optional[str]) –
Instrument type ID for the measurement.
If unspecified, this method reserve sessions for all instrument types connected in the registered pin map resource.
For NI instruments, use instrument type id constants, such as
INSTRUMENT_TYPE_NI_DCPOWERorINSTRUMENT_TYPE_NI_DMM.For custom instruments, use the instrument type id defined in the pin map file.
timeout (Optional[float]) –
Timeout in seconds.
Allowed values: 0 (non-blocking, fails immediately if resources cannot be reserved), -1 (infinite timeout), or any other positive numeric value (wait for that number of seconds)
- Returns:
A reservation object with which you can query information about the session and unreserve it.
- Return type:
ni_measurementlink_service.session_management._reservation.SingleSessionReservation
- reserve_sessions(context, pin_or_relay_names=None, instrument_type_id=None, timeout=0.0)[source]
Reserve multiple sessions.
Reserve sessions matching the given pins, sites, and instrument type ID and return the information needed to create or access the sessions.
- Parameters:
context (ni_measurementlink_service.session_management._types.PinMapContext) – Includes the pin map ID for the pin map in the Pin Map Service, as well as the list of sites for the measurement.
pin_or_relay_names (Union[str, Iterable[str], None]) –
One or multiple pins, pin groups, relays, or relay groups to use for the measurement.
If unspecified, reserve sessions for all pins and relays in the registered pin map resource.
instrument_type_id (Optional[str]) –
Instrument type ID for the measurement.
If unspecified, this method reserves sessions for all instrument types connected in the registered pin map resource.
For NI instruments, use instrument type id constants, such as
INSTRUMENT_TYPE_NI_DCPOWERorINSTRUMENT_TYPE_NI_DMM.For custom instruments, use the instrument type id defined in the pin map file.
timeout (Optional[float]) –
Timeout in seconds.
Allowed values: 0 (non-blocking, fails immediately if resources cannot be reserved), -1 (infinite timeout), or any other positive numeric value (wait for that number of seconds)
- Returns:
A reservation object with which you can query information about the sessions and unreserve them.
- Return type:
ni_measurementlink_service.session_management._reservation.MultiSessionReservation
- register_sessions(session_info)[source]
Register sessions with the session management service.
Indicates that the sessions are open and will need to be closed later.
- Parameters:
session_info (Iterable[ni_measurementlink_service.session_management._types.SessionInformation]) – Sessions to register.
- Return type:
None
- unregister_sessions(session_info)[source]
Unregisters sessions from the session management service.
Indicates that the sessions have been closed and will need to be reopened before they can be used again.
- Parameters:
session_info (Iterable[ni_measurementlink_service.session_management._types.SessionInformation]) – Sessions to unregister.
- Return type:
None
- reserve_all_registered_sessions(instrument_type_id=None, timeout=0.0)[source]
Reserve all sessions currently registered with the session management service.
- Parameters:
instrument_type_id (Optional[str]) –
Instrument type ID for the measurement.
If unspecified, reserve sessions for all instrument types connected in the registered pin map resource.
For NI instruments, use instrument type id constants, such as
INSTRUMENT_TYPE_NI_DCPOWERorINSTRUMENT_TYPE_NI_DMM.For custom instruments, use the instrument type id defined in the pin map file.
timeout (Optional[float]) –
Timeout in seconds.
Allowed values: 0 (non-blocking, fails immediately if resources cannot be reserved), -1 (infinite timeout), or any other positive numeric value (wait for that number of seconds)
- Returns:
A reservation object with which you can query information about the sessions and unreserve them.
- Return type:
ni_measurementlink_service.session_management._reservation.MultiSessionReservation
- register_multiplexer_sessions(multiplexer_session_info)[source]
Register multiplexer sessions with the session management service.
Indicates that the sessions are open and will need to be closed later.
- Parameters:
multiplexer_session_info (Iterable[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation]) – Sessions to register.
- Return type:
None
- unregister_multiplexer_sessions(multiplexer_session_info)[source]
Unregisters multiplexer sessions from the session management service.
Indicates that the sessions have been closed and will need to be reopened before they can be used again.
- Parameters:
multiplexer_session_info (Iterable[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation]) – Sessions to unregister.
- Return type:
None
- get_multiplexer_sessions(pin_map_context, multiplexer_type_id=None)[source]
Get all multiplexer session infos matching the specified criteria.
Returns the information needed to create or access the multiplexer sessions without reserving the connected instruments.
- Parameters:
pin_map_context (ni_measurementlink_service.session_management._types.PinMapContext) – Includes the pin map ID for the pin map in the pin map service, as well as the list of sites for the measurement.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
The multiplexer session container with the matching session infos.
- Return type:
ni_measurementlink_service.session_management._reservation.MultiplexerSessionContainer
- get_all_registered_multiplexer_sessions(multiplexer_type_id=None)[source]
Get all multiplexer session infos registered with the session management service.
- Parameters:
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
The multiplexer session container with the matching session infos registered with the session management service.
- Return type:
ni_measurementlink_service.session_management._reservation.MultiplexerSessionContainer
- ni_measurementlink_service.session_management.GRPC_SERVICE_CLASS = 'ni.measurementlink.sessionmanagement.v1.SessionManagementService'
- ni_measurementlink_service.session_management.GRPC_SERVICE_INTERFACE_NAME = 'ni.measurementlink.sessionmanagement.v1.SessionManagementService'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DAQMX = 'niDAQmx'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DCPOWER = 'niDCPower'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DIGITAL_PATTERN = 'niDigitalPattern'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DMM = 'niDMM'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_FGEN = 'niFGen'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_HSDIO = 'niHSDIO'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_MODEL_BASED_INSTRUMENT = 'niModelBasedInstrument'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RELAY_DRIVER = 'niRelayDriver'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFMX = 'niRFmx'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFPM = 'niRFPM'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFSA = 'niRFSA'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFSG = 'niRFSG'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_SCOPE = 'niScope'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_SWITCH_EXECUTIVE_VIRTUAL_DEVICE = 'niSwitchExecutiveVirtualDevice'
- ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NONE = ''
- ni_measurementlink_service.session_management.SITE_SYSTEM_PINS
Site number used to identify and filter by system pins.
Pins that have a site number of
SITE_SYSTEM_PINSare system pins and do not belong to a specific site.When querying connections, you can specify a site number of
SITE_SYSTEM_PINSto restrict the query to return only system pins.
- class ni_measurementlink_service.session_management.BaseReservation(session_management_client, session_info, multiplexer_session_info=None, pin_or_relay_group_mappings=None, reserved_pin_or_relay_names=None, reserved_sites=None)[source]
Bases:
_BaseSessionContainerManages session reservation.
- Parameters:
session_management_client (ni_measurementlink_service.session_management._client.SessionManagementClient) –
session_info (Sequence[ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1.session_management_service_pb2.SessionInformation]) –
multiplexer_session_info (Optional[Sequence[ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1.session_management_service_pb2.MultiplexerSessionInformation]]) –
pin_or_relay_group_mappings (Optional[Mapping[str, Iterable[str]]]) –
reserved_pin_or_relay_names (Union[str, Iterable[str], None]) –
reserved_sites (Optional[Iterable[int]]) –
- property multiplexer_session_info: Sequence[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation]
Multiplexer session information object.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation]
- __exit__(exc_type, exc_val, traceback)[source]
Context management protocol. Calls unreserve().
- Parameters:
exc_type (Optional[Type[BaseException]]) –
exc_val (Optional[BaseException]) –
traceback (Optional[types.TracebackType]) –
- Return type:
Literal[False]
- initialize_session(session_constructor, instrument_type_id)[source]
Initialize a single instrument session.
This is a generic method that supports any instrument driver.
- Parameters:
session_constructor (Callable[[ni_measurementlink_service.session_management._types.SessionInformation], ni_measurementlink_service.session_management._types.TSession]) – A function that constructs sessions based on session information.
instrument_type_id (str) –
Instrument type ID for the session.
For custom instruments, use the instrument type id defined in the pin map file.
- Returns:
A context manager that yields a session information object. The session object is available via the
sessionfield.- Raises:
ValueError – If the instrument type ID is empty, no reserved sessions match the instrument type ID, or too many reserved sessions match the instrument type ID.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[ni_measurementlink_service.session_management._types.TSession]]
- initialize_multiplexer_session(session_constructor, multiplexer_type_id=None)[source]
Initialize a single multiplexer session.
This is a generic method that supports any multiplexer driver.
- Parameters:
session_constructor (Callable[[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation], ni_measurementlink_service.session_management._types.TMultiplexerSession]) – A function that constructs multiplexer sessions based on multiplexer session information.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a multiplexer session information
object. The session object is available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available or too many multiplexer sessions are available.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_sessions(session_constructor, instrument_type_id)[source]
Initialize multiple instrument sessions.
This is a generic method that supports any instrument driver.
- Parameters:
session_constructor (Callable[[ni_measurementlink_service.session_management._types.SessionInformation], ni_measurementlink_service.session_management._types.TSession]) – A function that constructs sessions based on session information.
instrument_type_id (str) –
Instrument type ID for the session.
For custom instruments, use the instrument type id defined in the pin map file.
- Returns:
A context manager that yields a sequence of session information objects. The session objects are available via the
sessionfield.- Raises:
ValueError – If the instrument type ID is empty or no reserved sessions matched the instrument type ID.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[ni_measurementlink_service.session_management._types.TSession]]]
- initialize_multiplexer_sessions(session_constructor, multiplexer_type_id=None)[source]
Initialize multiple multiplexer sessions.
This is a generic method that supports any multiplexer driver.
- Parameters:
session_constructor (Callable[[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation], ni_measurementlink_service.session_management._types.TMultiplexerSession]) – A function that constructs multiplexer sessions based on multiplexer session information.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a sequence of multiplexer session information
objects. The session objects are available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[ni_measurementlink_service.session_management._types.TMultiplexerSession]]]
- get_connection(session_type, pin_or_relay_name=None, site=None, instrument_type_id=None)[source]
Get the connection matching the specified criteria.
This is a generic method that supports any instrument driver.
- Parameters:
session_type (Type[ni_measurementlink_service.session_management._types.TSession]) – The session type.
pin_or_relay_name (Optional[str]) – The pin or relay name to match against. If not specified, the pin or relay name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
instrument_type_id (Optional[str]) – The instrument type ID to match against. If not specified, the instrument type ID is ignored when matching connections.
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[ni_measurementlink_service.session_management._types.TSession]
- get_connection_with_multiplexer(session_type, multiplexer_session_type, pin_or_relay_name=None, site=None, instrument_type_id=None)[source]
Get the connection matching the specified criteria.
This is a generic method that supports any instrument driver.
- Parameters:
session_type (Type[ni_measurementlink_service.session_management._types.TSession]) – The instrument session type.
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_or_relay_name (Optional[str]) – The pin or relay name to match against. If not specified, the pin or relay name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
instrument_type_id (Optional[str]) – The instrument type ID to match against. If not specified, the instrument type ID is ignored when matching connections.
- Returns:
The matching connection along with its multiplexer info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[ni_measurementlink_service.session_management._types.TSession, ni_measurementlink_service.session_management._types.TMultiplexerSession]
- get_connections(session_type, pin_or_relay_names=None, sites=None, instrument_type_id=None)[source]
Get all connections matching the specified criteria.
This is a generic method that supports any instrument driver.
- Parameters:
session_type (Type[ni_measurementlink_service.session_management._types.TSession]) – The expected session type.
pin_or_relay_names (Union[str, Iterable[str], None]) – The pin or relay name(s) to match against. If not specified, the pin or relay name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
instrument_type_id (Optional[str]) – The instrument type ID to match against. If not specified, the instrument type ID is ignored when matching connections.
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[ni_measurementlink_service.session_management._types.TSession]]
- get_connections_with_multiplexer(session_type, multiplexer_session_type, pin_or_relay_names=None, sites=None, instrument_type_id=None)[source]
Get all connections matching the specified criteria.
This is a generic method that supports any instrument driver.
- Parameters:
session_type (Type[ni_measurementlink_service.session_management._types.TSession]) – The instrument session type.
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_or_relay_names (Union[str, Iterable[str], None]) – The pin or relay name(s) to match against. If not specified, the pin or relay name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
instrument_type_id (Optional[str]) – The instrument type ID to match against. If not specified, the instrument type ID is ignored when matching connections.
- Returns:
The matching connections along with their multiplexer(s) info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[ni_measurementlink_service.session_management._types.TSession, ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- create_nidaqmx_task(initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Create a single NI-DAQmx task.
- Parameters:
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will create a new task or attach to an existing task.
- Returns:
A context manager that yields a session information object. The task object is available via the
sessionfield.- Raises:
ValueError – If no NI-DAQmx tasks are reserved or too many NI-DAQmx tasks are reserved.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidaqmx.Task]]
Note
If the
session_existsfield isFalse, the returned task is empty and the caller is expected to add channels to it.See also
For more details, see
nidaqmx.Task.
- create_nidaqmx_tasks(initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Create multiple NI-DAQmx tasks.
- Parameters:
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will create a new task or attach to an existing task.
- Returns:
A context manager that yields a sequence of session information objects. The task objects are available via the
sessionfield.- Raises:
ValueError – If no NI-DAQmx tasks are reserved.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidaqmx.Task]]]
Note
If the
session_existsfield isFalse, the returned tasks are empty and the caller is expected to add channels to them.See also
For more details, see
nidaqmx.Task.
- get_nidaqmx_connection(pin_name=None, site=None)[source]
Get the NI-DAQmx connection matching the specified criteria.
- Parameters:
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[nidaqmx.Task]
- get_nidaqmx_connection_with_multiplexer(multiplexer_session_type, pin_name=None, site=None)[source]
Get the NI-DAQmx connection matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_name (Optional[str]) – The pin name to match against. If not specified, the pin name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connection with its multiplexer info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidaqmx.Task, ni_measurementlink_service.session_management._types.TMultiplexerSession]
- get_nidaqmx_connections(pin_names=None, sites=None)[source]
Get all NI-DAQmx connections matching the specified criteria.
- Parameters:
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[nidaqmx.Task]]
- get_nidaqmx_connections_with_multiplexer(multiplexer_session_type, pin_names=None, sites=None)[source]
Get all NI-DAQmx connections matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_names (Union[str, Iterable[str], None]) – The pin name(s) to match against. If not specified, the pin name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connections with their multiplexer(s) info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidaqmx.Task, ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_nidcpower_session(reset=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize a single NI-DCPower instrument session.
- Parameters:
reset (bool) – Specifies whether to reset channel(s) during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIDCPOWER_SIMULATE,NIDCPOWER_BOARD_TYPE, andNIDCPOWER_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a session information object. The session object is available via the
sessionfield.- Raises:
ValueError – If no NI-DCPower sessions are reserved or too many NI-DCPower sessions are reserved.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidcpower.Session]]
See also
For more details, see
nidcpower.Session.
- initialize_nidcpower_sessions(reset=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize multiple NI-DCPower instrument sessions.
- Parameters:
reset (bool) – Specifies whether to reset channel(s) during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIDCPOWER_SIMULATE,NIDCPOWER_BOARD_TYPE, andNIDCPOWER_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a sequence of session information objects. The session objects are available via the
sessionfield.- Raises:
ValueError – If no NI-DCPower sessions are reserved.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidcpower.Session]]]
See also
For more details, see
nidcpower.Session.
- get_nidcpower_connection(pin_name=None, site=None)[source]
Get the NI-DCPower connection matching the specified criteria.
- Parameters:
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[nidcpower.Session]
- get_nidcpower_connection_with_multiplexer(multiplexer_session_type, pin_name=None, site=None)[source]
Get the NI-DCPower connection matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_name (Optional[str]) – The pin name to match against. If not specified, the pin name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connection along with its multiplexer info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidcpower.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]
- get_nidcpower_connections(pin_names=None, sites=None)[source]
Get all NI-DCPower connections matching the specified criteria.
- Parameters:
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[nidcpower.Session]]
- get_nidcpower_connections_with_multiplexer(multiplexer_session_type, pin_names=None, sites=None)[source]
Get all NI-DCPower connections matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_names (Union[str, Iterable[str], None]) – The pin name(s) to match against. If not specified, the pin name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connections along with their multiplexer(s) info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidcpower.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_nidigital_session(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize a single NI-Digital Pattern instrument session.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIDIGITAL_SIMULATE,NIDIGITAL_BOARD_TYPE, andNIDIGITAL_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a session information object. The session object is available via the
sessionfield.- Raises:
ValueError – If no NI-Digital sessions are reserved or too many NI-Digital sessions are reserved.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidigital.Session]]
See also
For more details, see
nidigital.Session.
- initialize_nidigital_sessions(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize multiple NI-Digital Pattern instrument sessions.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIDIGITAL_SIMULATE,NIDIGITAL_BOARD_TYPE, andNIDIGITAL_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a sequence of session information objects. The session objects are available via the
sessionfield.- Raises:
ValueError – If no NI-Digital sessions are reserved.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidigital.Session]]]
See also
For more details, see
nidigital.Session.
- get_nidigital_connection(pin_name=None, site=None)[source]
Get the NI-Digital Pattern connection matching the specified criteria.
- Parameters:
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[nidigital.Session]
- get_nidigital_connection_with_multiplexer(multiplexer_session_type, pin_name=None, site=None)[source]
Get the NI-Digital Pattern connection matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_name (Optional[str]) – The pin name to match against. If not specified, the pin name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connection along with its multiplexer info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidigital.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]
- get_nidigital_connections(pin_names=None, sites=None)[source]
Get all NI-Digital Pattern connections matching the specified criteria.
- Parameters:
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[nidigital.Session]]
- get_nidigital_connections_with_multiplexer(multiplexer_session_type, pin_names=None, sites=None)[source]
Get all NI-Digital Pattern connections matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_names (Union[str, Iterable[str], None]) – The pin name(s) to match against. If not specified, the pin name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connections along with their multiplexer(s) info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidigital.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_nidmm_session(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize a single NI-DMM instrument session.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIDMM_SIMULATE,NIDMM_BOARD_TYPE, andNIDMM_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a session information object. The session object is available via the
sessionfield.- Raises:
ValueError – If no NI-DMM sessions are reserved or too many NI-DMM sessions are reserved.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidmm.Session]]
See also
For more details, see
nidmm.Session.
- initialize_nidmm_sessions(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize multiple NI-DMM instrument sessions.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIDMM_SIMULATE,NIDMM_BOARD_TYPE, andNIDMM_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a sequence of session information objects. The session objects are available via the
sessionfield.- Raises:
ValueError – If no NI-DMM sessions are reserved.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[nidmm.Session]]]
See also
For more details, see
nidmm.Session.
- get_nidmm_connection(pin_name=None, site=None)[source]
Get the NI-DMM connection matching the specified criteria.
- Parameters:
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[nidmm.Session]
- get_nidmm_connection_with_multiplexer(multiplexer_session_type, pin_name=None, site=None)[source]
Get the NI-DMM connection matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_name (Optional[str]) – The pin name to match against. If not specified, the pin name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connection along with its multiplexer info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidmm.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]
- get_nidmm_connections(pin_names=None, sites=None)[source]
Get all NI-DMM connections matching the specified criteria.
- Parameters:
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[nidmm.Session]]
- get_nidmm_connections_with_multiplexer(multiplexer_session_type, pin_names=None, sites=None)[source]
Get all NI-DMM connections matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_names (Union[str, Iterable[str], None]) – The pin name(s) to match against. If not specified, the pin name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connections along with their multiplexer(s) info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nidmm.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_nifgen_session(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize a single NI-FGEN instrument session.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIFGEN_SIMULATE,NIFGEN_BOARD_TYPE, andNIFGEN_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a session information object. The session object is available via the
sessionfield.- Raises:
ValueError – If no NI-FGEN sessions are reserved or too many NI-FGEN sessions are reserved.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[nifgen.Session]]
See also
For more details, see
nifgen.Session.
- initialize_nifgen_sessions(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize multiple NI-FGEN instrument sessions.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NIFGEN_SIMULATE,NIFGEN_BOARD_TYPE, andNIFGEN_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a sequence of session information objects. The session objects are available via the
sessionfield.- Raises:
ValueError – If no NI-FGEN sessions are reserved.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[nifgen.Session]]]
See also
For more details, see
nifgen.Session.
- get_nifgen_connection(pin_name=None, site=None)[source]
Get the NI-FGEN connection matching the specified criteria.
- Parameters:
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[nifgen.Session]
- get_nifgen_connection_with_multiplexer(multiplexer_session_type, pin_name=None, site=None)[source]
Get the NI-FGEN connection matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_name (Optional[str]) – The pin name to match against. If not specified, the pin name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connection along with its multiplexer info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nifgen.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]
- get_nifgen_connections(pin_names=None, sites=None)[source]
Get all NI-FGEN connections matching the specified criteria.
- Parameters:
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[nifgen.Session]]
- get_nifgen_connections_with_multiplexer(multiplexer_session_type, pin_names=None, sites=None)[source]
Get all NI-FGEN connections matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_names (Union[str, Iterable[str], None]) – The pin name(s) to match against. If not specified, the pin name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connections along with their multiplexer(s) info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[nifgen.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_niscope_session(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize a single NI-SCOPE instrument session.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NISCOPE_SIMULATE,NISCOPE_BOARD_TYPE, andNISCOPE_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a session information object. The session object is available via the
sessionfield.- Raises:
ValueError – If no NI-SCOPE sessions are reserved or too many NI-SCOPE sessions are reserved.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[niscope.Session]]
See also
For more details, see
niscope.Session.
- initialize_niscope_sessions(reset_device=False, options=None, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize multiple NI-SCOPE instrument sessions.
- Parameters:
reset_device (bool) – Specifies whether to reset the instrument during the initialization procedure.
options (Optional[Dict[str, Any]]) – Specifies the initial value of certain properties for the session. If this argument is not specified, the default value is an empty dict, which you may override by specifying
NISCOPE_SIMULATE,NISCOPE_BOARD_TYPE, andNISCOPE_MODELin the configuration file (.env).initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a sequence of session information objects. The session objects are available via the
sessionfield.- Raises:
ValueError – If no NI-SCOPE sessions are reserved.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[niscope.Session]]]
See also
For more details, see
niscope.Session.
- get_niscope_connection(pin_name=None, site=None)[source]
Get the NI-SCOPE connection matching the specified criteria.
- Parameters:
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[niscope.Session]
- get_niscope_connection_with_multiplexer(multiplexer_session_type, pin_name=None, site=None)[source]
Get the NI-SCOPE connection matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_name (Optional[str]) – The pin name to match against. If not specified, the pin name is ignored when matching connections.
site (Optional[int]) – The site number to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connection along with its multiplexer info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[niscope.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]
- get_niscope_connections(pin_names=None, sites=None)[source]
Get all NI-SCOPE connections matching the specified criteria.
- Parameters:
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[niscope.Session]]
- get_niscope_connections_with_multiplexer(multiplexer_session_type, pin_names=None, sites=None)[source]
Get all NI-SCOPE connections matching the specified criteria.
- Parameters:
multiplexer_session_type (Type[ni_measurementlink_service.session_management._types.TMultiplexerSession]) – The multiplexer session type.
pin_names (Union[str, Iterable[str], None]) – The pin name(s) to match against. If not specified, the pin name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connections along with their multiplexer(s) info.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnectionWithMultiplexer[niscope.Session, ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_niswitch_session(topology=None, simulate=None, reset_device=False, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize a single NI-SWITCH relay driver instrument session.
- Parameters:
topology (Optional[str]) – Specifies the switch topology. If this argument is not specified, the default value is “Configured Topology”, which you may override by setting
MEASUREMENTLINK_NISWITCH_TOPOLOGYin the configuration file (.env).simulate (Optional[bool]) – Enables or disables simulation of the switch module. If this argument is not specified, the default value is
False, which you may override by settingMEASUREMENTLINK_NISWITCH_SIMULATEin the configuration file (.env).reset_device (bool) – Specifies whether to reset the switch module during the initialization procedure.
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a session information object. The session object is available via the
sessionfield.- Raises:
ValueError – If no relay driver sessions are reserved or too many relay driver sessions are reserved.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedSessionInformation[niswitch.Session]]
See also
For more details, see
niswitch.Session.
- initialize_niswitch_sessions(topology=None, simulate=None, reset_device=False, initialization_behavior=SessionInitializationBehavior.AUTO)[source]
Initialize multiple NI-SWITCH relay driver instrument sessions.
- Parameters:
topology (Optional[str]) – Specifies the switch topology. If this argument is not specified, the default value is “Configured Topology”, which you may override by setting
MEASUREMENTLINK_NISWITCH_TOPOLOGYin the configuration file (.env).simulate (Optional[bool]) – Enables or disables simulation of the switch module. If this argument is not specified, the default value is
False, which you may override by settingMEASUREMENTLINK_NISWITCH_SIMULATEin the configuration file (.env).reset_device (bool) – Specifies whether to reset the switch module during the initialization procedure.
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
- Returns:
A context manager that yields a sequence of session information objects. The session objects are available via the
sessionfield.- Raises:
ValueError – If no relay driver sessions are reserved.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedSessionInformation[niswitch.Session]]]
See also
For more details, see
niswitch.Session.
- get_niswitch_connection(relay_name=None, site=None)[source]
Get the NI-SWITCH relay driver connection matching the specified criteria.
- Parameters:
- Returns:
The matching connection.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match or too many reserved connections match.
- Return type:
ni_measurementlink_service.session_management._types.TypedConnection[niswitch.Session]
- get_niswitch_connections(relay_names=None, sites=None)[source]
Get all NI-SWITCH relay driver connections matching the specified criteria.
- Parameters:
relay_names (Union[str, Iterable[str], None]) – The relay name(s) to match against. If not specified, the relay name is ignored when matching connections.
sites (Union[int, Iterable[int], None]) – The site number(s) to match against. If not specified, the site number is ignored when matching connections.
- Returns:
The matching connections.
- Raises:
TypeError – If the argument types or session type are incorrect.
ValueError – If no reserved connections match.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.TypedConnection[niswitch.Session]]
- initialize_niswitch_multiplexer_session(topology=None, simulate=None, reset_device=False, initialization_behavior=SessionInitializationBehavior.AUTO, multiplexer_type_id=None)[source]
Initialize a single NI-SWITCH multiplexer session.
- Parameters:
topology (Optional[str]) – Specifies the switch topology. If this argument is not specified, the default value is “Configured Topology”, which you may override by setting
MEASUREMENTLINK_NISWITCH_TOPOLOGYin the configuration file (.env).simulate (Optional[bool]) – Enables or disables simulation of the switch module. If this argument is not specified, the default value is
False, which you may override by settingMEASUREMENTLINK_NISWITCH_SIMULATEin the configuration file (.env).reset_device (bool) – Specifies whether to reset the switch module during the initialization procedure.
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a session information object. The
multiplexer session object is available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available or too many multiplexer sessions are available.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[niswitch.Session]]
See also
For more details, see
niswitch.Session.
- initialize_niswitch_multiplexer_sessions(topology=None, simulate=None, reset_device=False, initialization_behavior=SessionInitializationBehavior.AUTO, multiplexer_type_id=None)[source]
Initialize multiple NI-SWITCH multiplexer sessions.
- Parameters:
topology (Optional[str]) – Specifies the switch topology. If this argument is not specified, the default value is “Configured Topology”, which you may override by setting
MEASUREMENTLINK_NISWITCH_TOPOLOGYin the configuration file (.env).simulate (Optional[bool]) – Enables or disables simulation of the switch module. If this argument is not specified, the default value is
False, which you may override by settingMEASUREMENTLINK_NISWITCH_SIMULATEin the configuration file (.env).reset_device (bool) – Specifies whether to reset the switch module during the initialization procedure.
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a sequence of multiplexer session
information objects. The session objects are available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[niswitch.Session]]]
See also
For more details, see
niswitch.Session.
- class ni_measurementlink_service.session_management.MultiplexerSessionContainer(session_management_client, multiplexer_session_info)[source]
Bases:
_BaseSessionContainerManages multiplexer session information.
- Parameters:
session_management_client (ni_measurementlink_service.session_management._client.SessionManagementClient) –
multiplexer_session_info (Optional[Sequence[ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1.session_management_service_pb2.MultiplexerSessionInformation]]) –
- property multiplexer_session_info: Sequence[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation]
Multiplexer session information object.
- Return type:
Sequence[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation]
- __exit__(exc_type, exc_val, traceback)[source]
Context management protocol.
- Parameters:
exc_type (Optional[Type[BaseException]]) –
exc_val (Optional[BaseException]) –
traceback (Optional[types.TracebackType]) –
- Return type:
None
- initialize_multiplexer_session(session_constructor, multiplexer_type_id=None)[source]
Initialize a single multiplexer session.
This is a generic method that supports any multiplexer driver.
- Parameters:
session_constructor (Callable[[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation], ni_measurementlink_service.session_management._types.TMultiplexerSession]) – A function that constructs multiplexer sessions based on multiplexer session information.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a multiplexer session information
object. The session object is available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available or too many multiplexer sessions are available.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[ni_measurementlink_service.session_management._types.TMultiplexerSession]]
- initialize_multiplexer_sessions(session_constructor, multiplexer_type_id=None)[source]
Initialize multiple multiplexer sessions.
This is a generic method that supports any multiplexer driver.
- Parameters:
session_constructor (Callable[[ni_measurementlink_service.session_management._types.MultiplexerSessionInformation], ni_measurementlink_service.session_management._types.TMultiplexerSession]) – A function that constructs multiplexer sessions based on multiplexer session information.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a sequence of multiplexer session information
objects. The session objects are available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[ni_measurementlink_service.session_management._types.TMultiplexerSession]]]
- initialize_niswitch_multiplexer_session(topology=None, simulate=None, reset_device=False, initialization_behavior=SessionInitializationBehavior.AUTO, multiplexer_type_id=None)[source]
Initialize a single NI-SWITCH multiplexer session.
- Parameters:
topology (Optional[str]) – Specifies the switch topology. If this argument is not specified, the default value is “Configured Topology”, which you may override by setting
MEASUREMENTLINK_NISWITCH_TOPOLOGYin the configuration file (.env).simulate (Optional[bool]) – Enables or disables simulation of the switch module. If this argument is not specified, the default value is
False, which you may override by settingMEASUREMENTLINK_NISWITCH_MULTIPLEXER_SIMULATEin the configuration file (.env).reset_device (bool) – Specifies whether to reset the switch module during the initialization procedure.
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a session information object. The
multiplexer session object is available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available or too many multiplexer sessions are available.
- Return type:
ContextManager[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[niswitch.Session]]
See also
For more details, see
niswitch.Session.
- initialize_niswitch_multiplexer_sessions(topology=None, simulate=None, reset_device=False, initialization_behavior=SessionInitializationBehavior.AUTO, multiplexer_type_id=None)[source]
Initialize multiple NI-SWITCH multiplexer sessions.
- Parameters:
topology (Optional[str]) – Specifies the switch topology. If this argument is not specified, the default value is “Configured Topology”, which you may override by setting
MEASUREMENTLINK_NISWITCH_TOPOLOGYin the configuration file (.env).simulate (Optional[bool]) – Enables or disables simulation of the switch module. If this argument is not specified, the default value is
False, which you may override by settingMEASUREMENTLINK_NISWITCH_MULTIPLEXER_SIMULATEin the configuration file (.env).reset_device (bool) – Specifies whether to reset the switch module during the initialization procedure.
initialization_behavior (ni_measurementlink_service.session_management._types.SessionInitializationBehavior) – Specifies whether the NI gRPC Device Server will initialize a new session or attach to an existing session.
multiplexer_type_id (Optional[str]) – User-defined identifier for the multiplexer type in the pin map editor. If not specified, the multiplexer type id is ignored when matching multiplexer sessions.
- Returns:
- A context manager that yields a sequence of multiplexer session
information objects. The session objects are available via the
sessionfield.
- Raises:
TypeError – If the argument types are incorrect.
ValueError – If no multiplexer sessions are available.
- Return type:
ContextManager[Sequence[ni_measurementlink_service.session_management._types.TypedMultiplexerSessionInformation[niswitch.Session]]]
See also
For more details, see
niswitch.Session.
- class ni_measurementlink_service.session_management.MultiSessionReservation(session_management_client, session_info, multiplexer_session_info=None, pin_or_relay_group_mappings=None, reserved_pin_or_relay_names=None, reserved_sites=None)[source]
Bases:
BaseReservationManages reservation for multiple sessions.
- Parameters:
session_management_client (ni_measurementlink_service.session_management._client.SessionManagementClient) –
session_info (Sequence[ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1.session_management_service_pb2.SessionInformation]) –
multiplexer_session_info (Optional[Sequence[ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1.session_management_service_pb2.MultiplexerSessionInformation]]) –
pin_or_relay_group_mappings (Optional[Mapping[str, Iterable[str]]]) –
reserved_pin_or_relay_names (Union[str, Iterable[str], None]) –
reserved_sites (Optional[Iterable[int]]) –
- property session_info: List[ni_measurementlink_service.session_management._types.SessionInformation]
Multiple session information objects.
- Return type:
List[ni_measurementlink_service.session_management._types.SessionInformation]
- class ni_measurementlink_service.session_management.SingleSessionReservation(session_management_client, session_info, multiplexer_session_info=None, pin_or_relay_group_mappings=None, reserved_pin_or_relay_names=None, reserved_sites=None)[source]
Bases:
BaseReservationManages reservation for a single session.
- Parameters:
session_management_client (ni_measurementlink_service.session_management._client.SessionManagementClient) –
session_info (Sequence[ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1.session_management_service_pb2.SessionInformation]) –
multiplexer_session_info (Optional[Sequence[ni_measurementlink_service._internal.stubs.ni.measurementlink.sessionmanagement.v1.session_management_service_pb2.MultiplexerSessionInformation]]) –
pin_or_relay_group_mappings (Optional[Mapping[str, Iterable[str]]]) –
reserved_pin_or_relay_names (Union[str, Iterable[str], None]) –
reserved_sites (Optional[Iterable[int]]) –
- property session_info: ni_measurementlink_service.session_management._types.SessionInformation
Single session information object.
- class ni_measurementlink_service.session_management.ChannelMapping[source]
Bases:
NamedTupleMapping of each channel to the pin and site it is connected to.
- site: int
The site on which the pin or relay is mapped to a channel.
For system pins/relays, the site number is
SITE_SYSTEM_PINS(-1) as they do not belong to a specific site.
- class ni_measurementlink_service.session_management.Connection[source]
Bases:
NamedTupleDescribes the connection between an instance of a pin and an instrument channel.
This object maps a pin or relay on a specific site to the corresponding instrument session and channel name.
- site: int
The site number.
For system pins/relays, the site number is
SITE_SYSTEM_PINS(-1) as they do not belong to a specific site.
- session_info: SessionInformation
The instrument session information.
- multiplexer_route: str
The multiplexer route through which the pin is connected to an instrument’s channel.
- multiplexer_session_info: MultiplexerSessionInformation | None
The multiplexer session information.
- class ni_measurementlink_service.session_management.PinMapContext[source]
Bases:
NamedTupleContainer for the pin map and sites.
- class ni_measurementlink_service.session_management.MultiplexerSessionInformation[source]
Bases:
NamedTupleContainer for the multiplexer session information.
- session_exists: bool
Indicates whether the session is registered with the session management service.
When calling measurements from TestStand, the test sequence’s
ProcessSetupcallback creates instrument sessions and registers them with the session management service so that they can be shared between multiple measurement steps. In this case, the session_exists attribute isTrue, indicating that the instrument sessions were already created and any one-time setup has been performed.When calling measurements outside of TestStand, the session_exists attribute is
False, indicating that the measurement is responsible for creating the instrument sessions and performing any one-time setup.
- class ni_measurementlink_service.session_management.SessionInformation[source]
Bases:
NamedTupleContainer for the session information.
- channel_list: str
Channel list used for driver initialization and measurement methods.
This field is empty for any SessionInformation returned from Client.reserve_all_registered_sessions.
- instrument_type_id: str
Indicates the instrument type for this session.
Pin maps have built in instrument definitions using the instrument type id constants such as INSTRUMENT_TYPE_NI_DCPOWER. For custom instruments, the user defined instrument type id is defined in the pin map file.
- session_exists: bool
Indicates whether the session is registered with the session management service.
When calling measurements from TestStand, the test sequence’s
ProcessSetupcallback creates instrument sessions and registers them with the session management service so that they can be shared between multiple measurement steps. In this case, the session_exists attribute isTrue, indicating that the instrument sessions were already created and any one-time setup (such as creating NI-DAQmx channels or loading NI-Digital files) has been performed.When calling measurements outside of TestStand, the session_exists attribute is
False, indicating that the measurement is responsible for creating the instrument sessions and performing any one-time setup.
- channel_mappings: Iterable[ChannelMapping]
List of mappings from channels to pins and sites.
Each item contains a mapping for a channel in this instrument resource, in the order of the channel_list. This field is empty for any SessionInformation returned from Client.reserve_all_registered_sessions.
- class ni_measurementlink_service.session_management.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.
- class ni_measurementlink_service.session_management.TypedConnection[source]
Bases:
Protocol,Generic[TSession_co]Generic version of
Connectionthat preserves the session type.For more details, see the corresponding documentation for
Connection.- property site: int
The site number.
For system pins/relays, the site number is
SITE_SYSTEM_PINS(-1) as they do not belong to a specific site.- Return type:
- property session_info: TypedSessionInformation[TSession_co]
The instrument session information.
- Return type:
TypedSessionInformation[TSession_co]
- property session: TSession_co
The instrument session.
- Return type:
TSession_co
- class ni_measurementlink_service.session_management.TypedConnectionWithMultiplexer[source]
Bases:
TypedConnection[TSession_co],Protocol,Generic[TSession_co,TMultiplexerSession_co]Generic version of Connection that preserves the instrument and multiplexer session type.
For more details, see the corresponding documentation for Connection.
- property multiplexer_resource_name: str
Resource name used to open this session in the driver.
- Return type:
- property multiplexer_type_id: str
User-defined identifier for the multiplexer type in the pin map editor.
- Return type:
- property multiplexer_route: str
The multiplexer route through which the pin is connected to an instrument’s channel.
- Return type:
- property multiplexer_session_info: TypedMultiplexerSessionInformation[TMultiplexerSession_co]
The multiplexer session information.
- Return type:
TypedMultiplexerSessionInformation[TMultiplexerSession_co]
- property multiplexer_session: TMultiplexerSession_co
The multiplexer session.
- Return type:
TMultiplexerSession_co
- class ni_measurementlink_service.session_management.TypedMultiplexerSessionInformation[source]
Bases:
Protocol,Generic[TMultiplexerSession_co]Generic version of
MultiplexerSessionInformationthat preserves the session type.For more details, see the corresponding documentation of
MultiplexerSessionInformation.- property session_name: str
Session name used by the session management service and NI gRPC Device Server.
- Return type:
- property multiplexer_type_id: str
User-defined identifier for the multiplexer type in the pin map editor.
- Return type:
- property session_exists: bool
Indicates whether the session is registered with the session management service.
- Return type:
- property session: TMultiplexerSession_co
The driver session object.
- Return type:
TMultiplexerSession_co
- class ni_measurementlink_service.session_management.TypedSessionInformation[source]
Bases:
Protocol,Generic[TSession_co]Generic version of
SessionInformationthat preserves the session type.For more details, see the corresponding documentation for
SessionInformation.- property session_name: str
Session name used by the session management service and NI gRPC Device Server.
- Return type:
- property channel_list: str
Channel list used for driver initialization and measurement methods.
- Return type:
- property session_exists: bool
Indicates whether the session is registered with the session management service.
- Return type:
- property channel_mappings: Iterable[ChannelMapping]
List of mappings from channels to pins and sites.
- Return type:
Iterable[ChannelMapping]
- property session: TSession_co
The driver session object.
- Return type:
TSession_co
- ni_measurementlink_service.session_management.Client
Alias for compatibility with code that uses session_management.Client.