09-29-2011 10:29 AM
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 clue.
Greetings,
Mariusz
Solved! Go to Solution.
09-29-2011 11:20 AM
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.
09-29-2011 11:53 AM
Thanks for respond.
Here's a code explaining the main idea.
09-29-2011 12:17 PM
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.
09-29-2011 12:48 PM
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
09-29-2011 01:15 PM
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.
09-29-2011 01:21 PM
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.
09-29-2011 01:41 PM
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.
09-29-2011 04:47 PM
Please mark Matthew's post as the solution and give him the credit. Your thank you is not the solution.