V6.7.5_beta

This commit is contained in:
2026-07-22 11:47:13 +08:00
parent e90e80000f
commit 50c4999d90
26 changed files with 798 additions and 743 deletions
+147 -111
View File
@@ -5,6 +5,7 @@
#include <QElapsedTimer>
#include "VerBVersion.h"
#include <QEvent>
#include "DialogFileOperation.h"
#ifdef __RFID_CARD
#define DETECT_WARNING_TIME 10 //Seconds
@@ -92,6 +93,9 @@ void InkJetPrinter::init()
m_scheduleShiftsEditor = new ScheduleShiftsEditor(this);
m_DateVarSet = new DateVarSet(this);
m_CounterVarSet = new CounterVarSet(this);
m_dlgFileOperation = new DialogFileOperation(this);
connect(m_dlgFileOperation, &DialogFileOperation::openFile, this, &InkJetPrinter::onDlgFileOpen);
viscosity_timer = new QTimer();
connect(viscosity_timer, SIGNAL(timeout()), this, SLOT(viscosity_timerHandler()));
@@ -103,6 +107,10 @@ void InkJetPrinter::init()
// 我真的不想拉,但是今天状态燃尽了,以后再改了
m_TestPrintWidget->setPrintSettingWidget(m_PrintSetting);
// 初始文件名为 空
ui.label_currWorkFile->setText("");
ui.label_currEditFile->setText("");
// 信号槽连接(原逻辑完全不变)
connect(m_MainWidget, &MainWidget::sendButtonClickedSignal, this, &InkJetPrinter::getMainWidgetButtonClickedSlot);
connect(m_MainWidget,SIGNAL(setDisableAll()),this,SLOT(disableTabClick()));
@@ -116,25 +124,28 @@ void InkJetPrinter::init()
#ifndef FPGA_TEST
// 调入文件喷印时,主动重启打印
connect(m_TestPrintWidget, &TestPrintWidget::sig_stopPrint, m_MainWidget, [this](){
auto isPrinting = sysPara->status.isPrinting;
if(isPrinting) {
m_MainWidget->on_m_StopBtn_clicked();
// connect(m_TestPrintWidget, &TestPrintWidget::sig_currentFileChanged, this, [this](){
QTimer::singleShot(500, [this](){
// ui.label_currWorkFile->setText(m_TestPrintWidget->currentFile());
m_PrintSetting->applyPrintSettingsToSysPara(false);
// auto isPrinting = sysPara->status.isPrinting;
// if(isPrinting) {
// m_MainWidget->on_m_StopBtn_clicked();
m_MainWidget->on_m_StartBtn_clicked();
LogInfo::setRunStatusText("Restarting the print because the work file was switched.");
});
}
else {
QTimer::singleShot(300, [this](){
m_PrintSetting->applyPrintSettingsToSysPara(false);
});
}
});
// QTimer::singleShot(500, [this](){
// m_PrintSetting->applyPrintSettingsToSysPara(false);
// m_MainWidget->on_m_StartBtn_clicked();
// LogInfo::setRunStatusText("Restarting the print because the work file was switched.");
// });
// }
// else {
// QTimer::singleShot(300, [this](){
// m_PrintSetting->applyPrintSettingsToSysPara(false);
// });
// }
// });
#endif
// 班时元素与编辑 连接
@@ -166,7 +177,6 @@ void InkJetPrinter::init()
// connect(myInputMethod,&MyInputMethod::sendEnterClickedSignal,&TestPrintWidget::onEditItemDone);
// connect(myInputMethod,SIGNAL(sendEnterClickedSignal()),m_TestPrintWidget,SLOT(onEditItemDone()));
connect(m_DateVarSet,SIGNAL(backSpaceBtn()),myInputMethod,SLOT(backSapceButtonDel()));
connect(m_TestPrintWidget,SIGNAL(sendUpdateFontSignl(int)),m_FontSetWidget,SLOT(updateFontSelect(int)));
connect (m_MainWidget,SIGNAL(repeatInitedPid()),this,SLOT(handleInitedPID()));
connect(m_MainWidget,SIGNAL(clearPressureFault()),this,SLOT(resetPressureCnt()));
@@ -193,7 +203,6 @@ void InkJetPrinter::init()
m_OtherInfo->bindSysPara(para);
m_TestPrintWidget->bindSysPara(para);
m_DateVarSet->bindSysPara(para);
m_CounterVarSet->bindSysPara(para);
m_MainInstruction->bindSysPara(para);
m_BarCodeDlg->bindSysPara(para);
m_QRCodeDlg->bindSysPara(para);
@@ -208,11 +217,8 @@ void InkJetPrinter::init()
m_CounterVarSet->updateSysParaToUI();
m_SystemManage->loadKeyBoardType();
m_MainWidget->bindTxTEdit(m_TestPrintWidget->getQTextEdit());
m_MainWidget->bindPicScene(m_TestPrintWidget->getPicScene());
m_FontSetWidget->bindTxTEdit(m_TestPrintWidget->getQTextEdit());
m_CounterVarSet->bindTxTEdit(m_TestPrintWidget->getQTextEdit());
m_BarCodeDlg->bindTxTEdit(m_TestPrintWidget->getQTextEdit());
m_QRCodeDlg->bindTxTEdit(m_TestPrintWidget->getQTextEdit());
m_textEdit = m_TestPrintWidget->getQTextEdit();
@@ -238,62 +244,16 @@ void InkJetPrinter::init()
m_StackedWidget->addWidget(m_DateVarSet);
m_StackedWidget->addWidget(m_CounterVarSet);
// 创建 32 线程和 FPGA 线程,并初始化串口
m_serialThreadFPGA = new QThread;
serialFPGA = new Serial("/dev/ttyAS5");
connect(m_serialThreadFPGA,&QThread::started,serialFPGA,&Serial::startInitSlot);
serialFPGA->moveToThread(m_serialThreadFPGA);
connect(serialFPGA,SIGNAL(sendQueueData(int,int,unsigned char*,int,int)),sysPara->devOp,SLOT(resendFPGADate(int,int,unsigned char*,int,int)));
connect(serialFPGA,SIGNAL(resendFPGAData(int,int,unsigned char*,int,int)),sysPara->devOp,SLOT(resendFPGADate(int,int,unsigned char*,int,int)));
connect(sysPara->devOp,SIGNAL(sendSerialDataToFPGA(int,int,unsigned char*,int,int)),serialFPGA,SLOT(sendSerialData(int,int,unsigned char*,int,int)),Qt::QueuedConnection);
connect(serialFPGA,SIGNAL(getFPGAVersion(uint)),this,SLOT(saveFPGAVersionNum(uint)));
connect(serialFPGA,SIGNAL(stopSendData(bool)),this,SLOT(stopSendFPGAData(bool)));
connect(serialFPGA,SIGNAL(getFPGAPhaseDetectHighTm(unsigned char*)),this,SLOT(saveFPGAPhaseDetectHighTm(unsigned char*)));
connect(serialFPGA,SIGNAL(getFPGAStatus(unsigned char*)),this,SLOT(saveFPGAStatus(unsigned char*)));
connect(serialFPGA,SIGNAL(getFPGACalandarAndDat(unsigned char*)),this,SLOT(saveFPGACalandarAndDat(unsigned char*)));
connect(serialFPGA,SIGNAL(getFPGACnt3CurrValue(unsigned char*)),this,SLOT(saveFPGACnt3CurrValue(unsigned char*)));
connect(serialFPGA,SIGNAL(getFPGAXXXDay(unsigned char*)),this,SLOT(saveFPGAXXXDay(unsigned char*)));
connect(serialFPGA,SIGNAL(queueSizeFPGA(int)),this,SLOT(showFPGAqueuesize(int)));
connect(serialFPGA,SIGNAL(queueFPGASizeSIG(int)),this,SLOT(showqueueFPGAsize(int)));
connect(serialFPGA, &Serial::FPGABuildDat, this, [this](int buildTime){
sysPara->status.build_dat.builTime = quint16(buildTime);
qDebug() << "FPGA build time: " << buildTime;
LogInfo::setRunStatusText(QString("FPGA build time: %1").arg(buildTime));
});
m_serialThreadSTM32 = new QThread();
serialSTM32 = new Serial("/dev/ttyAS2");
connect(m_serialThreadSTM32,&QThread::started,serialSTM32,&Serial::startInitSlot);
serialSTM32->moveToThread(m_serialThreadSTM32);
connect(serialSTM32,SIGNAL(sendQueueData(int,int,unsigned char*,int,int)),sysPara->devOp,SLOT(resendSTM32Date(int,int,unsigned char*,int,int)));
connect(sysPara->devOp,SIGNAL(sendSerialDataToSTM32(int,int,unsigned char*,int,int)),serialSTM32,SLOT(sendSerialData(int,int,unsigned char*,int,int)));
connect(serialSTM32,SIGNAL(getSTM32Status(unsigned char*)),this,SLOT(saveSTM32Status(unsigned char*)));
connect(serialSTM32,SIGNAL(getGearPumpVal(unsigned char*)),this,SLOT(saveGearPumpVal(unsigned char*)));
connect(serialSTM32,SIGNAL(getPulseCnt(unsigned char*)),this,SLOT(savePulseCntVal(unsigned char*)));
connect(serialSTM32,SIGNAL(getSTM32Version(unsigned char*)),this,SLOT(saveSTM32Version(unsigned char*)));
connect(serialSTM32,SIGNAL(getSTM32Time(unsigned char*)),this,SLOT(saveSTM32Time(unsigned char*)));
connect(serialSTM32,SIGNAL(stopSendData(bool)),this,SLOT(stopSendSTM32Data(bool)));
connect(serialSTM32,SIGNAL(powerOffReady()),m_MainWidget,SLOT(powerOffConfirmed()));
connect(serialSTM32,SIGNAL(queueSizeSTM32(int)),this,SLOT(showSTM32queuesize(int)));
connect(serialSTM32, &Serial::STM32Connected, this, [this](bool ok, QString errorMsg){
if(ok){
LogInfo::setRunStatusText("Connected to STM32 serial port");
}
else{
LogInfo::setRunStatusText("STM32 serial port connection failed: " + errorMsg);
}
});
initSerialPorts();
connect(m_SystemManage,SIGNAL(sigToCloseSerialFPGA()),this,SLOT(closeSerialFPGA()));
connect(m_SystemManage,SIGNAL(sigToCloseSerialSTM32()),this,SLOT(closeSerialSTM32()));
connect(m_SystemManage,SIGNAL(restartSerial()),this,SLOT(restartSerialPort()));
connect(m_SystemManage, &SystemManage::rebootAppAcquired, this, &InkJetPrinter::rebootApp);
flagOfSerialThreadStratEn = true;
connect(m_SystemManage,SIGNAL(enableClick(bool)),this,SLOT(enableInkJetTabClick(bool)));
connect(m_SystemManage,SIGNAL(upgradeSTM32(QString)),serialSTM32,SLOT(upgradeSTM32File(QString)));
@@ -311,9 +271,6 @@ void InkJetPrinter::init()
sysPara->status.machineMac = m_MainInstruction->dlgInputAddr->jd.addr;
sysPara->para.rfidCountDown = 5;
if (m_TestPrintWidget)
m_TestPrintWidget->loadLastWork();
timer = new QTimer();
connect(timer, SIGNAL(timeout()), this, SLOT(timerHandler()));
timer->start(10);
@@ -362,9 +319,7 @@ void InkJetPrinter::showEvent(QShowEvent *e)
QWidget::showEvent(e);
if(firstShow) {
if (m_TestPrintWidget)
m_TestPrintWidget->loadLastWork();
loadLastWorkAndPreparePrint();
firstShow = false;
}
}
@@ -1524,19 +1479,9 @@ void InkJetPrinter::getTestPrintWidgetButtonClickedSlot(int index)
case 20:
{
m_StackedWidget->setCurrentWidget(m_MainWidget);
MySleep(200);
m_MainWidget->onPreviewScene();
m_MainWidget->SendPrintDataToFpga(0);
ui.label_currEditFile->setText("");
break;
}
// 哪个天才写的? 有什么用?
case 21:
{
// 没用的切换,不讲逻辑的嘛?
// m_StackedWidget->setCurrentWidget(m_TestPrintWidget);
break;
}
default:
break;
}
@@ -1553,10 +1498,9 @@ void InkJetPrinter::openDatetimeEditor(DateItemModel dateModel, TextItemModel te
m_StackedWidget->setCurrentWidget(m_DateVarSet);
}
void InkJetPrinter::slt_updatePrintContent()
void InkJetPrinter::slt_updatePrintContent(const QString &filename)
{
m_MainWidget->onPreviewScene();
m_MainWidget->SendPrintDataToFpga(0);
loadWorkFileAndPreparePrint(filename);
}
void InkJetPrinter::getFontSetWidgetButtonClickedSlot(int index)
@@ -1577,12 +1521,17 @@ void InkJetPrinter::getMainWidgetButtonClickedSlot(int index)
{
switch (index)
{
case 1:
case 1: { // 编辑当前文件
m_TestPrintWidget->openWorkFile(sysPara->para.lastOpenedFileName);
QFileInfo fileInfo(sysPara->para.lastOpenedFileName);
ui.label_currEditFile->setText(QString("E: %1").arg(fileInfo.baseName()));
m_StackedWidget->setCurrentWidget(m_TestPrintWidget);
break;
case 2:
// m_StackedWidget->setCurrentWidget(m_MainInterfaceWidget);
m_TestPrintWidget->on_openfileButton_pressed();
}
case 2: // 调入文件喷印
m_dlgFileOperation->setWindowModality(Qt::WindowModal);
m_dlgFileOperation->refreshListView(SCENE);
m_dlgFileOperation->show();
break;
case 3:
close();
@@ -1888,10 +1837,10 @@ void InkJetPrinter::saveFPGACalandarAndDat(unsigned char *data){
QString hexStr = QString::number(sysPara->status.calandar_and_dat.cnt1CurrValue, 16);
bool ok;
sysPara->para.cnt1CurrValue = hexStr.toUInt(&ok, 10);
// sysPara->para.cnt1CurrValue = hexStr.toUInt(&ok, 10);
hexStr = QString::number(sysPara->status.calandar_and_dat.cnt2CurrValue, 16);
sysPara->para.cnt2CurrValue = hexStr.toUInt(&ok, 10);
// sysPara->para.cnt2CurrValue = hexStr.toUInt(&ok, 10);
}
void InkJetPrinter::saveFPGACnt3CurrValue(unsigned char *data){
@@ -2070,13 +2019,18 @@ void InkJetPrinter::restartSerialPort(){
closeSerialFPGA();
closeSerialSTM32();
initSerialPorts();
}
void InkJetPrinter::initSerialPorts()
{
serialFPGA = new Serial("/dev/ttyAS5");
connect(m_serialThreadFPGA, &QThread::started, serialFPGA, &Serial::startInitSlot);
serialFPGA->moveToThread(m_serialThreadFPGA);
connect(serialFPGA,SIGNAL(sendQueueData(int,int,unsigned char*,int,int)),sysPara->devOp,SLOT(resendFPGADate(int,int,unsigned char*,int,int)));
connect(serialFPGA,SIGNAL(resendFPGAData(int,int,unsigned char*,int,int)),sysPara->devOp,SLOT(resendFPGADate(int,int,unsigned char*,int,int)));
connect(sysPara->devOp,SIGNAL(sendSerialDataToFPGA(int,int,unsigned char*,int,int)),serialFPGA,SLOT(sendSerialData(int,int,unsigned char*,int,int)),Qt::QueuedConnection);
connect(serialFPGA,SIGNAL(getFPGAVersion(uint)),this,SLOT(saveFPGAVersionNum(uint)));
connect(m_serialThreadFPGA,&QThread::started,serialFPGA,&Serial::startInitSlot);
connect(serialFPGA,SIGNAL(stopSendData(bool)),this,SLOT(stopSendFPGAData(bool)));
connect(serialFPGA,SIGNAL(getFPGAPhaseDetectHighTm(unsigned char*)),this,SLOT(saveFPGAPhaseDetectHighTm(unsigned char*)));
connect(serialFPGA,SIGNAL(getFPGAStatus(unsigned char*)),this,SLOT(saveFPGAStatus(unsigned char*)));
@@ -2092,6 +2046,7 @@ void InkJetPrinter::restartSerialPort(){
});
serialSTM32 = new Serial("/dev/ttyAS2");
connect(m_serialThreadSTM32, &QThread::started, serialSTM32, &Serial::startInitSlot);
serialSTM32->moveToThread(m_serialThreadSTM32);
connect(serialSTM32,SIGNAL(sendQueueData(int,int,unsigned char*,int,int)),sysPara->devOp,SLOT(resendSTM32Date(int,int,unsigned char*,int,int)));
connect(sysPara->devOp,SIGNAL(sendSerialDataToSTM32(int,int,unsigned char*,int,int)),serialSTM32,SLOT(sendSerialData(int,int,unsigned char*,int,int)));
@@ -2102,7 +2057,6 @@ void InkJetPrinter::restartSerialPort(){
connect(serialSTM32,SIGNAL(getSTM32Time(unsigned char*)),this,SLOT(saveSTM32Time(unsigned char*)));
connect(serialSTM32,SIGNAL(stopSendData(bool)),this,SLOT(stopSendSTM32Data(bool)));
connect(serialSTM32,SIGNAL(powerOffReady()),m_MainWidget,SLOT(powerOffConfirmed()));
connect(m_serialThreadSTM32,&QThread::started,serialSTM32,&Serial::startInitSlot);
connect(serialSTM32,SIGNAL(queueSizeSTM32(int)),this,SLOT(showSTM32queuesize(int)));
connect(serialSTM32, &Serial::STM32Connected, this, [this](bool ok, QString errorMsg){
if(ok){
@@ -2696,9 +2650,81 @@ void InkJetPrinter::handleInitedPID()
PID_init();
}
bool InkJetPrinter::loadLastWorkAndPreparePrint()
{
// 打开最后一次作业文件
qDebug() << sysPara->sysFile;
qDebug() << sysPara->para.lastOpenedFileName;
QString lastFilename = QString(sysPara->para.lastOpenedFileName);
QFileInfo fileInfo(lastFilename);
if (!(fileInfo.exists() && fileInfo.isFile())) {
LogInfo::setRunStatusText(QString("Last work file not found: %1").arg(lastFilename));
return false;
}
return loadWorkFileAndPreparePrint(lastFilename);
}
bool InkJetPrinter::loadWorkFileAndPreparePrint(const QString &filename)
{
auto u8Filename = filename.toUtf8();
if(u8Filename.size() > int(ARRAY_SIZE(sysPara->para.lastOpenedFileName) - 1)) {
LogInfo::setRunStatusText(QString("File name is too long: %1").arg(filename));
return false;
}
PicScene* scene = new PicScene();
PrintSettingModel model;
auto ret = PicSceneLoader::loadSceneFromFile(filename, scene, &model);
if(!ret) {
LogInfo::setRunStatusText(QString("Failed to load work file: %1").arg(filename));
delete scene;
return false;
}
bool rePrint = false;
if(sysPara->status.isPrinting && sysPara->status.selfCheckDone) {
m_MainWidget->on_m_StopBtn_clicked();
rePrint = true;
}
PrintSettingModel::applyToSysPara(model, sysPara);
// 应用完数据之后,将当前值编辑标志位清除,避免下次读取时为 true
model.cnt1Settings.editCurrValue = false;
model.cnt2Settings.editCurrValue = false;
PicSceneLoader::saveSceneToXmlFile(filename, scene, &model);
ret = m_MainWidget->generatePrintContent(scene);
if(!ret) {
LogInfo::setRunStatusText(QString("Failed to generate print content from work file: %1").arg(filename));
delete scene;
return false;
}
LogInfo::setRunStatusText(QString("Work file loaded: %1").arg(filename));
ui.label_currWorkFile->setText(QFileInfo(filename).baseName());
strncpy(sysPara->para.lastOpenedFileName, u8Filename.constData(), sizeof(sysPara->para.lastOpenedFileName) - 1);
sysPara->para.lastOpenedFileName[sizeof(sysPara->para.lastOpenedFileName) - 1] = '\0';
sysPara->saveParaToFile();
if(rePrint) {
m_MainWidget->on_m_StartBtn_clicked();
}
return true;
}
static int highPressureCnt = 0;
static unsigned int logCnt = 0;
void InkJetPrinter::checkPressureControl(){ //1s
void InkJetPrinter::checkPressureControl()
{ // 1s
unsigned int alarmPressure = 0;
if(sysPara->para.pressure <= 700)
alarmPressure = 800;
@@ -2879,19 +2905,9 @@ void InkJetPrinter::warningShow(int type,int num){
*/
void InkJetPrinter::createNewJobFile()
{
auto currentFile = m_TestPrintWidget->currentFile();
if(!currentFile.isEmpty() && !currentFile.contains("LastWork.xml")) {
QFileInfo fileInfo(currentFile);
auto ret = QMessageBox::information(nullptr, "", tr("当前正在使用\r\n %1 \r\n确定要新建文件吗?").arg(fileInfo.baseName()),
QMessageBox::Ok, QMessageBox::Cancel);
if(ret == QMessageBox::Cancel) {
LogInfo::setRunStatusText("Canceled create new job file.");
return;
}
}
LogInfo::setRunStatusText("Create new job file...");
qInfo() << "Switch to job edit widget...";
ui.label_currEditFile->setText(("E: (New file)"));
m_StackedWidget->setCurrentWidget(m_TestPrintWidget);
m_TestPrintWidget->on_newfileButton_pressed();
}
@@ -3018,6 +3034,15 @@ void InkJetPrinter::initRFIDManager()
this, &InkJetPrinter::slt_showMsg);
connect(manager_rfid,SIGNAL(sig_maintenanceShow()),
m_MainInstruction,SLOT(maintenanceDialogShow()));
auto checkReclaimOpenBtn = [this]() {
if(sysPara->status.selfCheckDone && (sysPara->status.reclaimTankstatus == 2 || sysPara->status.reclaimTankstatus == 6)) {
m_MainWidget->setReclaimOpenBtnStatus(true);
}
};
connect(manager_rfid, &RFIDManager::sig_inkCardProgressFinished, this, checkReclaimOpenBtn);
connect(manager_rfid, &RFIDManager::sig_solventProgressFinished, this, checkReclaimOpenBtn);
}
}
@@ -3197,3 +3222,14 @@ void InkJetPrinter::slt_showMsg(QString msg)
LogInfo::setRunStatusText(msg);
}
void InkJetPrinter::onDlgFileOpen(const QString& filename)
{
QFileInfo fileInfo(filename);
if(!fileInfo.exists() || !fileInfo.isFile()) {
LogInfo::setRunStatusText(tr("File not found: %1").arg(filename));
return;
}
loadWorkFileAndPreparePrint(filename);
}