Hello,
writing this script inside a tag event script generate a dispatcher log error as expected.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value != previousValue.value :
a = 2/0
...
If i write this function :
def handler(tag, id_richiesta):
logger_name = "test"
log = system.util.getLogger(logger_name)
log.trace("log 1")
a = 2/0
log.trace("log 2")
I call this function form the tag event script like so :
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value != previousValue.value :
id_richiesta = currentValue.value
RequestHandler.handler(tag, id_richiesta)
The result is that I find the trace message "log 1" in the logger, then the script stops working without giving any message.
If I place "a = 2/0" inside a try-catch block, the script behaves as expected.
I would like to understand what is happening, as my aim is to write an event handler function that will always return a message code to the PLC, so I would like to understand why, in this case, the script ends silently.
At the moment my idea is to use something like this, so i can notify plc and get detailed error in the ignition logger.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value != previousValue.value :
id_richiesta = currentValue.value
try :
RequestHandler.handler(tag, id_richiesta)
except :
## write to plc, not handled error
...
raise
Thank you for your time.