diff --git a/openopc2/da_client.py b/openopc2/da_client.py index a32789f..f0efbc1 100644 --- a/openopc2/da_client.py +++ b/openopc2/da_client.py @@ -147,11 +147,11 @@ def set_trace(self, trace): if self._open_serv is None: self.trace = trace - def connect(self, opc_server=None, opc_host='localhost'): + def connect(self, opc_server: str | None = None, opc_host: str = 'localhost'): """Connect to the specified OPC server""" log.info(f"OPC DA OpcDaClient connecting to {opc_server} {opc_host}") - self._opc.connect(opc_host, opc_server) + self._opc.connect(opc_server, opc_host) self.connected = True # With some OPC servers, the next OPC call immediately after Connect() diff --git a/openopc2/da_com.py b/openopc2/da_com.py index 5917f38..b99b5a4 100644 --- a/openopc2/da_com.py +++ b/openopc2/da_com.py @@ -42,8 +42,8 @@ class OpcCom: def __init__(self, opc_class: str): # TODO: Get browser type (hierarchical etc) - self.server: string = None - self.host: string = 'localhost' + self.server: str | None = None + self.host: str = 'localhost' self.groups = None self.opc_class = opc_class self.client_name = None @@ -69,9 +69,9 @@ def initialize_client(self, opc_class): pythoncom.CoUninitialize() raise OPCError(f'Dispatch: {err} opc_class:"{opc_class}"') - def connect(self, host: str, server: str): + def connect(self, server: str | None, host: str): self.server = server - self.host = "localhost" + self.host = host try: log.info(f"Connecting OPC Client Com interface: '{self.server}', '{self.host}'") self.opc_client.Connect(self.server, self.host)