313 lines
8.5 KiB
C++
313 lines
8.5 KiB
C++
#pragma once
|
|
|
|
#include <QtWidgets/QWidget>
|
|
#include <QTimer>
|
|
#include <QLabel>
|
|
#include <QStackedWidget>
|
|
// 包含UI自动生成的头文件(qmake编译时会自动生成)
|
|
#include "ui_InkJetPrinter.h"
|
|
#include "mainwidget.h"
|
|
#include "testprintwidget.h"
|
|
//#include "ercodesettings.h"
|
|
//#include "loadfilesetting.h"
|
|
//#include "MainInterfaceWidget.h"
|
|
|
|
#include "MyInputMethod.h"
|
|
#include <QMessageBox>
|
|
#include <QSpinBox>
|
|
#include <QTime>
|
|
#include <QThread>
|
|
#include "fontsetwidget.h"
|
|
#include "Printsetting.h"
|
|
#include "MainInstruction.h"
|
|
#include "SystemManage.h"
|
|
#include "SystemSetting.h"
|
|
#include "SystemUpdate.h"
|
|
#include "OtherInfo.h"
|
|
#include "scene/ScheduleShiftsEditor.h"
|
|
#include "Serial/serial.h"
|
|
#include "LogInfo.h"
|
|
#include "DateVarSet.h"
|
|
#include "CounterVarSet.h"
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
#include "QBarCode.h"
|
|
#include "dlgQrCode.h"
|
|
|
|
#include "rfid/RFIDManager.h"
|
|
#include "runtimectrl.h"
|
|
#include "scene/PicSceneLoader.h"
|
|
|
|
// 状态机
|
|
#include "StateMachine/PrinterStateManager.h"
|
|
|
|
class DialogFileOperation;
|
|
|
|
class InkJetPrinter : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
InkJetPrinter(QWidget* parent = nullptr);
|
|
~InkJetPrinter();
|
|
|
|
private:
|
|
// UI对象(由.ui文件生成)
|
|
Ui::InkJetPrinter ui;
|
|
SysPara* sysPara = nullptr;
|
|
|
|
QLabel* m_LabelTimer; // 保留原有变量,和ui中的控件关联
|
|
QTimer* m_Timer;
|
|
bool m_warn = false;
|
|
QTimer* timer;
|
|
QTimer* viscosity_timer;
|
|
// QTimer* jd_timer;
|
|
|
|
QStackedWidget* m_StackedWidget; // 关联ui中的m_StackedWidget
|
|
MainWidget* m_MainWidget;
|
|
TestPrintWidget* m_TestPrintWidget;
|
|
|
|
QBarCode* m_BarCodeDlg __attribute__((deprecated("Use BarcodeEditor instead"))) = nullptr;
|
|
|
|
dlgQrCode* m_QRCodeDlg __attribute__((deprecated("Use BarcodeEditor instead"))) = nullptr;
|
|
|
|
SystemManage* m_SystemManage;
|
|
SystemUpdate* m_SystemUpdate;
|
|
SystemSetting* m_SystemSetting;
|
|
OtherInfo* m_OtherInfo;
|
|
|
|
DialogFileOperation* m_dlgFileOperation = nullptr;
|
|
|
|
FontSetWidget* m_FontSetWidget;
|
|
|
|
PrintSetting* m_PrintSetting;
|
|
|
|
bool m_isDefaultPrintSettingMode = false;
|
|
PrintSettingModel m_savedPrintSettingModel;
|
|
|
|
MainInstruction* m_MainInstruction;
|
|
|
|
LogInfo* m_LogInfo;
|
|
LogInfoCtrl* ctrl_loginfo = nullptr;
|
|
|
|
ScheduleShiftsEditor* m_scheduleShiftsEditor = nullptr;
|
|
|
|
DateVarSet* m_DateVarSet;
|
|
|
|
CounterVarSet* m_CounterVarSet;
|
|
|
|
QTextEdit *m_textEdit;
|
|
|
|
QTextCursor cursor;
|
|
|
|
Serial *serialFPGA;
|
|
Serial *serialSTM32;
|
|
QThread* m_serialThreadFPGA;
|
|
QThread* m_serialThreadSTM32;
|
|
bool flagOfSerialThreadStratEn;
|
|
|
|
private:
|
|
bool pushButtonStartFlag;
|
|
void init();
|
|
void initSerialPorts();
|
|
void autoControlValvePump();
|
|
|
|
void autoControlCycleValve();
|
|
|
|
void autoControlViscosityPump();
|
|
|
|
void autoControlViscosityPumpForSelfCheck(int selfCheckCnt);
|
|
|
|
void pressureAdj();
|
|
void autoControlHeater();
|
|
void cycleValveRunForSelfCheck();
|
|
void detectAndcontrolReclaimTank();
|
|
|
|
/**
|
|
* @brief 加载最后一次作业文件并准备打印
|
|
* 包括:加载打印内容,打印设置
|
|
* @return 加载是否成功
|
|
*
|
|
*/
|
|
bool loadLastWorkAndPreparePrint();
|
|
|
|
/**
|
|
* @brief 加载指定作业文件并准备打印
|
|
*
|
|
* @param filename 作业文件的路径
|
|
* @return 加载是否成功
|
|
*/
|
|
bool loadWorkFileAndPreparePrint(const QString& filename);
|
|
|
|
QString currWorkFile;
|
|
|
|
void checkPressureControl();
|
|
void showMessage(QString);
|
|
|
|
void enterDefaultPrintSettingMode();
|
|
void exitDefaultPrintSettingMode();
|
|
|
|
bool cardTouchConfirm(QString msgTxt, QString variableMsgTxt);
|
|
|
|
QMessageBox *msgtest;
|
|
// 本次开机时间
|
|
QDateTime curPowerOnDateTime;
|
|
int timeoutDay;
|
|
|
|
RunTimeCtrl* ctrl_runTime = nullptr;
|
|
void initRunTimeCtrl();
|
|
|
|
#ifdef __RFID_CARD
|
|
RFIDManager* manager_rfid = nullptr;
|
|
void initRFIDManager();
|
|
void handleWarnInk();
|
|
void handleWarnSolvent();
|
|
QDateTime inkWarnTime = QDateTime();
|
|
QDateTime solventWarnTime = QDateTime();
|
|
#endif
|
|
void setWarn(bool flag);
|
|
private slots:
|
|
|
|
void resetRFIDStatus();
|
|
|
|
void onDlgFileOpen(const QString& filename);
|
|
|
|
void restartPrintWhenSwitchedWorkFile(bool isPrinting);
|
|
|
|
void slt_showMsg(QString msg);
|
|
void timerHandler();
|
|
void slt_mTimer();
|
|
void getMainWidgetButtonClickedSlot(int index);
|
|
void getTestPrintWidgetButtonClickedSlot(int index);
|
|
void openDatetimeEditor(DateItemModel dateModel, TextItemModel textItemModel);
|
|
// 更新打印内容
|
|
void slt_updatePrintContent(const QString& filename);
|
|
// void getErCodeSettingsWidgetButtonClickedSlot(int index);
|
|
// void getMainInterfaceWidgetButtonClickedSlot(int index);
|
|
void viscosity_timerHandler();
|
|
|
|
void rebootApp();
|
|
|
|
void getFontSetWidgetButtonClickedSlot(int index);
|
|
void getPrintSettingButtonClickedSlot(int index);
|
|
void getMainInstructWidgetButtonClickedSlot(int index);
|
|
void getSystemManageWidgetButtonClickSlot(int index);
|
|
void getSystemUpdateWidgetButtonClickSlot(int index);
|
|
void getSystemSettingWidgetButtonClickSlot(int index);
|
|
void getOtherInfoWidgetButtonClickSlot(int index);
|
|
void getLogInfoWidgetButtonClickSlot(int index);
|
|
void getDateSetWidgetButtonClickSlot(int index);
|
|
void getCounterVarSetWidgetButtonClickSlot(int index);
|
|
void slt_counterVarUpdate();
|
|
|
|
void showScheduleShiftsEditor(QVector<ScheduleModel> schedules, TextItemModel txtModel);
|
|
|
|
void onScheduleShiftsEditDone();
|
|
|
|
//Serial
|
|
void saveFPGAVersionNum(unsigned int);
|
|
void saveFPGAStatus(unsigned char *data);
|
|
void saveFPGAPhaseDetectHighTm(unsigned char *data);
|
|
void saveFPGACalandarAndDat(unsigned char *data);
|
|
void saveFPGACnt3CurrValue(unsigned char *data);
|
|
void saveFPGAXXXDay(unsigned char *data);
|
|
void stopSendFPGAData(bool);
|
|
void closeSerialFPGA();
|
|
|
|
void closeSerialSTM32();
|
|
void stopSendSTM32Data(bool);
|
|
void saveSTM32Status(unsigned char *data);
|
|
void saveGearPumpVal(unsigned char *data);
|
|
void savePulseCntVal(unsigned char *data);
|
|
void saveSTM32Version(unsigned char *data);
|
|
void saveSTM32Time(unsigned char *data);
|
|
void closedSerial();
|
|
void showFPGAqueuesize(int size);
|
|
void showSTM32queuesize(int size);
|
|
void showqueueFPGAsize(int size);
|
|
void restartSerialPort();
|
|
|
|
void disableTabClick();
|
|
|
|
void setShowVserionInfo(QString);
|
|
|
|
void OnFinished(int event);
|
|
|
|
void slt_editCounter(CounterViewModel vm);
|
|
|
|
// 保养警告
|
|
void slt_warningMaintenance();
|
|
|
|
void checkStatusAndStartGearPump();
|
|
signals:
|
|
void maintenanceShow();
|
|
|
|
void printStatusChanged(bool isPrinting);
|
|
|
|
void pipingStatusChanged();
|
|
|
|
protected:
|
|
void showEvent(QShowEvent* e) override;
|
|
|
|
public slots:
|
|
void close_jd_timer();
|
|
void enableInkJetTabClick(bool flag);
|
|
|
|
void handleInitedPID();
|
|
void resetPressureCnt();
|
|
// 从文件获取墨水和溶剂各自第一次警告的时间
|
|
int updateWarningTime(int);
|
|
void warningHandler(int);
|
|
void warningShow(int,int);
|
|
|
|
void createNewJobFile();
|
|
|
|
public:
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
|
|
|
private:
|
|
// 压力调节算法状态变量
|
|
bool m_rampDone = false; // pressureAdj 软启动完成标志
|
|
int m_adjSkip = 0; // pressureAdj 节拍计数(软启动/超时复用)
|
|
int m_lastPressure = 0; // pressureAdj 上次采样压力(稳定检测用)
|
|
int m_stableCount = 0; // pressureAdj 压力连续稳定计数
|
|
int m_pressureBuf[10] = {}; // pressureAdj 压力滑动平均缓冲(10点=1s)
|
|
int m_bufIdx = 0; // pressureAdj 滑动平均写入索引
|
|
bool m_lastByHand = false; // 上一帧手动控制标志(边沿检测用)
|
|
bool m_lastReclaimMode = false; // 上一帧回收泵模式(边沿检测用)
|
|
|
|
// 去抖(管路/墨水警告清除)——使用 QElapsedTimer 实现连续 2s 无警告判断
|
|
QElapsedTimer m_pipingClearSince;
|
|
|
|
bool gearPumpRunFlag = false;
|
|
bool gearPumpStartFlag = false;
|
|
|
|
|
|
// 状态机
|
|
PrinterStateManager* m_stateManager = nullptr;
|
|
// 测试定时器
|
|
QTimer* m_testTimer = nullptr;
|
|
int m_testStep = 0;
|
|
private:
|
|
void initStateManager();
|
|
void initStateTimer();
|
|
// 不同状态的处理
|
|
// 自检
|
|
void handleSelfCheck();
|
|
|
|
// 就绪
|
|
void handleReady();
|
|
|
|
// 开始和暂停打印
|
|
void handleStartPrint();
|
|
void handleStopPrint();
|
|
|
|
// 关机
|
|
void handlePowerOff();
|
|
private slots:
|
|
void slt_stateTest();
|
|
void slt_stateChanged(PrinterState newState, PrinterState oldState, QString reason);
|
|
|
|
};
|