We are trying to configure a label to output the current in-mode of a loop as feedback back to the user which exists in a UDT popup. The label contains a script that is supposed to look at three tag paths and determine what to show the user based on these paths, but it lacks the ability to update in real-time. Currently the method is only called in the startup event of the label. Ideally it should be set to update within a specified interval to give better/more up-to-date feedback. We have considered putting the custom method in the gateway, but this would complicate the transfer of data between the gateway and the label. What is the most effective way to go about getting the label to correctly display the in-mode of the loop in real-time?
Script:
def method_loop_mode(self, text):
autoBit = self.view.params.Loop_auto_mode.value
cascadeBit = self.view.params.Loop_cascade_mode.value
manualBit = self.view.params.Loop_manual_switch.value
output = " "
if manualBit == 1:
output = "Manual"
elif autoBit == 1:
output = "Auto"
elif cascadeBit == 1:
output = "Cascade"
else:
output = "Manual"
self.props.text = output
#print output
One possible solution we have investigated using is the perspective refresh function or alternatively a timer script which may allow for the periodic updates to the label. These may be work but we’d like to avoid potential additional overhead that this may introduce after the pop-up has been closed.
Any help is greatly appreciated!
Edit: The case statement worked but we did have to add additional cases for other possible combinations.