MATLAB SIMULINK VERIFICATION AND VALIDATION - S Podręcznik Użytkownika Strona 526

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 674
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 525
21 Automating Model Coverage Tasks
21-14
Use Coverage Commands in a Script
The following script demonstrates some common model coverage commands.
This script:
Creates two data files to load before simulation.
Creates two cvtest objects, testObj1 and testObj2, and simulates them using the
default model parameters. Each cvtest object uses the setupCmd property to load a
data file before simulation.
Enables decision, condition, and MCDC coverage.
Retrieves the decision coverage results for the Adjustable Rate Limited subsystem.
Uses cvhtml to display the coverage results for the two tests and the cumulative
coverage.
Compute cumulative coverage with the + operator and save the results
mdl = 'slvnvdemo_ratelim_harness';
mdl_subsys = 'slvnvdemo_ratelim_harness/Adjustable Rate Limiter';
open_system(mdl);
open_system(mdl_subsys);
t_gain = (0:0.02:2.0)'; u_gain = sin(2*pi*t_gain);
t_pos = [0;2]; u_pos = [1;1]; t_neg = [0;2]; u_neg = [-1;-1];
save('within_lim.mat','t_gain','u_gain','t_pos','u_pos', ...
't_neg', 'u_neg');
t_gain = [0;2]; u_gain = [0;4]; t_pos = [0;1;1;2];
u_pos = [1;1;5;5]*0.02; t_neg = [0;2]; u_neg = [0;0];
save('rising_gain.mat','t_gain','u_gain','t_pos','u_pos', ...
't_neg', 'u_neg');
testObj1 = cvtest(mdl_subsys);
testObj1.label = 'Gain within slew limits';
testObj1.setupCmd = 'load(''within_lim.mat'');';
testObj1.settings.mcdc = 1;
testObj1.settings.condition = 1;
testObj1.settings.decision = 1;
testObj2 = cvtest(mdl_subsys);
testObj2.label = 'Rising gain that temporarily exceeds slew limit';
testObj2.setupCmd = 'load(''rising_gain.mat'');';
testObj2.settings.mcdc = 1;
testObj2.settings.condition = 1;
testObj2.settings.decision = 1;
[dataObj1,simOut1] = cvsim(testObj1);
decision_cov1 = decisioninfo(dataObj1,mdl_subsys);
percent_cov1 = 100 * decision_cov1(1) / decision_cov1(2)
cc_cov2 = complexityinfo(dataObj1, mdl_subsys);
[dataObj2,simOut2] = cvsim(testObj2,[0 2]);
Przeglądanie stron 525
1 2 ... 521 522 523 524 525 526 527 528 529 530 531 ... 673 674

Komentarze do niniejszej Instrukcji

Brak uwag