|
| 1 | +// |
| 2 | +// Created by clemens on 5/7/25. |
| 3 | +// |
| 4 | + |
| 5 | +#ifndef OPENMOWER_MOWER_UI_SERVICE_HPP |
| 6 | +#define OPENMOWER_MOWER_UI_SERVICE_HPP |
| 7 | + |
| 8 | +#include <MowerUiServiceBase.hpp> |
| 9 | + |
| 10 | +#include "globals.hpp" |
| 11 | +#include <etl/string.h> |
| 12 | +#include <xbot-service/Lock.hpp> |
| 13 | + |
| 14 | +using namespace xbot::service; |
| 15 | + |
| 16 | +class MowerUiService : public MowerUiServiceBase { |
| 17 | + private: |
| 18 | + THD_WORKING_AREA(wa, 1024) {}; |
| 19 | + |
| 20 | + public: |
| 21 | + explicit MowerUiService(uint16_t service_id) : MowerUiServiceBase(service_id, wa, sizeof(wa)) { |
| 22 | + } |
| 23 | + |
| 24 | + [[nodiscard]] HighLevelStatus getStateId() { |
| 25 | + xbot::service::Lock lk{&mtx_}; |
| 26 | + return state_id_; |
| 27 | + } |
| 28 | + [[nodiscard]] etl::string<100> getStateName() { |
| 29 | + xbot::service::Lock lk{&mtx_}; |
| 30 | + return state_name_; |
| 31 | + } |
| 32 | + [[nodiscard]] etl::string<100> getSubStateName() { |
| 33 | + xbot::service::Lock lk{&mtx_}; |
| 34 | + return sub_state_name_; |
| 35 | + } |
| 36 | + [[nodiscard]] float getGpsQuality() { |
| 37 | + xbot::service::Lock lk{&mtx_}; |
| 38 | + return gps_quality_; |
| 39 | + } |
| 40 | + [[nodiscard]] int16_t getCurrentArea() { |
| 41 | + xbot::service::Lock lk{&mtx_}; |
| 42 | + return current_area_; |
| 43 | + } |
| 44 | + [[nodiscard]] int16_t getCurrentPath() { |
| 45 | + xbot::service::Lock lk{&mtx_}; |
| 46 | + return current_path_; |
| 47 | + } |
| 48 | + [[nodiscard]] int16_t getCurrentPathIndex() { |
| 49 | + xbot::service::Lock lk{&mtx_}; |
| 50 | + return current_path_index_; |
| 51 | + } |
| 52 | + |
| 53 | + void SendAction(HighLevelAction action); |
| 54 | + |
| 55 | + private: |
| 56 | + MUTEX_DECL(mtx_); |
| 57 | + |
| 58 | + HighLevelStatus state_id_ = MowerUiServiceBase::HighLevelStatus::UNKNOWN; |
| 59 | + etl::string<100> state_name_{}; |
| 60 | + etl::string<100> sub_state_name_{}; |
| 61 | + float gps_quality_ = 0; |
| 62 | + int16_t current_area_ = 0; |
| 63 | + int16_t current_path_ = 0; |
| 64 | + int16_t current_path_index_ = 0; |
| 65 | + |
| 66 | + void OnStateIDChanged(const HighLevelStatus& new_value) override; |
| 67 | + void OnStateNameChanged(const char* new_value, uint32_t length) override; |
| 68 | + void OnSubStateNameChanged(const char* new_value, uint32_t length) override; |
| 69 | + void OnGpsQualityChanged(const float& new_value) override; |
| 70 | + void OnCurrentAreaChanged(const int16_t& new_value) override; |
| 71 | + void OnCurrentPathChanged(const int16_t& new_value) override; |
| 72 | + void OnCurrentPathIndexChanged(const int16_t& new_value) override; |
| 73 | +}; |
| 74 | + |
| 75 | +#endif // OPENMOWER_MOWER_UI_SERVICE_HPP |
0 commit comments