www.gusucode.com > ecoder 案例源码程序 matlab代码 > ecoder/GenerateAUTOSARCodeForMultipleRunnableEntitiesExample.m
%% Generate AUTOSAR-Compliant Code for Multiple Runnable Entities % Cnfigure and generate AUTOSAR-compliant code and export AUTOSAR software component % description XML files for a Simulink(R) model with multiple runnable entities. % Copyright 1990-2016 The MathWorks, Inc. %% Prerequisites % The Embedded Coder Support Package for AUTOSAR Standard is required for % working with the model in this example. % % <matlab:matlab.addons.supportpackage.internal.explorer.showSupportPackages({'EC_AUTOSAR'},'autosar_doc') Install the AUTOSAR Standard Support Package> % % <matlab:helpview(fullfile(docroot,'matlab','helptargets.map'),'rttsetup') Support Package Installation> %% Overview of Multiple Runnable Support % You can use the rtwdemo_autosar_multirunnables model to see how to construct a % Simulink model to designate multiple runnable entities. % % * Open the model rtwdemo_autosar_multirunnables. % % Model defines modelName = 'rtwdemo_autosar_multirunnables'; % open the model open_system( modelName ); %% Designate Multiple Runnable Entities % The model rtwdemo_autosar_multirunnables represents an AUTOSAR atomic software % component. You can see the multiple runnable entities that compose the atomic % software component. Each function-call subsystem defines a runnable % entity. This model contains three function-call subsystems: Runnable1, % Runnable2, and Runnable3. An additional runnable entity aggregating the % initialization functions for each of the function-call subsystems is also % created at code generation. %% Define Inter-Runnable Variables % Inter-runnable variables provide data consistency between runnable % entities. You define these variables through the signals that connect the % entities. Label the signals with their inter-runnable variable % names. This model has four inter-runnable variables: irv1, irv2, irv3, and irv4. % You may route inter-runnable variables through Goto and From blocks, as well % as through virtual subsystem boundaries. However, check that % labels on the respective line segments are consistent. %% Configure Model as AUTOSAR Component Using the Configure AUTOSAR Interface Dialog Box % <matlab:helpview(fullfile(docroot,'toolbox','ecoder','helptargets.map'),'autosar_interface_dialog_box') Overview of the Configure AUTOSAR Interface dialog box> % % # Click the *Code* menu and select *C/C++ Code* > *Configure Model % as AUTOSAR Component*. % # In the Simulink-AUTOSAR Mapping Explorer, configure the mapping of Simulink % inports, outports, entry point functions, and data transfers. % # In the AUTOSAR Properties Explorer, configure the AUTOSAR ports, % runnables, events, inter-runnable variables, interfaces, % computational methods, and XML options. % # After making changes, click *Validate* to confirm % that the changes conform to AUTOSAR identifier naming conventions. % % An alternative method to change the AUTOSAR configuration is to modify % programmatically using methods in the autosar.api package. help autosar.api.getAUTOSARProperties; help autosar.api.getSimulinkMapping; %% Generate AUTOSAR-Compliant Code % Click the *Code* menu and select *C/C++ Code* > *Build Model*. % % An alternative method to generate AUTOSAR-compliant code from the model is % to press Ctrl-B, or use the following command. rtwbuild( modelName ); %% Further Information % % <matlab:helpview(fullfile(docroot,'toolbox','ecoder','helptargets.map'),'ecoder_autosar_doc') Embedded Coder AUTOSAR documentation>