%% Stateflow Chart as Test Harness Scheduler and Source
% This example shows how to use a single Stateflow chart as both a test scheduler
% and source in a test harness. The test harness for the 
% |sltest_autosar_chart.slx| model in this example has already been created. 
%
% |sltest_autosar_chart| is an AUTOSAR composition model of a throttle position
% controller for an automobile. AUTOSAR composition models contain a 
% network of interconnected Model blocks, each of which represents an 
% atomic AUTOSAR software component (ASWC). The Simulink inports and 
% outports represent AUTOSAR ports. The signal lines represent AUTOSAR 
% component connectors.
%
% The inputs that capture the primary and secondary throttle position
% are modeled using an external time series input and are directly fed 
% through the Chart without modification. This modeling style is useful 
% when some stimulus inputs can be modeled and others are only available 
% as externally captured data.
%
% Navigate to a directory with write permissions before running this example.

% Copyright 2019 The MathWorks, Inc.

%% Open the Model
open_system('sltest_autosar_chart')
%% Open the Test Harness
% The test harness has already been created for this example. 
%
% This image shows the portion of the Create Test Harness dialog where 
% |Chart| was selected as both the source and scheduler. You do not need to
% recreate the test harness.
%%
% <<../create_th_dialog_charts.png>>
%%
% To open the harness, use the perspective control in the lower-right 
% corner of the editor canvas and click *Internal Test Harness*.
%%
% <<../open_harness.png>>
%%
% The test harness opens. 
%%
% <<../sf_chart_harness.png>>
%% Open the Stateflow Chart
% Double-click the chart in the test harness to view the scheduling logic.
%%
% <<../sf_chart_src_sch.png>>
%%
% The component under test (the AUTOSAR model) requires the accelerator 
% pedal position sensor input |APP_HwIO_Value|, which is modeled in the 
% chart by three states. 
%
% The |Initialize| state sets the input to a nominal value (170) and the |Run|
% state models a steady acceleration command for 950 ms. The acceleration 
% command is reset to the nominal value in the |Terminate| state. 
%
% The component under test uses the export-function modeling style. (See 
% <docid:simulink_ug#bt170no Export-Function Models Overview>.) When the
% test harness was created, its Stateflow chart was configured to 
% call each root-level Simulink Function block and send a trigger event to 
% each function-call subsystem in the model. In this example, the code to send 
% the trigger events is in each state after the stimulus waveforms
% have been generated. 

%% Run the Model
% Run the model from the test harness. To see the throttle command output, 
% open the Scope in the test harness.
%%
% <<../autosar_scope.png>>
