RTA Knowledge Base

We are going to describe how to create a BswM rule. In particular, we are going to refer the creation of the BswM rule that we performed to implement and test a specific requirement of the SUSD module

The problem

Concerning the SUSD module, the team had to implement and test the following requirement: 

[SUM-1708] SUM_SUSD shall implement an interface, BattCharge_DisableWkups, to BswM that can enable or disable local wakeups when the Battery State of Charge is low.


Implementation

We implemented the requirement as depicted in the following scheme:


In brief:

  1. The SUM_SUSD receives a notification about the Vehicle Battery State of Charge through the VehicleBatteryStateOfCharge boolean S/R interface.
  2. If the VehicleBatteryStateOfCharge is LOW, the SUM_SUSD asks the BswM to set the mode to DisableWakeups; otherwise, it asks the BswM to set the mode to EnableWakeups. In both cases, the notification is sent to the BswM through an S/R port.
  3. The BswM receives the notification through the S/R interface (that is used to implement a ModeRequestPort) and evaluates the status of other possible ModeRequestPorts. In particular, for each ModeRequestPort related to the rule, the BswM defines a condition. In our case, the condition related to the ModeRequestPort is TRUE if the value read is equal to DisableWakeups (which we set equal to boolean TRUE); otherwise, the condition is FALSE.
  4. A Logical Expression is built from the mode conditions.  This can be obtained by performing the logical AND or logical OR of all the mode conditions related to this rule.
  5. If the Logical Expression is TRUE, the BswM executes the Action List (TRUE). This Action List includes a set of Actions. We necessarily require only one Action that is RteSwitch (DisableWakeups)  which consists of switching the mode to DisableWakeups. However, the user may define other actions to be executed when the Logical Expression is TRUE.
  6. If the Logical Expression is FALSE, the BswM executes the Action List (FALSE). This Action List includes a set of Actions. We necessarily require only one Action that is RteSwitch (EnableWakeups)  which consists of switching the mode to EnableWakeups. However, the user may define other actions to be executed when the Logical Expression is FALSE.
  7. The SUM_SUSD reads the mode through a Mode Switch interface and if the mode is DisableWakeups, it starts ignoring local wakeups. 


SWCD modification

We defined an implementation data type in the SUSD SWCD file such that:


        <IMPLEMENTATION-DATA-TYPE>
          <SHORT-NAME>BswMDisablingEnablingWakeupType</SHORT-NAME>
          <CATEGORY>TYPE_REFERENCE</CATEGORY>
          <SW-DATA-DEF-PROPS>
            <SW-DATA-DEF-PROPS-VARIANTS>
              <SW-DATA-DEF-PROPS-CONDITIONAL>
                <IMPLEMENTATION-DATA-TYPE-REF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_PlatformTypes/ImplementationDataTypes/boolean</IMPLEMENTATION-DATA-TYPE-REF>
              </SW-DATA-DEF-PROPS-CONDITIONAL>
            </SW-DATA-DEF-PROPS-VARIANTS>
          </SW-DATA-DEF-PROPS>
        </IMPLEMENTATION-DATA-TYPE>

We also created a Sender-Receiver interface which makes use of the implementation data type defined above:

        <SENDER-RECEIVER-INTERFACE>
              <SHORT-NAME>BatteryCharge_DisableWkups</SHORT-NAME>
              <IS-SERVICE>false</IS-SERVICE>
              <DATA-ELEMENTS>
                <VARIABLE-DATA-PROTOTYPE>
                  <SHORT-NAME>SUSD_BswM_DisableWkups</SHORT-NAME>
                  <TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE">/SUM_SUSD/BswMDisablingEnablingWakeupType</TYPE-TREF>
                </VARIABLE-DATA-PROTOTYPE>
              </DATA-ELEMENTS>
        </SENDER-RECEIVER-INTERFACE>


