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: 

Asynchronous Statechart input data update?

Hi all,
 
I do have a problem figuring out when an asynchronous statechart is updating its input data.
When I send an external trigger, the input data are not updated before the trigger is processed.
Weirdly enough it seems that the input data are actually updated at the next call of "Run Statechart.vi".
As work around I created a dummy trigger from my Idle state to itself for forcing that update.
Did I miss something or is there an easier way to get an update input data before a trigger is sent?
 
thanx in advance for your input,
 
Jean-Philippe
0 Kudos
Message 1 of 4
(2,442 Views)
Hi Jean-Philippe,

The behavior you are seeing is the expected behavior.

What is happening is that the statechart is sitting and waiting for the asynchronous trigger, and as such already has its input values determined for the next step it takes. After it takes that step, when you come back into the loop again, the source of the statechart inputs is re-read and these new values sit and wait for the next asynchronous step. Because of this you see this behavior where it seems like the input data is one step behind.

I think if you turn execution highlighting on in the caller of your statechart, you will see what I am talking about. The input data will flow to the Run Statechart node, and then the node will sit there and wait until the asynchronous trigger is sent. The next time in the loop new data will flow into the Run Statechart node.

There is not currently a way to pass data directly with your trigger, which is probably what you are wanting to do. You can use the workaround you described, or you might consider using a synchronous statechart if that would work with what you are doing.

You could also consider using a LabVIEW queue as one element of your statechart inputs as a way to push data into the statechart with the trigger. Basically you feed the reference to the queue into the statechart, and then use the same reference from the place you send the trigger to push some data into the queue before sending the trigger. Then your statechart can read this data out of the queue. If you want more details on this, let me know and I can find them.
0 Kudos
Message 2 of 4
(2,434 Views)
Hi Nick,
 
Thanx a lot for your help!
Obviously I didn't know that that 'one-step behind' behavior was the one to expect. 🙂
It would be nice to be able to send data with the trigger. Maybe in a future version of the Statechart Module?
I saw on the 'missile defense' example how to use a synchronous statechart with triggers in order to pass the input data before sending the trigger.
I didn't think of having a queue as input data but that's a very nice work-around idea, thanx.
 
best regards,
 
Jean-Philippe
0 Kudos
Message 3 of 4
(2,402 Views)
Glad the explanation helped. 🙂

We are always looking for ways to improve in future versions, and sending data with asynchronous triggers is definitely something we're considering.
0 Kudos
Message 4 of 4
(2,396 Views)