Main Content

模拟Autosar基本软件服务和运行时环境

Simulate AUTOSAR component calls to Basic Software memory and diagnostic services by using reference implementations.

Configure Calls to AUTOSAR Basic Software Services

这AUTOSAR standard defines Basic Software (BSW) services that run in the AUTOSAR run-time environment. The services include NVRAM Manager (NvM) Diagnostic Event Manager (Dem), and Function Inhibition Manager (FiM) services. In the AUTOSAR run-time environment, AUTOSAR software components typically access BSW services using client-server or sender-receiver communication.

在您的Autosar软件组件模型中,要实现对NVM,DEM和FIM服务接口的客户呼叫,您可以拖放预先配置的NVM,DEM和FIM呼叫者块。每个块都有预先人居的参数,例如Client port nameandOperation。例如,您可以配置块参数,以选择要调用的服务操作。要在Autosar软件组件中配置添加的呼叫者块,请同步模型。该软件创建AutoSar客户端服务接口,操作和端口,并映射每个Simulink函数调用到AutoSar客户端端口和操作。万博1manbetx有关更多信息,请参阅配置对Autosar NVRAM Manager服务的呼叫,,,,配置对AutoSar诊断事件管理器服务的呼叫,,,,andConfigure Calls to AUTOSAR Function Inhibition Manager Service

Here is a throttle position integration model, which integrates two throttle position sensor components and a throttle position monitor component. The sensor components take a raw throttle position sensor (TPS) value and convert it to a TPS percent value. The monitor component takes the TPS percent values provided by the primary and secondary sensor components and decides which TPS signal to pass through. The sensor components call BSW NvM and Dem services, and the monitor component calls BSW Dem services.

open_system('autosar_bsw_presim');

Sensor componentsautosar_bsw_sensor1andautosar_bsw_sensor2每个都包含一个初始化功能块,该功能块调用NVM服务接口NvMService。这calls are implemented using the Basic Software library blockNVMServiceCaller。每个块配置为调用NvMService手术ReadBlock。这ReadBlock呼叫使用客户端端口s1lowsetpointands2lowsetpoint。这是初始化功能块autosar_bsw_sensor1

Here is the NvMServiceCaller block dialog box for theReadBlock调用初始化功能块。有关更多信息,请参阅NVMServiceCaller

Sensor componentsautosar_bsw_sensor1andautosar_bsw_sensor2each contain two calls to the Dem service interface诊断。两个呼叫均使用基本软件库块实现DiagnosticMonitorCaller。每个块配置为调用诊断手术SetEventStatus。这SetEventStatus呼叫使用客户端端口S1stucklow,,,,S1stuckhigh,,,,S2StuckLow,,,,andS2StuckHigh

Here is the DiagnosticMonitorCaller block dialog box for theStuckLowcall in the first sensor component. For more information, seeDiagnosticMonitorCaller

Monitor componentautosar_bsw_monitor包含对DEM服务界面的调用诊断and four calls to the Dem service interface诊断

  • As in the sensor component, aDiagnosticMonitorCaller块实现诊断call, and it is configured to call theSetEventStatus手术。这client port name isTPS

  • 四个诊断calls are implemented using the Basic Software library block诊断Caller。每个块配置为调用诊断手术GetEventFailed。这GetEventFailed呼叫使用客户端端口TPS1StuckLow,,,,TPS1StuckHigh,,,,tps2stucklow,,,,andtps2stuckhigh

Here is theDiagnosticinfoCallerblock dialog box for theTPS1StuckLow称呼。有关更多信息,请参阅诊断Caller

If you have Simulink Coder and Embedded Coder software, you can generate C code and export ARXML descriptions for the NvM and Dem service calls. Open and build each component model. For example, to build modelautosar_bsw_monitor,打开模型。按Ctrl+Bor enter the MATLAB commandslbuild('autosar_bsw_monitor')

To see the results of the model build, examine the code generation report.

配置AutoSar基本软件服务的参考实现以模拟

To simulate an AUTOSAR component model that calls BSW services, create a containing composition, system, or harness model. In that containing model, provide reference implementations of the NvM, Dem, and FiM service operations called by the component.

Autosar基本软件块库包括一个NVRAM服务组件block and a诊断服务组件block. The blocks provide reference implementations of NvM, Dem, and FiM service operations. To support simulation of component calls to the NvM, Dem, and FiM services, include the blocks in the containing model. You can insert the blocks in either of two ways:

  • 通过创建Simulink测试线束模型自动插入块万博1manbetx

  • 手动将块插入包含的组成,系统或线束模型中

要自动插入调用BSW NVM,DEM和FIM服务的模型的服务组件块,打开模型(或包含模型)并创建Simulink测试测试安全带(需要Simulink测试)。万博1manbetx有关更多信息,请参阅创建测试安全带(万博1manbetxSimulink测试)。Creating a test harness compiles the model, adds the Service Component blocks, and creates ports and other elements required for simulation.

This example manually inserts Service Component blocks for NvM and Dem service calls. Open the integration modelautosar_bsw_presim。使用库浏览器或add_block命令,或通过在模型窗口中键入块名,将NVRAM和诊断服务组件块添加到模型中。

open_system('autosar_bsw_presim');add_block('autosarlibnvm/nvram服务组件',,,,'autosar_bsw_presim/NVRAM Service Component');add_block('autosarlibdem/Diagnostic Service Component',,,,'autosar_bsw_presim/诊断服务组件');set_param('autosar_bsw_presim',,,,“仿真”,,,,'update');

NVRAM服务组件块具有预先置的参数,包括运行时环境(RTE)参数和NVRAM Properties参数。检查参数设置,并根据您使用NVM服务操作的方式考虑是否需要修改。有关更多信息,请参阅NVRAM服务组件

RTE选项卡表列出了组件客户端端口及其映射到NVM服务块ID。表中的每一行都代表从基本软件呼叫者块中呼叫到NVM服务。在同一NVM块上起作用的调用通常使用相同的块ID。此示例映射NVMReadBlock客户端端口到不同的块ID。

诊断服务组件块具有预先人置的参数,包括RTE参数和DEM基于计数器的辩论参数。Examine the parameter settings and consider if any require modifying, based on how you are using the Dem service operations.

基于计数器的辩论参数控制counter-based debounce algorithm provided by the Dem service reference implementations. During multiple simulation runs, you can tune event step size and threshold parameters and observe the effects. For more information, see诊断服务组件

RTE选项卡表列出了组件客户端端口及其映射到DEM或FIM服务ID(在此示例中,事件ID)。表中的每一行都代表从基本软件呼叫者块中拨打DEM服务的调用。在同一事件上行动的调用通常使用相同的事件ID。此示例映射DEMSetEventStatusclient ports to different event IDs, and then maps the DemGetEventFailed与之共享的事件ID的客户端端口SetEventStatus港口s. For example,SetEventStatus港口S1stuckhighandgetfailedevent港口TPS1StuckHigh共享事件ID 1;S1stucklowandTPS1StuckLow共享事件ID 2;等等。

模拟对Autosar NVM和DEM服务的电话

在集成模型中配置了NVRAM和诊断服务组件块后,请模拟该模型。模拟在节气门位置传感器和监视组件模型中练习Autosar NVM和DEM服务呼叫。

open_system('autosar_bsw_simulation');simoutIntegration = sim('autosar_bsw_simulation');

相关链接