05-19-2016 09:27 AM
Hi everyone,
I am having a problem I cannot find the solution for. I searched the forum and google, but I couldn't find an explenation. Hopefully you can help!
In the attached project there is the "main.vi", which I use to control an industrial manufacturin mashine. On the frontpanel I have a cluster called "manual control". Whenever I change a value in the cluster an event is triggered to execute the "manual control" case in the "Wirbelschicht_main.vi" [called "FBC (Fluid bed control)" in the main.vi block diagram]. In this case, the data from the cluster is updated via a reference. The order to execute the "Manual control" case is passed in a queue.
When I change the value of, for example, "InAirTempSet" from 0 to 5 and then from 5 to 9, I would expect the numbers in the subvi to update in the same manner (first from 0 to 5, and with the next click from 5 to 9). What I see is that the update process in the subviis always one step behind. Meaning, I change the value from 0 to 5 in the main.vi and nothing happens. Then I change the number to 9 and 5 in the subvi 5 is received. Only when I change the number in the main.vi another time, the 9 is passed to the subvi.
What is the reason for this and how can I fix this?
Thank you!
Qbach
Solved! Go to Solution.
05-19-2016 09:43 AM
This is expected behavior. You read the value of control reference concurrently to waiting for the queue command. That means that once the queue command ("Manual control") is received, the value was already read a long time ago.
In order to prevent such race conditions, pass the data using the queue instead of reading it asynchronuously with property nodes. You are running into a race condition here because this is exactly what your code instructs the application to do!
Norbert
05-19-2016 09:58 AM
I love programming because the program does exactly what you tell it to do; I hate programming because the program does exactly what you tell it to do.
05-20-2016 01:12 AM
...putting it that way makes absolute sense. I'll wire it into a queue. Thank you!
@billko: I will steal that and make it my motto. More likely the second part 😉