From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

user interface menu

Solved!
Go to solution

Hello,

 

I'm relatively new to Labview, I was given an interactive menu that allows the user to select a series of processes to execute.  I have the subVIs of these processes but I have no idea how to have the user defined sequence execute. I thought about using a state machine and create  all the combinations but the amount of cases would be ridiculous. Does any of you have an idea on how to do this?

 

Thanks

0 Kudos
Message 1 of 9
(3,128 Views)

The code you have so far looks good (I haven't tried to executeit) for generating the sequences.

 

You know you want to use a state machine for for going through the tests.  That is good.

 

I don't understand your comment about needing to generate cases for all the combinations.  A state machine only needs a case for each state.  In essence, you are looking for a queued state machine, where the next state to execute will be based on whatever is the next element in your array.

0 Kudos
Message 2 of 9
(3,117 Views)

@RavensFan wrote:

 

In essence, you are looking for a queued state machine, where the next state to execute will be based on whatever is the next element in your array.


Yup this is also known as a Queued Message Handler.  LabVIEW ships with a couple examples but the simplest one can be found by going to File >> New...  Then picking it from under the templates section.

0 Kudos
Message 3 of 9
(3,113 Views)

What I meat to say is, if the user selects the sequence Start-FDM1-CNC-FDM1-FDM2-End how would the state machine execute that? Would I have to create a case for every combination if I use a state machine?

 

Thanks for replying

0 Kudos
Message 4 of 9
(3,103 Views)

@aleks_6 wrote:

What I meat to say is, if the user selects the sequence Start-FDM1-CNC-FDM1-FDM2-End how would the state machine execute that? Would I have to create a case for every combination if I use a state machine?

 

Thanks for replying


No you make a case for each individual step, and then go to them one at a time.  Make a state for Start, one for FDM1, one for CNC...etc.  Then when the user selects to go to Start, then FDM2 then End, just go to each of them one at a time.

0 Kudos
Message 5 of 9
(3,096 Views)

Alright, thank you. 

I've tried that, but now I ecountered another problem. If you check my Menu VI my output is a 1D string array so I found a VI that converts it to an enum. Now that I've got that enum I can connect it to the case structure but this enum is going to change depending on what the user selects from the menu. My teammate suggested having the case structure wired to another enum that had all the processes (start, fdm1, fdm2, cnc, end) and then somehow find a way to use the first enum to help select the cases that need to be executed.

We are stuck in that part, if you could please give me some suggestions on how to do that I would very much appreciate it.

 

 

0 Kudos
Message 6 of 9
(3,025 Views)
Solution
Accepted by topic author aleks_6

You are making things far too complicated.  Did you read up on how a Queued Message Handler works?  You have a 1D array of strings.  You then delete the first element in the string.  Now you have a scalar string that goes to your case structure.  Do the operation for that scalar string.  Next use the remainder of the 1D array and delete the next item from index 0 and do the step according to that scalar string.  Do this over and over, until there are no string values left.  Alternatively you could do this with a for loop, but there is less control for things like needing to go to other cases based on the steps that have been visited previously.

Message 7 of 9
(2,997 Views)

Thank you so much! It works perfectly! Another quick question, is that what what a QMH is? 'cause it doesn't have any obtain queue or dequeue. I ask just to know how to call the other one.

0 Kudos
Message 8 of 9
(2,964 Views)

Yeah there are too many software terms that can mean different things.  At the root of it a Queue is a thing that objects are added to, and then removed from.  You can get more specific and define the type of queue as FIFO or LIFO, then there are instances were higher priority objects can be inserted wherever they like.

 

So a QMH is a more basic definition of a queue with strings being appended to one end or the other, and then pulling them off one at a time from one end or the other.

 

The Queue data type  is an attempt to create a queue by a reference, and not by value.  It works well but a QMH doesn't require to use this data type.

0 Kudos
Message 9 of 9
(2,954 Views)