Files
EJM_Display/Pages/P00_PublicPage.h

139 lines
4.3 KiB
C
Raw Normal View History

2025-09-15 22:28:43 +08:00
#ifndef P00_PUBLICPAGE_H
#define P00_PUBLICPAGE_H
2025-08-20 23:06:28 +08:00
#include <QWidget>
#include <QVariant>
2025-09-15 22:28:43 +08:00
#include <QMap>
#include <QTextToSpeech>
#include <QLocale>
#include <QTimer>
#include <QLabel>
2025-09-28 17:14:34 +08:00
#include <QScrollBar>
2025-09-30 15:36:46 +08:00
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
2025-08-20 23:06:28 +08:00
#include "DataCenter/DataCenter.h"
#include "DataCenter/OpcUaManager.h"
#include "Pages/P01_MianPage.h"
#include "Pages/P02_ShieldPage.h"
#include "Pages/P07_CylinderPage.h"
#include "Pages/P08_AlarmPage.h"
#include "Pages/P09_RemotePage.h"
#include "Pages/P10_IntelligentPage.h"
#include "Pages/P11_IsolationPage.h"
#include "Pages/P12_NetworkPage.h"
#include "Pages/P13_InsPage.h"
#include "Pages/P14_AtlasPage.h"
#include "Pages/P15_ParameterPage.h"
#include "Pages/P16_SettingPage.h"
#include "Pages/P301_PumpPage.h"
#include "Pages/P401_CuttingPage.h"
#include "Pages/P501_LoaderPage.h"
#include "Pages/P601_TransportPage.h"
2025-09-15 22:28:43 +08:00
// 前向声明
class DataCenter;
class OpcUaManager;
class CursorController;
class QKeyEvent;
2025-08-20 23:06:28 +08:00
namespace Ui {
class P00_PublicPage;
}
2025-09-15 22:28:43 +08:00
2025-08-20 23:06:28 +08:00
class P00_PublicPage : public QWidget
{
Q_OBJECT
2025-09-30 15:36:46 +08:00
Q_PROPERTY(QRect voiceGeometry READ voiceGeometry WRITE setVoiceGeometry)
2025-08-20 23:06:28 +08:00
public:
explicit P00_PublicPage(QWidget *parent = nullptr);
2025-09-15 22:28:43 +08:00
~P00_PublicPage() override;
2025-09-28 17:14:34 +08:00
void smoothScrollTo(int targetX);
2025-08-20 23:06:28 +08:00
void WinInit();
void CursorInit();
void SignalSlotInit();
2025-09-28 17:14:34 +08:00
void ChangePage(uint16_t PageIndex,uint16_t PageNum,QString PageNames);
2025-09-30 15:36:46 +08:00
void VoiceWin(const QString &Info, bool shouldShow);
2025-08-20 23:06:28 +08:00
protected:
void keyPressEvent(QKeyEvent *e) override;
2025-09-15 22:28:43 +08:00
private slots:
2025-08-20 23:06:28 +08:00
void UIRefreshTimeOut();
void CursorScanTimerOut();
void onOpcStateChanged(QOpcUaClient::ClientState state);
void on_But_Close_clicked();
2025-09-15 22:28:43 +08:00
// 页面切换槽函数
2025-08-20 23:06:28 +08:00
void on_But_Page_0_clicked();
void on_But_Page_1_clicked();
void on_But_Page_2_clicked();
void on_But_Page_3_clicked();
void on_But_Page_4_clicked();
void on_But_Page_5_clicked();
void on_But_Page_6_clicked();
void on_But_Page_7_clicked();
void on_But_Page_8_clicked();
void on_But_Page_9_clicked();
void on_But_Page_10_clicked();
void on_But_Page_11_clicked();
void on_But_Page_12_clicked();
void on_But_Page_13_clicked();
void on_But_Page_14_clicked();
void on_But_Page_15_clicked();
private:
2025-09-15 22:28:43 +08:00
// 光标移动处理
void onCursorMoved(const QPoint &global);
2025-09-30 15:36:46 +08:00
QRect voiceGeometry() const;
void setVoiceGeometry(const QRect &g);
void startGeometryAnim(const QRect &start, const QRect &end, int dur);
bool m_realShow = false;
2025-09-15 22:28:43 +08:00
Ui::P00_PublicPage *ui;
2025-09-28 17:14:34 +08:00
QScrollBar* hScroll;
2025-09-15 22:28:43 +08:00
QLabel *m_cursorLabel = nullptr; // 自绘光标
OpcUaManager *m_opcManager; // OPC通信实例
DataCenter *m_dataCenter; // 数据中心
QString m_currentNodeId; // 当前操作节点ID
QTextToSpeech *tts; // 文本转语音
QTimer *UIRefresh_Timer; // UI刷新定时器
QTimer *CursorScan_Timer; // 光标扫描定时器
bool PLC_Started; // PLC运行状态标志
// 页面实例
P01_MianPage *Pub_MianPage = nullptr;
P02_ShieldPage *Pub_ShieldPage = nullptr;
P07_CylinderPage *Pub_CylinderPage = nullptr;
P08_AlarmPage *Pub_AlarmPage = nullptr;
P09_RemotePage *Pub_RemotePage = nullptr;
P10_IntelligentPage *Pub_IntelligentPage = nullptr;
P11_IsolationPage *Pub_IsolationPage = nullptr;
P12_NetworkPage *Pub_NetworkPage = nullptr;
P13_InsPage *Pub_InsPage = nullptr;
P14_AtlasPage *Pub_AtlasPage = nullptr;
P15_ParameterPage *Pub_ParameterPage = nullptr;
P16_SettingPage *Pub_SettingPage = nullptr;
P301_PumpPage *Pub_PumpPage = nullptr;
P401_CuttingPage *Pub_CuttingPage = nullptr;
P501_LoaderPage *Pub_LoaderPage = nullptr;
P601_TransportPage *Pub_TransportPage = nullptr;
QMap<uint16_t, QWidget*> m_widgetCache; // 页面缓存
QList<QString> slMotorCurColor; // 电机电流颜色列表
QList<QString> slMotorTempColor; // 电机温度颜色列表
// 光标状态变量(静态化避免重复定义)
static bool OldUp;
static bool OldDown;
static bool OldLeft;
static bool OldRight;
static bool OldConfirm;
2025-09-30 15:36:46 +08:00
bool OldShowVoice = false;
2025-08-20 23:06:28 +08:00
};
2025-09-15 22:28:43 +08:00
#endif // P00_PUBLICPAGE_H