Main Content

at

Execute chart at event broadcast or specified time

Description

example

at(n,E)returnstrueif the eventEhas occurred exactlyntimes since the associated state became active. Otherwise, the operator returnsfalse.

example

at(n,tick)returnstrueif the chart has woken up exactlyntimes since the associated state became active. Otherwise, the operator returnsfalse.

The implicit eventtickis not supported when a Stateflow®chart in a Simulink®model has input events.

example

at(n,sec)returnstrueif exactlynseconds have elapsed since the associated state became active. Otherwise, the operator returnsfalse.

In standalone charts in MATLAB®, specifynwith a value greater than or equal to0.001. The operator creates a MATLABtimerobject that generates an implicit event to wake up the chart. MATLABtimerobjects are limited to 1 millisecond precision. For more information, seeEvents in Standalone Charts.

  • Thetimerobject is created when the chart finishes executing theentryactions of the associated state and its substates. If you specifynas an expression whose value changes during chart execution, the chart does not adjust the temporal delay of thetimerobject.

  • Thetimerobject starts running at the end of the chart step when the associated state becomes active. This step can include the execution of other parallel states in the chart.

  • If the chart is processing another operation when it receives the implicit event from thetimerobject, the chart queues the event. When the current step is completed, the chart processes the event.

  • If the state associated with the temporal logic operator becomes inactive before the chart processes the implicit event, the event does not wake up the chart.

Note

Usingatas an absolute-time temporal logic operator is supported only in standalone charts in MATLAB. For charts in Simulink models, use theafteroperator instead. For more information, seeDo Not Use at for Absolute-Time Temporal Logic in Charts in Simulink Models.

Examples

expand all

Display a status message when the chart processes the third broadcast of the eventEafter the state became active.

on at(3,E): disp("ON");

Stateflow chart that uses the at operator in a state.

Transition out of the associated state when the chart processes the fifth broadcast of the eventEafter the state became active.

at(5,E)

Stateflow chart that uses the at operator in a transition.

Transition out of the associated state if the state has been active for exactly five broadcasts of the eventE.

In charts in a Simulink model, enter:

[at(5,E)]

Stateflow chart that uses the at operator in a transition.

Conditional notation for temporal logic operators is not supported in standalone charts in MATLAB.

Transition out of the associated state when the chart wakes up for the seventh time since the state became active, but only if the variabletempis greater than 98.6.

at(7,tick)[temp > 98.6]

Stateflow chart that uses the at operator in a transition.

Set thetempvariable toHIGHif the state has been active for exactly 12.3 seconds.

In standalone charts in MATLAB, enter:

on at(12.3,sec): temp = HIGH;

Stateflow chart that uses the at operator in a state.

Usingeveryas an absolute-time temporal logic operator is not supported in charts in Simulink models.

Tips

  • You can use quotation marks to enclose the keywords'tick'and'sec'. For example,at(5,'tick')是等效toat(5,tick).

  • Stateflow图重置计数器使用的atoperator each time the associated state reactivates.

  • Standalone charts in MATLAB define absolute-time temporal logic in terms of wall-clock time, which is limited to 1 millisecond precision.

Version History

Introduced in R2014b