-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmainwindow.h
More file actions
140 lines (107 loc) · 3.78 KB
/
mainwindow.h
File metadata and controls
140 lines (107 loc) · 3.78 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
133
134
135
136
137
138
139
140
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTimer>
#include <QDebug>
#include <QProcess>
#include <QTime>
#include <QButtonGroup>
#include <QString>
// Legacy include'ы удалены.
#include <QKeyEvent>
#include <memory>
#include "joy_stick.h"
#include "key_board.h"
#include "input/i_input_source.h"
#include "input/gamepad_input_source.h"
#include "control/control_service.h"
// #include "power_system.h"
// #include "mode_automatic.h"
// #include "map_widget.h"
#include "diagnostic_board.h"
#include "ros2_bridge.h"
#include "uv_state.h"
#include <QSettings>
#include <QSpinBox>
#include "Gamepad/gamepad.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void setConsole();
private:
Gamepad *gamepad = nullptr;
std::unique_ptr<GamepadInputSource> gamepadInput;
// Используем enum class с фиксированным типом uint8_t
enum class SpeedMode : uint8_t { Slow = 0, Medium = 1, Fast = 2 };
SpeedMode currentMode; // инициализируется в конструкторе
QMap<int, QMap<QString, double>> speedModeGains; // [режим][имя]
QVector<QSpinBox*> gainSpinBoxes;
QStringList gainNames = {"surge", "sway", "depth", "yaw", "pitch", "roll"};
void saveCurrentModeGains();
void setSpinBoxValuesForCurrentMode();
void saveSettings();
void loadSettings();
void useGamepad();
void setTimer_updateImpact(int periodUpdateMsec);
void setBottom();
void setBottom_mode();
/*!
* \brief setTab устанавливает названия вкладкам.
*/
void setTab();
void setUpdateUI();
void setWidget();
void setInterface();
bool status_keyboard = false;
// legacy widgets (сейчас не используются в сборке)
// PowerSystem *powerSystem;
// CheckMsg *checkMsg;
// ModeAutomatic *modeAutomatic;
Diagnostic_board *diagnostic_board;
RosBridge *rosBridge;
UVState *uvState;
private slots:
// Единый слот для переключения режима скорости
void setSpeedMode(SpeedMode mode);
void displayText(QString str);
void updateUi_fromControl();
/*!
* \brief updateUi_Compass слот обновления компаса на UI форме.
* \param yaw новое значение курса.
*/
void updateUi_Compass(float yaw);
void useKeyBoard();
void useJoyStick();
signals:
void updateCompass(float yaw);
void publishTwistRequested(double x, double y, double z,
double angular_x, double angular_y, double angular_z);
void controlFlagRequested(uint8_t bit, bool value);
// legacy signals (пока не используются)
// void updateIMU(DataAH127C imuData);
// void updateSetupMsg();
// void updateDataMission();
// void updateStatePushButton();
// void updateMap();
// void pointAdded(qreal x, qreal y);
// void toggleMissionPlanning_cppPointsEnabled();
// void signal_sendCurrentPos(double latitude, double longitude);
protected:
Ui::MainWindow *ui;
QTimer *updateTimer = nullptr;
std::unique_ptr<JoyStick> joyStick;
std::unique_ptr<KeyBoard> keyBoard;
umas::input::IInputSource *activeInput = nullptr;
umas::control::ControlService controlService;
umas::input::ControlCommand applyGains(const umas::input::ControlCommand& raw) const;
void updateControlLabels(const umas::input::ControlCommand& scaled);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
};
#endif // MAINWINDOW_H