LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling menu selection in multi states of states machine

Solved!
Go to solution

Hi everyone,

 

My application uses states machine architecture, I have to handle menu selection in two different states and the 2nd of them has to be handled by the event case structure.

The problem is that when I use event structure in the 1st state it is also handled later by the event case in the 2nd state and it is impossible to handle menu selection in the 1st state by the "Get Menu Selection" block because according to it's descripton if event structure is configured to handle the same menu as item as this block, LabVIEW ignores this function.

 

I would be greatful for any clueSmiley Happy.

 

Greetings,

Mariusz

0 Kudos
Message 1 of 9
(2,512 Views)

You didn't explain the exact situation whihc makes you have to handle a menu selection in two different places.  I would just have the state machine handle everything and make the state machine aware of the first menu, so when the second occurs, you know the path you took to get there.  If you could explain more about what you are trying to do (or better yet, give some sample code that demonstrates your problem). we can give you some options.

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

Thanks for respond.

 

Here's a code explaining the main idea.

Download All
0 Kudos
Message 3 of 9
(2,490 Views)

Why can you not just have an idle state which is your event structure.  On Init, you go idle.  When the user chooses a menu item, you kick off the right state and then return to idle, which allows the event structure to run again.  And so on.

0 Kudos
Message 4 of 9
(2,484 Views)

I think it's not possible to use the idle state in my application because it works in sequence:

1.Init - Initialize graphs,arrays etc

2.WaitForData - Wait until user select data source from menubar,the choice is passed throug local var. to next state

3.OpenData 

4.RangeSelection - allows user to select data range

5.WaitForAction - this the main state of the application, this event case handles main functionality, allowing to work with opened data set so it can go to another state.User can open new data set by the same menu item, if it is so, the app starts the sequence from the beginning (goes to init)

6.STOP

 

 

0 Kudos
Message 5 of 9
(2,476 Views)

Sorry for mistake,to be precise,in the WaitForAction state, if you select from menu to open new data it goes to Init state but this time bypassing WaitForData state.

0 Kudos
Message 6 of 9
(2,467 Views)

1.  Init - disable all menu items that are not relevant.  So, it sounds like Select Data source should be the only active item.

2.  WaitforAction - your event case that handles the menu.  At this stage, the user can only select one menu item.

3.  OpenData - activate available menu items.

4.  Range Select

5.  WaitforAction - now all menu items are available.

6.  Stop

 

This way, you have one state to look for menu items.  From the start, the user only has one available action, to open the data file, so the flow will still be the way you want it, but you only have one place to get the menu selection.

Message 7 of 9
(2,463 Views)
Solution
Accepted by topic author MuhAli

Thanks, it solved my problem! 

I also had to add state selector into the Init state. If data is being reopened,the machine goes straight to the OpenDataState.

 

 

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

Please mark Matthew's post as the solution and give him the credit. Your thank you is not the solution.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 9
(2,437 Views)