%% Get Selector by Type and Description
% This example shows how to get a selector by type and description. In this
% example, you get all selectors for the False outcomes of the And block whose type is
% |ConditionOutcome|.

% Copyright 2020 The MathWorks, Inc.

%%
% Load the model into memory.

modelName = 'slcoverage_lct_bus';
load_system(modelName);
load slcoverage_lct_data.mat

%%
% The slcoverage_lct_bus model has an S-Function. Build the S-Function by
% using legacy_code.

def = legacy_code('initialize');
def.SFunctionName = 'slcoverage_sfun_counterbus';
def.OutputFcnSpec = 'void counterbusFcn(COUNTERBUS u1[1], int32 u2, COUNTERBUS y1[1], int32 y2[1])';
def.HeaderFiles   = {'counterbus.h'};
def.SourceFiles   = {'counterbus.c'};
def.Options.supportCoverage = true;
legacy_code('generate_for_sim', def);

%%
% Get the false outcome condition selectors for the And block by searching
% for descriptions that include |F|.

id = getSimulinkBlockHandle([modelName,'/slCounter/And']);
sel = slcoverage.Selector.allSelectors(id, ...
         'Type',slcoverage.MetricSelectorType.ConditionOutcome, ...
         'Description','F')

%%
% Look at the constructor code for the two selectors that were returned.
%

sel.ConstructorCode