systemcomposer.allocation.AllocationSet
一组分配方案
说明
AllocationSet 对象定义了两个 System Composer™ 模型之间的分配方案集合。
创建对象
使用 systemcomposer.allocation.createAllocationSet 函数创建名称为 myNewAllocation 的分配集。
systemcomposer.allocation.createAllocationSet("myNewAllocation", ... "Source_Model_Allocation","Target_Model_Allocation");
属性
分配集名称,指定为字符向量。
示例: 'MyNewAllocation'
数据类型: char
分配的源模型,指定为 systemcomposer.arch.Model 对象。
分配的目标模型,指定为 systemcomposer.arch.Model 对象。
指定为 systemcomposer.allocation.AllocationScenario 对象数组的分配方案。
分配集关联的配置文件,指定为 systemcomposer.profile.Profile 对象的数组。
分配集描述,指定为字符向量。
数据类型: char
应用于分配集中的分配的默认构造型的名称,以 "<profile>.<stereotype>" 的形式指定。配置文件必须已导入分配集。
数据类型: char | string
分配集是否与源模型、目标模型或两者都过时,指定为 1 (true) 或 0 (false)。
数据类型: logical
分配集是否有未保存的更改,指定为 1 (true) 或 0 (false)。
数据类型: logical
统一唯一标识符,指定为字符向量
示例: '91d5de2c-b14c-4c76-a5d6-5dd0037c52df'
数据类型: char
对象函数
applyProfile | 将配置文件应用到模型 |
removeProfile | 从模型中移除配置文件 |
createScenario | 创建新的空分配方案 |
getScenario | 获取分配方案 |
deleteScenario | 删除分配方案 |
synchronizeChanges | 同步更改分配集中的模型 |
find | 查找已加载的分配集 |
save | 将分配集保存为文件 |
rebindSourceModel | 更改源模型 |
rebindTargetModel | 更改目标模型 |
close | 关闭分配集 |
closeAll | 关闭所有打开的分配组 |
示例
使用分配来分析轮胎压力监控系统。
概述
在系统工程中,以不同的抽象层次描述系统是很常见的。例如,您可以用系统的高级函数来描述系统。这些函数可能没有任何相关联的行为,但很可能追溯到系统必须满足的一些操作需求。我们将这一层(或架构)称为功能架构。在此示例中,介绍了三种不同架构的汽车轮胎压力监控系统:
功能架构 - 从高级函数的角度描述系统。连接显示了函数之间的依赖关系 [1]。
逻辑架构 - 根据系统的逻辑组件以及它们之间的数据交换方式来描述系统。此外,此架构还规定了模型仿真的行为 [2]。
平台架构 - 高层面描述系统所需的物理硬件 [3]。
注意:此示例展示了使用特定方法在 System Composer™ 中进行分配的情形。不过,您也可以使用其他适合您需要的方法。
分配过程被定义为将这三个完全描述系统的架构链接起来。链接功能可捕捉每个架构层的信息,并使其他架构层也能访问这些信息。
使用此命令打开工程。
openProject("scExampleTirePressureMonitorSystem");
打开 FunctionalAllocation.mldatx 文件,该文件显示分配编辑器中从 TPMS_FunctionalArchitecture 到 TPMS_LogicalArchitecture 的分配情况。TPMS_FunctionalArchitecture 的元素显示在第一列。TPMS_LogicalArchitecture 的元素显示在第一行。箭头表示模型元素之间的分配。

