-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstrategyprocess.cpp
More file actions
executable file
·132 lines (111 loc) · 2.82 KB
/
Copy pathstrategyprocess.cpp
File metadata and controls
executable file
·132 lines (111 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include "strategyprocess.h"
#include <QtMath>
StrategyProcess::StrategyProcess(TcpHandler* tcp_, QObject *parent) : QObject{parent},
tcp(tcp_)
{
QObject::connect(tcp, &TcpHandler::jsonMsgChanged, this, &StrategyProcess::parseMsg);
}
void StrategyProcess::parseMsg()
{
auto &obj = tcp->jsonMsg();
if(obj.contains("page"))
if(obj["page"].toString() == "strategy")
{
setRobot_id(obj["rId"].toInt());
setRobot_running(obj["rRun"].toBool());
setRobot_x(obj["rX"].toString().toDouble() * 100);// toDouble());
setRobot_y(obj["rY"].toString().toDouble() * 100);
setRobot_a(QString::number((obj["rA"].toString().toDouble()), 'f', 2).toDouble());
setBall_x(obj["bX"].toString().toDouble() * 100);
setBall_y(obj["bY"].toString().toDouble() * 100);
setBall_visible(obj["bVisible"].toBool());
}
}
double StrategyProcess::robot_a() const
{
return m_robot_a;
}
void StrategyProcess::setRobot_a(double newRobot_a)
{
if (qFuzzyCompare(m_robot_a, newRobot_a))
return;
m_robot_a = newRobot_a;
emit robot_aChanged();
}
double StrategyProcess::robot_x() const
{
return m_robot_x;
}
void StrategyProcess::setRobot_x(double newRobot_x)
{
if (qFuzzyCompare(m_robot_x, newRobot_x))
return;
m_robot_x = newRobot_x;
emit robot_xChanged();
}
double StrategyProcess::robot_y() const
{
return m_robot_y;
}
void StrategyProcess::setRobot_y(double newRobot_y)
{
if (qFuzzyCompare(m_robot_y, newRobot_y))
return;
m_robot_y = newRobot_y;
emit robot_yChanged();
}
double StrategyProcess::ball_x() const
{
return m_ball_x;
}
void StrategyProcess::setBall_x(double newBall_x)
{
if (qFuzzyCompare(m_ball_x, newBall_x))
return;
m_ball_x = newBall_x;
emit ball_xChanged();
}
double StrategyProcess::ball_y() const
{
return m_ball_y;
}
void StrategyProcess::setBall_y(double newBall_y)
{
if (qFuzzyCompare(m_ball_y, newBall_y))
return;
m_ball_y = newBall_y;
emit ball_yChanged();
}
bool StrategyProcess::ball_visible() const
{
return m_ball_visible;
}
void StrategyProcess::setBall_visible(bool newBall_visible)
{
if (m_ball_visible == newBall_visible)
return;
m_ball_visible = newBall_visible;
emit ball_visibleChanged();
}
int StrategyProcess::robot_id() const
{
return m_robot_id;
}
void StrategyProcess::setRobot_id(int newRobot_id)
{
if (m_robot_id == newRobot_id)
return;
m_robot_id = newRobot_id;
emit robot_idChanged();
}
bool StrategyProcess::robot_running() const
{
return m_robot_running;
}
void StrategyProcess::setRobot_running(bool newRobot_running)
{
if (m_robot_running == newRobot_running)
return;
m_robot_running = newRobot_running;
emit robot_runningChanged();
}