MBD (Model-Based Design 基于模型设计)在建模过程中为使图形的可读性、健壮性提高,MathWorks 咨询委员会 (MAB) 规范规定了在 Simulink® 和 Stateflow® 中建模的重要基本规则。这些建模规范的总体目的是让控制系统模型的建模者和使用方能实现简单、共同的理解。
MAB、MAAB、JMAAB区别与联系
使用MATLAB建模,会频繁听到MAB 、MAAB 、JMAAB的缩写,这些缩写均是基于模型设计(MBD)在不同阶段或区域的建模规范。
- MAB(MathWorks Advisory Board):当前通用跨行业的官方建模规范,是 MAAB 的演进与更名版本。
- MAAB(MathWorks Automotive Advisory Board):汽车行业专属的建模规范,2020 年起更名为 MAB。
- JMAAB(Japan MathWorks Automotive Advisory Board):日本区域分支,基于 MAAB/MAB 制定,不仅有Simulink规范,还补充了MATLAB规范,Simscape建模规范,适配日本车企与供应商的本地化规范。
MAAB和MAB的发布时间线
| 版本 | 发布时间 | MATLAB版本 |
|---|---|---|
| MAAB 2.0 | 2009/03 | R2009a |
| MAAB 2.1 | 2009/09 | R2009b |
| MAAB 2.2 | 2012/03 | R2012a |
| MAAB 3.0 | 2013/03 | R2013a |
| MAAB 3.1 | 2014/03 | R2014a |
| MAAB 5.0 / MAB 5.0 | 2020/03 | R2020a |
| MAB 5.1 | 2021 | R2021a |
| MAB 6.0 | 2023 | R2023a |
规范ID的字母意义
在阅读MAB建模规范时,规范ID中有ar、jc、na、db、jm、hd的前缀,这些前缀含义如下
| 前缀 | 全称/含义 | 适用版本 / 范围 | 说明 |
|---|---|---|---|
| ar | Architecture(架构) | MAAB 1.0 | 早期架构类规则的作者 / 来源标识 |
| db | Database(数据库 / 文档) | MAAB 1.0 | 早期文档 / 数据库相关规则的作者 / 来源标识 |
| jm | Japan MAAB(日本) | MAAB 1.0 | 早期日本区域贡献的规则标识 |
| hd | Hardware Design(硬件设计) | MAAB 1.0 | 早期硬件设计相关规则的作者 / 来源标识 |
| na | North America(北美) | MAAB 2.0+ / MAB | 北美 / 欧洲通用规则(NA‑MAAB) |
| jc | Japan Committee(日本委员会) | MAAB 2.0+ / JMAAB | 日本专属 / 本地化规则(J‑MAAB) |
建模规范的定位
建模规范类似于编码规范,测试端可以通过MATLAB自带的Model Advisor进行建模规范检查。
MAB 5.0和JMAAB 5.1对比
| No | MAB (Version 5.0) | JMAAB (Version 5.1) | Model Advisor Check |
|---|---|---|---|
| 1 | ar_0001: Usable characters for file names | ar_0001 | Check file names |
| 2 | ar_0002: Usable characters for folder names | ar_0002 | Check folder names |
| 3 | jc_0241: Length restriction for model file names | jc_0241 | Check length of model file name |
| 4 | jc_0242: Length restriction for folder names | jc_0242 | Check length of folder name at every level of model path |
| 5 | jc_0201: Usable characters for subsystem names | jc_0201 | Check Subsystem names |
| 6 | jc_0231: Usable characters for block names | jc_0231 | Check character usage in block names |
| 7 | jc_0211: Usable characters for Inport blocks and Outport block | jc_0211 | Check port block names |
| 8 | jc_0243: Length restriction for subsystem names | jc_0243 | Check length of subsystem names |
| 9 | jc_0247: Length restriction for block names | jc_0247 | Check length of block names |
| 10 | jc_0244: Length restriction for Inport and Outport names | jc_0244 | Check length of Inport and Outport names |
| 11 | jc_0222: Usable characters for signal and bus names | jc_0222 | Check usable characters for signal names and |
| 12 | jc_0232: Usable characters for parameter names | jc_0232 | Check usable characters for parameter names |
| 13 | jc_0245: Length restriction for signal and bus names | jc_0245 | Check length of signal and bus names |
| 14 | jc_0246: Length restriction for parameter name | jc_0246 | Check length of parameter names |
| 15 | jc_0795: Usable characters for Stateflow data names | jc_0795 | Check usable characters for Stateflow data |
| 16 | jc_0796: Length restriction for Stateflow data names | jc_0796 | Check length of Stateflow data name |
| 17 | jc_0791: Duplicate data name definitions | jc_0791 | Check duplication of Simulink data names |
| 18 | jc_0792: Unused Data | jc_0792 | Check unused data in Simulink Model |
| 19 | jc_0700: Unused data in Stateflow block | jc_0700 | Check for unused data in Stateflow Charts |
| 20 | na_0019: Restricted variable names | / | Check usage of restricted variable names |
| 21 | jc_0011: Optimization parameters for Boolean data types | jc_0011 | Check Implement logic signals as Boolean data (vs. double) |
| 22 | jc_0642: Integer rounding mode setting | jc_0642 | Check Signed Integer Division Rounding mode |
| 23 | jc_0806: Detecting incorrect calculation results | jc_0806 | Check diagnostic settings for incorrect calculation results |
| 24 | jc_0021: Model diagnostic settings | / | Check model diagnostic parameters |
| 25 | na_0004: Simulink model appearance settings | na_0004 | Check for Simulink diagrams using nonstandard display attributes |
| 26 | db_0043: Model font and font size | db_0043 | Check Model font settings |
| 27 | jm_0002: Block resizing | jm_0002 | No check |
| 28 | db_0142: Position of block names | db_0142 | Check whether block names appear below blocks |
| 29 | jc_0061: Display of block names | jc_0061 | Check the display attributes of block names |
| 30 | db_0140: Display of block parameters | db_0140 | Check for nondefault block attributes |
| 31 | jc_0603: Model description | jc_0603 | Check Model Description |
| 32 | jc_0604: Using block shadow | jc_0604 | Check if blocks are shaded in the model |
| 33 | db_0081: Unconnected signals and blocks | db_0081 | Check for unconnected signal lines and blocks |
| 34 | db_0032: Signal line connections | db_0032 | Check signal line connections |
| 35 | db_0141: Signal flow in Simulink models | db_0141 | Check signal flow in model Check position of signal labels |
| 36 | jc_0110: Direction of block | jc_0110 | Check block orientation |
| 37 | jc_0171: Clarification of connections between structural subsystems | jc_0171 | Check connections between structural subsystems |
| 38 | jc_0602: Consistency in model element names | jc_0602 | Check for consistency in model element names |
| 39 | jc_0281: Trigger signal names | jc_0281 | Check trigger signal names |
| 40 | db_0143: Usable block types in model hierarchy | db_0143 | Check for mixing basic blocks and subsystems |
| 41 | db_0144: Use of subsystems | db_0144 | Not checkable |
| 42 | jc_0653: Delay block layout in feedback loops | jc_0653 | Check for avoiding algebraic loops between subsystems |
| 43 | hd_0001: Prohibited Simulink sinks | / | Check for prohibited sink blocks |
| 44 | na_0010: Usage of vector and bus signals | na_0010 | Check usage of vector and bus signals |
| 45 | jc_0008: Definition of signal names | jc_0008 | Check signal line labels |
| 46 | jc_0009: Signal name propagation | jc_0009 | Check for propagated signal labels |
| 47 | db_0097: Position of labels for signals and buses | db_0097 | Check signal flow in model Check position of signal labels |
| 48 | na_0008: Display of labels on signals | / | Check signal line labels |
| 49 | na_0009: Entry versus propagation of signal labels | / | Check for propagated signal labels |
| 50 | db_0110: Block parameters | db_0110 | Check usage of tunable parameters in blocks |
| 51 | db_0112: Usage of index | db_0112 | Check Indexing Mode |
| 52 | jc_0645: Parameter definition for calibration | jc_0645 | Check if tunable block parameters are defined as named constants |
| 53 | jc_0641: Sample time setting | jc_0641 | Check for sample time setting |
| 54 | jc_0643: Fixed-point setting | jc_0643 | Check usage of fixed-point data type with non-zero bias |
| 55 | jc_0644: Type setting | jc_0644 | Check type setting by data objects |
| 56 | db_0146: Block layout in conditional subsystems | db_0146 | Check position of conditional blocks and iterator blocks |
| 57 | jc_0640: Initial value settings for Outport blocks in conditional subsystems | jc_0640 | Check undefined initial output for conditional subsystems |
| 58 | jc_0659: Usage restrictions of signal lines input to Merge blocks | jc_0659 | Check usage of Merge block |
| 59 | na_0003: Usage of If blocks | na_0003 | Check logical expressions in If blocks |
| 60 | jc_0656: Usage of Conditional Control blocks | jc_0656 | Check default/else case in Switch Case blocks and If blocks |
| 61 | jc_0657: Retention of output value based on conditional control flow blocks and Merge blocks | jc_0657 | Not checkable |
| 62 | na_0002: Appropriate usage of basic logical and numerical operations | na_0002 | Check fundamental logical and numerical operations |
| 63 | jc_0121: Usage of add and subtraction blocks | jc_0121 | Check usage of Sum blocks |
| 64 | jc_0610: Operator order for multiplication and division block | jc_0610 | Check operator order of Product blocks |
| 65 | jc_0611: Input sign for multiplication and division blocks | jc_0611 | Check signs of input signals in product blocks |
| 66 | jc_0794: Division in Simulink | jc_0794 | Check for division by zero in Simulink |
| 67 | jc_0805: Numerical operation block inputs | jc_0805 | No check |
| 68 | jc_0622: Usage of Fcn blocks | jc_0622 | Check for parentheses in Fcn block expressions |
| 69 | jc_0621: Usage of Logical Operator blocks | jc_0621 | Check icon shape of Logical Operator blocks |
| 70 | jc_0131: Usage of Relational Operator blocks | jc_0131 | Check usage of Relational Operator blocks |
| 71 | jc_0800: Comparing floating-point types in Simulink | jc_0800 | Comparing floating point types in Simulink |
| 72 | jc_0626: Usage of Lookup Table blocks | jc_0626 | Check usage of Lookup Tables |
| 73 | jc_0623: Usage of continuous-time Delay blocks and discrete-time Delay blocks | jc_0623 | Check usage of Memory and Unit Delay blocks |
| 74 | jc_0624: Usage of Tapped Delay blocks/Delay blocks | jc_0624 | Check for cascaded Unit Delay blocks |
| 75 | jc_0627: Usage of Discrete-Time Integrator blocks | jc_0627 | Check usage of Discrete-Time Integrator block |
| 76 | jc_0628: Usage of Saturation blocks | jc_0628 | Check usage of the Saturation blocks |
| 77 | jc_0651: Implementing a type conversion | jc_0651 | Check output data type of operation blocks |
| 78 | db_0042: Usage of Inport and Outport blocks | db_0042 | Check position of Inport and Outport blocks |
| 79 | jc_0081: Inport and Outport block icon display | jc_0081 | Check display for port blocks |
| 80 | na_0011: Scope of Goto and From blocks | na_0011 | Check scope of From and Goto blocks |
| 81 | jc_0161: Definition of Data Store Memory blocks | jc_0161 | Check for usage of Data Store Memory blocks |
| 82 | jc_0141: Usage of the Switch blocks | jc_0141 | Check usage of Switch blocks |
| 83 | jc_0650: Block input/output data type with switching function | jc_0650 | Check input and output datatype for Switch blocks |
| 84 | jc_0630: Usage of Multiport Switch blocks | jc_0630 | Check settings for data ports in Multiport Switch blocks |
| 85 | na_0020: Number of inputs to variant subsystems | na_0020 | Check for missing ports in Variant Subsystems |
| 86 | na_0036: Default variant | na_0036 | Check use of default variants |
| 87 | na_0037: Use of single variable for variant condition | na_0037 | Check use of single variable variant conditionals |
| 88 | db_0122: Stateflow and Simulink interface signals and parameters | db_0122 | Check for Strong Data Typing with Simulink I/O |
| 89 | db_0123: Stateflow port names | / | Check for names of Stateflow ports and associated signals |
| 90 | db_0125: Stateflow local data | db_0125 | Check definition of Stateflow data |
| 91 | db_0126: Defining Stateflow events | db_0126 | Check definition of Stateflow events |
| 92 | jc_0701: Usable number for first index | jc_0701 | Check usable number for first index |
| 93 | jc_0712: Execution timing for default transition path | jc_0712 | Check execution timing for default transition path |
| 94 | jc_0722: Local data definition in parallel states | jc_0722 | Check scope of data in parallel states |
| 95 | jc_0797: Unconnected transitions / states / connective junctions | jc_0797 | Check for unconnected objects in |
| 96 | db_0137: States in state machines | db_0137 | Check for state in state machines |
| 97 | jc_0721: Usage of parallel states | jc_0721 | Check usage of parallel states |
| 98 | db_0129: Stateflow transition appearance | db_0129 | Check for Stateflow transition appearance |
| 99 | jc_0531: Default transition | jc_0531 | Check default transition placement in Stateflow charts |
| 100 | jc_0723: Prohibited direct transition from external state to child state | jc_0723 | Check usage of transitions to external states |
| 101 | jc_0751: Backtracking prevention in state transition | jc_0751 | Check for unexpected backtracking in state transitions |
| 102 | jc_0760: Starting point of internal transition | jc_0760 | Check starting point of internal transition in Stateflow |
| 103 | jc_0763: Usage of multiple internal transitions | jc_0763 | Check usage of internal transitions in Stateflow states |
| 104 | jc_0762: Prohibition of state action and flow chart combination | jc_0762 | Check prohibited combination of state action and flow chart |
| 105 | db_0132: Transitions in flow charts | db_0132 | Check transitions in Stateflow Flow charts |
| 106 | jc_0773: Unconditional transition of a flow chart | jc_0773 | Check usage of unconditional transitions in flow charts |
| 107 | jc_0775: Terminating junctions in flow charts | jc_0775 | Check terminal junctions in Stateflow |
| 108 | jc_0738: Usage of Stateflow comments | jc_0738 | Check usage of Stateflow comments |
| 109 | jc_0790: Action language of Chart block | jc_0790 | Check Stateflow chart action language |
| 110 | jc_0702: Use of named Stateflow parameters and constants | jc_0702 | Check usage of numeric literals in Stateflow |
| 111 | jm_0011: Pointers in Stateflow | jm_0011 | Check for pointers in Stateflow charts |
| 112 | jc_0491: Reuse of Stateflow data | jc_0491 | Not checkable |
| 113 | jm_0012: Usage restrictions of events and broadcasting events | jm_0012 | Check for usage of events and broadcasting events in Stateflow charts |
| 114 | jc_0733: Order of state action types | jc_0733 | Check order of state action types |
| 115 | jc_0734: Number of state action types | jc_0734 | Check repetition of Action types |
| 116 | jc_0740: Limitation on use of exit state action | jc_0740 | Check if state action type 'exit' is used in the model |
| 117 | jc_0741: Timing to update data used in state chart transition conditions | jc_0741 | Check updates to variables |
| 118 | jc_0772: Execution order and transition conditions of transition lines | jc_0772 | Check usage of transition conditions in Stateflow transitions |
| 119 | jc_0753: Condition actions and transition actions in Stateflow | jc_0753 | Check condition actions and transition actions in Stateflow |
| 120 | jc_0711: Division in Stateflow | jc_0711 | Not checkable |
| 121 | db_0127: Limitation on MATLAB commands in Stateflow blocks | db_0127 | Check for MATLAB expressions in Stateflow charts |
| 122 | jc_0481: Use of hard equality comparisons for floating point numbers in Stateflow | jc_0481 | Check usage of floating-point expressions in Stateflow charts |
| 123 | na_0001: Standard usage of Stateflow operators | na_0001 | Check Stateflow operators |
| 124 | jc_0655: Prohibition of logical value comparison in Stateflow | jc_0655 | Check prohibited comparison operation of logical type signals |
| 125 | jc_0451: Use of unary minus on unsigned integers | jc_0451 | Check usage of unary minus operations in Stateflow charts |
| 126 | jc_0802: Prohibited use of implicit type casting in Stateflow | jc_0802 | Check for implicit type casting in Stateflow |
| 127 | jc_0803: Passing values to library functions | jc_0803 | Not checkable |
| 128 | jc_0732: Distinction between state names, data names, and event names | jc_0732 | Check uniqueness of Stateflow State and Data names |
| 129 | jc_0730: Unique state name in Stateflow blocks | jc_0730 | Check uniqueness of State names |
| 130 | jc_0731: State name format | jc_0731 | Check usage of State names |
| 131 | jc_0501: Format of entries in a State block | jc_0501 | Check entry formatting in State blocks in Stateflow charts |
| 132 | jc_0736: Uniform indentations in Stateflow blocks | jc_0736 | Check indentation of code in Stateflow states |
| 133 | jc_0739: Describing text inside states | jc_0739 | Check for usage of text inside states |
| 134 | jc_0770: Position of transition label | jc_0770 | Check placement of Label String in Transitions |
| 135 | jc_0771: Comment position in transition labels | jc_0771 | Check position of comments in transition labels |
| 136 | jc_0752: Condition action in transition label | jc_0752 | Check usage of parentheses in Stateflow transitions |
| 137 | jc_0774: Comments for through transition | jc_0774 | Check for comments in unconditional transitions |
| 138 | jc_0511: Return values from a graphical function | jc_0511 | Check return value assignments in Stateflow |
| 139 | jc_0804: Prohibited use of recursive calls with graphical functions | jc_0804 | Check usage of graphical functions in Stateflow |
| 140 | na_0042: Usage of Simulink functions | na_0042 | Check usage of Simulink function in Stateflow |
| 141 | na_0039: Limitation on Simulink functions in Chart blocks | na_0039 | Check use of Simulink in Stateflow |
| 142 | na_0018: Number of nested if/else and case statement | / | Check nested conditions in MATLAB Functions |
| 143 | na_0025: MATLAB Function header | / | No check |
| 144 | na_0024: Shared data in MATLAB functions | na_0024 | Check MATLAB code for global variables |
| 145 | na_0031: Definition of default enumerated value | na_0031 | Check usage of enumerated values |
| 146 | na_0034: MATLAB Function block input/output settings | na_0034 | Check input and output settings of MATLAB Functions |
| 147 | na_0016: Source lines of MATLAB Functions | / | Check lines of code in MATLAB Functions |
| 148 | na_0017: Number of called function levels | / | Check the number of function calls in MATLAB Function blocks |
| 149 | na_0021: Strings in MATLAB functions | na_0021 | Check usage of character vector inside MATLAB Function |
| 150 | na_0022: Recommended patterns for Switch/Case statements | / | Check usage of recommended patterns for Switch/Case statements |
| 151 | jc_0801: Prohibited use of the /* and */ comment symbols | jc_0801 | Check for use of C-style comment symbols |