getSeparators
类: slmetric.dashboard.Group
命名空间: slmetric.dashboard
(待删除)确定“度量仪表板”组的侧边是否有线条
以后的版本中将会删除度量仪表板用户界面、metricdashboard 函数、slmetric 包 API 以及相应的自定义项。有关详细信息,请参阅从度量盘迁移到模型可维护性仪表盘。
输入参数
确定 slmetric.dashboard.Group 对象的两侧是否有分隔符。
输出参量
输出结果是一个结构体或结构体数组,包含以下字段:
S.topS.bottomS.leftS.right
每个字段为空,或者值为 1 或 0。空字段表示您未设置值。1 值表示该组侧有一条线。0 值表示该组侧没有行。
示例
创建一个自定义度量,用于统计非虚拟块的数量。指定一个组件,在度量仪表板上显示此度量。将其添加到大小组。
通过输入以下命令打开模型 vdp:
openExample('simulink_general/VanDerPolOscillatorExample')创建自定义度量类。
className = 'nonvirtualblockcount';
slmetric.metric.createNewMetricClass(className);
通过将此代码添加到 nonvirtualblockcount.m 文件中来创建非虚拟模块计数度量。
classdef nonvirtualblockcount < slmetric.metric.Metric %nonvirtualblockcount calculates number of nonvirtual blocks per level. % BusCreator, BusSelector and BusAssign are treated as nonvirtual. properties VirtualBlockTypes = {'Demux','From','Goto','Ground', ... 'GotoTagVisibility','Mux','SignalSpecification', ... 'Terminator','Inport'}; end methods function this = nonvirtualblockcount() this.ID = 'nonvirtualblockcount'; this.Name = 'Nonvirtual Block Count'; this.Version = 1; this.CompileContext = 'None'; this.Description = 'Algorithm that counts nonvirtual blocks per level.'; this.AggregatedValueName = 'Nonvirtual Blocks (incl. Descendants)' this.ValueName = 'Nonvirtual Blocks' this.ComponentScope = [Advisor.component.Types.Model, ... Advisor.component.Types.SubSystem]; this.AggregationMode = slmetric.AggregationMode.Sum; this.ResultChecksumCoverage = true; this.SupportsResultDetails = true; end function res = algorithm(this, component) % create a result object for this component res = slmetric.metric.Result(); % set the component and metric ID res.ComponentID = component.ID; res.MetricID = this.ID; % Practice D1=slmetric.metric.ResultDetail('identifier 1','Name 1'); D1.Value=0; D1.setGroup('Group1','Group1Name'); D2=slmetric.metric.ResultDetail('identifier 2','Name 2'); D2.Value=1; D2.setGroup('Group1','Group1Name'); % use find_system to get all blocks inside this component blocks = find_system(getPath(component), ... 'SearchDepth', 1, ... 'Type', 'Block'); isNonVirtual = true(size(blocks)); for n=1:length(blocks) blockType = get_param(blocks{n}, 'BlockType'); if any(strcmp(this.VirtualBlockTypes, blockType)) isNonVirtual(n) = false; else switch blockType case 'SubSystem' % Virtual unless the block is conditionally executed % or the Treat as atomic unit check box is selected. if strcmp(get_param(blocks{n}, 'IsSubSystemVirtual'), ... 'on') isNonVirtual(n) = false; end case 'Outport' % Outport: Virtual when the block resides within % SubSystem block (conditional or not), and % does not reside in the root (top-level) Simulink window. if component.Type ~= Advisor.component.Types.Model isNonVirtual(n) = false; end case 'Selector' % Virtual only when Number of input dimensions % specifies 1 and Index Option specifies Select % all, Index vector (dialog), or Starting index (dialog). nod = get_param(blocks{n}, 'NumberOfDimensions'); ios = get_param(blocks{n}, 'IndexOptionArray'); ios_settings = {'Assign all', 'Index vector (dialog)', ... 'Starting index (dialog)'}; if nod == 1 && any(strcmp(ios_settings, ios)) isNonVirtual(n) = false; end case 'Trigger' % Virtual when the output port is not present. if strcmp(get_param(blocks{n}, 'ShowOutputPort'), 'off') isNonVirtual(n) = false; end case 'Enable' % Virtual unless connected directly to an Outport block. isNonVirtual(n) = false; if strcmp(get_param(blocks{n}, 'ShowOutputPort'), 'on') pc = get_param(blocks{n}, 'PortConnectivity'); if ~isempty(pc.DstBlock) && ... strcmp(get_param(pc.DstBlock, 'BlockType'), ... 'Outport') isNonVirtual(n) = true; end end end end end blocks = blocks(isNonVirtual); res.Value = length(blocks); end end end
在度量库中注册新度量。
[id_metric,err_msg] = slmetric.metric.registerMetric(className);
首先,打开度量仪表板布局的默认配置。
conf = slmetric.dashboard.Configuration.open();
从 slmetric.dashboard.Configuration 对象中获取 slmetric.dashboard.Layout 对象。
layout = getDashboardLayout(conf);
获取布局对象中的控件对象。
layoutWidget = getWidgets(layout);
移除代表 Simulink 模块计数度量的小组件。
sizeGroup = layoutWidget(2); sizeGroupWidgets = sizeGroup.getWidgets(); sizeGroup.removeWidget(sizeGroupWidgets(1));
添加一个显示非虚拟模块计数度量的小组件。对于自定义小组件,默认可视化类型为单值。如果要使用不同的可视化技术,请为 VisualizationType 属性指定不同的值。
newWidget = sizeGroup.addWidget('Custom', 1); newWidget.Title = ('Nonvirtual Block Count'); newWidget.setMetricIDs('nonvirtualblockcount'); newWidget.setWidths(slmetric.dashboard.Width.Medium); newWidget.setHeight(70);
指定自定义小组件与组中其他小组件之间是否有分隔线。这些命令指定在小组件右侧有一条线。
s.top = false; s.bottom = false; s.left = false; s.right = true; newWidget.setSeparators([s, s, s, s]);
保存配置对象。此命令将 API 信息序列化为 XML 文件。
save(conf,'Filename','DashboardConfig.xml');
设置活动配置。
slmetric.dashboard.setActiveConfiguration(fullfile(pwd,'DashboardConfig.xml'));打开模型 vdp 的度量仪表板。
metricsdashboard vdp点击所有度量按钮以运行所有度量。
版本历史记录
在 R2018b 中推出以后的版本中将会删除度量仪表板用户界面、metricdashboard 函数、slmetric 包 API 以及相应的自定义项。有关详细信息,请参阅从度量盘迁移到模型可维护性仪表盘。
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)