LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

GUI & menu

I have created a GUI with several test functions where the user may pick either one option or several option  to be performed, by clicking in the on/off checkbox for a given function. I need some advice for handling the alternative where the user pick several options to be performed. I link all the checkboxes into a build array and furthermore "search in 1-D array" searches for checkboxes equal to "true" (to reach the checkbox chosen), and "the variant to data" then uses a enumbox for handling multiple case structure with a while loop with a shift register.  
 
I have manage to run one option but I am not able to get several option to run after each other. Some advices to give on the desperate road to more Labview knowlegde?  
 
Anita
0 Kudos
Message 1 of 6
(3,596 Views)
Hi Anita,
It would help if you attach a simplified VI wich shows the problem. So I have to guess: You have to use the search 1D array in a loop to find all checkboxes. Maybe that's the reason, you can handle only one check.
Greets, Dave
Greets, Dave
0 Kudos
Message 2 of 6
(3,576 Views)
Hi!!
 
I tried with a for loop without any luck, see attachment.
 
For every task in the application I have to reboot to be asure that the application is running where it is suppose to run; in boot or in application(linux) mode. The reboot takes a huge effort in time, after testing different solution when inculding the reboot I ended up with the occurence solution. Is there any better alternative you would recommend??
 
 
A
0 Kudos
Message 3 of 6
(3,554 Views)
You cannot run several options because you do not have a loop to run them.  There are two ways to fix it - the fast, easy one and the "refactor so your life is much easier in the future" one.

The Easy Way
  1. In your Go value change event, replace the outer loop with a FOR loop.
  2. Now move the code which creates the boolean array outside the loop.
  3. Delete the FOR loop which used to search the boolean array before you moved that code outside the main FOR loop.
  4. Wire the iteration terminal (the "i") of the main FOR loop into the Variant To Data node to replace the search value.
  5. Wrap a CASE statement around all the code remaining in the main FOR loop.
  6. Wire the boolean array from outside the FOR loop to the selector terminal of the CASE statement inside the FOR loop.  Autoindexing will take care of the type conversion from boolean array to boolean.
At this point, you should be good to go.  The main FOR loop now loops once for each of your booleans.  If the boolean is FALSE, the FALSE case of the CASE structure executes and nothing happens.  If the boolean is TRUE, your original logic is executed.  A FALSE iteration occurs in microseconds, so it is not a performance issue.

Note that you can get rid of the Occurrences you are using by wiring the error wire from the first frame into the error wire input of the second.  You can then delete the frames as well.  Data flow is a wonderful thing, once you get the hang of it.

Refactor So Your Life Is Much Easier In The Future

This sort of application is easier to maintain if it is implemented using an interrupt driven, queued state machine.  I have attached an example of this type of architecture (LV7.1, so you should be able to open it).  In this architecture, your main loop is WHILE loop containing a CASE selector.  The CASE is selected by the output of a Queue.  The default case is an event structure waiting for GUI input.  When an event occurs, it places one or move items on the Queue (your tests, in this case).  These items are then executed in the order they are placed on the queue.  When there are no more items to be processed, the code returns to the default state and waits for more GUI input.

The example should make it much clearer than any words.  Good luck.  Let us know if you need more help.
0 Kudos
Message 4 of 6
(3,536 Views)

DFGrey!!

 

Thanks a lot for your guidence! My VI is still not working perfectly, see attachment if you have time to check if I understood your advices correctly. Check the case for Programming - boot code as well, I change the design as you recommended in your post.

Even if it is chosen or not, the first option "Programming - boot code" is always running, this happens probably since it is the first item on the enum list. I try to avoid this by putting an item called "none" first, but then the GUI meny hang. 

 

A

0 Kudos
Message 5 of 6
(3,530 Views)
You correctly identified your error (and mine, that's what I get for not actually trying the edits I suggested).  You need to add a None value to your enum.  However, to do it fully, you need to do three things:
  1. Modify your enum to add a None option
  2. Create a constant on the FALSE frame from the output tunnel so in the FALSE case, None is selected (you don't have to make None the first option if you do this)
  3. Create a None case in the CASE selector of what is done.  It will have no code.  You should probably make it the Default case, as well.
Let me know if you still have problems.
0 Kudos
Message 6 of 6
(3,508 Views)