C Dienstschnittstellen
Seit R2022b
Beim Generieren von Code aus einem Komponentenmodell, das eine C Dienstcode-Schnittstellenkonfiguration verwendet, ordnen Sie die Modelldatenelemente entsprechenden Dienstschnittstellen zu. Eine Dienstschnittstelle legt Funktionsprototypen-Informationen und eine Datenkommunikationsmethode (direkter Zugriff, außerhalb der Ausführung oder während der Ausführung) für den generierten Code fest, je nach Anforderungen der Zielplattformdienste. Der Codegenerator wendet bei der Erzeugung von Dienstschnittstellencode Beschränkungen an, sodass dieser einfacher zur Verwendung in einer bestimmten Zielumgebung integriert werden kann. Die Liste der zum Mapping verfügbaren Dienstschnittstellen wird von den im geteilten Embedded Coder Dictionary definierten Schnittstellen bestimmt, das dem Modell angehängt ist. Wenn die Standard-Dienstschnittstellen des Dictionary Ihren Zielplattform-Dienstanforderungen entsprechen, müssen Sie das Mapping nicht ändern und können direkt mit der Generation und Überprüfung des Komponenten-Schnittstellencodes fortfahren.
Tools
| Code Mappings Editor – Service Interface | Associate model elements with code interface definitions |
Objekte
coder.mapping.api.CodeMapping | Model data and function interface configuration for C code generation |
Funktionen
Themen
Grundlagen der Konfiguration
- Service Interface Configuration for Model Interface Elements
Control the representation of model data elements and functions in generated C code by using a service code interface configuration. - Code Definition and Mapping Limitations and Considerations
Restrictions, constraints, and considerations that apply to code definitions and code mappings. - Manage Multiple Code Mappings for a Model
Design models that are platform-neutral and ready to deploy to different run-time environments. - How Generated Code Exchanges Data with an Environment
The generated code exchanges signal, state, and parameter data with the calling environment through a data interface. - Compare Code Mappings of Simulink Models
Compare the mappings of models using the Simulink Comparison Tool.
Konfiguration einer aufrufbaren Funktion
- Periodic and Aperiodic Function Interfaces
Generate callable entry-point functions for the algorithm represented by a top model. - Startup, Reset, and Shutdown Function Interfaces
Generate callable entry-point functions for startup, reset, and shutdown processing represented by a model.
Dienstschnittstellen-Konfiguration
- Service Interfaces
Generate C service interface code for components that interact with target environment resources. - Configure Sender and Receiver Service Interfaces for Model Inports and Outports
Configure sender and receiver service interfaces for model Inports and Outports. - Configure Data Transfer Service Interfaces for Data Transfer Signals
Configure data transfer service interfaces for signals representing data transfers between functions. - Configure Parameter and Parameter Argument Tuning Service Interfaces for Model Parameters and Model Parameter Arguments
Configure parameter and parameter argument tuning service interfaces for model parameters and model parameter arguments. - Configure Measurement Service Interfaces for Signals, States, and Data Stores
Configure measurement services for signals, states, and data stores. - Configure Measurement Service Interface for Persistent Data for States and Data Stores
Configure measurement services for states and data stores that use persistent data. (Seit R2025a) - Configure Timer Service Interfaces
Configure timer services for export functions.
Datenzugriff und Initialisierung
- Reuse Parameter Data in Different Data Type Contexts
Reuse parameter data by creating aSimulink.Parameterobject or numeric MATLAB® variable that you can use in different data type contexts. - Limitations for Block Parameter Tunability in Generated Code
Limitations can prevent a block parameter from appearing in the generated code as tunable, which means you cannot interact with the parameter value after compiling the code. - Access Signal, State, and Parameter Data During Execution
As you iteratively develop a model, capture output signal and state data that model execution generates. Tune parameter values during execution to observe results on the outputs. - Switch Between Sets of Parameter Values During Simulation and Code Execution
Switch between independent sets of values for the same block parameters by storing the sets in an array of structures. - Configure Packaging of Parameter Arguments in Generated Code
Customize the implementation of parameter arguments in generated code. - Control Signal and State Initialization in the Generated Code
Generate code that enables you to store tunable initial conditions in memory, for example, for modeling a system that shuts down and restarts. - Initialization of Signal, State, and Parameter Data in the Generated Code
To match the numerics of a simulation in Simulink®, the generated code assigns initial values to global data, especially for block states and parameters. - Compile Code Conditionally for All Values of Variant Parameters with Same and Different Dimensions
This example shows how to generate a C code that contains all the active and inactive values of variant parameters.





