06-19-2023 11:46 AM
Hello, I'm trying to create dependency in my program, if one Boolean control is high, it sets other Boolean control to high, and that control may also need to set yet another Boolean control to high. Right now I'm using a bunch of OR gates to achieve that but wiring is becoming very messy.
Like, in this example, I want my Boolean3 to enable Boolean2 or Boolean4 to enable the LED. I've tried using Disabled property nodes but they just enable/disable the control, not setting it to high. Besides, how would I approach this problem if I have, say, 7 controls that have Boolean2 as a dependency.
Solved! Go to Solution.
06-19-2023 12:28 PM
The property you are looking for is "value" or "value signaling" read the help to determine what property is appropriate for your situation.
Honestly if you could explain what you're trying to achieve on a higher level, we can probably come up with a better way as this screams "Rube Goldberg".
06-19-2023 03:05 PM
You are following the motto of my colleague RTSLVU -- what you are engineering is definitely Ambiguous! Before you worry about the (undescribed, untested, heavily nested, snarled) Boolean Logic, get your code working with a single Boolean and make sure it "does what you want it to do" (as opposed to doing what you tell it to do, which is often quite different ...)
Bob Schor
06-19-2023 04:24 PM
Like I said, I want to establish a dependency. User controls Boolean buttons that enable case structures that do measurements. Some of the measurements require the use of previous measurements, so, if user only selects "Measurement 5" Boolean, I want software to enable "Measurement 1" and "Measurement 4". If user selects "Measurement 7", I want to enable "Meas1" and "Meas5". Rig ht now I implement it like this with OR gates
, but it's messy and I think there should be a better way.
06-19-2023 04:26 PM
@John32d wrote:
Hello, I'm trying to create dependency in my program, if one Boolean control is high, it sets other Boolean control to high, and that control may also need to set yet another Boolean control to high. Right now I'm using a bunch of OR gates to achieve that but wiring is becoming very messy.
Like, in this example, I want my Boolean3 to enable Boolean2 or Boolean4 to enable the LED. I've tried using Disabled property nodes but they just enable/disable the control, not setting it to high. Besides, how would I approach this problem if I have, say, 7 controls that have Boolean2 as a dependency.
The code image you show has no obvious connection to your description. There is only one OR gate, not a bunch. You already have a disable property, so resize that and add a "value" property wired to a TRUE constant.
You talk about a much more complicated scenario with seven controls but don't provide any details. Should "4" be TRUE and disabled if at least one of the seven is true? Only if all of the seven are true? Something else?
Is there still only one LED? Is "4" the only control that is dependent?
(And please don't do greedy loops that cannot be stopped!)
So go back to the drawing board and create the VI with the many controls, then describe the exact truth table you need that changes the dependent control(s). Then attach that VI here (i.e. not a picture!).
06-19-2023 04:28 PM
@John32d wrote:
...but it's messy and I think there should be a better way.
of course this is way to messy, so follow my instructions above and attach your actual VI and a description of the desired behavior. we cannot work with pictures!
06-19-2023 04:46 PM - edited 06-19-2023 05:22 PM
@John32d wrote:
Like I said, I want to establish a dependency. User controls Boolean buttons that enable case structures that do measurements. Some of the measurements require the use of previous measurements, so, if user only selects "Measurement 5" Boolean, I want software to enable "Measurement 1" and "Measurement 4". If user selects "Measurement 7", I want to enable "Meas1" and "Meas5". Rig ht now I implement it like this with OR gates
, but it's messy and I think there should be a better way.
Yes there is. For instance if measurement 4 is dependent on measurement 1 and 2 being taken first. Then do not allow the user to select measurement 4 until measurement 1 and 2 are completed.
Or if the user selects measurment 4 and measurement 1 or 2 have not been completed. Then take measurement 1 or 2 before you take measurement 4.
BTW: If your program architecture was a State Machine instead of One Big Loop either solution would be quite simple to implement without a bunch of convoluted logic.
06-19-2023 09:08 PM
06-20-2023 06:36 AM
@RTSLVU wrote:BTW: If your program architecture was a State Machine instead of One Big Loop either solution would be quite simple to implement without a bunch of convoluted logic.
I'm not sure you actually need a State Machine. I think the OP can accomplish the desired effects with a simple Event Structure inside of a loop. Initialize "4" to be disabled until 1 and 2 have been ran. With the Event Structure, it is easy to react to each button individually and keep track of what measurements are complete in a shift register.
06-20-2023 08:00 AM
Have you though about using Tab Control to implement like a Wizard type of thing ?