getCheckInstanceIDs
Class: Advisor.Application
Namespace: Advisor
Obtain check instance IDs
Syntax
Description
Obtain the check instance ID for a check using the check ID. A check instance is an
instantiation of a ModelAdvisor.Check
object in the Model Advisor
configuration. When you change the Model Advisor configuration, the check instance ID can
change. The check ID is a static identifier that does not change.
returns a cell array of check instance IDs.CheckInstanceIDs
= getCheckInstanceIDs(app
)
returns the instance ID or instance IDs associated with a check. CheckInstanceIDs
= getCheckInstanceIDs(app
,CheckID
)getCheckInstanceIDs
returns multiple check instance IDs if a check appears in
multiple folders in the Model Advisor tree.
Input Arguments
Model Advisor application object, specified as an
Advisor.Application
object. You can use an
Advisor.Application
object to run Model Advisor checks on a model
reference hierarchy. Create an Advisor.Application
object by using the
method Advisor.Manager.createApplication
.
Check ID associated with Model Advisor check, specified as a character vector.
Example: 'mathworks.design.UnconnectedLinesPorts'
Output Arguments
Check instance IDs, returned as a cell array.
Examples
This example shows how to create an
Advisor.Application
object, set the root of the Model Advisor analysis,
and find each of the selected check instance IDs.
Open the example model sldemo_mdlref_basic
. In the MATLAB® Command Window, enter:
openExample("sldemo_mdlref_basic")
Create an Advisor.Application
object that you can use to run Model
Advisor
checks.
app = Advisor.Manager.createApplication();
Specify which model or subsystem to analyze. For this example, specify the model
sldemo_mdlref_basic
as the root of the Model Advisor
analysis.
setAnalysisRoot(app,Root = "sldemo_mdlref_basic");
Select each of the check instances in the current Model Advisor configuration.
selectCheckInstances(app);
Get the check instance IDs for each check instance in the current Model Advisor configuration.
CheckInstanceIDs = getCheckInstanceIDs(app);
This example shows how to create an
Advisor.Application
object, set the root of the Model Advisor analysis,
and find the check instance IDs associated with the check Check root
model Inport block specifications.
Open the example model sldemo_mdlref_basic
. In the MATLAB Command Window, enter:
openExample("sldemo_mdlref_basic")
Create an Advisor.Application
object that you can use to run Model
Advisor
checks.
app = Advisor.Manager.createApplication();
Specify which model or subsystem to analyze. For this example, specify the model
sldemo_mdlref_basic
as the root of the Model Advisor
analysis.
setAnalysisRoot(app,Root = "sldemo_mdlref_basic");
Specify that you want Model Advisor to run the check Identify unconnected lines, input ports, and output ports by finding and using the check instance ID.
checkID = "mathworks.design.UnconnectedLinesPorts";
instanceIDs = getCheckInstanceIDs(app,checkID)
You can use the check instance ID to select or deselect the checks that run during
Model Advisor analysis. For more information, see the methods selectCheckInstances
and deselectCheckInstances
.
For more information on running Model Advisor using the
Advisor.Application
object, see Advisor.Application
.
This example shows how to run the check Check
root model Inport block specifications on the model
sldemo_mdlref_basic
and its referenced model
sldemo_mdlref_counter
.
Open the example model sldemo_mdlref_basic
. In the MATLAB Command Window, enter:
openExample("sldemo_mdlref_basic")
The model sldemo_mdlref_basic
is a parent model that contains three Model blocks: CounterA
, CounterB
, and CounterC
. These blocks reference the same model, sldemo_mdlref_counter
, which is a separate model and not a subsystem of sldemo_mdlref_basic
.
Create an Advisor.Application
object that you can use to run Model Advisor checks across the model reference hierarchy in sldemo_mdlref_basic
.
app = Advisor.Manager.createApplication();
Specify which model or subsystem to analyze. For this example, specify the model sldemo_mdlref_basic
as the root of the Model Advisor analysis.
setAnalysisRoot(app,Root = "sldemo_mdlref_basic");
When you specify a model as the analysis root for an Advisor.Application
object, Model Advisor analyzes that model and any referenced models. For more information, see setAnalysisRoot
.
Suppose that you only want to run the check Check root model Inport block specifications.
By default, the Advisor.Application
object is set up to run each check instance in the current Model Advisor configuration and has all check instances selected. Clear the check instances to remove all check instances from the Model Advisor analysis.
deselectCheckInstances(app);
Specify that you want Model Advisor to run only the check Check root model Inport block specifications by finding and using the check instance ID.
checkID = "mathworks.design.RootInportSpec";
instanceIDs = getCheckInstanceIDs(app,checkID);
instanceID = instanceIDs(1);
selectCheckInstances(app,ID = instanceID);
Now the check Check root model Inport block specifications is selected for Model Advisor analysis.
The method getCheckInstanceIDs
returns multiple check instance IDs because the check Check root model Inport block specifications appears in multiple folders in the Model Advisor tree. For this example, the instanceID
is specified as the first check instance ID returned by getCheckInstanceIDs
, but you can select any of the check instance IDs returned by getCheckInstanceIDs
.
Note
Alternatively, if you want to load a Model Advisor configuration file instead of selecting individual checks, use the method loadConfiguration
.
Run the Model Advisor analysis.
run(app);
Model Advisor runs the check Check root model Inport block specifications on both sldemo_mdlref_basic
and sldemo_mdlref_counter
.
Get the results from the Model Advisor analysis.
res = getResults(app);
Generate and view a Model Advisor report.
report = generateReport(app); web(report);
The Model Advisor report provides a summary of the results for sldemo_mdlref_basic
and sldemo_mdlref_counter
and hyperlinks to individual reports for each model.
This example shows how to run the check Identify unconnected lines, input ports, and output ports on the different
variant choices in the model slexVariantManagement
.
Open the example model slexVariantManagement
. In the MATLAB Command Window, enter:
openExample("slexVariantManagement")
The model slexVariantManagement
contains several variant subsystem blocks including Controller
and Plant
. Inside the variant subsystem blocks are different implementations of those components.
slexVariantManagement
has multiple variant configurations stored in the variant configuration data object vcd
associated with the model. Advisor.Application
objects can only run Model Advisor analysis on active and inactive variant blocks in models with variant configurations created by using Variant Manager. For more information, see Variant Manager for Simulink and Variant Configurations.
Create an Advisor.Application
object that you can use to run Model Advisor checks.
app = Advisor.Manager.createApplication();
Specify AnalyzeVariants
as true
so that Advisor.Application
object can run Model Advisor for each of the variant choices in slexVariantManagement
.
app.AnalyzeVariants = true;
Specify which model to analyze. For this example, specify the model slexVariantManagement
as the root of the Model Advisor analysis.
setAnalysisRoot(app,Root = "slexVariantManagement");
Suppose that you want to run only the check Identify unconnected lines, input ports, and output ports.
By default, the Advisor.Application
object is set up to run each check instance in the current Model Advisor configuration and has all check instances selected. Clear the check instances to remove all check instances from the Model Advisor analysis.
deselectCheckInstances(app);
Specify that you want Model Advisor to run the check Identify unconnected lines, input ports, and output ports by finding and using the check instance ID.
checkID = "mathworks.design.UnconnectedLinesPorts";
instanceIDs = getCheckInstanceIDs(app,checkID);
instanceID = instanceIDs(1);
selectCheckInstances(app,ID = instanceID);
Now the check Identify unconnected lines, input ports, and output ports is selected for Model Advisor analysis.
The method getCheckInstanceIDs
returns multiple check instance IDs because the check Identify unconnected lines, input ports, and output ports appears in multiple folders in the Model Advisor tree. For this example, the instanceID
is specified as the first check instance ID returned by getCheckInstanceIDs
, but you can select any of the check instance IDs returned by getCheckInstanceIDs
.
Note
Alternatively, if you want to load a Model Advisor configuration file instead of selecting individual checks, use the method loadConfiguration
.
Run the Model Advisor analysis.
run(app);
Model Advisor runs the check on both active variants in the model and referenced models.
Get the results from the Model Advisor analysis.
res = getResults(app);
Generate and view a Model Advisor report.
report = generateReport(app); web(report);
The Model Advisor report provides a summary of the results for slexVariantManagement
and hyperlinks to individual reports for each variant.
Alternatives
In the left-hand pane of the Model Advisor window, right-click the check and select Send Check Instance ID to Workspace.
Version History
Introduced in R2015b
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)