ni_measurementlink_service
releases/1.0
  • API Reference
    • ni_measurementlink_service
      • Subpackages
      • Submodules
        • ni_measurementlink_service.session_management
          • Module Contents
            • Classes
            • Attributes
              • GRPC_SERVICE_INTERFACE_NAME
              • GRPC_SERVICE_CLASS
              • INSTRUMENT_TYPE_NONE
              • INSTRUMENT_TYPE_NI_DCPOWER
              • INSTRUMENT_TYPE_NI_HSDIO
              • INSTRUMENT_TYPE_NI_RFSA
              • INSTRUMENT_TYPE_NI_RFMX
              • INSTRUMENT_TYPE_NI_RFSG
              • INSTRUMENT_TYPE_NI_RFPM
              • INSTRUMENT_TYPE_NI_DMM
              • INSTRUMENT_TYPE_NI_DIGITAL_PATTERN
              • INSTRUMENT_TYPE_NI_SCOPE
              • INSTRUMENT_TYPE_NI_FGEN
              • INSTRUMENT_TYPE_NI_DAQMX
              • INSTRUMENT_TYPE_NI_RELAY_DRIVER
              • INSTRUMENT_TYPE_NI_MODEL_BASED_INSTRUMENT
              • INSTRUMENT_TYPE_NI_SWITCH_EXECUTIVE_VIRTUAL_DEVICE
              • PinMapContext
                • PinMapContext.pin_map_id
                • PinMapContext.sites
              • ChannelMapping
                • ChannelMapping.pin_or_relay_name
                • ChannelMapping.site
                • ChannelMapping.channel
              • SessionInformation
                • SessionInformation.session_name
                • SessionInformation.resource_name
                • SessionInformation.channel_list
                • SessionInformation.instrument_type_id
                • SessionInformation.session_exists
                • SessionInformation.channel_mappings
              • Reservation
                • Reservation.__enter__()
                • Reservation.__exit__()
                • Reservation.unreserve()
                • Reservation.session_info()
              • Client
                • Client.reserve_sessions()
                • Client.register_sessions()
                • Client.unregister_sessions()
                • Client.reserve_all_registered_sessions()
              • GRPC_SERVICE_INTERFACE_NAME
              • GRPC_SERVICE_CLASS
              • INSTRUMENT_TYPE_NONE
              • INSTRUMENT_TYPE_NI_DCPOWER
              • INSTRUMENT_TYPE_NI_HSDIO
              • INSTRUMENT_TYPE_NI_RFSA
              • INSTRUMENT_TYPE_NI_RFMX
              • INSTRUMENT_TYPE_NI_RFSG
              • INSTRUMENT_TYPE_NI_RFPM
              • INSTRUMENT_TYPE_NI_DMM
              • INSTRUMENT_TYPE_NI_DIGITAL_PATTERN
              • INSTRUMENT_TYPE_NI_SCOPE
              • INSTRUMENT_TYPE_NI_FGEN
              • INSTRUMENT_TYPE_NI_DAQMX
              • INSTRUMENT_TYPE_NI_RELAY_DRIVER
              • INSTRUMENT_TYPE_NI_MODEL_BASED_INSTRUMENT
              • INSTRUMENT_TYPE_NI_SWITCH_EXECUTIVE_VIRTUAL_DEVICE
              • PinMapContext
              • ChannelMapping
              • SessionInformation
              • Reservation
                • __enter__
                • __exit__
                • unreserve
                • session_info
              • Client
                • reserve_sessions
                • register_sessions
                • unregister_sessions
                • reserve_all_registered_sessions
      • Package Contents
ni_measurementlink_service
  • API Reference
  • ni_measurementlink_service
  • ni_measurementlink_service.session_management
  • Edit on GitHub

ni_measurementlink_service.session_management

Contains methods related to managing driver sessions.

Module Contents

Classes

PinMapContext

Container for the pin map and sites.

ChannelMapping

Mapping of each channel to the pin and site it is connected to.

SessionInformation

Container for the session information.

Reservation

Manage session reservation.

Client

Class that manages driver sessions.

Attributes

GRPC_SERVICE_INTERFACE_NAME

GRPC_SERVICE_CLASS

INSTRUMENT_TYPE_NONE

INSTRUMENT_TYPE_NI_DCPOWER

INSTRUMENT_TYPE_NI_HSDIO

INSTRUMENT_TYPE_NI_RFSA

INSTRUMENT_TYPE_NI_RFMX

INSTRUMENT_TYPE_NI_RFSG

INSTRUMENT_TYPE_NI_RFPM

INSTRUMENT_TYPE_NI_DMM

INSTRUMENT_TYPE_NI_DIGITAL_PATTERN

INSTRUMENT_TYPE_NI_SCOPE

INSTRUMENT_TYPE_NI_FGEN

INSTRUMENT_TYPE_NI_DAQMX

INSTRUMENT_TYPE_NI_RELAY_DRIVER

INSTRUMENT_TYPE_NI_MODEL_BASED_INSTRUMENT

INSTRUMENT_TYPE_NI_SWITCH_EXECUTIVE_VIRTUAL_DEVICE

