01-26-2021 09:56 AM - edited 01-26-2021 09:57 AM
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?
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).
Solved! Go to Solution.
01-26-2021 10:17 AM
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,
01-26-2021 11:11 AM - edited 01-26-2021 11:16 AM
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.)
01-26-2021 11:46 AM - edited 01-26-2021 12:30 PM
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)
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..
01-26-2021 01:26 PM - edited 01-26-2021 01:59 PM
@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)
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.
01-26-2021 03:32 PM
@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. 😉