Questions about system.util.invokeAsynchronous

I’ve been trying to use system.util.invokeAsynchronous without success. I am suspicious that it is because I am using Sepasoft’s Instrument Interface module to read data from a device over a serial port.

The way to get control of a serial port using the Instrument Interface module is put a “Serial Controller” object onto an Ignition screen. This object is only visible in the designer. It would serve no purpose in a client.

You use the object’s properties and methods to work with a serial port.

What I am doing is reading a large amount of data from the serial port, massaging it and then inserting it into a database. I don’t want the user to have to wait while this is going on - he has plenty that he could be doing during that time. I would like to define all of that as a function and call it with system.util.invokeAsynchronous.

I know that you should not interact with the GUI in the asynchronous thread. Since this object is invisible on the screen and the user can’t interact with it, I wonder if this is considered to be “part of the GUI”. If so, I’m sure that is my problem.

Also, is using Python’s “print” command considered to be an interaction with the GUI? I have sprinkled a few of them throughout the code that I’m trying to run asynchronously to troubleshoot this issue.

Yeah, you want to run a dedicated thread. This might help:

Technically, yes. But you can get away with it. The down side is it is prone to disappear into the bitbucket on the floor when used in the background. You should use system.util.getLogger() in the background, and everywhere in a gateway scope.

1 Like

Thank you so much Phil. I hope that one day I will be able read and understand everything in clientserial.py, but at age 53 I’m not sure I have the life expectancy to do so. :smiley:

Heh. I guess it needs more comments. (-:

FWIW, I turn 52 next month…