Internal Behavior
What You Will Do
In this chapter you add the runnables of both SW-Cs. A runnable is a C function the RTE calls. An access point says which port it uses, and an RTE event says when it runs.
Before You Begin
- Start after finishing SW-Cs and Ports, inside the composition
ECUon the tabVehicleDesign:VFB.
| SW-C | Runnable (NAME, SYMBOL) | Access point | RTE event | Event values |
|---|---|---|---|---|
SwcSensor | Sensor_Cyclic | DataSendPoint from PpSpeed, SyncServerCallPoint from RpScale | TimingEvent SensorCyclicTiming | PERIOD 0.02 s |
SwcActuator | Actuator_Init | InitEvent ActuatorInitEvent | ||
SwcActuator | Actuator_OnData | DataReceivedPoint from RpSpeed | DataReceivedEvent ActuatorOnDataEvent | R-PORT RpSpeed, DATA ELEMENT speed |
SwcActuator | Actuator_GetScale | OperationInvokedEvent ActuatorGetScaleEvent | P-PORT PpScale, OPERATION GetScale |
Actuator_GetScale also gets CAN BE INVOKED = TRUE.
SwcSensor
-
Double-click
SwcSensor. The SWC Internal Behavior [SwcSensor] window opens. -
Right-click the SW-C body and click Add Runnable. Click Auto Layout in the window's toolbar if the runnable overlaps a port.

Figure 5-1. ① Add Runnable.
-
Click the runnable, then enter
Sensor_Cyclicin NAME and SYMBOL. -
Hold
Shiftand drag from the portPpSpeedto the runnable. Click DataSendPoint in the menu that opens.
Figure 5-2. ① DataSendPoint.
-
Hold
Shiftand drag from the portRpScaleto the runnable, and click SyncServerCallPoint.
Figure 5-3. ① SyncServerCallPoint.
ACCESS POINTS now lists
Rte_Write_PpSpeed_speedandRte_Call_RpScale_GetScale. These are the RTE functions the runnable can call. You write the calls yourself. -
Click the runnable again, click + on the RTE EVENTS header, and click TimingEvent.

Figure 5-4. ① + (Add RTE Event), ② TimingEvent.
-
Enter
SensorCyclicTimingin NAME and0.02in PERIOD, leaving the unit ats.
Figure 5-5. ① NAME, ② PERIOD.
-
Click Auto Layout, and click an empty spot of the canvas. Save with
Ctrl+Sand click Close.
Figure 5-6.
SwcSensorwith its runnable and access points.
SwcActuator
Double-click SwcActuator and add its three runnables from the table in the same way.
-
For
Actuator_OnData, the DataReceivedEvent asks for a port and a data element. Pick them first, then enter the event's NAME.
Figure 5-7. ① R-PORT, ② DATA ELEMENT.
-
For
Actuator_GetScale, click TRUE under CAN BE INVOKED.
Figure 5-8. ① TRUE.
-
The OperationInvokedEvent asks for a port and an operation.

Figure 5-9. ① P-PORT, ② OPERATION.
-
Click Auto Layout, click an empty spot of the canvas, save with
Ctrl+Sand click Close. Save the tab withCtrl+Sas well.
Figure 5-10.
SwcActuatorwith its three runnables.
Caution. Do not leave out TRUE on
Actuator_GetScale. Chapter 8 leaves its event unmapped to any task, and the code generator accepts that only for a server runnable that can be called concurrently. Otherwise generation stops withRTE_CS_SERVER_UNMAPPED_NOT_CONCURRENT.
Why Is It Designed This Way?
Sensor_Cyclicruns on a timer. The RTE starts it every 20 ms, and the access points allow it to write the speed and ask for the scale. The calls themselves are code you write later.Actuator_OnDataruns on arrival. It does not poll: the event starts it whenspeedarrives.Actuator_Initruns once at start. It is the place for one-time setup.Actuator_GetScaleruns when called. It runs directly inside the caller's call, without a task of its own.
Checklist
-
SwcSensorhas the runnableSensor_Cyclicwith two access points and the eventSensorCyclicTiming. -
SwcActuatorhas the runnablesActuator_Init,Actuator_OnDataandActuator_GetScale, each with its event. -
Actuator_GetScaleshows TRUE under CAN BE INVOKED.
Next Step
In PRTE Setup you bring in the BSW modules and set the start-up modules EcuM, BswM, Mcu and Det.