Open Trunk Standalone Application#
Note
Note
The devices and components run in the same process, therefore no need of the Proxy & Stub code to access the Interface s.
In the Standalone Application we has access to all Interface s including the signals in in the dispatch service.
Attention
The Basic Service responsible to open the trunk must check the speed of the vehicle. In case the vehicle is moving the request must be denied.
The auto generated code, the result of the sdv_vss_utility, can be used except for this basic service. Therefore the folder bs_vehicletrunk is copied and the code is enhanced to check the vehicle speed.
Add the speed RX signal interface to the header:
#include "../generated/vss_files/vss_vehiclespeed_bs_rx.h"
class CBasicServiceVehicleTrunk
, public vss::Vehicle::SpeedService::IVSS_SetSpeed_Event
BEGIN_SDV_INTERFACE_MAP()
SDV_INTERFACE_ENTRY(vss::Vehicle::SpeedService::IVSS_SetSpeed_Event)
END_SDV_INTERFACE_MAP()
/**
* @brief Set vehicleSpeed signal
* @param[in] value vehicle speed in km/h
*/
virtual void SetSpeed(float value) override;
private:
float m_Speed = 1.0; ///< Speed, start with representing a moveing vehicle.
When this is added we can get the vehicle speed in our cpp file:
CBasicServiceVehicleTrunk::CBasicServiceVehicleTrunk()
{
// Request the basic service for speed.
auto pSpeedSvc = sdv::core::GetObject("Vehicle.Speed_Service").GetInterface<vss::Vehicle::SpeedService::IVSS_GetSpeed>();
if (pSpeedSvc)
{
// Register speed change event handler.
pSpeedSvc->RegisterOnSignalChangeOfVehicleSpeed(static_cast<vss::Vehicle::SpeedService::IVSS_SetSpeed_Event*> (this));
}
}
void CBasicServiceVehicleTrunk::SetSpeed(float value)
{
m_Speed = value;
}
bool CBasicServiceVehicleTrunk::SetOpen(bool value)
{
if (m_Speed)
return false;
return m_ptrOpen->WriteOpen(value);
}
Now add this code to the project build and exclude the other auto generated code.
The Speed signal is coming via CAN bus by using the VAPI Component can_com_sim.sdv from the framework. The VAPI Component reads the CAN messages from a text file and sends these messages to the Data Link The Data Link component is created from a dbc file with the help of the helper tool sdv_dbc_util.
Attention
For safety reason the red connection in the picture must be prevented as the connection bypasses the validation against vehicle movement.
Attention
While the standalone application has access to the Vehicle Device a Complex Service has not. A Complex Service will run in its own isolated process.