PLC_RemoveSSStep for Distributed Code Generation
Generate structured text code for different components of your model.
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 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 Simulink PLC Coder.
Select the
TopSystem
block.Click Settings. Navigate to PLC Code Generation > Identifiers. In the
Identifier Names
box enterSubsystem1,Subsystem2,Subsystem3
.Click OK.
Code Generation
Open the Simulink PLC Coder app. For more information, see Simulink PLC Coder.
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
, andTopSystem
.
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');