Open Trunk Example#

Attention

Purpose: Opening the trunk is a safety‑critical operation and must be protected. Access shall be denied when the vehicle is in motion.

Note

Example can be found in <output-folder>/examples/bin:
open_trunk_example <instance>

Hint

The Vehicle Function will open the trunk. This should be blocked when the vehicle is moving:

  • Required: TX signal to open the trunk, RX signal representing the speed of the vehicle.

  • Convert the speed value from m/s to km/h. This represents the vehicle abstraction when the input signal unit does not match the standardized interface definition.

  • The basic service which offers the interface to open the trunk must deny the access when the vehicle is in motion.

../../../_images/open_trunk_overview.png

@startuml
 set separator ::
 package "Trunk Application executable"
 {
   class CTrunkControl
   {
      +bool Initialize(uint32_t uiInstance)
      +void SetRunningMode()
      +void Shutdown()
      -bool IsSDVFrameworkEnvironmentSet()
      -bool LoadConfigFile(const std::string& inputMsg, const std::string& configFileName)
      -sdv::app::CAppControl m_appcontrol
      -bool m_bInitialized
   }

   class CConsole
   {
      +struct SConsolePos
      {
         uint32_t uiRow
         uint32_t uiCol
      };
      +void PrintHeader(uint32_t uiInstance)
      +bool PrepareDataConsumers()
      +void RunUntilBreak()
      +{abstract} void WriteSpeed(float value)
      +{abstract} void SetSpeed(float value)
      +void ResetSignals()
      -void CallbackSpeed(sdv::any_t value)
      -bool KeyHit()
      -char GetChar()
      -SConsolePos GetCursorPos() const
      -void SetCursorPos(SConsolePos sPos)
      -void PrintText(SConsolePos sPos, const std::string& rssText)
      -void PrintValue(SConsolePos sPos, const std::string& rssName, TValue tValue, const std::string& rssStatus)
      -std::string AlignString(const std::string& message, uint32_t desiredLength)
      -mutable std::mutex m_mtxPrintToConsole
      -bool m_bRunning
      -sdv::core::CSignal m_SignalSpeed
      -float m_SpeedDL
      -float m_SpeedVD
      -float m_SpeedBS
      -vss::Vehicle::Body::TrunkService::IVSS_SetOpen* m_pTrunkSvc
      -ITrunkKitService* m_pITrunkComplexService
      -DWORD m_dwConsoleOutMode
      -DWORD m_dwConsoleInMode
      -struct termios m_sTermAttr{}
      -int m_iFileStatus
      -<<inline>> void PrintValue(SConsolePos sPos, const std::string& rssName, TValue tValue, const std::string& rssUnits)
      -<<inline>> void PrintValue<bool>(SConsolePos sPos, const std::string& rssName, bool bValue, const std::string& rssStatus)
   }
  }

   Interface vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event
   {
      {abstract} void WriteSpeed(float value)
   }

   Interface vss::Vehicle::SpeedService::IVSS_SetSpeed_Event
   {
      {abstract} void SetSpeed(float value)
   }

   CConsole ..|> vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event : Implements
   CConsole ..|> vss::Vehicle::SpeedService::IVSS_SetSpeed_Event : Implements
@enduml

Trunk example application class diagram#

@startuml
 set separator ::
   class CBasicServiceVehicleTrunk
   {
      +{abstract} void SetSpeed(float value)
      {abstract} bool SetOpen(bool value)
      +{abstract} RegisterOnSignalChangeOfVehicleSpeed(vss::Vehicle::SpeedService::IVSS_SetSpeed_Event* callback)
      -vss::Vehicle::Body::TrunkDevice::IVSS_WriteOpen* m_ptrOpen
   }

   class sdv::CSdvObject
   {
      {static} +sdv::sequence<sdv::u8string> GetClassAliasesStatic()
      {static} +sdv::u8string GetDefaultObjectNameStatic()
      {static} +bool IsSingletonStatic()
      {static} +sdv::sequence<sdv::u8string> GetObjectDependenciesStatic()
   }

   Interface vss::Vehicle::Body::TrunkService::IVSS_SetOpen
   {
      {abstract} bool SetOpen(bool value)
   }

   Interface vss::Vehicle::SpeedService::IVSS_SetSpeed_Event
   {
      {abstract} void SetSpeed(float value)
   }

   CBasicServiceVehicleTrunk --|> sdv::CSdvObject : Inherits
   CBasicServiceVehicleTrunk ..|> vss::Vehicle::Body::TrunkService::IVSS_SetOpen : Implements
@enduml

Vehicle Trunk basic service class diagram#

