文章目录
1. 问题描述
在 State 中的 chart 中,放置了两个输入事件,在运行的时候报错。
-
放置事件如下:
-
Matlab 给出的错误提示:
Chart ‘Chart’ has both function call triggered and edge triggered input events. This is not allowed.
2. 问题分析
2.1 官方链接
官方给出的文档链接为:Activate a Stateflow Chart by Sending Input Events
2.2 文档值得留意的地方
- 不能同时使用
事件触发
与函数调用
作为 chart 的输入事件;
An input event can activate a Stateflow chart through a change in a control signal (an edge trigger) or a function call from a Simulink block.
To specify an edge-triggered input event, set the Trigger property to one of these options:
Rising
Falling
Either
To specify a function-call input event, set the Trigger property to Function call.
You cannot mix edge-triggered and function-call input events in the same Stateflow chart. Mixing these input events results in an error during parsing and simulation.
2.2.1 Activate a Stateflow Chart by Using Edge Triggers
- When to Use Edge-Triggered Input Events
Use an edge-triggered input event to activate a chart when your model requires regular or periodic chart execution.
- Behavior of Multiple Edge-Triggered Input Events
At any given time step, input events are checked in ascending order based on their port numbers. The chart awakens once for each valid event.
For edge-triggered input events, multiple edges can occur in the same time step, waking the chart more than once in that time step. In this situation, the events wake the chart in ascending order based on their port numbers.
2.2.2 Activate a Stateflow Chart by Using Function Calls
A function-call input event causes a Stateflow chart to execute during the current time step of simulation. With this type of input event, you must also define a function-call output event for the block that calls the Stateflow chart.
- When to Use Function-Call Input Events
Use a function-call input event to activate a chart when your model requires access to output data from the chart in the same time step as the function call.
- Behavior of Multiple Function-Call Input Events
For function-call input events, only one trigger event exists. The caller of the event explicitly calls and executes the chart. Only one function call is valid in a single time step.
2.2.3 Association of Input Events with Control Signals
When you define one or more input events in a chart, a single trigger port appears on the top side of the chart block. Multiple external Simulink blocks can trigger the input events through a vector of signals connected to the trigger port. The Port property of an input event specifies the index into the control signal vector that connects to the trigger port.
By default, Port values appear in the order that you add input events. You can change these assignments by modifying the Port property of the events. When you change the Port property for an input event, the Port values for the remaining input events automatically renumber.
2.2.4 Data Types Allowed for Input Events
For multiple input events to a trigger port, all signals must have the same data type. Using signals of different data types as input events results in an error during simulation.