前页 | 后页 |
状态流建模
创建要呈现给Stateflow图的StateMachine图时,有很多选项。这些包括可以使用哪些元素和连接器,StateMachine的位置,可以在模型中定义代码的位置以及可以使用什么格式的代码。
国家机器安置
When creating a model to be generated out to a Stateflow diagram, the StateMachine diagram must be placed under a SysML Block and have a child StateMachine element, with a StateMachine diagram under that StateMachine element.
For example, in this case the Block 'Control' has a child StateMachine named 'ControlStateMachine', which has a child Statemachine diagram 'ControlStateMachine' :
Note that the Block must only contain a StateMachine diagram it should not contain other diagrams.
定义代码
There are a number of options for placing script in a StateMachine model. The key considerations for this are - what is the format of the script, and where can it be placed.
代码格式
When writing code any valid SysML code it will be translated to valid Stateflow code. The SysPhS specification defines the Modelica maths language as the 'standard' which is what Enterprise Architect accepts as code snippets in the StateMachine diagram, and translates these to the Matlab/Stateflow equivalent. For more details refer to section 10 of the OMG SysPhS specification.
代码放置
Stateflow在一个州内部并且符合UML规范,支持以下三个标准操作:
- 条目
- 出口
- 做。
在转换上,使用代码的三个主要选择是:
- 过渡卫队
- 过渡效应
- 触发。
使用块属性
For the code, the Block Properties such as constants and ports are able to be referenced within the script. In the case of the ports, the details being input into the Block are derived using the input port name and similarly values can be assigned to a variable of the same name as the output port.
For example:
笔记
The following SysML State Machine features are not available in Stateflow:
- Deep History state
- History states that have a transition going out from it (ie an initial state) - and will be used on all default entries.
- Fork/Join
- Sync
- Junction (only choice - junctions will be replaced with Choice where possible)
- Entry/Exit points
- References to other state machines. Stateflow can do child state machines but they can't be referenced again.
- Only one State Machine per SysML Block.