Invoke Code Generation Verification (CGV) API and execute model
invokes
the Code Generation Verification (CGV) API methods and executes the cgvObject
= slvnvruncgvtest(model
, dataFile
)model
by
using all test cases in dataFile
. cgvObject
is
a cgv.CGV
object that slvnvruncgvtest
creates
during the execution of the model
. slvnvruncgvtest
sets
the execution mode for cgvObject
to'sim'
by
default.
% Open the sldemo_mdlref_basic example model and log the input signals to the CounterA Model block: open_system('sldemo_mdlref_basic'); load_system('sldemo_mdlref_counter'); loggedData = slvnvlogsignals('sldemo_mdlref_basic/CounterA'); % Create the default configuration object for slvnvruncgvtest,and allow the model to be configured to % execute test cases with the CGV API: runOpts = slvnvruntestopts('cgv'); runOpts.allowCopyModel = true; % Using the logged signals, execute slvnvruncgvtest — first in simulation mode, and then in % Software-in-the-Loop (SIL) mode — to invoke the CGV API and execute the specified test % cases on the generated code for the model: cgvObjectSim = slvnvruncgvtest('sldemo_mdlref_counter', loggedData, runOpts); runOpts.cgvConn = 'sil'; cgvObjectSil = slvnvruncgvtest('sldemo_mdlref_counter', loggedData, runOpts); % Use the CGV API to compare the results of the first test case: simout = cgvObjectSim.getOutputData(1); silout = cgvObjectSil.getOutputData(1); [matchNames, ~, mismatchNames, ~ ] = cgv.CGV.compare(simout, silout); fprintf('\nTest Case: %d Signals match, %d Signals mismatch', ... length(matchNames), length(mismatchNames));
To run slvnvruncgvtest
, you must have the Embedded Coder® software.
If your model has parameters that are not configured for executing
test cases with the CGV API, slvnvruncgvtest
reports
warnings about the invalid parameters. If you see these warnings,
do one of the following:
Modify the invalid parameters and rerun slvnvruncgvtest
.
Set allowCopyModel
in runOpts
to
be true
and rerun slvnvruncgvtest
. slvnvruncgvtest
makes
a copy of your model configured for executing test cases, and invokes
the CGV API.
slvnvlogsignals
| slvnvruntest
| slvnvruntestopts
| cgv.CGV
(Embedded Coder)