Moreover, we created a PPort (which is used to require the mode switch to the BswM) and required the access to this port in the RE_SUSD_BatteryNotifications runnable :

            <P-PORT-PROTOTYPE>
              <SHORT-NAME>PP_SUSD_BatteryCharge_DisableWkups</SHORT-NAME>
              <PROVIDED-INTERFACE-TREF DEST="SENDER-RECEIVER-INTERFACE">/SUM_SUSD/BatteryCharge_DisableWkups</PROVIDED-INTERFACE-TREF>
            </P-PORT-PROTOTYPE>


            <PORT-API-OPTION>
              <ENABLE-TAKE-ADDRESS>true</ENABLE-TAKE-ADDRESS>
              <INDIRECT-API>false</INDIRECT-API>
              <PORT-REF DEST="P-PORT-PROTOTYPE">/SUM_SUSD/SUSD/PP_SUSD_BatteryCharge_DisableWkups</PORT-REF>
            </PORT-API-OPTION>
                    <VARIABLE-ACCESS>
                      <SHORT-NAME>DSP_BatteryCharge_DisableWkups</SHORT-NAME>
                      <ACCESSED-VARIABLE>
                        <AUTOSAR-VARIABLE-IREF>
                          <PORT-PROTOTYPE-REF DEST="P-PORT-PROTOTYPE">/SUM_SUSD/SUSD/PP_SUSD_BatteryCharge_DisableWkups</PORT-PROTOTYPE-REF>
                          <TARGET-DATA-PROTOTYPE-REF DEST="VARIABLE-DATA-PROTOTYPE">/SUM_SUSD/BatteryCharge_DisableWkups/SUSD_BswM_DisableWkups</TARGET-DATA-PROTOTYPE-REF>
                        </AUTOSAR-VARIABLE-IREF>
                      </ACCESSED-VARIABLE>
                    </VARIABLE-ACCESS>

We created a Mode Declaration Group and we included the mapping between the new created  Mode Declaration Group and the implementation data type uint8 into a Data Type Mapping Set:

        <MODE-DECLARATION-GROUP>
          <SHORT-NAME>SUSD_BswM_Wakeup_Enable_MDG</SHORT-NAME>
		  <CATEGORY>EXPLICIT_ORDER</CATEGORY>
          <INITIAL-MODE-REF DEST="MODE-DECLARATION">/SUM_SUSD/SUSD_BswM_Wakeup_Enable_MDG/ENABLE_WAKEUPS</INITIAL-MODE-REF>
          <MODE-DECLARATIONS>
            <MODE-DECLARATION>
              <SHORT-NAME>ENABLE_WAKEUPS</SHORT-NAME>
              <VALUE>0</VALUE>
            </MODE-DECLARATION>
            <MODE-DECLARATION>
              <SHORT-NAME>DISABLE_WAKEUPS</SHORT-NAME>
              <VALUE>1</VALUE>
            </MODE-DECLARATION>
          </MODE-DECLARATIONS>
        </MODE-DECLARATION-GROUP> 
            <MODE-REQUEST-TYPE-MAP>
              <IMPLEMENTATION-DATA-TYPE-REF DEST="IMPLEMENTATION-DATA-TYPE">/AUTOSAR_PlatformTypes/ImplementationDataTypes/uint8</IMPLEMENTATION-DATA-TYPE-REF>
              <MODE-GROUP-REF DEST="MODE-DECLARATION-GROUP">/SUM_SUSD/SUSD_BswM_Wakeup_Enable_MDG</MODE-GROUP-REF>
            </MODE-REQUEST-TYPE-MAP>

We also created a Mode Switch Interface which makes use of the above Mode Declaration Group

        <MODE-SWITCH-INTERFACE>
          <SHORT-NAME>MSI_BswM_SUSD_Disable_Wakeups</SHORT-NAME>
          <IS-SERVICE>false</IS-SERVICE>
          <MODE-GROUP>
            <SHORT-NAME>SUSD_BswM_Wakeup_Enable_MDG</SHORT-NAME>
            <TYPE-TREF DEST="MODE-DECLARATION-GROUP">/SUM_SUSD/SUSD_BswM_Wakeup_Enable_MDG</TYPE-TREF>
          </MODE-GROUP>
        </MODE-SWITCH-INTERFACE>

