LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do this without causing a race condition?

This is probably a naive question, because I am a beginner.
I have a front panel cluster (custom control) which contains various
elements, including buttons which need to be popped back up under
program control. In some program states nothing at all is done to the
cluster; it is passed through the case structures and subvis unchanged
in what amounts to a control wired directly to its own local variable.
The result is a race condition. While the VI is running, the user
tries to push the buttons, and they refuse to stay down (or come back
up)! This is true of other elements in the cluster, such as numeric
controls, that aren't even wired to anything yet - they refuse to
chang
e, but once in a while, if you click enough, a change will get
though.
What is the proper way to wire a front panel control through some
process (subvis etc) and back to itself (its local variable or property node)
without causing a race condition?

To get an idea of the situation: create an infinitely executing while
loop. Put a numeric control inside. Create a local variable for the
numeric control (write mode), also inside the loop, and wire it to the
numeric control. When you run this, it resists efforts to change
the control.

Thanks in advance for any help!

---------------------------
Dan Greenspan
Mail Stop 14-707M
Johns Hopkins University
Applied Physics Laboratory
11100 Johns Hopkins Road
Laurel, MD 20723-6099

240-228-7490
daniel.greenspan@jhuapl.edu
---------------------------
0 Kudos
Message 1 of 2
(2,657 Views)
If I understand you correctly, you're having a problem because in the same while loop, you need to read a value from a control *and* write a value to the same control? If that's the case, all you need to do is separate the two events temporally. There are a few ways to do this.

1)Create a sequence structure (Structures>>Sequence). They're a little cumbersome, but probably the easiest to use. In the first sequence frame, do all that need be done with reading the control. In the second sequence frame, write to the control if need be.

2)You can also keep the read and write events in separate vi's that your main vi or llb calls. As long as the first vi (read) has an output that feeds to the input of the second vi (write), it will ensure that all read events occur
before the write events. This data dependency could be as simple as an the cluster that you're interested in reading/writing. First pass it to the read vi. Then that vi passes the unaltered cluster to the write vi, which whill change it if need be.

Good luck,

Michael J. Eggertson
Department of Chemistry
University of Washington
0 Kudos
Message 2 of 2
(2,657 Views)