%% PLC_RemoveSSStep for Distributed Code Generation
% Generate structured text code for different
% components of your model.

% Copyright 2019 The MathWorks, Inc.


%% Open model
% Open the model by using the following command:
open_system('mSystemIntegration');
%% Configure Model Components for Distributed Code Generation
% To autogenerate structured text code with the same |ssMethod| type 
% for every component of your model for external code integration later on,
% use Keep Top-Level ssMethod Name the Same as the Non-Top Level Name.
% For more information, see <docid:plccoder_ug.mw_2e6d7f3d-1497-43fe-9aaa-ed5f8cb90d22
% Keep Top-Level ssmethod Name the Same as the Non-Top Level Name> function.
%% Mark Externally Defined Variables
% # Open the Simulink PLC Coder app.
% For more information, see <docid:plccoder_ref.mw_18cc822d-26bc-48aa-8ab8-3c0bbadb066b
% Simulink PLC Coder app>.
% # Select the |TopSystem| block.
% # Click *Settings*. Navigate to *PLC Code Generation* > *Identifiers*.
% In the |Identifier Names| box enter |Subsystem1,Subsystem2,Subsystem3|.
% # Click *OK*.
%% Code Generation
% # Open the Simulink PLC Coder app.
% For more information, see <docid:plccoder_ref.mw_18cc822d-26bc-48aa-8ab8-3c0bbadb066b
% Simulink PLC Coder app>.
% # Select the |Subsystem1| block.
% # Click *Settings*. Navigate to *PLC Code Generation* > *Identifiers*.
% Select the *Keep top level ssMethod name
% same as non-top level* check box.
% # Click *OK*.
% # Repeat steps 2 through 4 for |SubSystem2|, |SubSystem3|, and
% |TopSystem|.
%% Generate Code for the Subsystem
% To generate code for the individual subsystem use the plcgenerate code function:
%
% plcgeneratecode('mSystemIntegration/TopSystem/SubSystem1');
%
% plcgeneratecode('mSystemIntegration/TopSystem/SubSystem2');
%
% plcgeneratecode('mSystemIntegration/TopSystem/SubSystem3');
%% Generate Code for the Integrated Model
% To generate code for the integrated model:
%
% plcgeneratecode('mSystemIntegration/TopSystem');