主要内容

以编程方式创建架构视图

您可以以编程方式创建架构视图。本主题展示了两个以编程方式创建架构视图的示例,并向您展示了如何使用查询在System Composer™模型中查找元素。

一个查询是描述模型元素要满足的特定约束或标准的规范。使用查询来搜索带有约束条件的元素和过滤视图。

基于无钥匙输入系统的系统编写器架构视图

这个示例展示了如何使用无键输入系统来使用API以编程方式创建架构视图。

1.使用查询导入包。

进口systemcomposer.query。*

2.为无钥匙输入系统打金宝app开Simulink®项目文件。

scKeylessEntrySystem

3.将示例模型加载到System Composer™中。

zcModel = systemcomposer.loadModel (“KeylessEntryArchitecture”);

例1:硬件组件评审状态视图

属性创建筛选的视图,该视图选择体系结构模型中的所有硬件组件并使用ReviewStatus财产。

1.构造查询以选择所有硬件组件。

hwCompQuery = HasStereotype (IsStereotypeDerivedFrom (“AutoProfile。HardwareComponent”))
hwCompQuery = HasStereotype with properties: AllowedParentConstraints: {1x3 cell} SubConstraint: [1x1 systemcomposer.query. hwCompQuery = HasStereotype with properties: AllowedParentConstraints: {1x3 cell}IsStereotypeDerivedFrom] SkipValidation: 0

2.使用查询创建视图。

zcModel.createView (“硬件组件检查状态”...“选择”hwCompQuery,...%用于选择的查询“GroupBy”,{“AutoProfile.BaseComponent.ReviewStatus”},...%原型属性限定“IncludeReferenceModels”,真的,...%在引用的模型中包含组件“颜色”“紫色”);

3.打开建筑视图画廊。

zcModel.openViews

例2:FOB定位器系统供应商视图

这个示例展示了如何创建一个自由格式的视图,手动从FOB Locator System中提取组件,然后为供应商使用现有的和新的视图组件对它们进行分组。在本例中,您将使用元素组,将视图中的组件分组,以编程方式填充视图。

1.创建视图架构。

fobSupplierView = zcModel.createView (“FOB定位系统供应商细分”...“颜色”“lightblue”);

2.添加一个名为《供应商D '.添加FOB定位器模块到视图元素子组。

