From 9e87dfe5453c808acf9308473b18617a75b3d74e Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Mon, 18 Jan 2021 08:54:38 +0100 Subject: [PATCH] Allow manually setting the device to FAULT --- RCUSCC/RCUSCC/RCUSCC.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/RCUSCC/RCUSCC/RCUSCC.py b/RCUSCC/RCUSCC/RCUSCC.py index cf70f665a..90fa69337 100644 --- a/RCUSCC/RCUSCC/RCUSCC.py +++ b/RCUSCC/RCUSCC/RCUSCC.py @@ -57,6 +57,8 @@ class RCUSCC(Device): * -> OFF: Device is turned off. Triggered by the Off() command. FAULT -> INIT: Device is reinitialised to recover from an error. Triggered by the Init() command. OFF -> INIT: Device is turned on again. Triggered by the Init() command. + + For integration testing reasons, the user is allowed to manually set the device to FAULT. """ client = 0 name_space_index = 0 @@ -273,11 +275,11 @@ class RCUSCC(Device): self.client = opcua.Client("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_Time_Out) # timeout in seconds # Connect to OPC-UA -- will set ON state on success - self.opcua_connection = OPCUAConnection(self.client, self.On, self._Fault, self) + self.opcua_connection = OPCUAConnection(self.client, self.On, self.Fault, self) if not self.opcua_connection.connect(): # hardware or infra is down -- needs fixing first - self._Fault() + self.Fault() return # Retrieve and map server attributes @@ -285,7 +287,7 @@ class RCUSCC(Device): self._map_attributes() except Exception as e: self.error_stream("Could not map server interface: %s", e) - self._Fault() + self.Fault() return # Start keep-alive @@ -472,8 +474,11 @@ class RCUSCC(Device): # Turn off again, in case of race conditions through reconnecting self.set_state(DevState.OFF) - - def _Fault(self): + @command( + ) + @only_in_states([DevState.ON, DevState.INIT]) + @DebugIt() + def Fault(self): """ FAULT state is used to indicate our connection with the OPC-UA server is down. -- GitLab