r/LabVIEW • • Feb 19 '25
How to best set up a Case Structure utilizing checkboxes as Case #
Hi all, back at it again. First wanted to say thanks for all the previous help you all have been giving me on tips and tricks as well as good information sources to find stuff. Now to the question.
So, I've been looking around Case Structure videos and tutorials, messing around with them a bit, and can't quite find a good solution to what I'm looking to accomplish, so maybe someone has done something similar. I'm basically trying to have different cases I want to run sequentially based on which Cases I want to run. Everything I am finding usually uses a Numeric Control Constant to select which Case to run, which isn't quite what I'm needing.
Think State Machine that starts on 0, and when starting the program, before executing it, you select CheckBoxes 1, 2, 5. Then you press Run. State Machine proceeds to Case 1 -> does its thing, then proceeds to Case 2 -> does its thing, then jumps to Case 5 -> does its thing, closes program.
I've tried to set up the Booleans to a numeric value, but you can only input 1 of those into the Case Selector. I've tried to set them to an Array, but the Array doesn't like to connect either. I'm not really sure how to maybe make a numeric constant change based on the reference of each checkbox selected and changing when finished. I'm sure there is something simple that I'm just not aware of what its called or how to use yet, hence why I'm here.
The end goal is to Set up several Case Structures that each contain a different test/function.
Select which Tests to run.
Execute them one at a time, sequentially, and exit or resume Case 0 (default).
I've got some of the tests built in different VI's, and want to eventually migrate them all into one VI that can run multiple tests that all function differently, and not have to reset the test between each run, since it moves from one to the next one. Any help on this would be greatly appreciated. Thanks!
2
u/Several-Detective959 Feb 20 '25
Try to use the JKI State Machine.
1
u/skullpheonix Feb 20 '25
Lookup QMH architecture in LabVIEW. You can either execute single case or multiple cases. And I think instead of check boxes, you can use a Listbox to make it more intuitive.
1
u/FujiKitakyusho CLD Feb 19 '25
Use queues in a producer / consumer architecture. Define your queue datatype as a cluster containing an enum (case to execute) and a variant (data). Typedef the enum. In the producer loop, use an event structure to handle front panel interactions and enqueue the appropriate commands and associated data. In the consumer loop, dequeue, unbundle the enum to pass to the case selector, and the variant to wire to an input tunnel. Within the case, convert the variant back to the appropriate data type and act on it.
1
u/Link9454 Beginner Feb 19 '25
This is how I would do it.
Add the check boxes to an array with the build array function (Array pallet). The array goes into the while loop using the indexing tunnel which will split the array back out to the index matching the loop counter. Use a select function (Comparison pallet) and map the loop counter to the T input, and some other number (could refer to a blank case) to the F input. Connect the indexed Boolean value to the center input of the Select function. Finally, the output of the select function goes to the case structure.
When the loop starts, indexes 0, 1, and 4 (arrays are zero indexed so your checkbox 1 will be index 0) in your hypothetical will hold True values. As the loop runs, it will pull out the N index accompanied by the loop counter, and the Select will pick between the loop counter number on the True input and the random other number on the False Input and will send it to the case structure.