Use FMU Components with Architectural Data in Architecture Models - MATLAB & Simulink (original) (raw)
Main Content
This example shows how to link an FMU file to a component in System Composer™ to specify and view its architectural data.
Link FMU to Component in System Composer
Create a new System Composer model, add a new component f14comp
, and then link to the FMU file, f14.fmu
, from the component.
model = systemcomposer.createModel("archModel"); systemcomposer.openModel("archModel"); arch = get(model,"Architecture"); comp = addComponent(arch,"f14comp"); fmuHandle = linkToFMU(comp,"f14.fmu");
Inspect Ports and Interfaces on FMU Component
When your FMU component has ports with interfaces, you can inspect those interfaces for compatibility to connected ports. For each port on the f14comp
component, you cannot set a shared data interface. FMU components support read-only owned interfaces local to the port defined from the underlying FMU file. FMU ports without owned interfaces inherit from other connected ports.
portA = getPort(comp,"u"); portB = getPort(comp,"alpha_rad"); portC = getPort(comp,"Nz_pilot_g");
You can view owned interfaces assigned to the FMU component using Port Interface View in the Interface Editor, or this line of code.
portA.ArchitecturePort.Interface
ans =
0×0 DataInterface array with properties:
Name
Description
Owner
Elements
Model
UUID
ExternalUID
Apply Stereotypes to FMU Component
Generate a profile with a component stereotype.
profile = systemcomposer.profile.Profile.createProfile("LatencyProfile"); stereotype = addStereotype(profile,"electricalComponent",AppliesTo="Component");
Apply the profile to the model and the FMU file, then apply the electricalComponent
stereotype to the FMU component.
applyProfile(model,"LatencyProfile"); applyProfile(comp.Architecture,"LatencyProfile"); applyStereotype(comp,"LatencyProfile.electricalComponent");
Select the f14comp
component, and observe the electricalComponent
stereotype in the Property Inspector.
Note: Exporting an FMU from a Simulink model requires Simulink Compiler™ and the FMU Builder for Simulink Support Package.
load_system('f14') set_param('f14',SolverType='Fixed-step') exportToFMU('f14',SaveSourceCodeToFMU='on',ExportedParameters={''},FMIVersion='3.0',FMUType='CS', ... CreateModelAfterGeneratingFMU='off')