I have written Timer Script to update my window numeric text field element per 1000ms. I am reading system/client current date and time and separating it into two textfields. Below is my script .
[code]import system
global currentdate
global currenttime
global currenttime1
This script executes very well sometimes but sometimes it fails to update my on screen numeric text fields.
Anybody knows what is the problem in my code? Or is there any setting in Ignition that I am missing here.
Hello nmudge,
Thanks for testing my script. I get this problem when I do some changes in development environment and save project and when I return to run time I get this error.
After saving project sometimes it works but some time it doesn’t. Then I enable and Disable the numeric text field and again save it works. I don’t know why this happens. I never made any change in my timer script since I wrote it.
I am using numeric text fields.
Ignition uses Swing for its GUI components and Swing is single threaded. Using client timer scripts introduces another thread manipulating Swing components. The GUI thread is called the event dispath thread (EDT). Using the system.util.invokeLater function puts execution of code in the EDT.
I am wondering if your scripting problem will go away if you use system.util.invokeLater to execute your component code.