ni_measurementlink_service.session_management.GRPC_SERVICE_INTERFACE_NAME = ni.measurementlink.sessionmanagement.v1.SessionManagementService
ni_measurementlink_service.session_management.GRPC_SERVICE_CLASS = ni.measurementlink.sessionmanagement.v1.SessionManagementService
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NONE =
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DCPOWER = niDCPower
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_HSDIO = niHSDIO
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFSA = niRFSA
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFMX = niRFmx
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFSG = niRFSG
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RFPM = niRFPM
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DMM = niDMM
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DIGITAL_PATTERN = niDigitalPattern
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_SCOPE = niScope
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_FGEN = niFGen
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_DAQMX = niDAQmx
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_RELAY_DRIVER = niRelayDriver
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_MODEL_BASED_INSTRUMENT = niModelBasedInstrument
ni_measurementlink_service.session_management.INSTRUMENT_TYPE_NI_SWITCH_EXECUTIVE_VIRTUAL_DEVICE = niSwitchExecutiveVirtualDevice
class ni_measurementlink_service.session_management.PinMapContext[source]

Bases: NamedTuple

Container for the pin map and sites.

Attributes

pin_map_id (str): The resource id of the pin map in the Pin Map service that should be used

for the call.

sites (list): List of site numbers being used for the call. If None, use all sites in the

pin map.

pin_map_id :str
sites :Optional[List[int]]
class ni_measurementlink_service.session_management.ChannelMapping[source]

Bases: NamedTuple

Mapping of each channel to the pin and site it is connected to.

Attributes

pin_or_relay_name (str): The pin or relay that is mapped to a channel.

site (int): The site on which the pin or relay is mapped to a channel.

For system pins/relays the site number is -1 as they do not belong to a specific site.

channel (str): The channel to which the pin or relay is mapped on this site.

pin_or_relay_name :str
site :int
channel :str
class ni_measurementlink_service.session_management.SessionInformation[source]

Bases: NamedTuple

Container for the session information.

Attributes

session_name (str): Session identifier used to identify the session in the session

management service, as well as in driver services such as grpc-device.

resource_name (str): Resource name used to open this session in the driver.

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): Instrument type ID to identify which type of instrument the

session represents. 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 exists in the Session Manager. This

indicates whether the session has been created.

channel_mappings (Iterable[ChannelMapping]): List of site and pin/relay mappings that

correspond to each channel in the channel_list. 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.

session_name :str
resource_name :str
channel_list :str
instrument_type_id :str
session_exists :bool
channel_mappings :Iterable[ChannelMapping]
class ni_measurementlink_service.session_management.Reservation(session_manager, session_info)[source]

Bases: object

Manage session reservation.

__enter__()[source]

Context management protocol. Returns self.

__exit__(*exc)[source]

Context management protocol. Calls unreserve().

unreserve()[source]

Unreserve sessions.

session_info()

Return session information.

class ni_measurementlink_service.session_management.Client(*, grpc_channel)[source]

Bases: object

Class that manages driver sessions.

reserve_sessions(context, pin_or_relay_names=None, instrument_type_id=None, timeout=None)[source]

Reserve session(s).

Reserve session(s) for the given pins, sites, and instrument type ID and returns the information needed to create or access the session.

Args

context (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 (Iterable[str]): List of 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 (str): Instrument type ID for the measurement. If unspecified,

reserve sessions for all instrument types connected in the registered pin map resource. Pin maps have built in instrument definitions using the following NI driver based instrument type ids:

“niDCPower” “niDigitalPattern” “niScope” “niDMM” “niDAQmx” “niFGen” “niRelayDriver”

For custom instruments the user defined instrument type id is defined in the pin map file.

timeout (float): Timeout in seconds. Allowed values,

0 (non-blocking, fails immediately if resources cannot be reserved), -1 or negative (infinite timeout), or any positive numeric value (wait for that number of second).

Returns

Reservation: Context manager that can be used with a with-statement to unreserve the sessions.

register_sessions(session_info)[source]

Register the sessions with the Session Manager.

Indicates that the sessions are open and will need to be closed later.

Args:

session_info (Iterable[SessionInformation]): Sessions to register with the session management service to track as the sessions are open.

Raises

Exception: If a session by the same name is already registered.

unregister_sessions(session_info)[source]

Unregisters the sessions from the Session Manager.

Indicates that the sessions have been closed and will need to be reopened before they can be used again.

Parameters:

session_info (Iterable[SessionInformation]) – Sessions to be registered.

reserve_all_registered_sessions(instrument_type_id=None, timeout=None)[source]

Reserves and gets all sessions currently registered in the Session Manager.

Args

instrument_type_id (str): Instrument type ID for the measurement. If unspecified,

reserve sessions for all instrument types connected in the registered pin map resource. Pin maps have built in instrument definitions using the following NI driver based instrument type ids:

“niDCPower” “niDigitalPattern” “niScope” “niDMM” “niDAQmx” “niFGen” “niRelayDriver”

For custom instruments the user defined instrument type id is defined in the pin map file.

timeout (float): Timeout in seconds. Allowed values,

0 (non-blocking, fails immediately if resources cannot be reserved), -1 or negative (infinite timeout), or any positive numeric value (wait for that number of second).

Returns

Reservation: Context manager that can be used with a with-statement to unreserve the sessions.

Previous

© Copyright 2023, National Instruments. Revision 299ad6c0.

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