supplierD = fobSupplierView.Root.createSubGroup (《供应商D ');supplierD.addElement ('KeylessEntryArchitecture/FOB定位系统/FOB定位模块');

3.为。创建新的子组“供应商”

supplierA = fobSupplierView.Root.createSubGroup (“供应商”);

4.将每个FOB Receivers添加到view元素子组。

FOBLocatorSystem = zcModel.lookup (“路径”“KeylessEntryArchitecture / FOB定位系统”);找到所有包含名称“Receiver”的组件receiverCompPaths = zcModel.find (...包含(systemcomposer.query.Property (“名字”),“接收方”),...FOBLocatorSystem.Architecture);supplierA.addElement (receiverCompPaths)

使用查询在模型中查找元素

这个示例展示了如何使用查询在System Composer模型中查找组件。

打开模型。

进口systemcomposer.query。*;scKeylessEntrySystem zcModel = systemcomposer.loadModel(“KeylessEntryArchitecture”);

找到系统中的所有软件组件。

con1 = HasStereotype(属性(“名称”) = =“SoftwareComponent”);[compPaths, compObjs] = zcModel.find(con1)
compPaths =5 x1细胞{'KeylessEntryArchitecture/Engine Control System/ key - less Start Controller'} {'KeylessEntryArchitecture/Lighting System/Lighting Controller'} {'KeylessEntryArchitecture/Sound System/Sound Controller'} {'KeylessEntryArchitecture/FOB Locator System/FOB Locator Module'} {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller'}
compObjs =1×5对象1x5带有属性的组件数组:IsAdapterComponent Architecture ReferenceName Name Parent Ports OwnedPorts OwnedArchitecture Position Model SimulinkHandle SimulinkM金宝appodelHandle UUID ExternalUID
%在搜索中包含参考模型softwareComps = zcModel.find (con1,“IncludeReferenceModels”,真正的)
softwareComps =9 x1细胞{' KeylessEntryArchitecture /发动机控制系统/无钥匙启动控制器的}{KeylessEntryArchitecture /照明系统照明控制器的}{KeylessEntryArchitecture /音响/声音控制器的}{' KeylessEntryArchitecture / FOB定位系统/ FOB定位模块的}{KeylessEntryArchitecture /门锁/ /解锁系统/门锁控制器'}{'KeylessEntryArchitecture/门锁//解锁系统/后门门锁传感器/检测门锁状态'}{'KeylessEntryArchitecture/门锁//解锁系统/前门门锁传感器/检测门锁状态'}{'KeylessEntryArchitecture/门锁//解锁系统/前驾驶员门锁传感器/检测门锁状态'}

求出系统中的所有基本分量。

con2 = HasStereotype (IsStereotypeDerivedFrom (“AutoProfile。BaseComponent”));baseComps = zcModel.find (con2)
baseComps =18 x1细胞{' KeylessEntryArchitecture /发动机控制系统/无钥匙启动控制器的}{KeylessEntryArchitecture /照明系统照明控制器的}{KeylessEntryArchitecture /音响/声音控制器的}{' KeylessEntryArchitecture / FOB定位系统/ FOB定位模块的}{KeylessEntryArchitecture /门锁/ /解锁系统/门锁控制器'}{KeylessEntryArchitecture /音响/仪表盘议长的}{' KeylessEntryArchitecture /发动机控制系统/启动/停止按钮”}{KeylessEntryArchitecture /门锁/ /解锁系统/前司机门锁传感器}{KeylessEntryArchitecture /门锁/ /解锁系统/前通过门锁传感器}{KeylessEntryArchitecture /门锁/ /解锁{'KeylessEntryArchitecture/FOB Locator System/Center Receiver'} {'KeylessEntryArchitecture/FOB Locator System/Front Receiver'} {'KeylessEntryArchitecture/FOB Locator System/Rear Receiver'} {'KeylessEntryArchitecture/FOB Locator System/Rear Receiver'Lock//Unlock System/Front Driver Door Lock致动器}{'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock致动器}{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock致动器'}{'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock致动器}

使用接口查找所有组件KeyFOBPosition

con3 = HasPort (HasInterface(属性(“名称”) = =“KeyFOBPosition”));con3_a = HasPort(属性(“InterfaceName”) = =“KeyFOBPosition”);keyFOBPosComps = zcModel.find (con3)
keyFOBPosComps =10 x1细胞{“KeylessEntryArchitecture /门锁/ /解锁系统”}{KeylessEntryArchitecture /门锁/ /解锁系统/门锁控制器}{KeylessEntryArchitecture /发动机控制系统的}{' KeylessEntryArchitecture /发动机控制系统/无钥匙启动控制器}{“KeylessEntryArchitecture / FOB定位系统”}{' KeylessEntryArchitecture / FOB定位器System/FOB Locator Module'} {'KeylessEntryArchitecture/Lighting System'} {'KeylessEntryArchitecture/Lighting System/Lighting Controller'} {'KeylessEntryArchitecture/Sound System'} {'KeylessEntryArchitecture/Sound System/Sound Controller'}

找出WCET小于或等于5ms的所有组件。

con4 = PropertyValue (“AutoProfile.SoftwareComponent.WCET”) < = 5;zcModel.find (con4)
ans =1 x1单元阵列{“KeylessEntryArchitecture /音响/声音控制器”}
你可以指定单位,它会为你做转换con5 = PropertyValue (“AutoProfile.SoftwareComponent.WCET”) < =价值(5“女士”);query1Comps = zcModel.find (con5)
query1Comps =3 x1细胞{'KeylessEntryArchitecture/Lighting System/Lighting Controller'} {'KeylessEntryArchitecture/Sound System/Sound Controller'} {'KeylessEntryArchitecture/FOB Locator System/FOB Locator Module'}

找出WCET大于1毫秒或成本大于10美元的所有组件。

con6 = PropertyValue (“AutoProfile.SoftwareComponent.WCET”) >价值(1,“女士”) | PropertyValue (“AutoProfile.Base.Cost”) >价值(10,“美元”);query2Comps = zcModel.find (con6)
query2Comps =2 x1细胞{'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'} {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}

关闭模式。

zcModel.close;

另请参阅

||||||||

相关的话题