Main Content

find

Find AUTOSAR architecture elements

Since R2020a

Description

archElements = find(archCCM,category) searches AUTOSAR component, composition, or architecture model archCCM for architecture elements that match the specified category. The archElements output argument returns handles for the architecture elements found. Valid values for category are Component, Composition, Port, or Connector. The archCCM argument is a component, composition, or architecture model handle returned by a previous call to addComponent, addComposition, autosar.arch.createModel, or autosar.arch.loadModel. The default scope of find is the top level of the specified composition or architecture model, not all levels of the model hierarchy.

example

archElements = find(archCCM,category,'AllLevels',value) allows you to extend the search for AUTOSAR architecture elements to all levels of an AUTOSAR composition or architecture model hierarchy. To search all levels, specify value as true.

archElements = find(archCCM,category,property,value) specifies a constraining value on a property of the specified category of elements, narrowing the search.

Examples

collapse all

In AUTOSAR architecture model myArchModel:

  • Find components that are located only in the architecture model top level.

  • Find components located in all levels of the model hierarchy.

  • Find composition block ports and list their Kind and Name values.

% Create AUTOSAR architecture model
modelName = 'myArchModel';
archModel = autosar.arch.createModel(modelName);

% Add a composition
composition = addComposition(archModel,'Sensors');

% Add 2 components inside Sensors composition
names = {'PedalSnsr','ThrottleSnsr'};
sensorSWCs = addComponent(composition,names,'Kind','SensorActuator');
layout(composition); % Auto-arrange layout

% Add components at architecture model top level
addComponent(archModel,'Controller1');
actuator = addComponent(archModel,'Actuator');
set(actuator,'Kind','SensorActuator');

% Add architecture ports
addPort(archModel,'Receiver',{'TPS_Hw','APP_Hw'});
addPort(archModel,'Sender','ThrCmd_Hw');

% 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');
addPort(actuator,'Receiver','ThrCmd_Perc');
addPort(actuator,'Sender','ThrCmd_Hw');

% At top level, connect composition and components based on matching port names
connect(archModel,composition,controller);
connect(archModel,controller,actuator);

% Connect specified arch root ports to specified composition and component ports
connect(archModel,archModel.Ports(1),composition.Ports(1));
% Use find to construct port specifications
connect(archModel,...
    find(archModel,'Port','Name','APP_Hw'),...
    find(composition,'Port','Name','APP_Hw'));
connect(archModel,actuator.Ports(2),archModel.Ports(3));

layout(archModel);  % Auto-arrange layout

% Find components in architecture model top level only
components_in_arch_top_level = find(archModel,'Component')
% Find components in all hierarchy
components_in_all_hierarchy = find(archModel,'Component','AllLevels',true)
% Find ports for composition block only
composition_ports = find(composition,'Port')

% List Kind and Name property values for composition ports 
for ii=1:length(composition_ports)
    Port = composition_ports(ii);
    portName = get(Port,'Name');
    portKind = get(Port,'Kind');
    fprintf('%s port %s\n',portKind,portName);
end
components_in_arch_top_level = 
  2×1 Component array with properties:
    Name
    Kind
    Ports
    ReferenceName
    Parent
    SimulinkHandle

components_in_all_hierarchy = 
  4×1 Component array with properties:
    Name
    Kind
    Ports
    ReferenceName
    Parent
    SimulinkHandle

composition_ports = 
  4×1 CompPort array with properties:
    Kind
    Connected
    Name
    Parent
    SimulinkHandle

Receiver port TPS_Hw
Receiver port APP_Hw
Sender port TPS_Perc
Sender port APP_Perc

Input Arguments

collapse all

AUTOSAR component, composition, or architecture model in which to search for specified architecture elements. The argument is a component, composition, or architecture model handle returned by a previous call to addComponent, addComposition, autosar.arch.createModel, or autosar.arch.loadModel.

Example: archModel

Type of AUTOSAR architecture element to find. Valid categories are Component, Composition, Port, or Connector.

Example: 'Component'

Specify true to search all levels of an AUTOSAR composition or architecture model hierarchy for the specified architecture elements. The default scope of find is the top level of the specified composition or architecture model, not all levels of the model hierarchy.

Example: 'AllLevels',true

Valid property of the specified category of architecture elements, and a value to match for that property in the search.

Example: 'Name','APP_Hw'

Output Arguments

collapse all

Returns one or more handles for the architecture elements found.

Version History

Introduced in R2020a