1+ import uuid
2+ import grpc
3+ from google .protobuf import any_pb2
4+ import ni .pythonpanel .v1 .python_panel_service_pb2 as python_panel_service_pb2
5+ import ni .pythonpanel .v1 .python_panel_service_pb2_grpc as python_panel_service_pb2_grpc
6+
7+ class NiPanel :
8+ """
9+ This class allows you to access controls on the panel
10+ """
11+ def __init__ (self ):
12+ self ._stub = None # will be a PythonPanelServiceStub
13+ self .panel_uri = None
14+ self .panel_id = None
15+
16+ def __enter__ (self ):
17+ self .connect ()
18+
19+ def __exit__ (self ):
20+ self .disconnect ()
21+
22+ @classmethod
23+ def streamlit_panel (cls , streamlit_script_path : str ):
24+ """
25+ Create a panel using a streamlit script for the user interface
26+
27+ Args:
28+ streamlit_script_path: The file path of the streamlit script
29+
30+ Returns:
31+ NiPanel: A new panel associated with the streamlit script
32+ """
33+ panel = cls ()
34+ panel .panel_uri = streamlit_script_path
35+ panel .panel_id = str (uuid .uuid4 ())
36+ return panel
37+
38+ def connect (self ):
39+ """
40+ Connect to the panel and open it.
41+ """
42+ # TODO: AB#3095680 - Use gRPC pool management from the Measurement Plugin SDK, create the _stub, and call _stub.Connect
43+ pass
44+
45+ def disconnect (self ):
46+ """
47+ Disconnect from the panel (does not close the panel).
48+ """
49+ # TODO: AB#3095680 - Use gRPC pool management from the Measurement Plugin SDK, call _stub.Disconnect
50+ pass
51+
52+ def get_value (self , value_id : str ):
53+ """
54+ Get the value for a control on the panel
55+
56+ Args:
57+ value_id: The id of the value
58+
59+ Returns:
60+ object: The value
61+ """
62+ # TODO: AB#3095681 - get the Any from _stub.GetValue and convert it to the correct type to return it
63+ return "placeholder value"
64+
65+ def set_value (self , value_id : str , value ):
66+ """
67+ Set the value for a control on the panel
68+
69+ Args:
70+ value_id: The id of the value
71+ value: The value
72+ """
73+ # TODO: AB#3095681 - Convert the value to an Any and pass it to _stub.SetValue
74+ pass
0 commit comments