Configure AUTOSAR Runnables and Events
The internal behavior of an AUTOSAR software component is implemented by a set of runnable entities (runnables). A runnable is a sequence of operations provided by the component that can be started by the run-time environment (RTE). The component configures an event to activate each runnable – for example, a timing event, data received, a client request, a mode change, component startup or shutdown, or a trigger.
In Simulink®, you can configure these types of AUTOSAR events.
Event Type | Workflow | Example |
---|---|---|
DataReceivedEvent | Sender-receiver (S-R) communication | Programmatically Configure AUTOSAR Runnables and Events |
DataReceiveErrorEvent | Sender-receiver (S-R) communication | Configure AUTOSAR Receiver Port for DataReceiveErrorEvent |
ExternalTriggerOccurredEvent | External trigger event communication | Configure Receiver for AUTOSAR External Trigger Event Communication |
InitEvent | Activation of initialization runnable | Configure AUTOSAR Initialization Runnable (R4.1) |
ModeSwitchEvent | Mode-switch (M-S) communication | Configure AUTOSAR Mode-Switch Communication |
OperationInvokedEvent | Client-server (C-S) communication | Configure AUTOSAR Client-Server Communication |
TimingEvent | Periodic activation of runnable | Programmatically Configure AUTOSAR Runnables and Events |
To configure an AUTOSAR runnable in Simulink:
Open a model that is configured for AUTOSAR code generation. This example uses a writable copy of the example model
autosar_swc
.In the model, create or identify a root-level Simulink subsystem or function that implements a sequence of operations. The subsystem or function must generate an entry-point function in C code. In
autosar_swc
, the subsystem SS1 generates rate-based model step functionRunnable_1s
.Create or identify an AUTOSAR runnable to which to map the Simulink entry point function. Open the AUTOSAR Dictionary. Expand AtomicComponents, expand the component, and select the Runnables view. If you need to create a new AUTOSAR runnable, click the plus sign. The model
autosar_swc
contains the periodic runnableRunnable_1s
.Select the row containing the runnable and configure its properties, including name and symbol. The AUTOSAR runnable symbol-name that you specify is exported in ARXML descriptions and C code. For an AUTOSAR server runnable, set the runnable property
canBeInvokedConcurrently
to designate whether to enforce concurrency constraints. For non-server runnables, leavecanBeInvokedConcurrently
set tofalse
. For more information, see Concurrency Constraints for AUTOSAR Server Runnables.Configure an event to activate the runnable. Go to the Events pane for the selected runnable. If you need to create an event, click Add Event. Enter an event name and set the event type.
The steps to configure an event depend on the type of event. If the event relies on a communication interface, such as data received (sender-receiver) or client request (client-server), you must first configure the communication interface before configuring the event.
In the model
autosar_swc
, the periodic runnableRunnable_1s
is activated by aTimingEvent
namedEvent_1s
.Map the Simulink entry-point function to the AUTOSAR runnable. Open the Code Mappings editor and select the Functions tab. For model
autosar_swc
, select the periodic function with a 1s sample time and map it to AUTOSAR runnableRunnable_1s
.
To see the results of AUTOSAR runnable and event configuration in ARXML descriptions and C code, build the model.
If an AUTOSAR software component model contains multiple runnables, you can configure the order in which runnables execute. For more information, see Configure AUTOSAR Runnable Execution Order.
Related Examples
- Configure AUTOSAR Runnable Execution Order
- Import AUTOSAR XML Descriptions Into Simulink
- Modeling Patterns for AUTOSAR Runnables
- Model AUTOSAR Software Components
- Configure AUTOSAR Code Generation