LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping a parallel while loop with an event structure

Solved!
Go to solution

I have two while loops one with modbus data acquisition and control and another with an event structure to modify disable property of some of the controls. 

I have used tags to pass the value of stop from one loop to another, which works when there is no event structure. Can someone please explain to me why it doesn't work with an event structure?

girish_jadhav_0-1611676403055.png

PS: Is there any other way to modify the disable property of a control? I tried it by using just case structures but it makes the vi larger (occupy more space on the screen). 

 

Download All
0 Kudos
Message 1 of 6
(244 Views)

The loop isn't running. The one with the Event structure in it. It's waiting for a boolean AND the event to be triggered. Both are executing in parallel.

 

The "Value Change" does NOT trigger when writing to a terminal or local variable.

 

So unless you're certain you're doing BOTH exactly once per loop iteration, it won't work as you seem to think,

Message 2 of 6
(226 Views)

Get rid if the channel and simple add an event for "stop:value" changed. Wire a TRUE out to the termination of the upper while loop. Leave the lower while loop as is.

 

(It is a bad idea to have different controls with the same name.)


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 3 of 6
(201 Views)
Solution
Accepted by topic author girish_jadhav

Here is how to combine your two events into one and use scalable code. Next time you duplicate your control again, virtually no code changes are needed (just add the new control to the same event!).

 

The event gets triggered with any control change, but most of the time, nothing happens. (Empty case). Only if "betriebsart" has changed (old !=new), we process all controls of that cluster (except the first two). 

 

See if this can give you some ideas..... (Sorry, I took all the guts out of the lower loop because I don't have your hardware)

 

altenbach_0-1611682965220.png

 

 

You probably want to add some code to update all states (disabled, etc.) when the VI starts based on the cluster values I sometimes use value signaling properties placed before the main loop for that..


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 4 of 6
(182 Views)

@altenbach wrote:

Here is how to combine your two events into one and use scalable code. Next time you duplicate your control again, virtually no code changes are needed (just add the new control to the same event!).

 

The event gets triggered with any control change, but most of the time, nothing happens. (Empty case). Only if "betriebsart" has changed (old !=new), we process all controls of that cluster (except the first two). 

 

See if this can give you some ideas..... (Sorry, I took all the guts out of the lower loop because I don't have your hardware)

 

altenbach_0-1611682965220.png

 

 

You probably want to add some code to update all states (disabled, etc.) when the VI starts based on the cluster values I sometimes use value signaling properties placed before the main loop for that..


This is so elegant. 

 

Does it matter if we give same name to the controls even if they are in a cluster? I gave each cluster different name. 

0 Kudos
Message 5 of 6
(162 Views)

@girish_jadhav wrote:
Does it matter if we give same name to the controls even if they are in a cluster? I gave each cluster different name. 

Here you have no choice because it is the same typedef and this is OK.

 

It gets difficult to maintain and debug if you e.g. create property nodes for inner elements as you did. Hard to keep them apart and easy for bugs to hide. 😉


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 6 of 6
(152 Views)