%% Generating Structured Text for a Stateflow(R) Chart
% 
% This model shows the code generated for a 
% Stateflow chart.  

%   Copyright 2007-2013 The MathWorks, Inc.

%% 
%This model shows the use of a Stateflow chart to implement the 
%control logic for a drive.
mdl = 'plcdemo_stateflow_controller';
open_system(mdl);

%%
%The chart named "TestHarness" provides a test scenario of starting the 
%drive, holding it and resetting it.
open_system('plcdemo_stateflow_controller/TestHarness');


%%
%The chart named "BehaviorModel" provides a simplified behavior model that 
%allows for injecting faults to see how the ControlModule behaves.
open_system('plcdemo_stateflow_controller/BehaviorModel');

%%
% The chart named "ControlModule" contains the control logic and it will be 
% used for PLC code generation. 
open_system('plcdemo_stateflow_controller/ControlModule');

%%
% You can generate PLC Structured Text code for this subsystem by 
% right-clicking on the subsystem block and select 
%    PLC Code -> Generate Code for Subsystem
%
% Alternatively, you can use the following command
% generatedFiles = plcgeneratecode('plcdemo_stateflow_controller/ControlModule');

%%
% After the code generation, the Diagnostic Viewer window 
% is displayed with hyperlinks to the generated code files.
% You can open the generated files by clicking on the links.

