Main Content

set

Set property of AUTOSAR architecture element

Description

example

set(archElement,property,value) sets the specified property to 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

collapse all

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 and Name 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

collapse all

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 for which to set a value, among valid properties of the AUTOSAR architecture element.

Example: 'Name'

Value to set for the specified property of the specified AUTOSAR architecture element.

Example: 'NewPortName1'

Introduced in R2020a