set
Description
set(
sets the specified property to archElement
,property
,value
)value
for AUTOSAR architecture element
archElement
. The archElement
argument is a
component, composition, port, or connector handle returned by a previous call to
addComponent
, addComposition
,
addPort
, connect
, or
find
.
Examples
Set and List Properties of AUTOSAR Architecture Elements
In an AUTOSAR architecture model, use the set
function to:
Modify the
Name
property for two AUTOSAR composition ports.Modify the
Name
property for an AUTOSAR component port, which also renames the corresponding Simulink® implementation model port.Modify the
Kind
andName
properties for the AUTOSAR component.
Then list the model port Name
values, which reflect the port
renames.
% 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
Input Arguments
archElement
— Architecture element
handle
AUTOSAR architecture element for which to set the value of a property. The argument
is a component, composition, port, or connector handle returned by a previous call to
addComponent
, addComposition
,
addPort
, connect
, or
find
.
Example: port
property
— Element property
character vector | string scalar
Property for which to set a value, among valid properties of the AUTOSAR architecture element.
Example: 'Name'
value
— Property value
value of property
Value to set for the specified property of the specified AUTOSAR architecture element.
Example: 'NewPortName1'
Version History
Introduced in 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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)