@startuml
 set separator ::
   class CBasicServiceVehicleSpeed
   {
      +{abstract} void SetSpeed(float value)
      +{abstract} float GetSpeed() const
      +{abstract} void WriteSpeed(float value)
      +{abstract} RegisterOnSignalChangeOfVehicleSpeed(vss::Vehicle::SpeedService::IVSS_SetSpeed_Event* callback)
      +{abstract} void UnregisterOnSignalChangeOfVehicleSpeed(vss::Vehicle::SpeedService::IVSS_SetSpeed_Event* callback)
      -float m_vehicleSpeed
      -mutable std::mutex m_vehicleSpeedMutexCallbacks
      -std::set<vss::Vehicle::SpeedService::IVSS_SetSpeed_Event*> m_vehicleSpeedCallbacks
   }

   Interface vss::Vehicle::SpeedService::IVSS_GetSpeed
   {
      {abstract} float GetSpeed() const
      {abstract} void RegisterOnSignalChangeOfVehicleSpeed(IVSS_SetSpeed_Event* callback)
      {abstract} void UnregisterOnSignalChangeOfVehicleSpeed(IVSS_SetSpeed_Event* callback)
   }

   Interface vss::Vehicle::SpeedService::IVSS_SetSpeed_Event
   {
      {abstract} void SetSpeed(float value)
   }

   Interface vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event
   {
      {abstract} void WriteSpeed(float value)
   }

   class sdv::CSdvObject
   {
      {static} +sdv::sequence<sdv::u8string> GetClassAliasesStatic()
      {static} +sdv::u8string GetDefaultObjectNameStatic()
      {static} +bool IsSingletonStatic()
      {static} +sdv::sequence<sdv::u8string> GetObjectDependenciesStatic()
   }

   CBasicServiceVehicleSpeed --|> sdv::CSdvObject : Inherits
   CBasicServiceVehicleSpeed ..|> vss::Vehicle::SpeedService::IVSS_GetSpeed : Implements
   CBasicServiceVehicleSpeed ..|> vss::Vehicle::SpeedService::IVSS_SetSpeed_Event : Implements
   CBasicServiceVehicleSpeed ..|> vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event : Implements
@enduml

Vehicle Speed basic service class diagram#

@startuml
 set separator ::
   class CVehicleDeviceVehicleSpeed
   {
      +{abstract} void Initialize(const sdv::u8string& objectConfig)
      +{abstract} sdv::EObjectStatus GetStatus() const
      +{abstract} void SetOperationMode(sdv::EOperationMode eMode)
      +{abstract} void Shutdown()
      +{abstract} void RegisterSpeedEvent(vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event* event)
      +{abstract} void UnregisterSpeedEvent(vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event* event)
      -void ExecuteAllCallBacksForVehicleSpeed(sdv::any_t value)
      -sdv::core::CSignal m_vehicleSpeedSignal
      -mutable std::mutex m_vehicleSpeedMutexCallbacks
      -std::set<vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event*> m_vehicleSpeedCallbacks
      -std::atomic<sdv::EObjectStatus> m_status
   }

   class sdv::CSdvObject
   {
      {static} +sdv::sequence<sdv::u8string> GetClassAliasesStatic()
      {static} +sdv::u8string GetDefaultObjectNameStatic()
      {static} +bool IsSingletonStatic()
      {static} +sdv::sequence<sdv::u8string> GetObjectDependenciesStatic()
   }

   Interface sdv::IObjectControl
   {
      {abstract} void Initialize(const sdv::u8string& ssObjectConfig)
      {abstract} EObjectStatus GetStatus() const
      {abstract} void SetOperationMode(EOperationMode eMode)
      {abstract} void Shutdown()
   }

   Interface vss::Vehicle::SpeedDevice::IVSS_Speed
   {
      {abstract} void RegisterSpeedEvent(IVSS_WriteSpeed_Event* event)
      {abstract} void UnregisterSpeedEvent(IVSS_WriteSpeed_Event* event)
   }

   CVehicleDeviceVehicleSpeed --|> sdv::CSdvObject : Inherits
   CVehicleDeviceVehicleSpeed ..|> sdv::IObjectControl : Implements
   CVehicleDeviceVehicleSpeed ..|> vss::Vehicle::SpeedDevice::IVSS_Speed : Implements
@enduml

Vehicle Speed Vehicle device class diagram#

@startuml
 set separator ::
   class CVehicleDeviceVehicleTrunk
   {
      +{abstract} void Initialize(const sdv::u8string& objectConfig)
      +{abstract} sdv::EObjectStatus GetStatus() const
      +{abstract} void SetOperationMode(sdv::EOperationMode eMode)
      +{abstract} void Shutdown()
      +{abstract} bool WriteOpen(bool value)
      -sdv::core::CSignal m_trunk
      -std::atomic<sdv::EObjectStatus> m_status
   }

   class sdv::CSdvObject
   {
      {static} +sdv::sequence<sdv::u8string> GetClassAliasesStatic()
      {static} +sdv::u8string GetDefaultObjectNameStatic()
      {static} +bool IsSingletonStatic()
      {static} +sdv::sequence<sdv::u8string> GetObjectDependenciesStatic()
   }

   Interface sdv::IObjectControl
   {
      {abstract} void Initialize(const sdv::u8string& ssObjectConfig)
      {abstract} EObjectStatus GetStatus() const
      {abstract} void SetOperationMode(EOperationMode eMode)
      {abstract} void Shutdown()
   }

   Interface vss::Vehicle::Body::TrunkDevice::IVSS_WriteOpen
   {
      {abstract} bool WriteOpen(bool value)
   }

   CVehicleDeviceVehicleTrunk --|> sdv::CSdvObject : Inherits
   CVehicleDeviceVehicleTrunk ..|> sdv::IObjectControl : Implements
   CVehicleDeviceVehicleTrunk ..|> vss::Vehicle::Body::TrunkDevice::IVSS_WriteOpen : Implements
@enduml

Vehicle Speed Vehicle device class diagram#