253 lines
6.4 KiB
C++
253 lines
6.4 KiB
C++
#ifndef MainWidget_H
|
||
#define MainWidget_H
|
||
|
||
#define MDTFLAG 0xff00FF10
|
||
#define QRFLAG 0xff00FF20
|
||
#define BARFLAG 0xff00FF30
|
||
#define MMVAR 1
|
||
#define MAX_ALLOW_VISICOSITY_OVERFLOW_NUM 120 //连续超那么多次,会被认为粘度故障
|
||
|
||
#define EXPIRY_VARI_RECONISE 0x0000FF
|
||
#define RECICLARNUMBER 22
|
||
|
||
#include <QWidget>
|
||
#include <QVBoxLayout>
|
||
#include <QHBoxLayout>
|
||
#include <QLabel>
|
||
#include <QPushButton>
|
||
#include <QToolButton>
|
||
#include <QTextEdit>
|
||
#include <QTime>
|
||
#include <QElapsedTimer>
|
||
#include <QMessageBox>
|
||
#include "scene/picscene.h"
|
||
#include "LogInfo.h"
|
||
|
||
// 包含UI自动生成的头文件
|
||
#include "ui_MainWidget.h"
|
||
|
||
#include "fileManage/FileManageWidget.h"
|
||
|
||
#include "setnumdlg.h"
|
||
|
||
class MainWidget : public QWidget
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
MainWidget(QWidget* parent = nullptr);
|
||
~MainWidget();
|
||
bool m_warn = false;
|
||
|
||
void bindSysPara(SysPara *SysPara);
|
||
|
||
/**
|
||
* @brief 生成打印内容,并发送打印内容到 FPGA
|
||
*
|
||
* @param pPicScene 包含打印内容的场景
|
||
* @return 成功返回true,否则false,查看日志
|
||
*/
|
||
bool generatePrintContent(PicScene* pPicScene);
|
||
|
||
/**
|
||
* @brief 重新生成打印内容,所用场景是由调用 generatePrintContent 时设置的,generatePrintContent 也会调用此函数
|
||
*
|
||
*/
|
||
void onPreviewScene();
|
||
|
||
// 260420 hlp:场景为空时,渲染空场景并刷新界面
|
||
void handleEmptySize();
|
||
|
||
QString strWarring,strTitle;
|
||
bool m_2sFlag;
|
||
bool printintFlag; //判断当前是否在打印
|
||
bool startPrintingFlag;
|
||
|
||
bool pushButtonFlag;
|
||
|
||
// 单独更新时间类图元 byons@2026年4月11日
|
||
|
||
/**
|
||
* @brief 更新时间类图元到FPGA print 数据
|
||
* @return 返回需要更新的区域
|
||
* @remark 判断返回值用于决定是否SendPrintDataToFpga
|
||
*/
|
||
QList<QRect> variableItemsUpdate();
|
||
|
||
/**
|
||
* @brief 向FPGA print 数据缓冲区写入image
|
||
* @return 返回总计写入的点阵数量,返回 0 没有写入任何点阵
|
||
* @param img 要写入的image
|
||
* @param startX 起始x坐标
|
||
* @param startY 起始y坐标
|
||
*/
|
||
int imageToPrintData(QImage& img, int startX, int startY);
|
||
|
||
void generateCharRamData();
|
||
|
||
void generateCharRamDataV2();
|
||
|
||
void setRunStatus(QString str, bool enbRoll = true, bool warn = false);
|
||
void enablePrintButton(bool);
|
||
int getCurrPrintStatus();
|
||
|
||
// 回收槽开启按钮状态设置
|
||
void setReclaimOpenBtnStatus(bool enable);
|
||
|
||
// 回收槽关闭按钮状态设置
|
||
void setReclaimCloseBtnStatus(bool enable);
|
||
|
||
void flashReclaimOpenBtn();
|
||
|
||
void stopFlashReclaimOpenBtn();
|
||
|
||
PicScene* currScene() const {
|
||
return pPicScene;
|
||
}
|
||
|
||
/**
|
||
* @brief 设置回收槽开关状态
|
||
* @param isOpen true:开;false:关
|
||
* @param rate 回收槽开启程度,0~100;
|
||
*/
|
||
void setReclaimStatus(bool isOpen, int rate = 0);
|
||
|
||
void updateSysStatusToUI(); //重载
|
||
//Mainwindow获取机器总状态
|
||
DevStatusLightType m_stateColor = DEV_STATUS_GREEN;
|
||
//DEV_STATUS_GREEN:正常
|
||
QString m_stateStr = "正常";
|
||
bool checkRed(AlarmStatus &status);
|
||
bool checkYellow(AlarmStatus &status);
|
||
void updateGeneralState(AlarmStatus status);
|
||
|
||
|
||
void updateTotalCnt(int en);
|
||
int calculateMaxSpeed(int backup);
|
||
int getMaxSpeedCalcPara();
|
||
|
||
QTimer *timerShowItem,*timerPowerOff;
|
||
|
||
void SendPrintDataToFpga(unsigned char alterEnable, bool isUpdate = false);
|
||
|
||
void updatePrintDisplayLabel();
|
||
|
||
void RefreshStatusLight();
|
||
bool updatePhaseIndicatorLight();
|
||
|
||
bool flagOfClearHighVltageWarnning;
|
||
|
||
AlarmStatus alarmStatus;
|
||
|
||
// void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||
|
||
private:
|
||
// UI对象
|
||
Ui::MainWidget ui;
|
||
SysPara *sysPara = nullptr;
|
||
|
||
// 控件成员变量(关联UI控件)
|
||
QPushButton* m_EditBtn;
|
||
QPushButton* m_AddBtn;
|
||
QPushButton* m_MainBtn;
|
||
QPushButton* m_ManageBtn;
|
||
QPushButton* m_MsgBtn;
|
||
QPushButton* m_CloseBtn;
|
||
QPushButton* m_StopBtn;
|
||
QPushButton* m_StartBtn;
|
||
QPushButton* m_ToolBtn;
|
||
QToolButton* m_RightBtn;
|
||
QToolButton* m_LeftBtn;
|
||
PrintTextDisplay* m_PrintDisplay;
|
||
|
||
int r_ExpiryDay;
|
||
QTimer *airPushTimer;
|
||
|
||
PicScene *pPicScene = nullptr;
|
||
QGraphicsView *view;
|
||
|
||
FileManageWidget *m_fileManageWidget = nullptr;
|
||
|
||
int dlgMyWarringShowDlyCnt;
|
||
|
||
SetNumDlg* m_setNumDlg = nullptr;
|
||
|
||
//------自定义双击------
|
||
QPoint m_lastClickPos;
|
||
qint64 m_lastClickTime = 0;
|
||
const int m_doubleClickDistance = 25; // 自定义距离阈值(像素)
|
||
const int m_doubleClickInterval = 500; // 自定义时间阈值(毫秒)
|
||
|
||
void mousePressEvent(QMouseEvent *event) override;
|
||
void handleDoubleClick(QMouseEvent *event);
|
||
bool isInExpandedRect(QWidget* widget, const QPoint& globalPos, int expandSize);
|
||
bool checkTriggerMode();
|
||
//--------------------
|
||
public slots:
|
||
void powerOffConfirmed();
|
||
void on_m_StartBtn_clicked();
|
||
void on_m_StopBtn_clicked();
|
||
void sendPowerOffCmd();
|
||
void checkForPowerOff();
|
||
void _on_pushButtonPowerOff_pressed(bool notice);
|
||
|
||
void onLabelFaultRusumePressed();
|
||
|
||
void UpdateUIVersion();
|
||
|
||
void on_m_RightBtn_clicked();
|
||
|
||
void on_m_LeftBtn_clicked();
|
||
|
||
private:
|
||
void init();
|
||
// void SendPrintDataToFpga(unsigned char);
|
||
void reclaimTanOpen();
|
||
|
||
void initSheet();
|
||
|
||
void updateNozzleStateMarquee(const QString& str);
|
||
void stopNozzleStateMarquee();
|
||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||
|
||
bool m_reclaimFlashState = false;
|
||
|
||
QTimer* m_reclaimOpenBtnFlashTimer = nullptr;
|
||
|
||
QTimer* m_nozzleStateMarqueeTimer = nullptr;
|
||
QString m_nozzleStateFullText;
|
||
int m_nozzleStateMarqueeOffsetPx = 0;
|
||
int m_nozzleStateMarqueeTextWidth = 0;
|
||
int m_nozzleStateMarqueeGapPx = 0;
|
||
bool m_nozzleStateMarqueeEnabled = false;
|
||
|
||
// 高亮切换
|
||
void changeHighLight(bool isStart);
|
||
private slots:
|
||
void airPushingProcess();
|
||
void buttonClickedSlot();
|
||
|
||
void on_m_ManageBtn_clicked();
|
||
|
||
void slt_setNum();
|
||
|
||
void slt_clearCnt();
|
||
|
||
void onReclaimOpenBtnFlashTimerTimeout();
|
||
|
||
void onNozzleStateMarqueeTimeout();
|
||
|
||
signals:
|
||
void sendButtonClickedSignal(int index);
|
||
void setDisableAll();
|
||
void CloseJd();
|
||
void showVserionInfo(QString);
|
||
|
||
void repeatInitedPid();
|
||
void clearPressureFault();
|
||
|
||
void newFileAcquired();
|
||
};
|
||
|
||
#endif // MainWidget_H
|