and an R-Port which makes use of the above interface and guaranteed access to this port for several runnables:

            <R-PORT-PROTOTYPE>
              <SHORT-NAME>RP_BswM_SUSD_BatteryCharge_Disable_Wakeups</SHORT-NAME>
              <REQUIRED-INTERFACE-TREF DEST="MODE-SWITCH-INTERFACE">/SUM_SUSD/MSI_BswM_SUSD_Disable_Wakeups</REQUIRED-INTERFACE-TREF>
            </R-PORT-PROTOTYPE>
            <PORT-API-OPTION>
              <ENABLE-TAKE-ADDRESS>true</ENABLE-TAKE-ADDRESS>
              <INDIRECT-API>false</INDIRECT-API>
              <PORT-REF DEST="R-PORT-PROTOTYPE">/SUM_SUSD/SUSD/RP_BswM_SUSD_BatteryCharge_Disable_Wakeups</PORT-REF>
            </PORT-API-OPTION>
                  <MODE-ACCESS-POINTS>
                    <MODE-ACCESS-POINT>
                      <MODE-GROUP-IREF>
                        <R-MODE-GROUP-IN-ATOMIC-SWC-INSTANCE-REF>
                          <CONTEXT-R-PORT-REF DEST="R-PORT-PROTOTYPE">/SUM_SUSD/SUSD/RP_BswM_SUSD_BatteryCharge_Disable_Wakeups</CONTEXT-R-PORT-REF>
                          <TARGET-MODE-GROUP-REF DEST="MODE-DECLARATION-GROUP-PROTOTYPE">/SUM_SUSD/MSI_BswM_SUSD_Disable_Wakeups/SUSD_BswM_Wakeup_Enable_MDG</TARGET-MODE-GROUP-REF>
                        </R-MODE-GROUP-IN-ATOMIC-SWC-INSTANCE-REF>
                      </MODE-GROUP-IREF>
                    </MODE-ACCESS-POINT>
                  </MODE-ACCESS-POINTS>

In particular, we defined a new runnable:

                <RUNNABLE-ENTITY>
                  <SHORT-NAME>Runnable_SUSD_BswM_Wakeup_Enable</SHORT-NAME>
                  <MODE-ACCESS-POINTS>
                    <MODE-ACCESS-POINT>
                      <MODE-GROUP-IREF>
                        <R-MODE-GROUP-IN-ATOMIC-SWC-INSTANCE-REF>
                          <CONTEXT-R-PORT-REF DEST="R-PORT-PROTOTYPE">/SUM_SUSD/SUSD/RP_BswM_SUSD_BatteryCharge_Disable_Wakeups</CONTEXT-R-PORT-REF>
                          <TARGET-MODE-GROUP-REF DEST="MODE-DECLARATION-GROUP-PROTOTYPE">/SUM_SUSD/MSI_BswM_SUSD_Disable_Wakeups/SUSD_BswM_Wakeup_Enable_MDG</TARGET-MODE-GROUP-REF>
                        </R-MODE-GROUP-IN-ATOMIC-SWC-INSTANCE-REF>
                      </MODE-GROUP-IREF>
                    </MODE-ACCESS-POINT>
                  </MODE-ACCESS-POINTS>
                  <SYMBOL>RE_SUSD_BswM_Wakeup_Enable</SYMBOL>
                </RUNNABLE-ENTITY>

and a new event to trigger the runnable:

                <SWC-MODE-SWITCH-EVENT>
                  <SHORT-NAME>MSE_SUSD_BswM_Wakeup_Enable</SHORT-NAME>
                  <START-ON-EVENT-REF DEST="RUNNABLE-ENTITY">/SUM_SUSD/SUSD/IB_SUSD/Runnable_SUSD_BswM_Wakeup_Enable</START-ON-EVENT-REF>
                  <ACTIVATION>ON-TRANSITION</ACTIVATION>
                  <MODE-IREFS>
                    <MODE-IREF>
                      <CONTEXT-PORT-REF DEST="R-PORT-PROTOTYPE">/SUM_SUSD/SUSD/RP_BswM_SUSD_BatteryCharge_Disable_Wakeups</CONTEXT-PORT-REF>
                      <CONTEXT-MODE-DECLARATION-GROUP-PROTOTYPE-REF DEST="MODE-DECLARATION-GROUP-PROTOTYPE">/SUM_SUSD/MSI_BswM_SUSD_Disable_Wakeups/SUSD_BswM_Wakeup_Enable_MDG</CONTEXT-MODE-DECLARATION-GROUP-PROTOTYPE-REF>
                      <TARGET-MODE-DECLARATION-REF DEST="MODE-DECLARATION">/SUM_SUSD/SUSD_BswM_Wakeup_Enable_MDG/DISABLE_WAKEUPS</TARGET-MODE-DECLARATION-REF>
                    </MODE-IREF>
					<MODE-IREF>
                      <CONTEXT-PORT-REF DEST="R-PORT-PROTOTYPE">/SUM_SUSD/SUSD/RP_BswM_SUSD_BatteryCharge_Disable_Wakeups</CONTEXT-PORT-REF>
                      <CONTEXT-MODE-DECLARATION-GROUP-PROTOTYPE-REF DEST="MODE-DECLARATION-GROUP-PROTOTYPE">/SUM_SUSD/MSI_BswM_SUSD_Disable_Wakeups/SUSD_BswM_Wakeup_Enable_MDG</CONTEXT-MODE-DECLARATION-GROUP-PROTOTYPE-REF>
                      <TARGET-MODE-DECLARATION-REF DEST="MODE-DECLARATION">/SUM_SUSD/SUSD_BswM_Wakeup_Enable_MDG/ENABLE_WAKEUPS</TARGET-MODE-DECLARATION-REF>
                    </MODE-IREF>
                  </MODE-IREFS>
                </SWC-MODE-SWITCH-EVENT>

