Problem with invokeLater

Hi,

we have actually a problem with the function invokeLater.
We are trying to call a GLOBAL SCRIPT called “Reader” with the function “readAll” that is like this:

def readAll(ip,db):
dtNow = system.tag.read("[System]Gateway/CurrentDateTime").getValue();
minutes= dtNow.getMinutes();

def later():
now = system.tag.read("[System]Gateway/CurrentDateTime").getValue()
call = system.db.createSProcCall(“usp_Write_Log_Ignition”, db)

 procedure_name= "Ignition_Log"
 call.registerInParam("ID_PROCEDURE_NAME", system.db.VARCHAR, procedure_name)
 message_type = 0
 call.registerInParam("ID_MESSAGE_TYPE", system.db.INTEGER, message_type)
 call.registerInParam("DS_MESSAGE", system.db.VARCHAR, 'test1')
 call.registerInParam("DT_PROCEDURE_TIMESTAMP", system.db.TIMESTAMP, now)
 
 system.db.execSProcCall(call)  

system.util.invokeLater(later,10000)

When we call the global script from a Tag value changed (with shared.Reader.readAll("", “dbscada”)), we have this error:
AttributeError: ‘com.inductiveautomation.ignition.common.script.Scr’ object has no attribute 'invokeLater’

We need to log a string, but we need to wait 10 seconds after the tag changed, so we used the invokeLater.

Could you please help us to solve this problem?

Thanks
Andrea

invokeLater is only available in the client and designer scopes because it is specifically for launching a task on the EDT, the thread that runs the UI.

You probably need to use invokeAsynchronous and a call to sleep (yuck):
https://docs.inductiveautomation.com/display/DOC79/system.util.invokeAsynchronous

1 Like