winIDEA SDK
test_conn_is_connected.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2# (c) TASKING Germany GmbH, 2023
3#
4# This Python script connects to winIDEA, checks the connection status,
5# and prints whether it is connected.
6# It then proceeds to disconnect and again checks and prints
7# the connection status to verify the disconnection.
8
9import isystem.connect as ic
10import subprocess
11import time
12
13TIMEOUT_S = 15
14POLL_INTERVAL_S = 0.5
15
16
17def test_isConnected():
18 print("Connecting...")
19 cfg = ic.CConnectionConfig()
20 cfg.start_always()
21 conn_mgr = ic.ConnectionMgr()
22
23 conn_mgr.connect(cfg)
24
25 print(f"\tIs connected: {conn_mgr.isConnected()}")
26
27 print("Disconnecting...")
28 conn_mgr.disconnect_close(bSaveAll=False)
29 print(f"\tIs connected: {conn_mgr.isConnected()}")
30
31 # NOTE: 'isConnected()' will return False until 'disconnect()' is called, regardless of
32 # actual winIDEA state (might be closed before).
33
34
35if __name__ == "__main__":
36 test_isConnected()