This event triggers the runnable when the mode switches from DISABLE_WAKEUPS to ENABLE_WAKEUPS.

Static code modification

We are not going to describe all the modifications to the static code but we want to highlight that we added the following functions:

FUNC(void, SUSD_CODE) SUSD_BswM_VehicleBatteryStateOfCharge(void)
{
	/* Satisfies: [$SDD_SUSD 167]*/
	BatteryStateOfChargeType BatteryCharge;
	(void)Rte_Read_RP_SUSD_BatteryStateOfCharge_BatteryStateOfCharge(&BatteryCharge);
	if(BatteryCharge==SOC_LOW)
	{
       (void)Rte_Write_PP_SUSD_BatteryCharge_DisableWkups_SUSD_BswM_DisableWkups(SUSD_BSWM_DISABLE_WAKEUPS);
	}
	else
	{
	   (void)Rte_Write_PP_SUSD_BatteryCharge_DisableWkups_SUSD_BswM_DisableWkups(SUSD_BSWM_ENABLE_WAKEUPS);
	}

}
FUNC(void, SUSD_CODE) RE_SUSD_BswM_Wakeup_Enable(void)
{
	UpdateWakeUpStatusAfterBatteryLow();
}

Moreover, we want to point out that the SUSD checks the mode in the following function:

FUNC(void, SUSD_CODE) Processing_new_activated_deactivated_wakeup(uint32 WakeupSrc, uint32 WakeupStatus)
{
#if(SUSD_VEHICLE_BATTERY_STATE_OF_CHARGE_SUPPORTED == STD_ON)
    /*Variable used to store the current state of the Battery Charge*/
    uint8 Battery_Charge_Current_State;
#endif
	/*Two different conditions if the wakeup was activated or deactivated*/
#if(SUSD_VEHICLE_BATTERY_STATE_OF_CHARGE_SUPPORTED == STD_ON)
    Battery_Charge_Current_State=Rte_Mode_RP_BswM_SUSD_BatteryCharge_Disable_Wakeups_SUSD_BswM_Wakeup_Enable_MDG();
#endif
    if((WakeupSrc&WakeupStatus)!= 0u)
	{
#if(SUSD_VEHICLE_BATTERY_STATE_OF_CHARGE_SUPPORTED == STD_ON)
		/*If the Battery Charge is low, the activation of local wake-ups should be ignored*/
		if((WakeupSrc<=(ECUM_WKSOURCE_EXTERNAL_WDG))||
			(Battery_Charge_Current_State==(uint8)(SUSD_BSWM_ENABLE_WAKEUPS)))
		{
#endif
		  SUSD_ActivatedWakeupSource(WakeupSrc);
#if(SUSD_VEHICLE_BATTERY_STATE_OF_CHARGE_SUPPORTED == STD_ON)
		}
#endif
	}
	else
	{
		SUSD_DeactivatedWakeupSource(WakeupSrc);
	}
#if(SUSD_VEHICLE_BATTERY_STATE_OF_CHARGE_SUPPORTED == STD_ON)
    /*If the battery charge is low, store the EcuM Wake-up status in WakeupStatus_BatteryLow*/
	WakeupStatus_BatteryLow=WakeupStatus;
#endif

}

Setting the BswM rule

To set the BswM rule we took the following steps:


  • Create a Mode Request Port and specify the source of the mode request

                                                

  • Create a Mode Condition and specify the value which it should be equal (or not equal) to




  • Create a Logical Expression (in our case we only verified one condition):
  • Create the Mode Switch Port



  • Create the Actions you want to perform when the Logical Expression is TRUE or FALSE                                             



















  • Create the Action Lists referencing the actions to perform when the Logical Expression is TRUE or FALSE

                                             


  • Reference the Data Type Mapping Set


  • Create the rule referencing the Logical Expression and the Action Lists

  • Generate the BSW and connect the newly created ports to the SUSD



  • No labels