diff --git a/tangostationcontrol/tangostationcontrol/clients/opcua_client.py b/tangostationcontrol/tangostationcontrol/clients/opcua_client.py index 145c0ebe68c3824d764dd4417a81afeae8ce0247..ceacf690f067b1e872c4427953e608e7b1156ca6 100644 --- a/tangostationcontrol/tangostationcontrol/clients/opcua_client.py +++ b/tangostationcontrol/tangostationcontrol/clients/opcua_client.py @@ -153,15 +153,18 @@ class OPCUAConnection(AsyncCommClient): return read_function, write_function - async def call_method(self, method_path, *args): - node = await self.obj.get_child(method_path[:-1]) - return await node.call_method(method_path[-1], *args) + async def _call_method(self, method_path, *args): + method_path = self.get_node_path(method_path) + + try: + node = await self.obj.get_child(method_path[:-1]) + result = await node.call_method(method_path[-1], *args) + except Exception as e: + raise Exception(f"Calling method {method_path} failed") from e def call_method(self, method_path, *args): - method_path = self.get_node_path(method_path) - - raise NotImplementedError + return asyncio.run_coroutine_threadsafe(self._call_method(method_path, *args), self.event_loop).result() class ProtocolAttribute: