ni.measurementlink.sessionmanagement.v1.client 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ni.measurementlink.sessionmanagement.v1.client might be problematic. Click here for more details.
- ni/measurementlink/sessionmanagement/v1/client/__init__.py +107 -0
- ni/measurementlink/sessionmanagement/v1/client/_client.py +405 -0
- ni/measurementlink/sessionmanagement/v1/client/_constants.py +32 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/__init__.py +46 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_configuration.py +111 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_dotenvpath.py +73 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_grpcdevice.py +96 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_nidaqmx.py +54 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_nidcpower.py +63 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_nidigital.py +64 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_nidmm.py +64 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_nifgen.py +63 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_niscope.py +64 -0
- ni/measurementlink/sessionmanagement/v1/client/_drivers/_niswitch.py +82 -0
- ni/measurementlink/sessionmanagement/v1/client/_reservation.py +2769 -0
- ni/measurementlink/sessionmanagement/v1/client/_types.py +507 -0
- ni/measurementlink/sessionmanagement/v1/client/py.typed +0 -0
- ni_measurementlink_sessionmanagement_v1_client-0.1.0.dev0.dist-info/METADATA +80 -0
- ni_measurementlink_sessionmanagement_v1_client-0.1.0.dev0.dist-info/RECORD +20 -0
- ni_measurementlink_sessionmanagement_v1_client-0.1.0.dev0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import niswitch
|
|
6
|
+
from ni.measurementlink.discovery.v1.client import DiscoveryClient
|
|
7
|
+
from ni_grpc_extensions.channelpool import GrpcChannelPool
|
|
8
|
+
|
|
9
|
+
from ni.measurementlink.sessionmanagement.v1.client._drivers._configuration import (
|
|
10
|
+
NISWITCH_MULTIPLEXER_OPTIONS,
|
|
11
|
+
NISWITCH_OPTIONS,
|
|
12
|
+
)
|
|
13
|
+
from ni.measurementlink.sessionmanagement.v1.client._drivers._grpcdevice import (
|
|
14
|
+
get_insecure_grpc_device_server_channel,
|
|
15
|
+
)
|
|
16
|
+
from ni.measurementlink.sessionmanagement.v1.client._types import (
|
|
17
|
+
MultiplexerSessionInformation,
|
|
18
|
+
SessionInformation,
|
|
19
|
+
SessionInitializationBehavior,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
_INITIALIZATION_BEHAVIOR = {
|
|
23
|
+
SessionInitializationBehavior.AUTO: niswitch.SessionInitializationBehavior.AUTO,
|
|
24
|
+
SessionInitializationBehavior.INITIALIZE_SERVER_SESSION: niswitch.SessionInitializationBehavior.INITIALIZE_SERVER_SESSION,
|
|
25
|
+
SessionInitializationBehavior.ATTACH_TO_SERVER_SESSION: niswitch.SessionInitializationBehavior.ATTACH_TO_SERVER_SESSION,
|
|
26
|
+
SessionInitializationBehavior.INITIALIZE_SESSION_THEN_DETACH: niswitch.SessionInitializationBehavior.INITIALIZE_SERVER_SESSION,
|
|
27
|
+
SessionInitializationBehavior.ATTACH_TO_SESSION_THEN_CLOSE: niswitch.SessionInitializationBehavior.ATTACH_TO_SERVER_SESSION,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class SessionConstructor:
|
|
32
|
+
"""Constructs sessions based on SessionInformation."""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
discovery_client: DiscoveryClient,
|
|
37
|
+
grpc_channel_pool: GrpcChannelPool,
|
|
38
|
+
topology: str | None,
|
|
39
|
+
simulate: bool | None,
|
|
40
|
+
reset_device: bool,
|
|
41
|
+
initialization_behavior: SessionInitializationBehavior,
|
|
42
|
+
*,
|
|
43
|
+
is_multiplexer: bool = False,
|
|
44
|
+
) -> None:
|
|
45
|
+
"""Initialize the session constructor."""
|
|
46
|
+
self._grpc_channel = get_insecure_grpc_device_server_channel(
|
|
47
|
+
discovery_client, grpc_channel_pool, niswitch.GRPC_SERVICE_INTERFACE_NAME
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if is_multiplexer:
|
|
51
|
+
self._topology = NISWITCH_MULTIPLEXER_OPTIONS.topology if topology is None else topology
|
|
52
|
+
self._simulate = NISWITCH_MULTIPLEXER_OPTIONS.simulate if simulate is None else simulate
|
|
53
|
+
else:
|
|
54
|
+
self._topology = NISWITCH_OPTIONS.topology if topology is None else topology
|
|
55
|
+
self._simulate = NISWITCH_OPTIONS.simulate if simulate is None else simulate
|
|
56
|
+
|
|
57
|
+
self._reset_device = reset_device
|
|
58
|
+
self._initialization_behavior = _INITIALIZATION_BEHAVIOR[initialization_behavior]
|
|
59
|
+
|
|
60
|
+
def __call__(
|
|
61
|
+
self, session_info: SessionInformation | MultiplexerSessionInformation
|
|
62
|
+
) -> niswitch.Session:
|
|
63
|
+
"""Construct a session object."""
|
|
64
|
+
kwargs: dict[str, Any] = {}
|
|
65
|
+
if self._grpc_channel:
|
|
66
|
+
kwargs["grpc_options"] = niswitch.GrpcSessionOptions(
|
|
67
|
+
grpc_channel=self._grpc_channel,
|
|
68
|
+
session_name=session_info.session_name,
|
|
69
|
+
initialization_behavior=self._initialization_behavior,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Initializing a nonexistent switch module returns
|
|
73
|
+
# NISWITCH_ERROR_INVALID_RESOURCE_DESCRIPTOR, even if simulate=True.
|
|
74
|
+
resource_name = "" if self._simulate else session_info.resource_name
|
|
75
|
+
|
|
76
|
+
return niswitch.Session(
|
|
77
|
+
resource_name=resource_name,
|
|
78
|
+
topology=self._topology,
|
|
79
|
+
simulate=self._simulate,
|
|
80
|
+
reset_device=self._reset_device,
|
|
81
|
+
**kwargs,
|
|
82
|
+
)
|