Control strategy model modeling specification (STATEFLOW)


6.1. Basic behavior and status

1. There are at least two states in the Stateflow module, and there must be a default state. Each state cannot have only one sub-state.
2. Stateflow state chart can not be nested more than 3 levels.
3. The number of sub-states in a single state view is controlled within 6 and the maximum is not more than 9.
4. The logic in Stateflow does not use MATLAB functions, instructions, and operators.
5. The logic type signal prohibits the comparison operation. (Use if (logical type signal))
6. Logic operations cannot be used for two Boolean values. ([True && false])
7. Boolean signals cannot be compared with the numbers 0, 1, or the logical values ​​true or false.
8. Different types of data are forbidden to perform comparison operations. If necessary, the display type conversion operation must be performed first.
9. It is forbidden to perform strict == or != judgment operations on two floating-point values.
10. It is forbidden to perform negative operation [-] on unsigned numbers.
11. If you need to flip the logic type signal, you should use the Boolean operation NOT.
12. Inversion sign: ~ is used to invert bit by bit operation,! Used for logic inversion operation.

6.2. Event and variable settings

1. The same variable should not have multiple definitions within the scope of a single Stateflow.
2. Unused events and variables are not allowed to appear in the Stateflow block.
3. Partial data with the same name is not allowed in parallel blocks or state machines.
4. In Stateflow, except for 0 for initializing variables and 1 for auto-increment and auto-decrement operations, constants and variables are not allowed to use values ​​directly.
5. The event must be defined at a chart or lower level, and event interaction between charts is not allowed.
6. Except for triggering the calling function to call the subsystem, events should not be used as driving conditions for state transitions.
7. For readability, each event en:, du:, ex: should start on its own line; the specific content of each event should also start on its own line.

6.3. Label

The input and output port names of Stateflow should be consistent with the corresponding signal names.

6.4. Conditions and Conditional Actions

1. Conditional expressions can only use expressions whose return value is Boolean, and integer values ​​are not allowed.
2. Action type (entry(en), during(du), exit(ex), en, du:, du, ex:, en, ex:, en, du, ex:) cannot be repeated and combined The description of the action (en, du:, du, ex:, en, ex:, en, du, ex:) can only be placed at the top or bottom of the action sequence.
3. If the action sequence can be implemented in a condition action or transition action and the Entry action of the transition target state, do not use the Exit action of the state to implement it.
4. It is best not to use the transfer action, the conditional action is preferred.
5. The update operation of variables used for state transition judgment conditions is not allowed to be placed in the during action.

6.5. Internal transfer and state transfer

1. The transfer connection in Stateflow is not allowed to cross or overlap each other, and it is forbidden to pass through any state, node or text box. It can be transferred to an internal state, and the transfer label is connected to the corresponding transfer.
2. Stateflow transfer should follow: the conditions are marked in the horizontal direction, and the actions are marked in the vertical direction.
3. The Stateflow default transfer link should be placed at the top of the state, and the termination state of the default transfer should be at the highest position in the state of the same level.
4. Stateflow's default transition symbol should not exceed the boundary of the state.
5. Stateflow state chart: multiple internal transition branches are not allowed in a single state.
6. The transition label within Stateflow must start from the left boundary inside the state.

6.6. Flow chart

The SF state diagram or flowchart should reasonably avoid the phenomenon of "backtracking".
In order to facilitate data flow and code generation, the return value of the flowchart can only be placed in a certain position in the chart and cannot appear multiple times.


6.7. Function blocks and others

The SF state diagram should be constructed using C language, and the C-bit operation shall be enabled to
prohibit the Simulink model containing the SF state diagram as a subsystem of the higher-level SF state machine.

Guess you like

Origin blog.csdn.net/lm393485/article/details/88894310