当前位置:网站首页>Modeling specifications: naming conventions

Modeling specifications: naming conventions

2022-07-06 02:49:00 chhttty

This paper studies MAAB Naming conventions in modeling specifications , At the same time, talk about the understanding of bloggers in combination with the actual work .

1 Naming specification

Naming conventions are the first in MAAB Specification as defined in , It specifies the folder , Model , Variable , How should interfaces be named .

2 Naming convention content

2.1 The basic rule

1) In naming conventions , Modules can be 、 The characters used in the naming of signals can only be the following :

  • The case of English letters :a-z, A-Z
  • Arabic numerals :0-9
  • Underline :_

2) besides , Can not be used for naming . For example, the following points must not be allowed :

  • Chinese string cannot appear in path or module name , There may be an error parsing ;
  • No spaces 、 A carriage return 、 Special characters such as brackets , for example JMAAB(Model).slx;
  • The name must start with a letter , Cannot be numbers or underscores , for example 001_JMAABModel.slx;
  • You cannot write two underscores consecutively , for example JMAAB__Model.slx;

3) String length cannot be too long , It should be less than 63;

2.2 Model Advisor Check the item

stay Matlab 2018a Of Model Advisor in , The following items can be checked on the file 、 Check the naming specification of interfaces :

Check IDDescription
ar_0001Check file names
ar_0002Check folder names
jc_0201Check subsystem names
jc_0211Check port block names
jc_0221Check character usage in signal labels
jc_0231Check character usage in block names

These check items are located in Model Advisor In the inspector :
 Insert picture description here

2.3 Model Advisor Check examples

1) Create a new model , The modeling is as follows :
 Insert picture description here
In the model above , There are two naming mistakes :

  • 1 No. input port begins with an underscore ;
  • The output signal line begins with a number ;

These two questions can be used Model Advisor Check it out .

2) Run... Above Model Advisor Check the item , The results are as follows :
 Insert picture description here
Two of the inspection items on the left became Warning The exclamation mark of ,4 Article passed .

3) Click on one of them Warning, You can see exactly where the problem is in the model , And you can directly locate the past through hyperlinks ;
 Insert picture description here

3 Enterprise naming conventions

It's all about MAAB Basic specification entries in the document , Very easy to understand . In the actual work of the enterprise , Based on this , Develop your own naming conventions . This can facilitate the understanding and communication of engineers . The following bloggers will give examples of how the company they have been in has done .

3.1 Detailed explanation of enterprise naming norms

1) Be good at using abbreviations of names , Shrink the model name to a few characters of fixed length , Such as below ;
 Insert picture description here
In the figure , Vehicle speed control module VehicleSpeedControlModule Took four initials , Name the model VSCM.

2) For I / O interface , Information other than the meaning of the variable itself needs to be reflected ; For example, the data type is uint8 still uint16, In which module is the scope ;

For example, the speed is CAN Signal received , from CSDM Global variables output after module filtering ( use G Express Global), The physical unit is kmph( Km / h ), It can be named G_CSDM_kmph_VehSpd, Instead of directly naming it VehicleSpeed. This naming can be seen at a glance .

Variable type Physical units modular describe name
Global variables kmphCSDMVehSpdG_CSDM_kmph_VehSpd
Quantitative standard enum/GearPositionP_enum_GearPos
Macro definition enum/ReverseGearM_enum_ReverseGear
Input interface rpm/EngineSpeedGet_rpm_EngineSpeed
Output interface Nm/EngineTorqueSet_Nm_EngineTorque

In Africa Autosar In the application layer model of the architecture , Generally, the interface between models is made into global variables , The interface from the bottom layer to the application layer is Get_XXX() function , The interface from the application layer to the bottom layer is Set_XXX() function , The standard quantity or constant is done in Const Module . Based on these principles , You can formulate the naming standards of enterprises . Further more , You can also develop your own ModelAdvisor Check tools , Check whether the naming conventions in the model conform to the enterprise specifications .

3.2 Check naming conventions through scripts

MAAB Specifications can be passed Model Advisor Check , Customized naming conventions can also develop scripts by themselves , Publish to Model Advisor In the inspection item . Bloggers use a script to demonstrate how to check Constant Whether the module conforms to the standard quantity naming , Publish to Advisor The process can refer to other bloggers .

1) First , use find_system Function to search all in the model Const modular ;

%  Find Constant modular 
Const_Cell = find_system(gcs,'BlockType','Constant');

2) next , Loop through all arrays , Check by calling sub functions Constant Whether the value in the module is legal ;

%  Cycle test Constant Value in module 
for i = 1:length(Const_Cell)
    Const_Path = Const_Cell{i};
    Const_Value = get_param(Const_Path,'Value');
    if(CheckName(Const_Value))
        continue;
    else
        InvalidNameList{end+1} = Const_Path;
    end
end

3) The called sub function determines whether the initial letter is P, And whether it contains two underscores ;

function IsValidName = CheckName(Value)
if(Value(1) ~= 'P') % Whether or not to P start 
    IsValidName = false;
elseif(length(strfind(Value,'_')) ~= 2) % Whether to include two underscores 
    IsValidName = false;
else
    IsValidName = true;
end
end

Final , The whole script is as follows :

function InvalidNameList = CheckCaliName()
InvalidNameList = {};
%  Find Constant modular 
Const_Cell = find_system(gcs,'BlockType','Constant');
%  Cycle test Constant Value in module 
for i = 1:length(Const_Cell)
    Const_Path = Const_Cell{i};
    Const_Value = get_param(Const_Path,'Value');
    if(CheckName(Const_Value))
        continue;
    else
        InvalidNameList{end+1} = Const_Path;
    end
end
end
function IsValidName = CheckName(Value)
if(Value(1) ~= 'P') % Whether or not to P start 
    IsValidName = false;
elseif(length(strfind(Value,'_')) ~= 2) % Whether to include two underscores 
    IsValidName = false;
else
    IsValidName = true;
end
end

4 summary

This paper studies MAAB Naming conventions in modeling specifications , We should abide by MAAB And enterprise specifications , Name variables or signal names correctly .

>> Return to the general directory of personal blog

原网站

版权声明
本文为[chhttty]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060246342179.html