winIDEA SDK
Loading...
Searching...
No Matches
test_conn_is_connected.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
# (c) TASKING Germany GmbH, 2023
#
# This Python script connects to winIDEA, checks the connection status,
# and prints whether it is connected.
# It then proceeds to disconnect and again checks and prints
# the connection status to verify the disconnection.
import isystem.connect as ic
import subprocess
import time
TIMEOUT_S = 15
POLL_INTERVAL_S = 0.5
def test_isConnected():
print("Connecting...")
cfg = ic.CConnectionConfig()
cfg.start_always()
conn_mgr = ic.ConnectionMgr()
conn_mgr.connect(cfg)
print(f"\tIs connected: {conn_mgr.isConnected()}")
print("Disconnecting...")
conn_mgr.disconnect_close(bSaveAll=False)
print(f"\tIs connected: {conn_mgr.isConnected()}")
# NOTE: 'isConnected()' will return False until 'disconnect()' is called, regardless of
# actual winIDEA state (might be closed before).
if __name__ == "__main__":
test_isConnected()