箭头显示模型中已分配的组件。您可以观察模型层次结构中每个元素的分配情况。
示例的其余部分将展示如何使用这些分配信息来进一步分析模型。
从功能到逻辑的分配和覆盖率分析
本节介绍如何执行覆盖率分析,以验证所有函数都已分配。这一过程需要使用功能架构和逻辑架构之间指定的分配信息。
要开始分析,请加载分配集。
allocSet = systemcomposer.allocation.load('FunctionalAllocation');
scenario = allocSet.Scenarios;确认系统中的每个函数都已分配。
import systemcomposer.query.*; [~,allFunctions] = allocSet.SourceModel.find(HasStereotype(IsStereotypeDerivedFrom("TPMSProfile.Function"))); unAllocatedFunctions = []; ImplementedAllocations = []; for i = 1:numel(allFunctions) alloc = scenario.getAllocatedTo(allFunctions(i)); if isempty(alloc) unAllocatedFunctions = [unAllocatedFunctions allFunctions(i)]; end end allCompsSource = allocSet.SourceModel.find(AnyComponent); allCompsTarget = allocSet.TargetModel.find(AnyComponent); for i = 1:numel(allCompsSource) for j = 1:numel(allCompsTarget) sourceComp = allocSet.SourceModel.lookup(Path=allCompsSource{i}); targetComp = allocSet.TargetModel.lookup(Path=allCompsTarget{j}); allocated = scenario.getAllocation(sourceComp,targetComp); if ~isempty(allocated) if allocated.getPropertyValue("TPMSProfile.FunctionalAllocation.IsImplemented") ImplementedAllocations(end+1) = strcat(sourceComp.Name," to ",targetComp.Name); end end end end if isempty(unAllocatedFunctions) fprintf('All functions are allocated'); else fprintf('%d Functions have not been allocated',numel(unAllocatedFunctions)); end
All functions are allocated
if isempty(ImplementedAllocations) fprintf('No allocations are implemented'); else fprintf('%d Allocations have been implemented',numel(ImplementedAllocations)); end
6 Allocations have been implemented
结果显示 All functions are allocated,以验证系统中的所有函数都已分配,并列出尚未实现的分配。
分析提供函数的供应商
本节介绍如何使用指定的分配来确定哪些函数将由哪些供应商提供。由于供应商将向系统集成商提供这些组件,因此供应商信息将存储在逻辑模型中。
suppliers = {'Supplier A','Supplier B','Supplier C','Supplier D'};
functionNames = arrayfun(@(x) x.Name, allFunctions,'UniformOutput',false);
numFunNames = length(allFunctions);
numSuppliers = length(suppliers);
allocTable = table('Size',[numFunNames,numSuppliers],'VariableTypes',...
repmat("double",1,numSuppliers));
allocTable.Properties.VariableNames = suppliers;
allocTable.Properties.RowNames = functionNames;
for i = 1:numFunNames
elem = scenario.getAllocatedTo(allFunctions(i));
for j = 1:numel(elem)
elemSupplier = getEvaluatedPropertyValue(elem(j),'TPMSProfile.LogicalComponent.Supplier');
allocTable{i,strcmp(elemSupplier,suppliers)} = 1;
end
end下表显示了各供应商负责的相应函数。
allocTable
allocTable=8×4 table
Supplier A Supplier B Supplier C Supplier D
__________ __________ __________ __________
Calculate Tire Pressure 0 1 0 0
Measure pressure on tire 0 0 1 0
Report Low Tire Pressure 1 0 0 0
Measure Tire Pressure 0 0 0 0
Measure rotations 0 1 0 0
Report Tire Pressure Levels 1 0 0 0
Measure temperature of tire 0 0 0 1
Calculate if pressure is low 1 0 0 0
分析软件部署策略
您可以确定发动机控制单元 (ECU) 的容量是否足以容纳所有软件组件。软件组件分配给内核本身,但 ECU 是具有预算属性的组件。
获取平台架构。
platformArch = systemcomposer.loadModel('PlatformArchitecture');加载分配。
softwareDeployment = systemcomposer.allocation.load('SoftwareDeployment'); frontECU = platformArch.lookup('Path','PlatformArchitecture/Front ECU'); rearECU = platformArch.lookup('Path','PlatformArchitecture/Rear ECU'); scenario1 = softwareDeployment.getScenario('Scenario 1'); scenario2 = softwareDeployment.getScenario('Scenario 2'); frontECU_availMemory = getEvaluatedPropertyValue(frontECU,"TPMSProfile.ECU.MemoryCapacity"); rearECU_availMemory = getEvaluatedPropertyValue(rearECU,"TPMSProfile.ECU.MemoryCapacity"); frontECU_memoryUsed1 = getUtilizedMemoryOnECU(frontECU,scenario1); frontECU_isOverBudget1 = frontECU_memoryUsed1 > frontECU_availMemory; rearECU_memoryUsed1 = getUtilizedMemoryOnECU(rearECU,scenario1); rearECU_isOverBudget1 = rearECU_memoryUsed1 > rearECU_availMemory; frontECU_memoryUsed2 = getUtilizedMemoryOnECU(frontECU,scenario2); frontECU_isOverBudget2 = frontECU_memoryUsed2 > frontECU_availMemory; rearECU_memoryUsed2 = getUtilizedMemoryOnECU(rearECU,scenario2); rearECU_isOverBudget2 = rearECU_memoryUsed2 > rearECU_availMemory;
生成一个表来展示结果。
softwareDeploymentTable = table([frontECU_memoryUsed1;frontECU_availMemory;... frontECU_isOverBudget1;rearECU_memoryUsed1;rearECU_availMemory;rearECU_isOverBudget1],... [frontECU_memoryUsed2; frontECU_availMemory; frontECU_isOverBudget2;rearECU_memoryUsed2;... rearECU_availMemory; rearECU_isOverBudget2],... 'VariableNames',{'Scenario 1','Scenario 2'},... 'RowNames',{'Front ECU Memory Used (MB)','Front ECU Memory (MB)','Front ECU Overloaded',... 'Rear ECU Memory Used (MB)','Rear ECU Memory (MB)','Rear ECU Overloaded'})
softwareDeploymentTable=6×2 table
Scenario 1 Scenario 2
__________ __________
Front ECU Memory Used (MB) 110 90
Front ECU Memory (MB) 100 100
Front ECU Overloaded 1 0
Rear ECU Memory Used (MB) 0 20
Rear ECU Memory (MB) 100 100
Rear ECU Overloaded 0 0
function memoryUsed = getUtilizedMemoryOnECU(ecu, scenario)对于 ECU 中的每个组件,累计每个已分配软件组件所需的二进制大小。
coreNames = {'Core1','Core2','Core3','Core4'};
memoryUsed = 0;
for i = 1:numel(coreNames)
core = ecu.Model.lookup('Path',[ecu.getQualifiedName '/' coreNames{i}]);
allocatedSWComps = scenario.getAllocatedFrom(core);
for j = 1:numel(allocatedSWComps)
binarySize = getEvaluatedPropertyValue(allocatedSWComps(j),"TPMSProfile.SWComponent.BinarySize");
memoryUsed = memoryUsed + binarySize;
end
end
end详细信息
| 术语 | 定义 | 应用 | 更多信息 |
|---|---|---|---|
| 分配 | 分配建立从一个模型中的架构元素(组件、端口和连接器)到另一个模型中的架构元素的有向关系。 | 通过基于资源的分配,您可以将功能架构元素分配给逻辑架构元素,以及将逻辑架构元素分配给物理架构元素。 | |
| 分配方案 | 分配方案包含源模型和目标模型之间的一组分配关系。 | 在分配方案中的模型元素之间进行分配。默认分配方案称为 | 系统工程方法在系统级芯片 (SoC) 应用中的应用 |
| 分配集 | 分配集由一个或多个分配方案组成,这些分配方案描述源模型和目标模型之间的各种分配关系。 | 在分配编辑器中创建包含分配方案的分配集。分配集保存为 MLDATX 文件。 |
版本历史记录
在 R2020b 中推出
另请参阅
工具
模块
对象
函数
systemcomposer.allocation.createAllocationSet|systemcomposer.allocation.load|systemcomposer.allocation.open|systemcomposer.allocation.editor|close|systemcomposer.allocation.AllocationSet.closeAll|systemcomposer.allocation.AllocationSet.find|save|rebindSourceModel|rebindTargetModel|synchronizeChanges|createScenario|deleteScenario|getScenario|allocate|deallocate|getAllocation|getAllocatedFrom|getAllocatedTo|destroy
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)