メインコンテンツまでスキップ

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 ECU on the tab VehicleDesign:VFB.
SW-CRunnable (NAME, SYMBOL)Access pointRTE eventEvent values
SwcSensorSensor_CyclicDataSendPoint from PpSpeed, SyncServerCallPoint from RpScaleTimingEvent SensorCyclicTimingPERIOD 0.02 s
SwcActuatorActuator_InitInitEvent ActuatorInitEvent
SwcActuatorActuator_OnDataDataReceivedPoint from RpSpeedDataReceivedEvent ActuatorOnDataEventR-PORT RpSpeed, DATA ELEMENT speed
SwcActuatorActuator_GetScaleOperationInvokedEvent ActuatorGetScaleEventP-PORT PpScale, OPERATION GetScale

Actuator_GetScale also gets CAN BE INVOKED = TRUE.

SwcSensor​

  1. Double-click SwcSensor. The SWC Internal Behavior [SwcSensor] window opens.

  2. Right-click the SW-C body and click Add Runnable. Click Auto Layout in the window's toolbar if the runnable overlaps a port.

    The Add Runnable item

    Figure 5-1. ① Add Runnable.

  3. Click the runnable, then enter Sensor_Cyclic in NAME and SYMBOL.

  4. Hold Shift and drag from the port PpSpeed to the runnable. Click DataSendPoint in the menu that opens.

    Choosing DataSendPoint

    Figure 5-2. ① DataSendPoint.

  5. Hold Shift and drag from the port RpScale to the runnable, and click SyncServerCallPoint.

    Choosing SyncServerCallPoint

    Figure 5-3. ① SyncServerCallPoint.

    ACCESS POINTS now lists Rte_Write_PpSpeed_speed and Rte_Call_RpScale_GetScale. These are the RTE functions the runnable can call. You write the calls yourself.

  6. Click the runnable again, click + on the RTE EVENTS header, and click TimingEvent.

    The Add RTE Event menu

    Figure 5-4. ① + (Add RTE Event), ② TimingEvent.

  7. Enter SensorCyclicTiming in NAME and 0.02 in PERIOD, leaving the unit at s.

    The TimingEvent values

    Figure 5-5. ① NAME, ② PERIOD.

  8. Click Auto Layout, and click an empty spot of the canvas. Save with Ctrl+S and click Close.

    The finished SwcSensor

    Figure 5-6. SwcSensor with its runnable and access points.

SwcActuator​

Double-click SwcActuator and add its three runnables from the table in the same way.

  1. For Actuator_OnData, the DataReceivedEvent asks for a port and a data element. Pick them first, then enter the event's NAME.

    The DataReceivedEvent values

    Figure 5-7. ① R-PORT, ② DATA ELEMENT.

  2. For Actuator_GetScale, click TRUE under CAN BE INVOKED.

    The concurrency setting

    Figure 5-8. ① TRUE.

  3. The OperationInvokedEvent asks for a port and an operation.

    The OperationInvokedEvent values

    Figure 5-9. ① P-PORT, ② OPERATION.

  4. Click Auto Layout, click an empty spot of the canvas, save with Ctrl+S and click Close. Save the tab with Ctrl+S as well.

    The finished SwcActuator

    Figure 5-10. SwcActuator with 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 with RTE_CS_SERVER_UNMAPPED_NOT_CONCURRENT.

Why Is It Designed This Way?​

  • Sensor_Cyclic runs 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_OnData runs on arrival. It does not poll: the event starts it when speed arrives.
  • Actuator_Init runs once at start. It is the place for one-time setup.
  • Actuator_GetScale runs when called. It runs directly inside the caller's call, without a task of its own.

Checklist​

  • SwcSensor has the runnable Sensor_Cyclic with two access points and the event SensorCyclicTiming.
  • SwcActuator has the runnables Actuator_Init, Actuator_OnData and Actuator_GetScale, each with its event.
  • Actuator_GetScale shows 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.