Create Simulink Behavior Model
Create Simulink behavior models from the architecture model created in the previous step for the main application and service components. The behavior models serve as empty shells where the algorithms for each component are inserted. Copy the necessary logic for functionality of the new software component from the signal-based model to the corresponding behavior model.
To open the completed model, run this command.
open("EVPwrCntrllrEMSysFinal.slx");
Create Behavior Model for Service Components
To create the Simulink behavior models for the service components:
To create the empty shell with blocks that represent the client-server interface, right-click a service component box and select Create Simulink Behavior.
In the Create Simulink behavior dialog box specify a filename and location to save the shell model. Click OK.
Open the shell model subsystem.
Paste the logic required for the service component functionality from the signal-based model to the shell model.
Repeat these steps for each service component.
You can find the completed service component behavior models for this example in
the CreateSimulinkBehaviorModel/ServiceComponent
folder.
Create Behavior Model for Main Application
To create the behavior model for the main application:
To create the empty shell with blocks that represent the client-server interface, right-click on the application component box and select Create Simulink Behavior.
In the Create Simulink behavior dialog box specify a filename and location to save the shell model. Click OK.
Open the shell model subsystem.
Subsystems for each service are created in the application behavior model that contain a Function Caller block.
The Function prototype parameter is set according to the function prototype definitions added to the Interface Editor in the previous step.
Copy the required logic from the signal-based model to the Simulink behavior model.
In this example, the logic needed to generate brake and torque commands is copied to the Simulink behavior model.
Connect the service call outs to the application component logic.
In this example, the service call outs are grouped in pre-algorithm and post-algorithm subsystems and connected to the energy management logic to match the original software intent.
Note
This example creates the behavior model using an export-function model. You can also create the behavior model using a rate-based model when implementing a call to a synchronous service. For more information, see Implement Behavior of Functions Using Simulink (System Composer).
In this high-level overview of the connected subsystems, the pre-algorithm and post-algorithm subsystems are highlighted in blue, and the main application subsystem is highlighted in green.
You can find the completed application component behavior model for this example
in the CreateSimulinkBehaviorModel/ApplicationComponent
folder.
See Also
Topics
- System Composer Concepts (System Composer)
- Author Software Architectures (System Composer)
- Create Rate-Based Model