2026-07-30 12:06:02 +08:00
|
|
|
#ifndef PARKINGSPACEGUIDEVIEW_MAINWINDOW_H
|
|
|
|
|
#define PARKINGSPACEGUIDEVIEW_MAINWINDOW_H
|
|
|
|
|
|
2026-09-17 15:30:30 +08:00
|
|
|
#include <QJsonArray>
|
2026-07-30 12:06:02 +08:00
|
|
|
#include <QJsonObject>
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
2026-09-17 15:30:30 +08:00
|
|
|
class QComboBox;
|
2026-07-30 12:06:02 +08:00
|
|
|
class QLabel;
|
2026-09-17 15:30:30 +08:00
|
|
|
class QLineEdit;
|
|
|
|
|
class QPushButton;
|
2026-07-30 12:06:02 +08:00
|
|
|
class QResizeEvent;
|
2026-09-17 15:30:30 +08:00
|
|
|
class QTimer;
|
2026-07-30 12:06:02 +08:00
|
|
|
class RemoteGuideClient;
|
|
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
class MainWindow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit MainWindow(int discoveryPort = 5555,
|
|
|
|
|
QWidget* parent = nullptr);
|
|
|
|
|
~MainWindow() override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void resizeEvent(QResizeEvent* event) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct GuidePresentation
|
|
|
|
|
{
|
|
|
|
|
QString name;
|
|
|
|
|
QString englishName;
|
|
|
|
|
QString displayText;
|
|
|
|
|
QString meaning;
|
|
|
|
|
QString action;
|
|
|
|
|
QString level;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void ApplyStatus(const QJsonObject& status);
|
|
|
|
|
void ApplyGuideState(int stateCode, const QString& guideText);
|
|
|
|
|
void UpdateControls();
|
|
|
|
|
void SetMetric(QLabel* label,
|
|
|
|
|
const QJsonObject& status,
|
|
|
|
|
const char* field,
|
|
|
|
|
const QString& unit,
|
|
|
|
|
int precision = 2,
|
|
|
|
|
double divisor = 1.0);
|
|
|
|
|
void HandleConnectionState(bool connected,
|
|
|
|
|
const QString& message,
|
|
|
|
|
const QString& deviceName,
|
|
|
|
|
const QString& address);
|
|
|
|
|
void HandleCommandFinished(const QString& command,
|
|
|
|
|
bool ok,
|
|
|
|
|
const QString& message,
|
|
|
|
|
const QJsonObject& response);
|
2026-09-17 15:30:30 +08:00
|
|
|
void ApplyPanelConfig(const QJsonObject& panel);
|
|
|
|
|
void ApplySessionList(const QJsonArray& sessions);
|
|
|
|
|
void StartReplay(const QJsonArray& samples);
|
|
|
|
|
void StopReplay();
|
|
|
|
|
void PlayNextReplaySample();
|
|
|
|
|
void RebuildModelCombo(const QJsonArray& models);
|
|
|
|
|
void AddStatusRow(const QString& caption, QLabel*& valueLabel);
|
|
|
|
|
QString PromptControlPassword(const QString& title);
|
|
|
|
|
void RecordChockWithPassword(bool chockOn);
|
|
|
|
|
bool IsPasswordSessionValid() const;
|
|
|
|
|
void BeginPasswordSession();
|
|
|
|
|
void ExpirePasswordSession();
|
2026-07-30 12:06:02 +08:00
|
|
|
|
|
|
|
|
static const GuidePresentation& PresentationForState(int stateCode);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Ui::MainWindow* ui = nullptr;
|
|
|
|
|
RemoteGuideClient* m_client = nullptr;
|
|
|
|
|
|
|
|
|
|
int m_currentStateCode = 12;
|
|
|
|
|
bool m_connected = false;
|
|
|
|
|
bool m_guidanceRunning = false;
|
|
|
|
|
bool m_commandPending = false;
|
2026-09-17 15:30:30 +08:00
|
|
|
bool m_loggedIn = false;
|
|
|
|
|
bool m_requireLogin = true;
|
|
|
|
|
bool m_maintenanceMode = false;
|
|
|
|
|
int m_passwordValidSeconds = 120;
|
|
|
|
|
qint64 m_passwordValidUntilMs = 0;
|
|
|
|
|
bool m_replaying = false;
|
|
|
|
|
QLineEdit* m_passwordEdit = nullptr;
|
|
|
|
|
QPushButton* m_loginButton = nullptr;
|
|
|
|
|
QPushButton* m_maintenanceButton = nullptr;
|
|
|
|
|
QPushButton* m_chockOnButton = nullptr;
|
|
|
|
|
QPushButton* m_chockOffButton = nullptr;
|
|
|
|
|
QComboBox* m_sessionCombo = nullptr;
|
|
|
|
|
QPushButton* m_replayButton = nullptr;
|
|
|
|
|
QLabel* m_activatedLabel = nullptr;
|
|
|
|
|
QLabel* m_selfCheckLabel = nullptr;
|
|
|
|
|
QLabel* m_workModeLabel = nullptr;
|
|
|
|
|
QLabel* m_personChockLabel = nullptr;
|
|
|
|
|
QLabel* m_chockOnLabel = nullptr;
|
|
|
|
|
QLabel* m_chockOffLabel = nullptr;
|
|
|
|
|
QTimer* m_replayTimer = nullptr;
|
|
|
|
|
QTimer* m_passwordExpireTimer = nullptr;
|
|
|
|
|
QJsonArray m_replaySamples;
|
|
|
|
|
int m_replayIndex = 0;
|
2026-07-30 12:06:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // PARKINGSPACEGUIDEVIEW_MAINWINDOW_H
|