mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-04-18 02:38:15 +00:00
update examples (#9)
This commit is contained in:
@@ -125,14 +125,14 @@ bool CConsole::PrepareDataConsumers()
|
||||
auto deviceServiceSpeed = sdv::core::GetObject("Vehicle.Speed_Device").GetInterface<vss::Vehicle::SpeedDevice::IVSS_ReadSpeed>();
|
||||
if (deviceServiceSpeed)
|
||||
{
|
||||
PrintValue(g_sDeviceServiceSpeed, "Vehicle Speed RX", m_PlatformSpeed, "km/h [ Output of Platform Abstraction, not accessible by application ] ");
|
||||
PrintValue(g_sDeviceServiceSpeed, "Vehicle Speed RX", m_SpeedPlatform, "km/h [ Output of Platform Abstraction, not accessible by application ] ");
|
||||
deviceServiceSpeed->RegisterSpeedEvent(dynamic_cast<vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event*> (this));
|
||||
}
|
||||
|
||||
auto basicServiceSpeed = sdv::core::GetObject("Vehicle.Speed_Service").GetInterface<vss::Vehicle::SpeedService::IVSS_GetSpeed>();
|
||||
if (basicServiceSpeed)
|
||||
{
|
||||
PrintValue(g_sBasicServiceSpeed, "Vehicle Speed RX", m_BasicSpeed, "km/h [ Output of Speed Sensor Service, accessible by application ] ");
|
||||
PrintValue(g_sBasicServiceSpeed, "Vehicle Speed RX", m_SpeedbasicService, "km/h [ Output of Speed Sensor Service, accessible by application ] ");
|
||||
basicServiceSpeed->RegisterOnSignalChangeOfVehicleSpeed(dynamic_cast<vss::Vehicle::SpeedService::IVSS_SetSpeed_Event*> (this));
|
||||
}
|
||||
|
||||
@@ -141,19 +141,19 @@ bool CConsole::PrepareDataConsumers()
|
||||
|
||||
void CConsole::WriteSpeed( float value)
|
||||
{
|
||||
if (m_PlatformSpeed != value)
|
||||
if (m_SpeedPlatform != value)
|
||||
{
|
||||
m_PlatformSpeed = value;
|
||||
PrintValue(g_sDeviceServiceSpeed, "Vehicle Speed RX", m_PlatformSpeed, "km/h [ Output of Platform Abstraction, not accessible by application ] ");
|
||||
m_SpeedPlatform = value;
|
||||
PrintValue(g_sDeviceServiceSpeed, "Vehicle Speed RX", m_SpeedPlatform, "km/h [ Output of Platform Abstraction, not accessible by application ] ");
|
||||
}
|
||||
}
|
||||
|
||||
void CConsole::SetSpeed( float value)
|
||||
{
|
||||
if (m_BasicSpeed != value)
|
||||
if (m_SpeedbasicService != value)
|
||||
{
|
||||
m_BasicSpeed= value;
|
||||
PrintValue(g_sBasicServiceSpeed, "Vehicle Speed RX", m_BasicSpeed, "km/h [ Output of Speed Sensor Service, accessible by application ] ");
|
||||
m_SpeedbasicService = value;
|
||||
PrintValue(g_sBasicServiceSpeed, "Vehicle Speed RX", m_SpeedbasicService, "km/h [ Output of Speed Sensor Service, accessible by application ] ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,20 +154,20 @@ private:
|
||||
*/
|
||||
std::string AlignString(const std::string& message, uint32_t desiredLength = 0);
|
||||
|
||||
mutable std::mutex m_mtxPrintToConsole; ///< Mutex to print complete message
|
||||
bool m_bRunning = false; ///< When set, the application is running.
|
||||
std::string m_DataUnit = "[ --- Input data in m/s --- ]";
|
||||
std::string m_Unit = "m/s";
|
||||
mutable std::mutex m_mtxPrintToConsole; ///< Mutex to print complete message
|
||||
bool m_bRunning = false; ///< When set, the application is running.
|
||||
std::string m_DataUnit = "[ --- Input data in m/s --- ]";
|
||||
std::string m_Unit = "m/s";
|
||||
|
||||
sdv::core::CSignal m_SignalSpeed; ///< Signal to subscribe to the speed signal in dispatch service
|
||||
|
||||
float m_SpeedDataLink = 0.0; ///< Data Link value, either km/h or m/s
|
||||
float m_PlatformSpeed = 0.0; ///< Generalized Speed
|
||||
float m_BasicSpeed = 0.0; ///< Generalized Speed
|
||||
float m_SpeedDataLink = 0.0; ///< Data Link value, either km/h or m/s
|
||||
float m_SpeedPlatform = 0.0; ///< Generalized Speed after platform abstraction
|
||||
float m_SpeedbasicService = 0.0; ///< Generalized Speed can be used by vehicle function components
|
||||
|
||||
#ifdef _WIN32
|
||||
DWORD m_dwConsoleOutMode = 0u; ///< The console mode before switching on ANSI support.
|
||||
DWORD m_dwConsoleInMode = 0u; ///< The console mode before switching on ANSI support.
|
||||
DWORD m_dwConsoleOutMode = 0u; ///< The console mode before switching on ANSI support.
|
||||
DWORD m_dwConsoleInMode = 0u; ///< The console mode before switching on ANSI support.
|
||||
#elif defined __unix__
|
||||
struct termios m_sTermAttr{}; ///< The terminal attributes before disabling echo.
|
||||
int m_iFileStatus = 0; ///< The file status flags for STDIN.
|
||||
|
||||
@@ -43,12 +43,12 @@ bool CAbstractionControl::IsSDVFrameworkEnvironmentSet()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAbstractionControl::Initialize(bool bSimulate)
|
||||
bool CAbstractionControl::Initialize(bool bInputDataInKmh)
|
||||
{
|
||||
if (m_bInitialized)
|
||||
return true;
|
||||
|
||||
m_bSimulate = bSimulate;
|
||||
m_bInputDataInKmh = bInputDataInKmh;
|
||||
if (!IsSDVFrameworkEnvironmentSet())
|
||||
{
|
||||
// if SDV_FRAMEWORK_RUNTIME environment variable is not set we need to set the Framework Runtime directory
|
||||
@@ -62,7 +62,7 @@ bool CAbstractionControl::Initialize(bool bSimulate)
|
||||
bool bResult = LoadConfigFile("Load dispatch service: ", "data_dispatch_vehicle_abstraction.toml");
|
||||
bResult &= LoadConfigFile("Load task_timer_vehicle: ", "task_timer_vehicle.toml");
|
||||
|
||||
if (bSimulate)
|
||||
if (m_bInputDataInKmh)
|
||||
{
|
||||
bResult &= LoadConfigFile("Load can_com_simulation_vehicle_abstraction_kmh: ", "can_com_simulation_vehicle_abstraction_kmh.toml");
|
||||
bResult &= LoadConfigFile("Load data_link_vehicle_abstraction: ", "data_link_vehicle_abstraction.toml");
|
||||
|
||||
@@ -22,10 +22,10 @@ public:
|
||||
/**
|
||||
* @brief Start and initialize the application control and load
|
||||
* platform abstraction components and basic services
|
||||
* @param[in] bSimulate If signals should be simulated or CAN input signals should be used
|
||||
* @param[in] bInputDataInKmh If input speed data is in km/h
|
||||
* @return Return true on success otherwise false
|
||||
*/
|
||||
bool Initialize(bool bSimulate);
|
||||
bool Initialize(bool bInputDataInKmh);
|
||||
|
||||
/**
|
||||
* @brief After initialization/configuration the system mode needs to be set to running mode
|
||||
@@ -56,5 +56,5 @@ private:
|
||||
sdv::app::CAppControl m_appcontrol; ///< App-control of SDV V-API.
|
||||
bool m_bInitialized = false; ///< Set when initialized.
|
||||
|
||||
bool m_bSimulate = false;
|
||||
bool m_bInputDataInKmh = false; ///< true if the input data is in km/h
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user