setHeight
R2026b(即将删除)指定度量仪表板自定义小组件的高度
以后的版本中将会删除度量仪表板、模型度量、slmetric API 以及对应的自定义项。有关详细信息,请参阅Migrating from Metrics Dashboard to Model Design Dashboards。
描述
setHeight( 以像素为单位指定自定义小组件的高度。 CustomWidget,num)
输入参数
要为其指定高度的 slmetric.dashboard.CustomWidget。
slmetric.dashboard.CustomWidget 对象的高度(以像素为单位)。这些是您可以设置的最小高度。
对于
SingleValue自定义小组件,最小高度为 25 像素。对于
BarChart自定义小组件,最小高度为 150 像素。对于
RadialGauge自定义小组件,最小高度为 120 像素。对于
DistributionHeatMap自定义小组件,最小高度为 90 像素。
示例: setHeight(widget, 50)
示例
创建一个统计非虚拟模块的自定义度量。指定一个小组件以在度量仪表板上显示此度量。将其添加到大小组。
通过输入以下命令打开模型 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 中推出以后的版本中将会删除度量仪表板、模型度量、slmetric API 以及对应的自定义项。有关详细信息,请参阅Migrating from Metrics Dashboard to Model Design Dashboards。
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)