get
获取 AUTOSAR 架构元素的属性
说明
返回 AUTOSAR 架构元素 pValue = get(archElement,property)archElement 的指定属性的当前值 pValue。archElement 参量是由先前调用 addComponent、addComposition、addPort、connect 或 find 返回的组件、组合、端口或连接器句柄。
示例
在 AUTOSAR 架构模型中,查找位于模型层次结构所有层级中的端口。获取并列出其 Kind 和 Name 属性值。
% Create AUTOSAR architecture model modelName = 'myArchModel'; archModel = autosar.arch.createModel(modelName); % Add composition and component at architecture model top level composition = addComposition(archModel,'Sensors'); addComponent(archModel,'Controller1'); % Add composition ports addPort(composition,'Receiver',{'TPS_Hw','APP_Hw'}); addPort(composition,'Sender',{'TPS_Perc','APP_Perc'}); % Add component ports controller = find(archModel,'Component','Name','Controller1'); addPort(controller,'Receiver',{'TPS_Perc','APP_Perc'}); addPort(controller,'Sender','ThrCmd_Perc'); % Connect composition and component based on matching port names connect(archModel,composition,controller); % Create implementation model for component createModel(controller); layout(archModel); % Auto-arrange layout % Set properties set(composition.Ports(1),'Name','NewPortName1'); % Rename 2 composition ports set(composition.Ports(3),'Name','NewPortName2'); set(find(controller,'Port','Name','TPS_Perc'),... 'Name','NewPortName3'); % Rename port for Controller1 component & implementation set(controller,'Kind','ServiceProxy'); % Component type for Controller1 component set(controller,'Name','Instance1'); % Name for Controller1 component % Find ports in architecture model hierarchy ports_in_hierarchy = find(archModel,'Port','AllLevels',true) % List Kind and Name property values for each port for ii=1:length(ports_in_hierarchy) port = ports_in_hierarchy(ii); portName = get(port,'Name'); portKind = get(port,'Kind'); fprintf('%s port %s\n',portKind,portName); end
ports_in_hierarchy =
7×1 CompPort array with properties:
Kind
Connected
Name
Parent
SimulinkHandle
Receiver port NewPortName1
Receiver port APP_Hw
Sender port NewPortName2
Sender port APP_Perc
Sender port ThrCmd_Perc
Receiver port NewPortName3
Receiver port APP_Perc输入参数
要为其返回属性当前值的 AUTOSAR 架构元素。该参量是由先前调用 addComponent、addComposition、addPort、connect 或 find 返回的组件、组合、端口或连接器句柄。
示例: port
要为其返回值的属性,属于 AUTOSAR 架构元素的有效属性之一。
示例: 'Name'
输出参量
返回指定 AUTOSAR 架构元素的指定属性的值。
版本历史记录
在 R2020a 中推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)