Main Content

이 페이지는 기계 번역을 사용하여 번역되었습니다. 영어 원문을 보려면 여기를 클릭하십시오.

setWidths

클래스: slmetric.dashboard.CustomWidget
네임스페이스: slmetric.dashboard

(제거 예정) 지표 대시보드 사용자 정의 위젯에 대한 여러 너비 지정

Metrics Dashboard 사용자 인터페이스, metricdashboard 기능, slmetric 패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.

설명

setWidths(customName, widths)slmetric.dashboard.CustomWidget 객체가 가질 수 있는 너비를 지정합니다. 최대 4개의 서로 다른 너비를 지정할 수 있습니다. 입력 인수 widths의 경우 하나의 값 또는 4개 값의 배열을 전달합니다. 다음과 같은 가능한 값 중에서 선택할 수 있습니다.

  • slmetric.dashboard.Width.ExtraSmall — 2열 너비

  • slmetric.dashboard.Width.Small — 4열 너비

  • slmetric.dashboard.Width.Medium — 6열 너비

  • slmetric.dashboard.Width.Large — 8열 너비

  • slmetric.dashboard.Width.XLarge — 10열 너비

  • slmetric.dashboard.Width.XXLarge — 12열 너비

이러한 값은 화면 크기가 변경됨에 따라 사용자 정의 위젯이 가질 수 있는 다양한 크기에 해당합니다. 하나의 값을 지정하면 위젯은 화면 크기에 관계없이 항상 해당 값을 갖습니다. 4가지 다른 값을 지정하면 화면을 최대화하고 최소화함에 따라 위젯 크기가 4번 변경될 수 있습니다.

참고

메트릭 대시보드 레이아웃은 동일한 크기의 12개 열로 나뉩니다. 빈 대시보드에 새 위젯을 추가하면 대시보드는 12개의 열이 포함된 새 행을 생성합니다. 대시보드는 위젯 너비가 12열을 초과할 때까지 동일한 행에 위젯을 추가합니다. 너비가 12열을 초과하면 대시보드에서 새 행을 생성합니다. 예를 들어 너비가 slmetric.dashboard.Width.XXLarge인 하나의 위젯이 있는 경우 해당 위젯은 행의 12개 열을 모두 사용합니다. 더 작은 위젯이 있는 경우 대시보드는 행의 위젯이 최대 너비인 12에 도달할 때까지 해당 위젯을 동일한 행에 배치합니다.

열 12열3열4열5열6열7열8열9열열 10열 11열 12
slmetric.dashboard.Width.XXLarge
slmetric.dashboard.Width.Mediumslmetric.dashboard.Width.Medium
slmetric.dashboard.Width.Mediumslmetric.dashboard.Width.Small(비어 있음)
slmetric.dashboard.Width.Small(비어 있음)

입력 인수

모두 확장

너비가 1~4개인 slmetric.dashboard.CustomWidget 객체

다음 값 중 하나 또는 최대 4개를 지정하십시오.

  • slmetric.dashboard.Width.ExtraSmall — 2열 너비

  • slmetric.dashboard.Width.Small — 4열 너비

  • slmetric.dashboard.Width.Medium — 6열 너비

  • slmetric.dashboard.Width.Large — 8열 너비

  • slmetric.dashboard.Width.XLarge — 10열 너비

  • slmetric.dashboard.Width.XXLarge — 12열 너비

예제

모두 확장

비가상 블록 수를 계산하는 사용자 지정 메트릭을 만듭니다. 지표 대시보드에 이 지표를 표시하려면 위젯을 지정하세요. 크기 그룹에 추가합니다.

다음을 입력하여 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에 개발됨

모두 축소

R2022a: Metrics Dashboard이 제거됩니다

Metrics Dashboard 사용자 인터페이스, metricdashboard 기능, slmetric 패키지 API 및 해당 사용자 정의는 향후 릴리스에서 제거될 예정입니다. 자세한 내용은 Migrating from Metrics Dashboard to Model Maintainability Dashboard를 참조하세요.