%% Reuse Desktop Test Case for Real-Time Testing
% This example shows a basic desktop test case reuse workflow using external input data defined in an Excel file. You run the baseline test case on the desktop, update the baseline data, convert a copy of the test case to a real-time test, then run the test case on a target computer. The test file, baseline data, and Excel input data file are provided. This example runs only on Windows systems.
%% Open the Test Manager and Test File
% The test file runs a transmission shift controller algorithm through four iterations, each corresponding to a different test scenario: passing, gradual acceleration, hard braking, and coasting. Baseline data associated with each scenario for the signals vehicle speed and output torque.

tf = sltest.testmanager.TestFile('sltestTestCaseRealTimeReuseExample.mldatx');
sltest.testmanager.load(tf.Name);
sltest.testmanager.view;

%
%% Run the Baseline Test and View Results
% Click Run in the toolbar.
% When the test finishes running, select output torque under Baseline Criteria Result to view the comparison. The Passing result fails due to transient signals that fall outside the relative tolerance.
%
%% Update the Baseline
% Assume that the transient signals are not significant, and update the baseline data:
% Click Next Failure. The first failure region is bounded by data cursors.
% Click Update Baseline > Replace Signal Segment in Baseline File from the toolstrip, and confirm that you want to overwrite the data.
% Repeat this process for the other two failure regions.
%% Convert Baseline Test to Real-Time Test
% In the Test Browser, right-click Baseline Test and select Copy.
% Paste the new test case under the test suite.
% Rename the new test case RT Baseline Test.
% Right-click RT Baseline Test and select Convert to > Real-Time Test.
%% Run the Real-Time Test Case
% Set the Target Computer.
% Set the system under test to load from Model.
% Run the RT Baseline Test test case.
%% Examine and Resolve Test Failures
% In this example, several of the scenarios fail due to timing impacts on the data output. For example, in the HardBrake iteration, the vehicle speed output falls outside the relative tolerance after the brake is applied. To resolve this failure, you could:
% Increase the relative tolerance for the real-time test.
% Create a separate set of baseline data for the real-time test.
%
%
% Copyright 2021 The MathWorks, Inc.