LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

statechart state execution

When using a statechart, will a state finish its entry action if a trigger is sent that is a vaild transisiton out of the state?  Or will the exectution of the action stop midstate and transition to the state dictated by the trigger?  Attached is a simple statechart that I am using to understand how they work.  I placed a 1000 ms wait timer in the entry action of the calculate state.  My intent was to have the boolean output true for 1 s while in the calculate state.  However, it doesn't seem to be working correctly.

Thanks
0 Kudos
Message 1 of 7
(3,212 Views)
Hi martym,

Your attachment is missing.
0 Kudos
Message 2 of 7
(3,200 Views)
Hi Martym,

Yes, the state will finish its entry action. We will not even consider the next transition(s) to take for the next trigger until all current transitions and resulting entry actions have completed. If you attach your file we can take a look and see what's causing your unexpected behavior.
0 Kudos
Message 3 of 7
(3,197 Views)
Sorry about that!
Download All
0 Kudos
Message 4 of 7
(3,196 Views)
Anyone trying to open the files, you will want to rename the statechart to Statechart 2.lvsc before opening the top level1.vi

Martym, what is happening is that the delay in your entry action happens within the run statechart node, which is before the outputs indicator in top level1.vi is updated. They are updated to have Calculating = TRUE, but then the statechart quickly takes its next step and leaves the calculating state and sets Calculating=FALSE, and this value flows to the indicator after this quick step.

I think for the behavior you are looking for, you would have the delay in an exit action of the calculating state or in the transition action for going from calculating to wait for input. Then you would take a step and enter calculating, Calculating would be set to TRUE, the value would flow out to the indicator in top level1.vi; then the next step of the statechart would have a 1 second delay before it could set Calculating = FALSE and this value could flow to the indicator in top level1.vi

Hope that helps.
0 Kudos
Message 5 of 7
(3,192 Views)
Thanks for your help.  I changed the updating of the "calculating" indicator to the entry and exit action of the calc. state, with the timing in the exit action.  Does this imply that it is poor practice to update an indicator during a transition?  Attached is Rev 2!

Download All
0 Kudos
Message 6 of 7
(3,172 Views)
You can't actually update the indicator during a transition. The indicator lives in top level1.vi, and has data flow to it from the run statechart node. What you are doing is changing the data that flows out of the run statechart node, and the indicator reflects this.

Wording aside, it isn't necessarily poor practice to change output values and have delays within the statechart so that an indicator connected to the run statechart node shows the changed value for a certain period of time; it depends on what you are trying to get your statechart to do. If it is just driving a UI, it may be ok.
0 Kudos
Message 7 of 7
(3,149 Views)