Skip to content

Commit 34b18a4

Browse files
ClemensElfleinrovo89
authored andcommitted
wip
1 parent 9ecde09 commit 34b18a4

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Created by clemens on 5/7/25.
3+
//
4+
5+
#include "mower_ui_service.hpp"
6+
7+
void MowerUiService::OnStateIDChanged(const HighLevelStatus &new_value) {
8+
xbot::service::Lock lk{&mtx_};
9+
state_id_ = new_value;
10+
}
11+
12+
void MowerUiService::OnStateNameChanged(const char *new_value, uint32_t length) {
13+
xbot::service::Lock lk{&mtx_};
14+
if (new_value && length > 0 && length < state_name_.max_size()) {
15+
state_name_ = new_value;
16+
}
17+
}
18+
19+
void MowerUiService::OnSubStateNameChanged(const char *new_value, uint32_t length) {
20+
xbot::service::Lock lk{&mtx_};
21+
if (new_value && length > 0 && length < sub_state_name_.max_size()) {
22+
sub_state_name_ = new_value;
23+
}
24+
}
25+
26+
void MowerUiService::OnGpsQualityChanged(const float &new_value) {
27+
xbot::service::Lock lk{&mtx_};
28+
gps_quality_ = new_value;
29+
}
30+
31+
void MowerUiService::OnCurrentAreaChanged(const int16_t &new_value) {
32+
xbot::service::Lock lk{&mtx_};
33+
current_area_ = new_value;
34+
}
35+
36+
void MowerUiService::OnCurrentPathChanged(const int16_t &new_value) {
37+
xbot::service::Lock lk{&mtx_};
38+
current_path_ = new_value;
39+
}
40+
41+
void MowerUiService::OnCurrentPathIndexChanged(const int16_t &new_value) {
42+
xbot::service::Lock lk{&mtx_};
43+
current_path_index_ = new_value;
44+
}
45+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)