gRPC device server (v0.2.1)
SmartLabCtrl is the public device-control API. SmartLabUIA performs Windows GUI operations; grpc_frame handles RPC transport.
Server (Windows PC running SmartLab Studio II)
python example/server.py
The server uses the grpc_frame COM runner and proxy to create and run the SmartLabCtrl subclass on a dedicated COM thread. The capture stream uses the same proxy.
example/server.py loads the adjacent config_smartlab.yaml and binds to its SERVER_IP:SERVER_PORT. SERVER_IP must be assigned to the server PC. Run the script from the project root.
SERVER_IP: "10.170.175.213"
SERVER_PORT: 50100
TIMEOUT: null
LOGGER_LEVEL: "INFO"
Client
Desktop capture (v0.2.6)
Use v0.2.6 or later and grpc-frame>=0.5.20 on both hosts. The v0.2.9 Windows x64 server captures PNGs with WGC through SmartLabCtrl and DesktopCapture. Display the target user’s desktop and run the server as that user in the target session. Servers running v0.2.6 through v0.2.8 use Snipping Tool auto-save. Launch setup and session diagnostics
from smartlab_studio_ctrl.server_grpc.client import SmartLabGrpcClient
client = SmartLabGrpcClient("10.170.175.213", 50100)
try:
png = client.capture_screenshot(output_directory=".")
finally:
client.close()
output_directory must exist on the client. The client saves screenshot_local.png after the stream completes and returns the PNG bytes. A failed transfer preserves any previous image. Omit the directory to receive only the bytes. The v0.2.9 server captures the PNG in memory and sends it through the existing stream. Runnable example
Read instrument state
from smartlab_studio_ctrl.server_grpc.client import SmartLabGrpcClient
client = SmartLabGrpcClient("192.168.1.10", 50100)
try:
print(client.is_running())
finally:
client.close()
Saving exported data on the client
The Windows server performs the clicks and visibility checks through SmartLabUIA.export_data(), including the v0.2.7 waits and retries. Windows can reject mouse input even when the process can read the UIA tree. Run the server on the logged-in desktop where the graph is visible and mouse input is allowed. GUI sequence and verification
client.export_data(filename="measurement.txt", save=True) asks SmartLab Studio II on the server PC to export into a temporary directory, transfers the file bytes using the framework RPC result, and saves the file on the client PC. The server-side temporary file is removed after reading. Communication is entirely handled by grpc_frame.
from smartlab_studio_ctrl.server_grpc.client import SmartLabGrpcClient
client = SmartLabGrpcClient("192.168.1.10", 50100)
try:
print(client.export_data(filename="measurement.txt", save=True))
finally:
client.close()
Local SmartLabCtrl.export_data() and SmartLabUIA.export_data() retain their original GUI-save semantics. Remote save=False delegates to the original server-side GUI operation. Existing client files are not overwritten. gRPC message limits are set to 64 MiB; actual usable file size is slightly lower. File generation is polled after the Save button action. This does not validate measurement completion or exported content.
Properties and remote API
grpc_frame automatically exposes public methods via Describe, but does not expose Python @property descriptors. For remote access, use the existing SmartLabCtrl methods such as get_start() / set_start(value) and get_running(). Properties remain available for direct local use of SmartLabCtrl and SmartLabUIA.
Device class separation
SmartLabCtrl is transport-independent. The server uses SmartLabGrpcCtrl(SmartLabCtrl) and overrides only export_data() for file transfer. The original SmartLabCtrl and SmartLabUIA remain unchanged. grpc_frame handles transport and serialization.
Overriding the same API
Both SmartLabGrpcCtrl(SmartLabCtrl) and SmartLabGrpcClient(GrpcClient) override only export_data(). The server reads the temporary file and returns bytes; the client calls _raw_export_data() and saves locally. All other methods retain their inherited or dynamically dispatched behavior.