diff options
author | Scott Murray <scott.murray@konsulko.com> | 2023-11-29 15:40:23 -0500 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2023-11-29 15:43:58 -0500 |
commit | 1f55937667e35fb79dabee0e180787e34a59169a (patch) | |
tree | 707961d1643ed844b7f55db25a3a07b7865447ca | |
parent | be3bc37fbdd48f70a2cee4fb0f61c8b688707b1f (diff) |
Handle more signalsricefish_18.0.2ricefish_18.0.1ricefish_18.0.0ricefish/18.0.2ricefish/18.0.1ricefish/18.0.0quillback_17.1.2quillback_17.1.1quillback_17.1.0quillback_17.0.2quillback_17.0.1quillback_17.0.0quillback/17.1.2quillback/17.1.1quillback/17.1.0quillback/17.0.2quillback/17.0.1quillback/17.0.018.0.218.0.118.0.017.1.217.1.117.1.017.0.217.0.117.0.0
Add minimal mock support for the VSS signals:
Vehicle.Cabin.HVAC.IsAirConditioningActive
Vehicle.Cabin.HVAC.IsFrontDefrosterActive
Vehicle.Cabin.HVAC.IsRearDefrosterActive
Vehicle.Cabin.HVAC.IsRecirculationActive
The implemented behavior is to simply push the actuator target value
out as the new value, so that VSS clients will see the operation as
having completed.
Bug-AGL: SPEC-5000
Change-Id: I9501d54dae13825c7eadcdc417d6355b64f9cd36
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-rw-r--r-- | src/HvacService.cpp | 82 | ||||
-rw-r--r-- | src/HvacService.h | 15 | ||||
-rw-r--r-- | src/KuksaClient.cpp | 7 | ||||
-rw-r--r-- | src/KuksaClient.h | 1 |
4 files changed, 104 insertions, 1 deletions
diff --git a/src/HvacService.cpp b/src/HvacService.cpp index 455f4ee..b909758 100644 --- a/src/HvacService.cpp +++ b/src/HvacService.cpp @@ -10,7 +10,6 @@ #include <iostream> #include <algorithm> - HvacService::HvacService(const KuksaConfig &config, GMainLoop *loop) : m_loop(loop), m_config(config), @@ -55,6 +54,10 @@ HvacService::HvacService(const KuksaConfig &config, GMainLoop *loop) : signals["Vehicle.Cabin.HVAC.Station.Row1.Driver.FanSpeed"] = true; signals["Vehicle.Cabin.HVAC.Station.Row1.Passenger.Temperature"] = true; signals["Vehicle.Cabin.HVAC.Station.Row1.Passenger.FanSpeed"] = true; + signals["Vehicle.Cabin.HVAC.IsAirConditioningActive"] = true; + signals["Vehicle.Cabin.HVAC.IsFrontDefrosterActive"] = true; + signals["Vehicle.Cabin.HVAC.IsRearDefrosterActive"] = true; + signals["Vehicle.Cabin.HVAC.IsRecirculationActive"] = true; m_broker->subscribe(signals, [this](const std::string &path, const Datapoint &dp) { HandleSignalChange(path, dp); @@ -101,6 +104,22 @@ void HvacService::HandleSignalChange(const std::string &path, const Datapoint &d if (speed >= 0 && speed <= 100) set_right_fan_speed(speed); } + } else if (path == "Vehicle.Cabin.HVAC.IsAirConditioningActive") { + if (dp.has_bool_()) { + set_ac_active(dp.bool_()); + } + } else if (path == "Vehicle.Cabin.HVAC.IsFrontDefrosterActive") { + if (dp.has_bool_()) { + set_front_defrost_active(dp.bool_()); + } + } else if (path == "Vehicle.Cabin.HVAC.IsRearDefrosterActive") { + if (dp.has_bool_()) { + set_rear_defrost_active(dp.bool_()); + } + } else if (path == "Vehicle.Cabin.HVAC.IsRecirculationActive") { + if (dp.has_bool_()) { + set_recirculation_active(dp.bool_()); + } } // else ignore } @@ -221,3 +240,64 @@ void HvacService::set_fan_speed(uint8_t speed) { m_can_helper.set_fan_speed(speed); } + +void HvacService::set_ac_active(bool active) +{ + const std::lock_guard<std::mutex> lock(m_hvac_state_mutex); + if (m_IsAirConditioningActive != active) { + m_IsAirConditioningActive = active; + + // Push out new value + m_broker->set("Vehicle.Cabin.HVAC.IsAirConditioningActive", + active, + [this](const std::string &path, const Error &error) { + HandleSignalSetError(path, error); + }); + } +} + +void HvacService::set_front_defrost_active(bool active) +{ + const std::lock_guard<std::mutex> lock(m_hvac_state_mutex); + if (m_IsFrontDefrosterActive != active) { + m_IsFrontDefrosterActive = active; + + // Push out new value + m_broker->set("Vehicle.Cabin.HVAC.IsFrontDefrosterActive", + active, + [this](const std::string &path, const Error &error) { + HandleSignalSetError(path, error); + }); + } +} + +void HvacService::set_rear_defrost_active(bool active) +{ + const std::lock_guard<std::mutex> lock(m_hvac_state_mutex); + if (m_IsRearDefrosterActive != active) { + m_IsRearDefrosterActive = active; + + // Push out new value + m_broker->set("Vehicle.Cabin.HVAC.IsRearDefrosterActive", + active, + [this](const std::string &path, const Error &error) { + HandleSignalSetError(path, error); + }); + } +} + +void HvacService::set_recirculation_active(bool active) +{ + const std::lock_guard<std::mutex> lock(m_hvac_state_mutex); + if (m_IsRecirculationActive != active) { + m_IsRecirculationActive = active; + + // Push out new value + m_broker->set("Vehicle.Cabin.HVAC.IsRecirculationActive", + active, + [this](const std::string &path, const Error &error) { + HandleSignalSetError(path, error); + }); + } +} + diff --git a/src/HvacService.h b/src/HvacService.h index 756f6f3..44cb2cc 100644 --- a/src/HvacService.h +++ b/src/HvacService.h @@ -7,6 +7,7 @@ #ifndef _HVAC_SERVICE_H #define _HVAC_SERVICE_H +#include <mutex> #include <glib.h> #include "KuksaConfig.h" @@ -43,6 +44,12 @@ private: HvacCanHelper m_can_helper; HvacLedHelper m_led_helper; + std::mutex m_hvac_state_mutex; + bool m_IsAirConditioningActive = false; + bool m_IsFrontDefrosterActive = false; + bool m_IsRearDefrosterActive = false; + bool m_IsRecirculationActive = false; + void HandleSignalChange(const std::string &path, const Datapoint &dp); void HandleSignalSetError(const std::string &path, const Error &error); @@ -60,6 +67,14 @@ private: void set_right_fan_speed(uint8_t temp); void set_fan_speed(uint8_t temp); + + void set_ac_active(bool active); + + void set_front_defrost_active(bool active); + + void set_rear_defrost_active(bool active); + + void set_recirculation_active(bool active); }; #endif // _HVAC_SERVICE_H diff --git a/src/KuksaClient.cpp b/src/KuksaClient.cpp index 844ce0e..e7e2e25 100644 --- a/src/KuksaClient.cpp +++ b/src/KuksaClient.cpp @@ -73,6 +73,13 @@ void KuksaClient::set(const std::string &path, const std::string &value, SetResp set(path, dp, cb, actuator); } +void KuksaClient::set(const std::string &path, const bool value, SetResponseCallback cb, const bool actuator) +{ + Datapoint dp; + dp.set_bool_(value); + set(path, dp, cb, actuator); +} + void KuksaClient::set(const std::string &path, const int8_t value, SetResponseCallback cb, const bool actuator) { Datapoint dp; diff --git a/src/KuksaClient.h b/src/KuksaClient.h index fd9a9e0..a5f901e 100644 --- a/src/KuksaClient.h +++ b/src/KuksaClient.h @@ -36,6 +36,7 @@ public: void get(const std::string &path, GetResponseCallback cb, const bool actuator = false); void set(const std::string &path, const std::string &value, SetResponseCallback cb, const bool actuator = false); + void set(const std::string &path, const bool value, SetResponseCallback cb, const bool actuator = false); void set(const std::string &path, const int8_t value, SetResponseCallback cb, const bool actuator = false); void set(const std::string &path, const int16_t value, SetResponseCallback cb, const bool actuator = false); void set(const std::string &path, const int32_t value, SetResponseCallback cb, const bool actuator = false); |