05-16-2013 09:47 AM
Hi,
A quick question: I have this program consisting of multiple state machines. The user interface can start these state machines (asynchronous) and send commands to them. Now, the problem is that I need to be able to check whether a certain state machine is running or not. What's the best way of doing this?
Kind regards,
Wouter
Solved! Go to Solution.
05-16-2013 09:50 AM
I would have the state machines update their status in a functional global variable or Action Engine. The user interface can read the data from the FGV to update the front panel.
05-16-2013 10:06 AM
I already considered using a notifier or FGV but I was wondering whether there's not a more fundamental solution to check whether a process is running.
05-16-2013 10:34 AM
If I wasn't worried about race conditions, i.e. there is only one "writer", I would consider using a regular global variable or a shared variable. The state machine writes what state it is in to the variable, then one or more other readers read that variable and do what they want with the information.
05-16-2013 11:34 AM
Hallo wouter 🙂
As RavensFan already stated, if you want to know what the status of your parallel loops is, you have to put their status into a functional global.
You can keep more then just 'alive'
If there is hardware communication in there you can extend your statussen with : initialised, running, saving,...
05-16-2013 12:11 PM
The problem I have with this solution is that the FGV will not be in the correct state if a statemachine is aborted (which tends to be necessary during development). I think I might have to use some sort of hartbeat instead.
Is there really no way to just check whether a vi is running?
05-16-2013 12:39 PM
I would have the FGV or variable include a timestamp as well.
There is a property node for VI's called Execution:State. That will tell you the status of a VI. But I don't think I'd rely on it. It would tell you a VI is running, but perhaps you are actually stuck in some sort of endless loop that prevents it from effectively doing what you are expecting it to do. For your App, you would consider it stuck, but according to LabVIEW it is running.
I would rely on that watchdog method where you update a variable that would be a cluster of a timestamp and another useful piece of information such as your state machines current state. Now you'll know what is happening, and you'll know if that data is too old.