提交原始齿轮泵代码
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#include "sectionalmanager.h"
|
||||
|
||||
SectionalManager *SectionalManager::instance()
|
||||
{
|
||||
static SectionalManager *instance = nullptr;
|
||||
if(!instance) {
|
||||
instance = new SectionalManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void SectionalManager::emitUpdateCntShow(bool checked)
|
||||
{
|
||||
emit sig_updateCntShow(checked);
|
||||
}
|
||||
|
||||
void SectionalManager::emitApplySetting()
|
||||
{
|
||||
emit sig_applySetting();
|
||||
}
|
||||
|
||||
void SectionalManager::emitLoadUI()
|
||||
{
|
||||
emit sig_loadSettings2UI();
|
||||
}
|
||||
|
||||
SectionalManager::SectionalManager()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef SECTIONALMANAGER_H
|
||||
#define SECTIONALMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
/**
|
||||
迁移vx4桂林国际分段计米功能
|
||||
**/
|
||||
|
||||
class SectionalManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static SectionalManager* instance();
|
||||
virtual ~SectionalManager() = default;
|
||||
|
||||
// 更新计数器的可用
|
||||
void emitUpdateCntShow(bool);
|
||||
|
||||
//应用配置1
|
||||
void emitApplySetting();
|
||||
|
||||
//应用配置
|
||||
void emitLoadUI();
|
||||
|
||||
private:
|
||||
SectionalManager();
|
||||
|
||||
signals:
|
||||
void sig_updateCntShow(bool);
|
||||
void sig_applySetting();
|
||||
void sig_loadSettings2UI();
|
||||
void sig_updateCntGroupDisp(bool);
|
||||
|
||||
};
|
||||
|
||||
#endif // SECTIONALMANAGER_H
|
||||
@@ -0,0 +1,576 @@
|
||||
#include "sectionalwid.h"
|
||||
#include "ui_sectionalwid.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
SectionalWid::SectionalWid(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SectionalWid)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initUI();
|
||||
|
||||
connect(SectionalManager::instance(), &SectionalManager::sig_applySetting,
|
||||
this, &SectionalWid::slt_applySetting);
|
||||
connect(SectionalManager::instance(), &SectionalManager::sig_loadSettings2UI,
|
||||
this, &SectionalWid::slt_loadSettings2UI);
|
||||
connect(SectionalManager::instance(), &SectionalManager::sig_updateCntGroupDisp,
|
||||
this, &SectionalWid::slt_updateCntGroupDisp);
|
||||
}
|
||||
|
||||
SectionalWid::~SectionalWid()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SectionalWid::bindSysPara(SysPara* sysPara)
|
||||
{
|
||||
this->sysPara = sysPara;
|
||||
}
|
||||
|
||||
#ifdef COUNTER1_BY_GROUP /* 分段计米 */
|
||||
void SectionalWid::rowWidgetCreate(int rowIndex)
|
||||
{
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
QSpinBox *spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setMaximum(INT_MAX);
|
||||
spinBox->setMinimum(i == 2 ? 1 : 0);
|
||||
ui->tableWidget->setCellWidget(rowIndex,i,spinBox);
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::LoadCnt1GroupSettingsToUI()
|
||||
{
|
||||
ui->checkBoxGroupCnt1->setChecked(sysPara->para.cnt1ByGroupEnalbe);
|
||||
on_checkBoxGroupCnt1_clicked(sysPara->para.cnt1ByGroupEnalbe);
|
||||
ui->tableWidget->setRowCount(sysPara->para.Cnt1ByGroup.cnt1GroupCnt);
|
||||
for(int i=0; i<sysPara->para.Cnt1ByGroup.cnt1GroupCnt; i++)
|
||||
{
|
||||
QSpinBox *spinBox = new QSpinBox();
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(sysPara->para.Cnt1ByGroup.cnt1GroupSettings[i].StartValue);
|
||||
ui->tableWidget->setCellWidget(i,0,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(sysPara->para.Cnt1ByGroup.cnt1GroupSettings[i].EndValue);
|
||||
ui->tableWidget->setCellWidget(i,1,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setRange(1, INT_MAX);
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(sysPara->para.Cnt1ByGroup.cnt1GroupSettings[i].LoopTimes);
|
||||
ui->tableWidget->setCellWidget(i,2,spinBox);
|
||||
}
|
||||
updateCnt1GroupsTblWgt();
|
||||
}
|
||||
|
||||
void SectionalWid::on_Cnt3AddRowBtn_clicked()
|
||||
{
|
||||
int rowCnt=ui->tableWidget->rowCount();
|
||||
if(rowCnt>=MAX_CNT1_GROUPS_NUM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ui->tableWidget->setRowCount(rowCnt+1);
|
||||
rowWidgetCreate(rowCnt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SectionalWid::on_Cnt3InsertRowBtn_clicked()
|
||||
{
|
||||
int rowIndex=ui->tableWidget->currentRow();
|
||||
int rowCnt=ui->tableWidget->rowCount();
|
||||
if(rowIndex<0||rowCnt>=MAX_CNT1_GROUPS_NUM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ui->tableWidget->insertRow(rowIndex+1);
|
||||
rowWidgetCreate(rowIndex+1);
|
||||
}
|
||||
|
||||
void SectionalWid::on_cnt3RemoveAllRowsBtn_clicked()
|
||||
{
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("警告"),
|
||||
tr("是否确认删除全部设置?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok){
|
||||
int rowCnt=ui->tableWidget->rowCount();
|
||||
for(int i=rowCnt-1;i>=0;i--)
|
||||
{
|
||||
ui->tableWidget->removeRow(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::on_Cnt3RemoveRowBtn_clicked()
|
||||
{
|
||||
int rowIndex=ui->tableWidget->currentRow();
|
||||
if(rowIndex<0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QMessageBox::StandardButton ret;
|
||||
if(rowIndex==sysPara->status.cnt1GroupRunningIndex)
|
||||
{
|
||||
QMessageBox::warning(this, tr("错误"),
|
||||
tr("正在打印第%1组设置,不可删除").arg(rowIndex+1),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
ret = QMessageBox::warning(this, tr("警告"),
|
||||
tr("是否确认删除第%1组设置?").arg(rowIndex+1),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok){
|
||||
ui->tableWidget->removeRow(rowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::on_cnt3RemoveAllRowsBtn_3_clicked()
|
||||
{
|
||||
unsigned char temp = 1;
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("警告"),
|
||||
tr("是否确认清零计数器1的循环值已经打印次数?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok){
|
||||
sysPara->devOp->fpgaWr(0xb12c,(unsigned char *)&temp,1);
|
||||
temp = 0;
|
||||
sysPara->devOp->fpgaWr(0xb12c,(unsigned char *)&temp,1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SectionalWid::on_checkBoxGroupCnt1_clicked(bool checked)
|
||||
{
|
||||
// 信号修改计数器的显示
|
||||
ui->checkBoxGroupCnt_2->setChecked(checked);
|
||||
SectionalManager::instance()->emitUpdateCntShow(checked);
|
||||
}
|
||||
|
||||
void SectionalWid::updateCnt1GroupsTblWgt()
|
||||
{
|
||||
QPalette Palette;
|
||||
QSpinBox *spinBox;
|
||||
int rowCnt=ui->tableWidget->rowCount();
|
||||
|
||||
for(int i=0;i<rowCnt;i++)
|
||||
{
|
||||
for(int j=0;j<3;j++)
|
||||
{
|
||||
spinBox = (QSpinBox *)ui->tableWidget->cellWidget(i,j);
|
||||
QLineEdit *lineEdit = spinBox->findChild<QLineEdit*>();
|
||||
|
||||
if (lineEdit) {
|
||||
lineEdit->setAutoFillBackground(true);
|
||||
QPalette palette = lineEdit->palette();
|
||||
if(sysPara->para.cnt1ByGroupEnalbe && (i == sysPara->status.cnt1GroupRunningIndex))
|
||||
{
|
||||
palette.setColor(QPalette::Normal,QPalette::Base, Qt::green);
|
||||
}
|
||||
else
|
||||
{
|
||||
palette.setColor(QPalette::Normal,QPalette::Base, Qt::lightGray);
|
||||
}
|
||||
lineEdit->setPalette(palette);
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::ApplyCnt1GroupSetting()
|
||||
{
|
||||
QSpinBox *spinBox = nullptr;
|
||||
sysPara->para.cnt1ByGroupEnalbe = ui->checkBoxGroupCnt1->isChecked();
|
||||
sysPara->para.Cnt1ByGroup.cnt1GroupCnt=ui->tableWidget->rowCount();
|
||||
if(sysPara->para.cnt1ByGroupEnalbe && sysPara->para.Cnt1ByGroup.cnt1GroupCnt==0)
|
||||
{
|
||||
sysPara->para.cnt1ByGroupEnalbe=false;
|
||||
ui->checkBoxGroupCnt1->setChecked(false);
|
||||
on_checkBoxGroupCnt1_clicked(false);
|
||||
}
|
||||
|
||||
for(int i=0; i<sysPara->para.Cnt1ByGroup.cnt1GroupCnt; i++)
|
||||
{
|
||||
spinBox = (QSpinBox *)ui->tableWidget->cellWidget(i,0);
|
||||
sysPara->para.Cnt1ByGroup.cnt1GroupSettings[i].StartValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)ui->tableWidget->cellWidget(i,1);
|
||||
sysPara->para.Cnt1ByGroup.cnt1GroupSettings[i].EndValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)ui->tableWidget->cellWidget(i,2);
|
||||
sysPara->para.Cnt1ByGroup.cnt1GroupSettings[i].LoopTimes = spinBox->value();
|
||||
}
|
||||
sysPara->devOp->writeCnt1GroupSetting(1);
|
||||
sysPara->saveParaToFile();
|
||||
//改变当前执行的分段的背景颜色
|
||||
updateCnt1GroupsTblWgt();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COUNTER2_BY_GROUP /* 分段计米2 */
|
||||
void SectionalWid::rowWidgetCreate2(int rowIndex)
|
||||
{
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
QSpinBox *spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setMaximum(INT_MAX);
|
||||
spinBox->setMinimum(i == 2 ? 1 : 0);
|
||||
ui->tableWidget_2->setCellWidget(rowIndex,i,spinBox);
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::LoadCnt2GroupSettingsToUI()
|
||||
{
|
||||
ui->checkBoxGroupCnt_2->setChecked(sysPara->para.cnt2ByGroupEnalbe);
|
||||
on_checkBoxGroupCnt_2_clicked(sysPara->para.cnt2ByGroupEnalbe);
|
||||
//qDebug()<<"LoadCnt1GroupSettingsToUI:cnt1GroupCnt "<<sysPara->para.Cnt1ByGroup.cnt1GroupCnt;
|
||||
ui->tableWidget_2->setRowCount(sysPara->para.Cnt2ByGroup.cnt2GroupCnt);
|
||||
for(int i=0; i<sysPara->para.Cnt2ByGroup.cnt2GroupCnt; i++)
|
||||
{
|
||||
QSpinBox *spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(sysPara->para.Cnt2ByGroup.cnt2GroupSettings[i].StartValue);
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
ui->tableWidget_2->setCellWidget(i,0,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(sysPara->para.Cnt2ByGroup.cnt2GroupSettings[i].EndValue);
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
ui->tableWidget_2->setCellWidget(i,1,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(sysPara->para.Cnt2ByGroup.cnt2GroupSettings[i].LoopTimes);
|
||||
spinBox->setRange(1, INT_MAX);
|
||||
ui->tableWidget_2->setCellWidget(i,2,spinBox);
|
||||
}
|
||||
updateCnt2GroupsTblWgt();
|
||||
|
||||
}
|
||||
|
||||
void SectionalWid::on_checkBoxGroupCnt_2_clicked(bool checked)
|
||||
{
|
||||
// 信号修改计数器的显示
|
||||
ui->checkBoxGroupCnt1->setChecked(checked);
|
||||
SectionalManager::instance()->emitUpdateCntShow(checked);
|
||||
}
|
||||
|
||||
void SectionalWid::updateCnt2GroupsTblWgt()
|
||||
{
|
||||
QPalette Palette;
|
||||
int rowCnt=ui->tableWidget_2->rowCount();
|
||||
|
||||
for(int i=0;i<rowCnt;i++)
|
||||
{
|
||||
for(int j=0;j<3;j++)
|
||||
{
|
||||
auto spinBox = (QSpinBox *)ui->tableWidget_2->cellWidget(i,j);
|
||||
QLineEdit *lineEdit = spinBox->findChild<QLineEdit*>();
|
||||
|
||||
if (lineEdit) {
|
||||
lineEdit->setAutoFillBackground(true);
|
||||
|
||||
QPalette palette = lineEdit->palette();
|
||||
if(sysPara->para.cnt2ByGroupEnalbe && (i == sysPara->status.cnt2GroupRunningIndex))
|
||||
{
|
||||
palette.setColor(QPalette::Normal,QPalette::Base, Qt::green);
|
||||
}
|
||||
else
|
||||
{
|
||||
palette.setColor(QPalette::Normal,QPalette::Base, Qt::lightGray);
|
||||
}
|
||||
lineEdit->setPalette(palette);
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::ApplyCnt2GroupSetting()
|
||||
{
|
||||
QSpinBox *spinBox = nullptr;
|
||||
sysPara->para.cnt2ByGroupEnalbe = ui->checkBoxGroupCnt_2->isChecked();
|
||||
sysPara->para.Cnt2ByGroup.cnt2GroupCnt=ui->tableWidget_2->rowCount();
|
||||
if(sysPara->para.cnt2ByGroupEnalbe && sysPara->para.Cnt2ByGroup.cnt2GroupCnt==0)
|
||||
{
|
||||
sysPara->para.cnt2ByGroupEnalbe=false;
|
||||
ui->checkBoxGroupCnt_2->setChecked(false);
|
||||
on_checkBoxGroupCnt_2_clicked(false);
|
||||
}
|
||||
for(int i=0; i<sysPara->para.Cnt2ByGroup.cnt2GroupCnt; i++)
|
||||
{
|
||||
spinBox = (QSpinBox *)ui->tableWidget_2->cellWidget(i,0);
|
||||
sysPara->para.Cnt2ByGroup.cnt2GroupSettings[i].StartValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)ui->tableWidget_2->cellWidget(i,1);
|
||||
sysPara->para.Cnt2ByGroup.cnt2GroupSettings[i].EndValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)ui->tableWidget_2->cellWidget(i,2);
|
||||
sysPara->para.Cnt2ByGroup.cnt2GroupSettings[i].LoopTimes = spinBox->value();
|
||||
|
||||
}
|
||||
sysPara->devOp->writeCnt2GroupSetting(1);
|
||||
sysPara->saveParaToFile();
|
||||
//改变当前执行的分段的背景颜色
|
||||
updateCnt2GroupsTblWgt();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SectionalWid::moveRow(int nFrom, int nTo, QTableWidget* table)
|
||||
{
|
||||
if (table == nullptr) return;
|
||||
if( nFrom == nTo ) return;
|
||||
if( nFrom < 0 || nTo < 0 ) return;
|
||||
|
||||
int StartValue,EndValue,LoopTimes;
|
||||
int To_StartValue,To_EndValue,To_LoopTimes;
|
||||
QSpinBox *spinBox = nullptr;
|
||||
|
||||
int nRowCount = table->rowCount();
|
||||
if( nFrom >= nRowCount || nTo >= nRowCount ) return;
|
||||
|
||||
spinBox = (QSpinBox *)table->cellWidget(nFrom,0);
|
||||
StartValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)table->cellWidget(nFrom,1);
|
||||
EndValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)table->cellWidget(nFrom,2);
|
||||
LoopTimes = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)table->cellWidget(nTo,0);
|
||||
To_StartValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)table->cellWidget(nTo,1);
|
||||
To_EndValue = spinBox->value();
|
||||
|
||||
spinBox = (QSpinBox *)table->cellWidget(nTo,2);
|
||||
To_LoopTimes = spinBox->value();
|
||||
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(StartValue);
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
table->setCellWidget(nTo,0,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(EndValue);
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
table->setCellWidget(nTo,1,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(LoopTimes);
|
||||
spinBox->setRange(1, INT_MAX);
|
||||
table->setCellWidget(nTo,2,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(To_StartValue);
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
table->setCellWidget(nFrom,0,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(To_EndValue);
|
||||
spinBox->setRange(0, INT_MAX);
|
||||
table->setCellWidget(nFrom,1,spinBox);
|
||||
|
||||
spinBox = new QSpinBox();
|
||||
spinBox->setButtonSymbols(QSpinBox::NoButtons);
|
||||
spinBox->setValue(To_LoopTimes);
|
||||
spinBox->setRange(1, INT_MAX);
|
||||
table->setCellWidget(nFrom,2,spinBox);
|
||||
|
||||
table->selectRow(nTo);
|
||||
}
|
||||
|
||||
|
||||
void SectionalWid::on_pushButtonUpRow_clicked()
|
||||
{
|
||||
moveRow(ui->tableWidget->currentRow(),
|
||||
ui->tableWidget->currentRow() - 1,
|
||||
ui->tableWidget);
|
||||
}
|
||||
|
||||
void SectionalWid::on_pushButtonDownRow_clicked()
|
||||
{
|
||||
moveRow(ui->tableWidget->currentRow(),
|
||||
ui->tableWidget->currentRow() + 1,
|
||||
ui->tableWidget);
|
||||
}
|
||||
|
||||
#ifdef COUNTER2_BY_GROUP /* 分段计米 */
|
||||
void SectionalWid::on_Cnt3AddRowBtn_2_clicked()
|
||||
{
|
||||
int rowCnt=ui->tableWidget_2->rowCount();
|
||||
if(rowCnt>=MAX_CNT1_GROUPS_NUM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ui->tableWidget_2->setRowCount(rowCnt+1);
|
||||
rowWidgetCreate2(rowCnt);
|
||||
}
|
||||
|
||||
void SectionalWid::on_Cnt3InsertRowBtn_2_clicked()
|
||||
{
|
||||
int rowIndex=ui->tableWidget_2->currentRow();
|
||||
int rowCnt=ui->tableWidget_2->rowCount();
|
||||
if(rowIndex<0||rowCnt>=MAX_CNT1_GROUPS_NUM)
|
||||
{
|
||||
//qDebug()<<"max counter1 groups num is "<<MAX_CNT1_GROUPS_NUM;
|
||||
return;
|
||||
}
|
||||
ui->tableWidget_2->insertRow(rowIndex+1);
|
||||
rowWidgetCreate2(rowIndex+1);
|
||||
}
|
||||
|
||||
void SectionalWid::on_cnt3RemoveAllRowsBtn_2_clicked()
|
||||
{
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("警告"),
|
||||
tr("是否确认删除全部设置?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok){
|
||||
int rowCnt=ui->tableWidget_2->rowCount();
|
||||
for(int i=rowCnt-1;i>=0;i--)
|
||||
{
|
||||
ui->tableWidget_2->removeRow(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::on_Cnt3RemoveRowBtn_2_clicked()
|
||||
{
|
||||
|
||||
int rowIndex=ui->tableWidget_2->currentRow();
|
||||
if(rowIndex<0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QMessageBox::StandardButton ret;
|
||||
if(rowIndex==sysPara->status.cnt2GroupRunningIndex)
|
||||
{
|
||||
QMessageBox::warning(this, tr("错误"),
|
||||
tr("正在打印第%1组设置,不可删除").arg(rowIndex+1),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
ret = QMessageBox::warning(this, tr("警告"),
|
||||
tr("是否确认删除第%1组设置?").arg(rowIndex+1),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok){
|
||||
ui->tableWidget_2->removeRow(rowIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SectionalWid::on_cnt3RemoveAllRowsBtn_4_clicked()
|
||||
{
|
||||
unsigned char temp = 2;
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("警告"),
|
||||
tr("是否确认清零计数器2的循环值已经打印次数?"),
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok){
|
||||
sysPara->devOp->fpgaWr(0xb12c,(unsigned char *)&temp,1);
|
||||
temp = 0;
|
||||
sysPara->devOp->fpgaWr(0xb12c,(unsigned char *)&temp,1);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void SectionalWid::on_pushButtonUpRow_2_clicked()
|
||||
{
|
||||
moveRow(ui->tableWidget_2->currentRow(),
|
||||
ui->tableWidget_2->currentRow() - 1,
|
||||
ui->tableWidget_2);
|
||||
}
|
||||
|
||||
void SectionalWid::on_pushButtonDownRow_2_clicked()
|
||||
{
|
||||
moveRow(ui->tableWidget_2->currentRow(),
|
||||
ui->tableWidget_2->currentRow() + 1,
|
||||
ui->tableWidget_2);
|
||||
}
|
||||
|
||||
void SectionalWid::slt_applySetting()
|
||||
{
|
||||
#ifdef COUNTER1_BY_GROUP
|
||||
ApplyCnt1GroupSetting();
|
||||
#endif
|
||||
#ifdef COUNTER2_BY_GROUP
|
||||
ApplyCnt2GroupSetting();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SectionalWid::slt_loadSettings2UI()
|
||||
{
|
||||
#ifdef COUNTER1_BY_GROUP
|
||||
LoadCnt1GroupSettingsToUI();
|
||||
#endif
|
||||
#ifdef COUNTER2_BY_GROUP
|
||||
LoadCnt2GroupSettingsToUI();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SectionalWid::slt_updateCntGroupDisp(bool bChangeToNext)
|
||||
{
|
||||
if(bChangeToNext)//循环数走完
|
||||
{
|
||||
//改变当前执行的分段的背景颜色
|
||||
#ifdef COUNTER1_BY_GROUP /* 分段计米 */
|
||||
updateCnt1GroupsTblWgt();
|
||||
#endif
|
||||
#ifdef COUNTER2_BY_GROUP /* 分段计米2 */
|
||||
updateCnt2GroupsTblWgt();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void SectionalWid::initUI()
|
||||
{
|
||||
#ifdef COUNTER1_BY_GROUP /* 分段计米 */
|
||||
QStringList headerLabels = QStringList()<<QObject::tr("起始值")
|
||||
<<QObject::tr("结束值")
|
||||
<<QObject::tr("循环值");
|
||||
ui->tableWidget->setHorizontalHeaderLabels(headerLabels);
|
||||
ui->tableWidget->setFocusPolicy(Qt::NoFocus);
|
||||
ui->tableWidget->horizontalHeader()->setHighlightSections(false);
|
||||
ui->tableWidget->setColumnHidden(3,true);//第3列用来标志是否保存当前行
|
||||
QHeaderView* vertivalHeader = ui->tableWidget->verticalHeader();
|
||||
vertivalHeader->setFixedWidth(60);
|
||||
ui->tableWidget->setColumnWidth(2,120);
|
||||
#endif
|
||||
#ifdef COUNTER2_BY_GROUP /* 分段计米2 */
|
||||
QStringList headerLabels2 = QStringList()<<QObject::tr("起始值")
|
||||
<<QObject::tr("结束值")
|
||||
<<QObject::tr("循环值");
|
||||
ui->tableWidget_2->setHorizontalHeaderLabels(headerLabels2);
|
||||
ui->tableWidget_2->setFocusPolicy(Qt::NoFocus);
|
||||
ui->tableWidget_2->horizontalHeader()->setHighlightSections(false);
|
||||
ui->tableWidget_2->setColumnHidden(3,true);//第3列用来标志是否保存当前行
|
||||
QHeaderView* vertivalHeader2 = ui->tableWidget_2->verticalHeader();
|
||||
vertivalHeader2->setFixedWidth(60);
|
||||
ui->tableWidget_2->setColumnWidth(2,120);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef SECTIONALWID_H
|
||||
#define SECTIONALWID_H
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QWidget>
|
||||
#include "SysPara.h"
|
||||
#include "sectionalmanager.h"
|
||||
|
||||
/**
|
||||
迁移vx4桂林国际分段计米功能
|
||||
**/
|
||||
|
||||
#define MAX_CNT1_GROUPS_NUM 50
|
||||
|
||||
namespace Ui {
|
||||
class SectionalWid;
|
||||
}
|
||||
|
||||
class SectionalWid : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SectionalWid(QWidget *parent = 0);
|
||||
~SectionalWid();
|
||||
|
||||
void bindSysPara(SysPara* sysPara);
|
||||
|
||||
private slots:
|
||||
#ifdef COUNTER1_BY_GROUP /* 分段计米 */
|
||||
void on_Cnt3AddRowBtn_clicked();
|
||||
|
||||
void on_Cnt3InsertRowBtn_clicked();
|
||||
|
||||
void on_cnt3RemoveAllRowsBtn_clicked();
|
||||
|
||||
void on_Cnt3RemoveRowBtn_clicked();
|
||||
|
||||
void on_cnt3RemoveAllRowsBtn_3_clicked();
|
||||
|
||||
void on_checkBoxGroupCnt1_clicked(bool checked);
|
||||
#endif
|
||||
void on_pushButtonUpRow_clicked();
|
||||
|
||||
void on_pushButtonDownRow_clicked();
|
||||
|
||||
#ifdef COUNTER2_BY_GROUP /* 分段计米 */
|
||||
void on_Cnt3AddRowBtn_2_clicked();
|
||||
|
||||
void on_Cnt3InsertRowBtn_2_clicked();
|
||||
|
||||
void on_cnt3RemoveAllRowsBtn_2_clicked();
|
||||
|
||||
void on_Cnt3RemoveRowBtn_2_clicked();
|
||||
|
||||
void on_cnt3RemoveAllRowsBtn_4_clicked();
|
||||
|
||||
void on_checkBoxGroupCnt_2_clicked(bool checked);
|
||||
#endif
|
||||
void on_pushButtonUpRow_2_clicked();
|
||||
|
||||
void on_pushButtonDownRow_2_clicked();
|
||||
|
||||
void slt_applySetting();
|
||||
void slt_loadSettings2UI();
|
||||
void slt_updateCntGroupDisp(bool bChangeToNext);
|
||||
|
||||
private:
|
||||
Ui::SectionalWid *ui;
|
||||
SysPara* sysPara = nullptr;
|
||||
void initUI();
|
||||
|
||||
#ifdef COUNTER1_BY_GROUP /* 分段计米 */
|
||||
void rowWidgetCreate(int rowIndex);
|
||||
void LoadCnt1GroupSettingsToUI();
|
||||
void updateCnt1GroupsTblWgt();
|
||||
void ApplyCnt1GroupSetting();
|
||||
#endif
|
||||
|
||||
#ifdef COUNTER2_BY_GROUP /* 分段计米 */
|
||||
void rowWidgetCreate2(int rowIndex);
|
||||
void LoadCnt2GroupSettingsToUI();
|
||||
void updateCnt2GroupsTblWgt();
|
||||
void ApplyCnt2GroupSetting();
|
||||
#endif
|
||||
|
||||
/**
|
||||
type:选表格
|
||||
**/
|
||||
void moveRow(int currentRow, int toRow, QTableWidget* table);
|
||||
|
||||
};
|
||||
|
||||
#endif // SECTIONALWID_H
|
||||
@@ -0,0 +1,245 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SectionalWid</class>
|
||||
<widget class="QWidget" name="SectionalWid">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>778</width>
|
||||
<height>428</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>771</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_15">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxGroupCnt1">
|
||||
<property name="text">
|
||||
<string>分段计米1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="Cnt3RemoveRowBtn">
|
||||
<property name="text">
|
||||
<string>删 除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pushButtonUpRow">
|
||||
<property name="text">
|
||||
<string>上移</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pushButtonDownRow">
|
||||
<property name="text">
|
||||
<string>下移</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="Cnt3AddRowBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>添 加</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="cnt3RemoveAllRowsBtn">
|
||||
<property name="text">
|
||||
<string>全部删除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="Cnt3InsertRowBtn">
|
||||
<property name="text">
|
||||
<string>插 入</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="autoScroll">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rowCount">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>80</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>18</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>30</number>
|
||||
</attribute>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="cnt3RemoveAllRowsBtn_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>清零循环</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_21">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxGroupCnt_2">
|
||||
<property name="text">
|
||||
<string>分段计米2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="Cnt3RemoveRowBtn_2">
|
||||
<property name="text">
|
||||
<string>删 除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pushButtonUpRow_2">
|
||||
<property name="text">
|
||||
<string>上移</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pushButtonDownRow_2">
|
||||
<property name="text">
|
||||
<string>下移</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="Cnt3AddRowBtn_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>添 加</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="cnt3RemoveAllRowsBtn_2">
|
||||
<property name="text">
|
||||
<string>全部删除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="Cnt3InsertRowBtn_2">
|
||||
<property name="text">
|
||||
<string>插 入</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="QTableWidget" name="tableWidget_2">
|
||||
<property name="autoScroll">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rowCount">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>80</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>18</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>30</number>
|
||||
</attribute>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="cnt3RemoveAllRowsBtn_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>清零循环</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user