qt/ledset/expertsmartpointsetwin.cpp

877 lines
32 KiB
C++
Raw Normal View History

2022-08-25 18:43:03 +08:00
#include "expertsmartpointsetwin.h"
2023-05-27 17:43:57 +08:00
#include "gutil/qgui.h"
#include "globalfunc.h"
2022-08-25 18:43:03 +08:00
#include <QStackedLayout>
#include <QLabel>
#include <QRadioButton>
#include <QPushButton>
#include <QButtonGroup>
2022-08-25 22:52:52 +08:00
#include <QHeaderView>
2022-09-08 23:22:59 +08:00
#include <QMessageBox>
#include <QLineEdit>
#include <QApplication>
#include <QFileDialog>
2022-09-09 23:25:49 +08:00
#include <QJsonArray>
#include <QJsonDocument>
2023-05-27 17:43:57 +08:00
#include <QDialogButtonBox>
struct ModUnitMap {
byte UUID{ie(16)};
byte type{ipp(4)};
byte len{ipp(4)};
byte w{ipp(2)};
byte h{ipp(2)};
byte ex1{ipp(4)};
byte ChipType{ipp(2)};
byte decodeMode{ipp(2)};
byte ex3{ipp(4)};
byte smartset{ipp(4)};
byte smartset2{ipp(4)};
byte len{ipp(4)};
byte endFlag{ipp(4)};
byte end{fi};
} modUnitMap;
struct ModMap {
byte start{ie(4)};
byte {ipp(2)};
byte len{ipp(2)};
byte {ipp(2)};
byte {ipp(2)};
byte OE宽度{ipp(2)};
byte {ipp(2)};
byte GLK占空比{fi++};
byte {fi++};
byte {fi++};
byte {fi++};
byte {fi++};
byte {fi++};
byte {fi++};
byte {fi++};
byte {ipp(3)};
byte {ipp()};
byte Unit{ipp(modUnitMap.end)};
byte 2{ie(4)};
byte check{ie(4)};
byte end{fi};
} modMap;
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{expertWin}, expertWin(expertWin) {
2022-08-25 18:43:03 +08:00
setWindowModality(Qt::WindowModal);
setAttribute(Qt::WA_DeleteOnClose);
2022-12-16 15:08:53 +08:00
setWindowTitle(tr("智能走点参数配置"));
2022-08-25 18:43:03 +08:00
resize(900, 600);
2022-12-16 15:08:53 +08:00
ModuleWidth = expertWin->mModule["ModuleWidth"].toInt();
ModuleHeight = expertWin->mModule["ModuleHeight"].toInt();
GroupNum = expertWin->mModule["GroupNum"].toInt();
ScanNum = expertWin->mModule["ScanNum"].toInt();
ChipType = expertWin->mModule["ChipType"].toString();
DecodeMode = expertWin->mModule["DecodeMode"].toString();
GroupMode = expertWin->mModule["GroupMode"].toString();
2023-05-27 17:43:57 +08:00
auto vBox = new VBox(center);
2022-08-25 18:43:03 +08:00
vBox->setContentsMargins(0,0,0,0);
vBox->setSpacing(3);
vBox->addLayout(addBtns(new QHBoxLayout()));
2023-05-27 17:43:57 +08:00
auto stack = new QStackedLayout(vBox);
auto vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6);
2022-08-25 18:43:03 +08:00
2023-05-27 17:43:57 +08:00
auto lb = new QLabel(tr("基本参数"));
gFontSize(lb, 16);
auto bkBlue = lb->palette();
bkBlue.setColor(QPalette::WindowText, QColor(0x5599ff));
lb->setPalette(bkBlue);
vv->addWidget(lb);
vv->addSpacing(50);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto grid = new Grid(vv);
grid->setVerticalSpacing(30);
grid->setColumnStretch(0, 1);
grid->setColumnStretch(3, 1);
grid->setColumnStretch(6, 1);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
lb = new QLabel(tr("模组宽度: "));
grid->addWidget(lb, 0, 1);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
fdModuleWidth = new QSpinBox;
fdModuleWidth->setRange(0, 9999);
fdModuleWidth->setValue(ModuleWidth);
grid->addWidget(fdModuleWidth, 0, 2);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
lb = new QLabel(tr("模组高度: "));
grid->addWidget(lb, 1, 1);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
fdModuleHeight = new QSpinBox;
fdModuleHeight->setRange(0, 9999);
fdModuleHeight->setValue(ModuleHeight);
grid->addWidget(fdModuleHeight, 1, 2);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
lb = new QLabel(tr("数据组数: "));
grid->addWidget(lb, 2, 1);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
fdGroupNum = new QSpinBox;
fdGroupNum->setRange(0, 9999);
fdGroupNum->setValue(GroupNum);
grid->addWidget(fdGroupNum, 2, 2);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
lb = new QLabel(tr("驱动芯片: "));
grid->addWidget(lb, 0, 4);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto hhhh = new HBox;
hhhh->setSpacing(0);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
fdChipType = new QLineEdit("ICND2153");
fdChipType->setMinimumWidth(150);
hhhh->addWidget(fdChipType);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto btn = new QPushButton("...");
btn->setMaximumWidth(30);
connect(btn, &QPushButton::clicked, this, [=] {
QDialog dlg(this);
dlg.setWindowFlag(Qt::WindowMaximizeButtonHint);
dlg.setWindowTitle("选择芯片类型");
dlg.resize(800, 600);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto vBox = new VBox(&dlg);
vBox->setContentsMargins(0,0,0,0);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto table = new Table(24, 10);
table->setColFit();
table->setRowFit();
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setAlternatingRowColors(true);
table->setSelectionMode(QAbstractItemView::SingleSelection);
int rr = 0, cc = 0;
table->setHeaderText(cc, "ICN系列");
table->setText(rr++, cc, "ICN2026");
table->setText(rr++, cc, "ICN2027");
table->setText(rr++, cc, "ICN2028");
table->setText(rr++, cc, "ICN2037");
table->setText(rr++, cc, "ICN2038");
table->setText(rr++, cc, "ICN2038S");
table->setText(rr++, cc, "ICN2053");
table->setText(rr++, cc, "ICN2058");
table->setText(rr++, cc, "ICN2088");
table->setText(rr++, cc, "ICND2045");
table->setText(rr++, cc, "ICND2046");
table->setText(rr++, cc, "ICND2047");
table->setText(rr++, cc, "ICND2049");
table->setText(rr++, cc, "ICND2055");
table->setText(rr++, cc, "ICND2059");
table->setText(rr++, cc, "ICND2065");
table->setText(rr++, cc, "ICND2069");
table->setText(rr++, cc, "ICND2076");
table->setText(rr++, cc, "ICND2110");
table->setText(rr++, cc, "ICND2112");
table->setText(rr++, cc, "ICND2153");
table->setText(rr++, cc, "ICND2153_three");
table->setText(rr++, cc, "ICND2163");
table->setText(rr++, cc, "ICND2200");
rr = 0; cc++;
table->setHeaderText(cc, "SM系列");
table->setText(rr++, cc, "SM16017_NEW");
table->setText(rr++, cc, "SM16017S");
table->setText(rr++, cc, "SM16159S");
table->setText(rr++, cc, "SM16169S");
table->setText(rr++, cc, "SM16207S");
table->setText(rr++, cc, "SM16218");
table->setText(rr++, cc, "SM16227S");
table->setText(rr++, cc, "SM16237DS");
table->setText(rr++, cc, "SM16237S");
table->setText(rr++, cc, "SM16259S");
table->setText(rr++, cc, "SM16259S");
table->setText(rr++, cc, "SM16369");
table->setText(rr++, cc, "SM16380");
table->setText(rr++, cc, "SM16388");
table->setText(rr++, cc, "SM16389");
table->setText(rr++, cc, "SM16509/16399");
rr = 0; cc++;
table->setHeaderText(cc, "LS系列");
table->setText(rr++, cc, "LS9918S");
table->setText(rr++, cc, "LS9919S");
table->setText(rr++, cc, "LS9926S");
table->setText(rr++, cc, "LS9929C");
table->setText(rr++, cc, "LS9929S");
table->setText(rr++, cc, "LS9930S");
table->setText(rr++, cc, "LS9931S");
table->setText(rr++, cc, "LS9935B");
table->setText(rr++, cc, "LS9935S");
table->setText(rr++, cc, "LS9936S");
table->setText(rr++, cc, "LS9961S");
rr = 0; cc++;
table->setHeaderText(cc, "MBI系列");
table->setText(rr++, cc, "MBI5041/5042");
table->setText(rr++, cc, "MBI5051");
table->setText(rr++, cc, "MBI5124");
table->setText(rr++, cc, "MBI5151");
table->setText(rr++, cc, "MBI5153");
table->setText(rr++, cc, "MBI5155");
table->setText(rr++, cc, "MBI5158");
table->setText(rr++, cc, "MBI5252");
table->setText(rr++, cc, "MBI5253");
table->setText(rr++, cc, "MBI5253B");
table->setText(rr++, cc, "MBI5254");
table->setText(rr++, cc, "MBI5264");
table->setText(rr++, cc, "MBI5268");
table->setText(rr++, cc, "MBI5353");
table->setText(rr++, cc, "MBI5353B");
table->setText(rr++, cc, "MBI6322");
table->setText(rr++, cc, "MBI6328");
table->setText(rr++, cc, "MBI6334");
rr = 0; cc++;
table->setHeaderText(cc, "SUM系列");
table->setText(rr++, cc, "SUM2017");
table->setText(rr++, cc, "SUM2017T");
table->setText(rr++, cc, "SUM2017TD");
table->setText(rr++, cc, "SUM2028");
table->setText(rr++, cc, "SUM2030");
table->setText(rr++, cc, "SUM2030T");
table->setText(rr++, cc, "SUM2032");
table->setText(rr++, cc, "SUM2033");
table->setText(rr++, cc, "SUM2035");
table->setText(rr++, cc, "SUM2036");
table->setText(rr++, cc, "SUM2037");
table->setText(rr++, cc, "SUM2117");
table->setText(rr++, cc, "SUM2130");
table->setText(rr++, cc, "SUM2131");
table->setText(rr++, cc, "SUM2135");
table->setText(rr++, cc, "SUM6086");
rr = 0; cc++;
table->setHeaderText(cc, "FM系列");
table->setText(rr++, cc, "FM6128");
table->setText(rr++, cc, "FM6129");
table->setText(rr++, cc, "FM6153");
table->setText(rr++, cc, "FM6182");
table->setText(rr++, cc, "FM6253");
table->setText(rr++, cc, "FM6353");
table->setText(rr++, cc, "FM6356");
table->setText(rr++, cc, "FM6363");
table->setText(rr++, cc, "FM6555");
table->setText(rr++, cc, "FM6565/6569");
table->setText(rr++, cc, "FM6565CE");
rr = 0; cc++;
table->setHeaderText(cc, "DP系列");
table->setText(rr++, cc, "DP5135");
table->setText(rr++, cc, "DP5220X");
table->setText(rr++, cc, "DP5525");
rr = 0; cc++;
table->setHeaderText(cc, "MY系列");
table->setText(rr++, cc, "MY9758");
table->setText(rr++, cc, "MY9862");
table->setText(rr++, cc, "MY9866");
rr = 0; cc++;
table->setHeaderText(cc, "LYD系列");
table->setText(rr++, cc, "LYD6168B");
table->setText(rr++, cc, "LYD6168C");
table->setText(rr++, cc, "LYD6168D");
table->setText(rr++, cc, "LYD6168E");
table->setText(rr++, cc, "LYD6188");
table->setText(rr++, cc, "LYD6188PC");
rr = 0; cc++;
table->setHeaderText(cc, "其他系列");
table->setText(rr++, cc, "通用");
table->setText(rr++, cc, "A5065");
table->setText(rr++, cc, "AXS6018");
table->setText(rr++, cc, "CFD135A");
table->setText(rr++, cc, "CFD455A");
table->setText(rr++, cc, "CNS7153");
table->setText(rr++, cc, "CNS7253");
table->setText(rr++, cc, "CNS7263");
table->setText(rr++, cc, "CS2017");
table->setText(rr++, cc, "CS2033");
table->setText(rr++, cc, "D26188");
table->setText(rr++, cc, "HX8055");
table->setText(rr++, cc, "HX8864");
table->setText(rr++, cc, "HX8896");
table->setText(rr++, cc, "RT5965");
table->setText(rr++, cc, "RT5967");
table->setText(rr++, cc, "SCL8081A");
table->setText(rr++, cc, "XM11202G");
auto def = fdChipType->text();
QTableWidgetItem *item;
if(! def.isEmpty()) for(int r=0; r<table->rowCount(); r++) for(int c=0; c<table->columnCount(); c++) if((item = table->item(r, c)) && item->text()==def) item->setSelected(true);
connect(table, &Table::cellDoubleClicked, &dlg, [=, &dlg](int row, int column) {
auto text = table->text(row, column);
if(text.isEmpty()) return;
fdChipType->setText(text);
chipType = (column<<8) | row;
dlg.accept();
});
vBox->addWidget(table);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close);
connect(btnBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
connect(btnBox, &QDialogButtonBox::accepted, &dlg, [&, table] {
auto items = table->selectedItems();
if(items.isEmpty()) {
QMessageBox::warning(&dlg, "Warning", "请选择芯片类型");
return;
}
fdChipType->setText(items[0]->text());
auto ranges = table->selectedRanges();
chipType = (ranges[0].leftColumn()<<8) | ranges[0].topRow();
dlg.accept();
});
vBox->addWidget(btnBox);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
dlg.exec();
});
hhhh->addWidget(btn);
grid->addLayout(hhhh, 0, 5);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
lb = new QLabel(tr("译码方式: "));
grid->addWidget(lb, 1, 4);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
hhhh = new HBox;
hhhh->setSpacing(0);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
fdDecodeMode = new QLineEdit(tr("138译码"));
hhhh->addWidget(fdDecodeMode);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
btn = new QPushButton("...");
btn->setMaximumWidth(30);
connect(btn, &QPushButton::clicked, this, [=] {
QDialog dlg(this);
dlg.setWindowFlag(Qt::WindowMaximizeButtonHint);
dlg.setWindowTitle("选择译码方式");
dlg.resize(600, 400);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto vBox = new VBox(&dlg);
vBox->setContentsMargins(0,0,0,0);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto table = new Table(9, 7);
table->setColFit();
table->setRowFit();
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setAlternatingRowColors(true);
table->setSelectionMode(QAbstractItemView::SingleSelection);
int rr = 0, cc = 0;
table->setHeaderText(cc, "系列"+QString::number(cc+1));
table->setText(rr++, cc, "138译码");
table->setText(rr++, cc, "ICN2012");
table->setText(rr++, cc, "MW4958");
table->setText(rr++, cc, "SM5166P");
table->setText(rr++, cc, "TC7260");
table->setText(rr++, cc, "TC7258E");
table->setText(rr++, cc, "TC7258EN");
table->setText(rr++, cc, "HX6012");
table->setText(rr++, cc, "ICN2016");
rr = 0; cc++;
table->setHeaderText(cc, "系列"+QString::number(cc+1));
table->setText(rr++, cc, "595译码");
rr = 0; cc++;
table->setHeaderText(cc, "系列"+QString::number(cc+1));
table->setText(rr++, cc, "5958译码");
table->setText(rr++, cc, "5960译码");
table->setText(rr++, cc, "TC7558");
table->setText(rr++, cc, "RT5957");
table->setText(rr++, cc, "HX6058");
table->setText(rr++, cc, "HX6158H");
table->setText(rr++, cc, "MBI5988");
rr = 0; cc++;
table->setHeaderText(cc, "系列"+QString::number(cc+1));
table->setText(rr++, cc, "直接输出 (低)");
table->setText(rr++, cc, "直接输出 (高)");
table->setText(rr++, cc, "静态无译码");
rr = 0; cc++;
table->setHeaderText(cc, "系列"+QString::number(cc+1));
table->setText(rr++, cc, "ICND2018");
table->setText(rr++, cc, "ICND3018");
table->setText(rr++, cc, "ICND2019");
table->setText(rr++, cc, "TC7559");
table->setText(rr++, cc, "TC7519");
table->setText(rr++, cc, "SM5366");
table->setText(rr++, cc, "DP32020");
table->setText(rr++, cc, "DP7298A");
table->setText(rr++, cc, "SM5368");
rr = 0; cc++;
table->setHeaderText(cc, "系列"+QString::number(cc+1));
table->setText(rr++, cc, "ICND2013");
table->setText(rr++, cc, "TC7262");
table->setText(rr++, cc, "ICND2017");
table->setText(rr++, cc, "DP7268E");
table->setText(rr++, cc, "DP32019");
table->setText(rr++, cc, "HX6013");
rr = 0; cc++;
table->setHeaderText(cc, "系列"+QString::number(cc+1));
table->setText(rr++, cc, "SM5266P");
table->setText(rr++, cc, "FM7239");
table->setText(rr++, cc, "LS9736");
table->setText(rr++, cc, "D7266");
table->setText(rr++, cc, "CFD21338SPC");
table->setText(rr++, cc, "LS9737_1");
auto def = fdDecodeMode->text();
QTableWidgetItem *item;
if(! def.isEmpty()) for(int r=0; r<table->rowCount(); r++) for(int c=0; c<table->columnCount(); c++) if((item = table->item(r, c)) && item->text()==def) item->setSelected(true);
connect(table, &Table::cellDoubleClicked, &dlg, [=, &dlg](int row, int column) {
auto text = table->text(row, column);
if(text.isEmpty()) return;
fdDecodeMode->setText(text);
decodeMode = (column<<8) | row;
dlg.accept();
});
vBox->addWidget(table);
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close);
connect(btnBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
connect(btnBox, &QDialogButtonBox::accepted, &dlg, [&, table] {
auto items = table->selectedItems();
if(items.isEmpty()) {
QMessageBox::warning(&dlg, "Warning", "请选择译码方式");
return;
}
fdDecodeMode->setText(items[0]->text());
auto ranges = table->selectedRanges();
decodeMode = (ranges[0].leftColumn()<<8) | ranges[0].topRow();
dlg.accept();
});
vBox->addWidget(btnBox);
dlg.exec();
});
hhhh->addWidget(btn);
grid->addLayout(hhhh, 1, 5);
lb = new QLabel(tr("分组方式: "));
grid->addWidget(lb, 2, 4);
fdGroupMode = new QComboBox;
fdGroupMode->addItem(tr("三线并行"));
fdGroupMode->addItem(tr("三色1点串"));
fdGroupMode->addItem(tr("三色8点串"));
fdGroupMode->addItem(tr("三色16点串"));
grid->addWidget(fdGroupMode, 2, 5);
vv->addStretch();
2022-08-25 22:52:52 +08:00
2022-08-25 18:43:03 +08:00
{
2023-05-27 17:43:57 +08:00
auto vBox = new VBox(stack);
2022-08-25 22:52:52 +08:00
vBox->setContentsMargins(50, 50, 6, 6);
2022-08-25 18:43:03 +08:00
2022-12-16 15:08:53 +08:00
auto lb = new QLabel(tr("扫描行数"));
2023-05-27 17:43:57 +08:00
gFontSize(lb, 16);
2022-08-25 22:52:52 +08:00
lb->setPalette(bkBlue);
2022-08-25 18:43:03 +08:00
vBox->addWidget(lb);
vBox->addSpacing(50);
auto hBox = new QHBoxLayout;
vBox->addLayout(hBox);
hBox->addStretch();
auto vvv = new QVBoxLayout;
hBox->addLayout(vvv);
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("根据亮线的行/列数确定扫描行/列数: "));
2022-08-25 18:43:03 +08:00
vvv->addWidget(lb);
vvv->addSpacing(30);
auto hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdRow = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdRow);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdCol = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdCol);
hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("亮线的行/列数: "));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(lb);
auto fdNum = new QSpinBox;
fdNum->setRange(0, 9999);
fdNum->setValue(1);
hhhh->addWidget(fdNum);
hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addStretch();
hBox->addStretch();
vvv = new QVBoxLayout;
hBox->addLayout(vvv);
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("芯片245版本: "));
2022-08-25 18:43:03 +08:00
vvv->addWidget(lb);
vvv->addSpacing(30);
hhhh = new QHBoxLayout;
hhhh->addStretch();
auto fdA = new QRadioButton("A");
hhhh->addWidget(fdA);
hhhh->addStretch();
auto fdD = new QRadioButton("D");
hhhh->addWidget(fdD);
hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addStretch();
hBox->addStretch();
}
{
2023-05-27 17:43:57 +08:00
auto vBox = new VBox(stack);
2022-08-25 22:52:52 +08:00
vBox->setContentsMargins(50, 50, 6, 6);
2022-08-25 18:43:03 +08:00
2022-12-16 15:08:53 +08:00
auto lb = new QLabel(tr("数据线颜色"));
2023-05-27 17:43:57 +08:00
gFontSize(lb, 16);
2022-08-25 22:52:52 +08:00
lb->setPalette(bkBlue);
2022-08-25 18:43:03 +08:00
vBox->addWidget(lb);
vBox->addSpacing(50);
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("依次点击以下状态, 根据模组颜色选择对应颜色"));
2022-08-25 18:43:03 +08:00
vBox->addWidget(lb, 0, Qt::AlignCenter);
vBox->addSpacing(30);
auto hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdSta1 = new QRadioButton(tr("状态1"));
2022-09-07 23:10:35 +08:00
fdSta1->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdSta1);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdR1 = new QRadioButton(tr(""));
2022-09-07 23:10:35 +08:00
fdR1->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdR1);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdG1 = new QRadioButton(tr("绿"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdG1);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdB1 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdB1);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdNo1 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdNo1);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdSta2 = new QRadioButton(tr("状态2"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdSta2);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdR2 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdR2);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdG2 = new QRadioButton(tr("绿"));
2022-09-07 23:10:35 +08:00
fdG2->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdG2);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdB2 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdB2);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdNo2 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdNo2);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdSta3 = new QRadioButton(tr("状态3"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdSta3);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdR3 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdR3);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdG3 = new QRadioButton(tr("绿"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdG3);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdB3 = new QRadioButton(tr(""));
2022-09-07 23:10:35 +08:00
fdB3->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdB3);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdNo3 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdNo3);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addStretch();
2023-05-27 17:43:57 +08:00
auto btnGrp = new QButtonGroup(fdNo1);
2022-08-25 18:43:03 +08:00
btnGrp->addButton(fdR1);
btnGrp->addButton(fdG1);
btnGrp->addButton(fdB1);
btnGrp->addButton(fdNo1);
2023-05-27 17:43:57 +08:00
btnGrp = new QButtonGroup(fdNo2);
2022-08-25 18:43:03 +08:00
btnGrp->addButton(fdR2);
btnGrp->addButton(fdG2);
btnGrp->addButton(fdB2);
btnGrp->addButton(fdNo2);
2023-05-27 17:43:57 +08:00
btnGrp = new QButtonGroup(fdNo3);
2022-08-25 18:43:03 +08:00
btnGrp->addButton(fdR3);
btnGrp->addButton(fdG3);
btnGrp->addButton(fdB3);
btnGrp->addButton(fdNo3);
}
2022-08-25 22:52:52 +08:00
{
2023-05-27 17:43:57 +08:00
auto vBox = new VBox(stack);
2022-08-25 22:52:52 +08:00
vBox->setContentsMargins(0,0,0,0);
auto hhh = new QHBoxLayout;
2022-09-06 23:40:02 +08:00
auto btnUndo = new QPushButton("回撤");
btnUndo->setMinimumSize(90, 30);
connect(btnUndo, &QPushButton::clicked, this, [this] {
2022-09-07 23:10:35 +08:00
auto lastIdx = tableRow->columnCount()-1;
if(lastIdx==-1) return;
auto last = tableRow->item(1, lastIdx);
2023-03-31 18:44:09 +08:00
if(last->text()=="×") virtualCnt--;
else {
2022-09-07 23:10:35 +08:00
auto point = last->data(Qt::UserRole).toPoint();
2023-03-31 18:44:09 +08:00
table->setText(point.y(), point.x(), "");
2022-09-07 23:10:35 +08:00
if(lastIdx==virtualCnt) table->selectionModel()->clearCurrentIndex();
else {
for(int i=lastIdx-1; i>-1; i--) {
2023-03-31 18:44:09 +08:00
if(tableRow->text(1, i)=="×") continue;
auto point = tableRow->data(1, i).toPoint();
2022-09-07 23:10:35 +08:00
table->setCurrentCell(point.y(), point.x());
break;
}
}
2022-09-06 23:40:02 +08:00
}
2022-09-07 23:10:35 +08:00
tableRow->setColumnCount(lastIdx);
2022-09-06 23:40:02 +08:00
});
hhh->addWidget(btnUndo);
2022-08-25 22:52:52 +08:00
2022-12-16 15:08:53 +08:00
auto btnAddVoid = new QPushButton(tr("插入虚点"));
2022-09-07 23:10:35 +08:00
btnAddVoid->setMinimumSize(90, 30);
connect(btnAddVoid, &QPushButton::clicked, this, [this] {
virtualCnt++;
auto cnt = tableRow->columnCount();
tableRow->setColumnCount(cnt+1);
2023-03-31 18:44:09 +08:00
tableRow->setText(0, cnt, QString::number(cnt+1))->setTextAlignment(Qt::AlignCenter);
tableRow->setText(1, cnt, "×")->setTextAlignment(Qt::AlignCenter);
2022-09-07 23:10:35 +08:00
});
hhh->addWidget(btnAddVoid);
2022-12-16 15:08:53 +08:00
auto btnReset = new QPushButton(tr("重新走点"));
2022-09-07 23:10:35 +08:00
btnReset->setMinimumSize(90, 30);
connect(btnReset, &QPushButton::clicked, this, [this] {
table->clearContents();
tableRow->setColumnCount(0);
virtualCnt = 0;
});
hhh->addWidget(btnReset);
2022-12-16 15:08:53 +08:00
auto btnOK = new QPushButton(tr("完成"));
2022-09-08 23:22:59 +08:00
btnOK->setMinimumSize(90, 30);
connect(btnOK, &QPushButton::clicked, this, &ExpertSmartPointSetWin::save);
hhh->addWidget(btnOK);
2022-08-25 22:52:52 +08:00
hhh->addStretch();
vBox->addLayout(hhh);
2023-05-27 17:43:57 +08:00
table = new Table;
2023-03-31 18:44:09 +08:00
table->setNoEdit();
2022-09-07 23:10:35 +08:00
table->setSelectionMode(QTableWidget::SingleSelection);
2023-03-31 18:44:09 +08:00
table->setColWidth(40);
2022-08-25 22:52:52 +08:00
table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
table->verticalHeader()->setMinimumWidth(40);
table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
2022-12-16 15:08:53 +08:00
connect(table, &QTableWidget::currentCellChanged, this, [=](int row, int col) {
2022-09-06 23:40:02 +08:00
if(row < 0) return;
2023-03-31 18:44:09 +08:00
auto text = table->text(row, col);
if(! text.isEmpty()) return;
2022-09-09 23:25:49 +08:00
if(scans.isEmpty()) {
2022-09-08 23:22:59 +08:00
auto cnt = tableRow->columnCount() + 1;
tableRow->setColumnCount(cnt);
2023-03-31 18:44:09 +08:00
tableRow->setText(0, cnt-1, QString::number(cnt))->setTextAlignment(Qt::AlignCenter);
tableRow->setText(1, cnt-1, "")->setTextAlignment(Qt::AlignCenter);
tableRow->setData(1, cnt-1, QPoint{col, row});
2022-09-08 23:22:59 +08:00
auto realCnt = cnt - virtualCnt;
2023-03-31 18:44:09 +08:00
table->setText(row, col, QString::number(realCnt))->setTextAlignment(Qt::AlignCenter);
2022-09-09 23:25:49 +08:00
if(realCnt==ModuleWidth) {
scans.append({col, row});
2022-12-16 15:08:53 +08:00
QMessageBox::information(this, tr("提示"), tr("列走完"));
2022-09-08 23:22:59 +08:00
}
2022-09-09 23:25:49 +08:00
} else if(scans.size() < ScanNum) {
scans.append({col, row});
auto size = scans.size();
2023-03-31 18:44:09 +08:00
table->setText(row, col, "S"+QString::number(size))->setTextAlignment(Qt::AlignCenter);
2022-09-09 23:25:49 +08:00
if(size==ScanNum) {
2022-12-16 15:08:53 +08:00
QMessageBox::information(this, tr("提示"), tr("行走完"));
2022-09-08 23:22:59 +08:00
save();
}
}
2022-08-25 22:52:52 +08:00
});
2022-12-16 15:08:53 +08:00
2022-08-25 22:52:52 +08:00
vBox->addWidget(table);
2022-09-07 23:10:35 +08:00
2023-05-27 17:43:57 +08:00
tableRow = new Table(2, 0);
2023-03-31 18:44:09 +08:00
tableRow->setNoEdit();
2022-09-07 23:10:35 +08:00
tableRow->setSelectionMode(QTableWidget::NoSelection);
tableRow->horizontalHeader()->setDefaultSectionSize(40);
tableRow->horizontalHeader()->setVisible(false);
tableRow->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
tableRow->verticalHeader()->setMinimumWidth(120);
tableRow->setMaximumHeight(80);
auto item = tableRow->verticalHeaderItem(0);
if(item==0) tableRow->setVerticalHeaderItem(0, item = new QTableWidgetItem());
2022-12-16 15:08:53 +08:00
item->setText(tr("第一扫灯数:"));
2022-09-07 23:10:35 +08:00
item = tableRow->verticalHeaderItem(1);
if(item==0) tableRow->setVerticalHeaderItem(1, item = new QTableWidgetItem());
2022-12-16 15:08:53 +08:00
item->setText(tr("实: 虚:"));
2022-09-07 23:10:35 +08:00
vBox->addWidget(tableRow);
2022-08-25 22:52:52 +08:00
}
2023-05-27 17:43:57 +08:00
auto hBox = new HBox(vBox);
2022-08-25 18:43:03 +08:00
hBox->addStretch();
2022-12-16 15:08:53 +08:00
auto btnPrev = new QPushButton(tr("上一步"));
2022-08-25 18:43:03 +08:00
btnPrev->setMinimumSize(90, 30);
hBox->addWidget(btnPrev);
2022-12-16 15:08:53 +08:00
auto btnNext = new QPushButton(tr("下一步"));
2022-08-25 18:43:03 +08:00
btnNext->setMinimumSize(90, 30);
hBox->addWidget(btnNext);
connect(btnPrev, &QPushButton::clicked, this, [stack, btnPrev, btnNext] {
2022-08-25 22:52:52 +08:00
auto idx = stack->currentIndex();
stack->setCurrentIndex(--idx);
2022-09-08 23:22:59 +08:00
btnPrev->setEnabled(idx > 0);
btnNext->setEnabled(idx < stack->count()-1);
2022-08-25 18:43:03 +08:00
});
2022-12-16 15:08:53 +08:00
connect(btnNext, &QPushButton::clicked, this, [=] {
2022-08-25 22:52:52 +08:00
auto idx = stack->currentIndex();
if(idx==0) {
2022-09-09 23:25:49 +08:00
ModuleWidth = fdModuleWidth->value();
ModuleHeight = fdModuleHeight->value();
GroupNum = fdGroupNum->value();
ScanNum = (ModuleHeight + 1) / GroupNum;
2023-05-27 17:43:57 +08:00
ChipType = fdChipType->text();
DecodeMode = fdDecodeMode->text();
2022-09-09 23:25:49 +08:00
GroupMode = fdGroupMode->currentText();
2023-05-27 17:43:57 +08:00
// 开始标识 保留 长度 换行间/刻 OE宽 放电间 芯片通道数 模组类型数
auto msg = QByteArray::fromHex("5555 01 AD 0062 FFFFFFFF 0000ABCD B1000000 0000 415F94A7 AD000000 005C AA55AA55 0000 0036 1770 0000 0280 0000 32 10 00 00 0A 00 00 00 001000 01 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 00000000 00000008 00400020 00001400 FF00FF00 3C000000 00000000 1B022020 00000040 55AA55AA 00000000 B4B5C0AE DEEBB684");
auto unitptr = msg.data()+headMap.end+modMap.Unit;
auto w = (quint16_be*)(unitptr+modUnitMap.w);
qDebug()<<"w"<<QString::number(*w, 16);
*w = ModuleWidth;
auto h = (quint16_be*)(unitptr+modUnitMap.h);
qDebug()<<"h"<<QString::number(*h, 16);
*h = ModuleHeight;
auto groupNum = unitptr+modUnitMap.smartset2 + 1;
qDebug()<<"groupNum"<<QString::number(*groupNum, 16);
*groupNum = GroupNum;
// auto res = sendMsg(msg, {0x1E0, 30000, [=](const QByteArray data) {
// qDebug()<<"data"<<data;
// }});
// if(res) {
// QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+pcap_geterr(pcapSend));
// return;
// }
2022-08-25 22:52:52 +08:00
} else if(idx==2) {
2022-09-09 23:25:49 +08:00
table->setColumnCount(ModuleWidth);
table->setRowCount(ModuleHeight);
2023-03-31 18:44:09 +08:00
QColor altColor(0x445566);
for(int r=0; r<ModuleHeight; r++) {
if((r&7)!=7) for(int c=7; c<ModuleWidth; c+=8) table->itemValid(r, c)->setBackground(altColor);
else for(int c=0; c<ModuleWidth; c++) table->itemValid(r, c)->setBackground(altColor);
}
2022-08-25 22:52:52 +08:00
}
stack->setCurrentIndex(++idx);
2022-09-08 23:22:59 +08:00
btnPrev->setEnabled(idx > 0);
btnNext->setEnabled(idx < stack->count()-1);
2022-08-25 18:43:03 +08:00
});
auto btnCcl = new QPushButton("取消");
btnCcl->setMinimumSize(90, 30);
hBox->addWidget(btnCcl);
hBox->addSpacing(30);
}
2022-09-08 23:22:59 +08:00
void ExpertSmartPointSetWin::save() {
2022-12-16 15:08:53 +08:00
auto file = QApplication::applicationDirPath()+"/temp.module";
2022-09-09 23:25:49 +08:00
QFile qFile(file);
2022-12-16 15:08:53 +08:00
if(! qFile.open(QFile::WriteOnly)) {
QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file));
return;
}
2022-09-09 23:25:49 +08:00
QJsonObject obj;
obj.insert("ModuleWidth", ModuleWidth);
obj.insert("ModuleHeight", ModuleHeight);
obj.insert("GroupNum", GroupNum);
obj.insert("ScanNum", ScanNum);
obj.insert("ChipType", ChipType);
obj.insert("DecodeMode", DecodeMode);
obj.insert("GroupMode", GroupMode);
2022-12-16 15:08:53 +08:00
QJsonArray points;
auto cnt = tableRow->columnCount();
if(cnt > ModuleWidth) {
auto add = (cnt+ModuleWidth-1) / ModuleWidth * ModuleWidth - cnt;
for(int i=0; i<add; i++) points.append(-1);
}
for(int i=cnt-1; i>=0; i--) {
2023-03-31 18:44:09 +08:00
auto data = tableRow->data(1, i);
2022-12-16 15:08:53 +08:00
points.append(data.isValid() ? data.toPoint().x() : -1);
2022-09-09 23:25:49 +08:00
}
2022-12-16 15:08:53 +08:00
obj.insert("Points", points);
2022-09-09 23:25:49 +08:00
QJsonArray Scans;
foreach(QPoint scan, scans) Scans.append(scan.y());
obj.insert("Scans", Scans);
2022-12-16 15:08:53 +08:00
auto data = QJsonDocument(obj).toJson(QJsonDocument::Indented);
auto res = qFile.write(data);
2022-09-09 23:25:49 +08:00
qFile.close();
2022-12-16 15:08:53 +08:00
if(res < 0) {
QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file));
return;
}
expertWin->mModule = obj;
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
expertWin->fdModuleWidth->setText(QString::number(ModuleWidth));
expertWin->fdModuleHeight->setText(QString::number(ModuleHeight));
expertWin->fdGroupNum->setText(QString::number(GroupNum));
expertWin->fdScanNum->setText(QString::number(ScanNum));
expertWin->fdChipType->setText(ChipType);
expertWin->fdDecodeMode->setText(DecodeMode);
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
expertWin->fdCardWidth->setValue(ModuleWidth);
expertWin->fdCardHeight->setValue(ModuleHeight);
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
auto appDir = QApplication::applicationDirPath();
QDir(appDir).mkdir("ModuleFiles");
file = QFileDialog::getSaveFileName(this, tr("保存文件"), appDir+QString("/ModuleFiles/%1X%2_%3扫.module").arg(ModuleWidth).arg(ModuleHeight).arg(ScanNum), tr("Module file (*.module)"));
if(file.isEmpty()) return;
QFile qFile2(file);
if(! qFile2.open(QFile::WriteOnly)) {
QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file));
return;
}
res = qFile2.write(data);
qFile2.close();
if(res < 0) {
QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file));
return;
}
QMessageBox::information(this, tr("保存成功"), tr("保存成功"));
close();
2022-09-08 23:22:59 +08:00
}