LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with State Machines

Solved!
Go to solution

I am implementing my application using state machines, and I have the following problem.

 

1. I have an initialized state that will initialize my controls.

2. Next I want the next state to check for user input.(boolean button will be pressed to determine which state is next).

3. In one of the states, I want the user to be able to change the initialized values, and afterwards go back to the user input state, to determine which state is next

 

I have implemented the initialize state as well as the user input  state(use event structure for that state), but I do not know how to let the user be able to change the values of my control , then the user acknowledges the change, and the state goes back to the user input state waiting for the next state.

 

Thanks for any help

0 Kudos
Message 1 of 7
(3,265 Views)
Solution
Accepted by topic author ade77
Your user input state is also what I would call an idle state.  If nothing happens, it just goes back to itself.  (Put some wait statement in there so that the idle state doesn't act like a "greedy loop".)  If the change is acknowledged, then instead of the idle state being called, the initialize state gets called again.  The Initialize state runs and when it is done it goes back to the idle/user input state.
Message 2 of 7
(3,262 Views)

Thank you Ravens Fan, I did not really understand your message. I have a simplified version of what I am trying to accomplish.

 

1. I have 3 controls and one indicator

2. When the Vi is run , the controls should initialize to the values in the intialize state. The next state will now be the user input state.

3. When at the user input, the user can either press the "analyze button" and the result will be displayed in the indicator. or the the stop button to stop the simulation, or

4. The user can change the values of the control, after all the controls have been changed to his desired values, he can then press "accept values" and the state goes back to the "user input".

 

Thank you for any help

Download All
0 Kudos
Message 3 of 7
(3,236 Views)
There is an example here which does exactly what you want.  Let us know if you have problems.
0 Kudos
Message 4 of 7
(3,210 Views)

Thanks for the input. I found out that the earlier post by Ravens Fan actually solves the problem. When I change my values, and click the accept values, the initialize state will be called again. The initialize state will accept the control values.

 

The only thing I did not understand is putting a wait statement on the user input state. I was under the impression that the event case itself is a waiting statement.

 

Thanks.

0 Kudos
Message 5 of 7
(3,183 Views)

I didn't realize you had any event structure going on.  Yes, the Event structure will create a pause while it waits.

 

Check you conditions for your next state.  You start with Initialize.  The initialize state is calling Initialize again.  There isn't anything there to cause it to move to the next state.  I think that should be calling User Inputs.

 

In the user inputs state/Accept Parameters event, I would think you want to call initialize, not User inputs again.

 

I would recommend mapping out what all of your states are on a piece of paper, and what are the possible transitions to other states and what would cause them.  Then it will be easier to make your code match what you want it to to.

0 Kudos
Message 6 of 7
(3,170 Views)
Thank you. All points noted
0 Kudos
Message 7 of 7
(3,155 Views)