%% Generating Structured Text for a Hierarchical Simulink(R) Subsystem with Virtual Subsystems
% 
% This introductory model shows the code generated for a 
% hierarchical subsystem consisting of other Simulink subsystems.  

%   Copyright 2012-2013 The MathWorks, Inc.

mdl = 'plcdemo_hierarchical_virtual_subsystem';
open_system(mdl);

%%
% This model contains a hierarchical subsystem containing other virtual subsystems.
open_system('plcdemo_hierarchical_virtual_subsystem/HierarchicalSubsystem');

%%
% 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_hierarchical_virtual_subsystem/HierarchicalSubsystem');

%%
% 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.