Skip to content
Snippets Groups Projects
Commit 9e87dfe5 authored by Jan David Mol's avatar Jan David Mol
Browse files

Allow manually setting the device to FAULT

parent bd1a51d8
No related branches found
No related tags found
1 merge request!1State management
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment