Main Content

systemcomposer.profile.profile

Description

A轮廓对象代表系统Composer™模型的配置文件。

Creation

Create a profile.

profile = systemcomposer.profile.Profile.createProfile(“ profilename”);

Properties

expand all

Name of profile, specified as a character vector. This property must be a valid MATLAB®标识符。

Data Types:char

Descriptive name of profile, specified as a character vector. This property can contain spaces and special characters, but no new lines.

Data Types:char

描述个人资料的文字, specified as a multi-line character vector.

Data Types:char

Stereotypes defined in profile, specified as an array ofsystemcomposer.profile.Stereotypeobjects.

Data Types:char

Object Functions

创建个人资料 Create profile
addStereotype 将刻板​​印象添加到个人资料
removeStereotype 从个人资料中删除刻板印象
getStereotype Find stereotype in profile by name
getDefaultStereotype 获取个人资料的默认刻板印象
setDefaultStereotype Set default stereotype for profile
寻找 通过名称查找个人资料
打开 开放个人资料
load 文件中的加载配置文件
节省 将配置文件另存为文件
close 关profile
关闭所有 关all open profiles
destroy Remove model element

Examples

全部收缩

Build an architecture model programmatically using System Composer™.

构建模型

To build a model, add a data dictionary with data interfaces, data elements, and value types, then add components, ports, and connections. Assign an owned interface to a port. After the model is built, you can create custom views to focus on specific considerations. You can also query the model to collect different model elements according to criteria you specify.

Add Components, Ports, Connections, and Interfaces

创建模型并提取其体系结构。

model = systemcomposer.createModel("mobileRobotAPI");arch = model.Architecture;

Create an interface data dictionary and add a data interface. Add a data element to the data interface. Add a value type to the interface data dictionary. Assign the type of the data element to the value type. Link the data dictionary to the model.

dictionary = systemcomposer.createDictionary("SensorInterfaces.sldd");接口= dictionary.addinterface("GPSInterface");元素= interface.addelement(“信号强度”);valueType = dictionary.Addvaluetype("SignalStrengthType",“单位”,'D b','Description',“ GPS信号强度”);element.setType (valueType);linkDictionary(model,"SensorInterfaces.sldd");

Save the changes to the interface data dictionary.

字典

查看接口编辑器中的接口。

添加组件,端口和连接。将数据接口设置为端口,您将稍后连接。

componentSensor = addComponent(拱门,'Sensor');sensorPorts = addPort(componentSensor.Architecture,{'MotionData','sensordata'},{'在','out'});sensorPorts(2).setInterface(interface) componentPlanning = addComponent(arch,'Planning');planningports = addport(componentplanning.architecture,{'命令','SensorData1',“运动仪”},{'在','在','out'});planningports(2).setInterface(接口)componentMotion = AddComponent(Arch,,'运动');MotionPorts = AddPort(ComponentMotion.Architecture,{“运动仪”,'MotionData'},{'在','out'});

Create an owned interface on the'MotionData'port. Add an owned data element under the owned data interface. Assign the data element "Rotation"至a value type with units set todegrees.

ownedinterface = MotionPorts(2).createInterface(“ datainterface”);ownedElement = ownedInterface.addElement("Rotation");subInterface = ownedElement.createOwnedType(“单位”,'degrees');

查看接口编辑器中的接口。选择the'MotionData'port on the运动零件。在接口编辑器中,从字典视图端口接口视图.

Connect components with an interface rule and the default name rule. The interface rule connects ports on components that share the same interface. By default, the name rule connects ports on components that share the same name.

c_sensorData = connect(arch,componentSensor,componentPlanning,'Rule',"interfaces");c_motionData = connect(arch,componentMotion,componentSensor); c_motionCommand = connect(arch,componentPlanning,componentMotion);

Add and Connect Architecture Port

Add an architecture port on the architecture.

Archport = Addport(Arch,“命令”,"in");

Theconnect命令需要一个组件端口作为参数。获取组件端口,然后连接。

compport = getport(componentplanning,“命令”);c_Command = connect(archPort,compPort);

Save the model.

model.save

打开模型。

systemcomposer.openModel("mobileRobotAPI");

Arrange the layout by pressıngCtrl + Shift +一个or using this command.

金宝appsimulink.blockdiagram.arangesystem('mobileRobotAPI');

Create and Apply Profile with Stereotypes

配置文件是可以应用于任何模型的XML文件。您可以将带有属性的刻板印象添加到配置文件中,然后用特定值填充属性。除了系统作曲家的内置分析功能外,刻板印象还可以帮助您优化系统的性能,成本和可靠性。

Create Profile and Add Stereotypes

Create a profile.

profile = systemcomposer.createProfile(“通用”);

Create a stereotype that applies to all element types.

ElemStype = Addstereotype(配置文件,"projectElement");

Create stereotypes for different types of components. You can select these types are based on your design needs.

pCompSType = addStereotype(profile,“物理组合”,'AppliesTo',“零件”);scompstype = addstereotype(配置文件,"softwareComponent",'AppliesTo',“零件”);

为连接创建刻板印象。

sConnSType = addStereotype(profile,"standardConn",'AppliesTo',“连接器”);

Add Properties

将属性添加到刻板印象中。您可以使用属性来捕获模型元素的元数据并分析非功能性要求。这些属性被添加到在导入配置文件的任何模型中,将刻板印象应用到的所有元素中添加到了。

AddProperty(ElemStype,'ID','Type','uint8');AddProperty(ElemStype,'Description','Type','string');addProperty(pCompSType,'Cost','Type','双倍的',“单位”,'美元');addProperty(pCompSType,'重量','Type','双倍的',“单位”,'g');addProperty(sCompSType,'develCost','Type','双倍的',“单位”,'美元');addProperty(sCompSType,'develTime','Type','双倍的',“单位”,“小时”);AddProperty(sconnstype,'unitCost','Type','双倍的',“单位”,'美元');AddProperty(sconnstype,'unitWeight','Type','双倍的',“单位”,'g');AddProperty(sconnstype,'length','Type','双倍的',“单位”,“米”);

Save Profile

profile.save;

Apply Profile to Model

Apply the profile to the model.

applyProfile(model,“通用”);

将刻板​​印象应用于组件。有些组件是物理组件,而另一些则是软件组件。

applyStereotype(componentPlanning,"GeneralProfile.softwareComponent")applystereotype(compententSensor,"GeneralProfile.physicalComponent")applystereotype(componentMotion,"GeneralProfile.physicalComponent")

Apply the connector stereotype to all connections.

batchapplystereotype(Arch,'连接器',“ GeneralProfile.StandardConn”);

Apply the general element stereotype to all connectors and ports.

batchapplystereotype(Arch,'Component',"GeneralProfile.projectElement");batchapplystereotype(Arch,'连接器',"GeneralProfile.projectElement");

Set properties for each component.

setProperty(componentsensor,'GeneralProfile.projectElement.ID','001');setProperty(componentsensor,'GeneralProfile.Projectelement.Description',''“所有传感器的中央单元”'');setProperty(componentsensor,'general -profile.physicalcomponent.cost','200');setProperty(componentsensor,'general -profile.physicalcomponent.ueight','450');setProperty(componentPlanning,'GeneralProfile.projectElement.ID','002');setProperty(componentPlanning,'GeneralProfile.Projectelement.Description','''Planning computer''');setProperty(componentPlanning,'GeneralProfile.softwareComponent.develCost','20000');setProperty(componentPlanning,'GeneralProfile.softwareComponent.develTime','300');setProperty(componentMotion,'GeneralProfile.projectElement.ID','003');setProperty(componentMotion,'GeneralProfile.Projectelement.Description','''电机和电动机控制器'');setProperty(componentMotion,'general -profile.physicalcomponent.cost','4500');setProperty(componentMotion,'general -profile.physicalcomponent.ueight','2500');

Set the properties of connections to be identical.

connections = [c_sensorData c_motionData c_motionCommand c_Command];fork = 1:length(connections) setProperty(connections(k),'GeneralProfile.standardConn.unitCost','0.2');setProperty(connections(k),'GeneralProfile.standardConn.unitWeight','100');setProperty(connections(k),'GeneralProfile.standardConn.length','0.3');end

添加层次结构

添加两个名称的组件ControllerScope在 - 的里面运动零件。Define the ports. Connect the components to the architecture and to each other, applying a connector stereotype. Hierarchy in an architecture diagram creates an additional level of detail that specifies how components behave internally.

motionArch = componentMotion.Architecture; motionController = motionArch.addComponent('Controller');ControllerPorts = AddPort(MotionController.Architecture,{'controlIn','controlOut'},{'在','out'});controllerCompPortIn = motionController.getPort('controlIn');controllerCompPortOut = motionController.getPort('controlOut');motionsCope = MotionArch.AddComponent('Scope');scopePorts = addPort(motionScope.Architecture,{'scopeIn','scopeOut'},{'在','out'});scopeCompPortIn = motionScope.getPort('scopeIn');scopecompportout = motionscope.getport('scopeOut');c_planningController = connect(motionPorts(1),controllerCompPortIn);%用于外口连接,必须指定接口元素c_planningScope = connect(scopeCompPortOut,motionPorts(2),“目标元素”,"Rotation");c_planningConnect = connect(controllerCompportout,scopecompportin,'GeneralProfile.standardConn');

Save the model.

model.save

Arrange the layout by pressıngCtrl + Shift +一个or using this command.

金宝appsimulink.blockdiagram.arangesystem('mobileRobotAPI/Motion');

Create Model Reference

Model references can help you organize large models hierarchically and define architectures or behaviors once that you can then reuse. When a component references another model, any existing ports on the component are removed, and ports that exist on the referenced model will appear on the component.

创建一个新的系统作曲家模型。转换Sensorcomponent into a reference component to reference the new model. To add additional ports on theSensorcomponent, you must update the referenced model“ Mobilesensor”.

referenceModel = systemcomposer.createModel(“ Mobilesensor”);referenceArch = referenceModel.Architecture; newComponents = addComponent(referenceArch,"ElectricSensor");linkDictionary(ReferenceModel,"SensorInterfaces.sldd");referenceModel.save linkToModel(componentSensor,“ Mobilesensor”);

Apply a stereotype to the architecture and component of the linked reference model.

referenceModel.applyProfile(“通用”);Refeencearch.applystereotype("GeneralProfile.softwareComponent");batchApplyStereotype(referenceArch,'Component',"GeneralProfile.projectElement")

将端口和连接添加到参考组件。

sensorPorts = addPort(componentSensor.Architecture,{'MotionData','sensordata'},{'在','out'});sensorports(2).setInterface(interface)connect(Arch,ComponentSEnsor,componentplanning,'Rule','interfaces');connect(arch,componentMotion,componentSensor);

Save the models.

referenceModel.save model.save

制作变体组件

You can convert thePlanning使用的组件使用makeVariantfunction. The original component is embedded within a variant component as one of the available variant choices. You can design other variant choices within the variant component and toggle the active choice. Variant components allow you to choose behavioral designs programmatically in an architecture model to perform trade studies and analysis.

[variantComp,choice1] = makeVariant(componentPlanning);

Add an additional variant choice namedPlanningAlt. The second argument defines the name, and the third argument defines the label. The label identifies the choice. The active choice is controlled by the label.

选择2 = addChoice(variantComp,{'PlanningAlt'},{'PlanningAlt'});

创建必要的端口PlanningAlt.

setActiveChoice(variantComp,choice2) planningAltPorts = addPort(choice2.Architecture,{'命令','SensorData1',“运动仪”},{'在','在','out'});planningAltPorts(2).setInterface(interface)

制作PlanningAltthe active variant.

setActiveChoice(variantComp,'PlanningAlt')

Arrange the layout by pressıngCtrl + Shift +一个or using this command.

金宝appsimulink.blockdiagram.arangesystem(“ Mobilerobotapi/计划”);

Save the model.

model.save

Clean Up

删除此代码并运行它以清理此示例创建的工件。

% bdclose('mobileRobotAPI')%bdclose('MobileSensor')% Simulink.data.dictionary.closeAll% systemcomposer.profile.Profile.closeAll% delete('Profile.xml')% delete('SensorInterfaces.sldd')

More About

expand all

Introduced in R2019a