Skip to content
Snippets Groups Projects
Commit 799fd9b9 authored by Taya Snijder's avatar Taya Snijder
Browse files

added pass function in attribute wrapper and calls to it in the device configure_for_initialise

parent f19960f3
No related branches found
No related tags found
1 merge request!32Resolve L2SS-216 "2021 05 17 branched from master sdp hotfix"
......@@ -166,7 +166,9 @@ class APSCTL(hardware_device):
try:
i.set_comm_client(self.OPCua_client)
except:
self.debug_stream("error in getting APSCTL attribute: {} from client".format(i))
# use the pass function instead of setting read/write fails
i.set_pass_func(self.OPCua_client)
self.error_stream("error in getting APSCTL attribute: {} from client".format(i))
self.OPCua_client.start()
......
......@@ -140,12 +140,14 @@ class PCC(hardware_device):
self.OPCua_client = OPCUAConnection("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), "http://lofar.eu",
self.OPC_Time_Out, self.Fault, self)
# map the attributes to the OPC ua comm client
# map an access helper class
for i in self.attr_list():
try:
i.set_comm_client(self.OPCua_client)
except:
pass
# use the pass function instead of setting read/write fails
i.set_pass_func(self.OPCua_client)
self.error_stream("error in getting PCC attribute: {} from client".format(i))
self.OPCua_client.start()
......
......@@ -139,7 +139,9 @@ class SDP(hardware_device):
try:
i.set_comm_client(self.OPCua_client)
except:
self.debug_stream("error in getting SDP attribute: {} from client".format(i))
# use the pass function instead of setting read/write fails
i.set_pass_func(self.OPCua_client)
self.error_stream("error in getting SDP attribute: {} from client".format(i))
self.OPCua_client.start()
......
......@@ -88,9 +88,14 @@ class SNMP(hardware_device):
# set up the SNMP ua client
self.snmp_manager = SNMP_client(self.SNMP_community, self.SNMP_host, self.SNMP_timeout, self.Fault, self)
# map the attributes to the OPC ua comm client
# map an access helper class
for i in self.attr_list():
try:
i.set_comm_client(self.snmp_manager)
except:
# use the pass function instead of setting read/write fails
i.set_pass_func(self.snmp_manager)
self.error_stream("error in getting SNMP attribute: {} from client".format(i))
self.snmp_manager.start()
......
......@@ -108,7 +108,12 @@ class ini_device(hardware_device):
# map an access helper class
for i in self.attr_list():
try:
i.set_comm_client(self.ini_client)
except:
# use the pass function instead of setting read/write fails
i.set_pass_func(self.ini_client)
self.error_stream("error in getting ini attribute: {} from client".format(i))
self.ini_client.start()
......
......@@ -138,9 +138,14 @@ class attribute_wrapper(attribute):
def pass_func(value=None):
pass
logger.error("Exception while setting %s attribute with annotation: '%s' read/write functions. using pass function instead to to keep running", client.__class__.__name__, self.comms_annotation)
logger.error("Exception while setting {} attribute with annotation: '{}'".format(client.__class__.__name__, self.comms_annotation))
raise Exception("Exception while setting %s attribute with annotation: '%s'", client.__class__.__name__, self.comms_annotation) from e
def set_pass_func(self, client):
def pass_func(value=None):
pass
logger.debug("using pass function for {} attribute with annotation: {}".format(client.__class__.__name__, self.comms_annotation))
self.read_function = pass_func
self.write_function = pass_func
raise Exception("Exception while setting comm_client read/write functions. using pass function instead. %s") from e
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment