qt/ledset/expertsmartpointsetwin.cpp

984 lines
39 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"
2023-06-06 12:13:33 +08:00
#include "crc.h"
#include "waitingdlg.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 {
2023-09-01 16:17:33 +08:00
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 smartsetRes = ipp(4);
byte len = ipp(4);
byte endFlag = ipp(4);
byte end = fi;
2023-05-27 17:43:57 +08:00
} modUnitMap;
struct ModMap {
2023-09-01 16:17:33 +08:00
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 = ipp(4);
byte check = ipp(4);
byte end = fi;
2023-05-27 17:43:57 +08:00
} 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();
2023-07-28 14:48:41 +08:00
ChipType = expertWin->mModule["ChipType"].toStr();
DecodeMode = expertWin->mModule["DecodeMode"].toStr();
GroupMode = expertWin->mModule["GroupMode"].toStr();
2022-12-16 15:08:53 +08:00
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);
2023-06-07 19:11:03 +08:00
2023-05-27 17:43:57 +08:00
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("基本参数"));
2023-06-06 12:13:33 +08:00
gFont(lb, 16);
2023-05-27 17:43:57 +08:00
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-06-06 12:13:33 +08:00
{
dlgChipType = new QDialog(this);
dlgChipType->setWindowFlag(Qt::WindowMaximizeButtonHint);
dlgChipType->setWindowTitle("选择芯片类型");
dlgChipType->resize(800, 600);
2022-08-25 22:52:52 +08:00
2023-06-06 12:13:33 +08:00
auto vBox = new VBox(dlgChipType);
2023-05-27 17:43:57 +08:00
vBox->setContentsMargins(0,0,0,0);
2022-08-25 22:52:52 +08:00
2023-06-06 12:13:33 +08:00
tableChipType = new Table(24, 10);
2023-08-24 16:55:38 +08:00
tableChipType->verticalHeader()->setMinimumWidth(30); //added by alahover 20230822
2023-06-06 12:13:33 +08:00
tableChipType->setColFit();
tableChipType->setRowFit();
tableChipType->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableChipType->setAlternatingRowColors(true);
tableChipType->setSelectionMode(QAbstractItemView::SingleSelection);
2023-05-27 17:43:57 +08:00
int rr = 0, cc = 0;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "ICN系列");
tableChipType->setText(rr++, cc, "ICN2026");
tableChipType->setText(rr++, cc, "ICN2027");
tableChipType->setText(rr++, cc, "ICN2028");
tableChipType->setText(rr++, cc, "ICN2037");
tableChipType->setText(rr++, cc, "ICN2038");
tableChipType->setText(rr++, cc, "ICN2038S");
tableChipType->setText(rr++, cc, "ICN2053");
tableChipType->setText(rr++, cc, "ICN2058");
tableChipType->setText(rr++, cc, "ICN2088");
tableChipType->setText(rr++, cc, "ICND2045");
tableChipType->setText(rr++, cc, "ICND2046");
tableChipType->setText(rr++, cc, "ICND2047");
tableChipType->setText(rr++, cc, "ICND2049");
tableChipType->setText(rr++, cc, "ICND2055");
tableChipType->setText(rr++, cc, "ICND2059");
tableChipType->setText(rr++, cc, "ICND2065");
tableChipType->setText(rr++, cc, "ICND2069");
tableChipType->setText(rr++, cc, "ICND2076");
tableChipType->setText(rr++, cc, "ICND2110");
tableChipType->setText(rr++, cc, "ICND2112");
tableChipType->setText(rr++, cc, "ICND2153");
tableChipType->setText(rr++, cc, "ICND2153_three");
tableChipType->setText(rr++, cc, "ICND2163");
tableChipType->setText(rr++, cc, "ICND2200");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "SM系列");
tableChipType->setText(rr++, cc, "SM16017_NEW");
tableChipType->setText(rr++, cc, "SM16017S");
tableChipType->setText(rr++, cc, "SM16159S");
tableChipType->setText(rr++, cc, "SM16169S");
tableChipType->setText(rr++, cc, "SM16207S");
tableChipType->setText(rr++, cc, "SM16218");
tableChipType->setText(rr++, cc, "SM16227S");
tableChipType->setText(rr++, cc, "SM16237DS");
tableChipType->setText(rr++, cc, "SM16237S");
tableChipType->setText(rr++, cc, "SM16259S");
tableChipType->setText(rr++, cc, "SM16259S");
tableChipType->setText(rr++, cc, "SM16369");
tableChipType->setText(rr++, cc, "SM16380");
tableChipType->setText(rr++, cc, "SM16388");
tableChipType->setText(rr++, cc, "SM16389");
tableChipType->setText(rr++, cc, "SM16509/16399");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "LS系列");
tableChipType->setText(rr++, cc, "LS9918S");
tableChipType->setText(rr++, cc, "LS9919S");
tableChipType->setText(rr++, cc, "LS9926S");
tableChipType->setText(rr++, cc, "LS9929C");
tableChipType->setText(rr++, cc, "LS9929S");
tableChipType->setText(rr++, cc, "LS9930S");
tableChipType->setText(rr++, cc, "LS9931S");
tableChipType->setText(rr++, cc, "LS9935B");
tableChipType->setText(rr++, cc, "LS9935S");
tableChipType->setText(rr++, cc, "LS9936S");
tableChipType->setText(rr++, cc, "LS9961S");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "MBI系列");
tableChipType->setText(rr++, cc, "MBI5041/5042");
tableChipType->setText(rr++, cc, "MBI5051");
tableChipType->setText(rr++, cc, "MBI5124");
tableChipType->setText(rr++, cc, "MBI5151");
tableChipType->setText(rr++, cc, "MBI5153");
tableChipType->setText(rr++, cc, "MBI5155");
tableChipType->setText(rr++, cc, "MBI5158");
tableChipType->setText(rr++, cc, "MBI5252");
tableChipType->setText(rr++, cc, "MBI5253");
tableChipType->setText(rr++, cc, "MBI5253B");
tableChipType->setText(rr++, cc, "MBI5254");
tableChipType->setText(rr++, cc, "MBI5264");
tableChipType->setText(rr++, cc, "MBI5268");
tableChipType->setText(rr++, cc, "MBI5353");
tableChipType->setText(rr++, cc, "MBI5353B");
tableChipType->setText(rr++, cc, "MBI6322");
tableChipType->setText(rr++, cc, "MBI6328");
tableChipType->setText(rr++, cc, "MBI6334");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "SUM系列");
tableChipType->setText(rr++, cc, "SUM2017");
tableChipType->setText(rr++, cc, "SUM2017T");
tableChipType->setText(rr++, cc, "SUM2017TD");
tableChipType->setText(rr++, cc, "SUM2028");
tableChipType->setText(rr++, cc, "SUM2030");
tableChipType->setText(rr++, cc, "SUM2030T");
tableChipType->setText(rr++, cc, "SUM2032");
tableChipType->setText(rr++, cc, "SUM2033");
tableChipType->setText(rr++, cc, "SUM2035");
tableChipType->setText(rr++, cc, "SUM2036");
tableChipType->setText(rr++, cc, "SUM2037");
tableChipType->setText(rr++, cc, "SUM2117");
tableChipType->setText(rr++, cc, "SUM2130");
tableChipType->setText(rr++, cc, "SUM2131");
tableChipType->setText(rr++, cc, "SUM2135");
tableChipType->setText(rr++, cc, "SUM6086");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "FM系列");
tableChipType->setText(rr++, cc, "FM6128");
tableChipType->setText(rr++, cc, "FM6129");
tableChipType->setText(rr++, cc, "FM6153");
tableChipType->setText(rr++, cc, "FM6182");
tableChipType->setText(rr++, cc, "FM6253");
tableChipType->setText(rr++, cc, "FM6353");
tableChipType->setText(rr++, cc, "FM6356");
tableChipType->setText(rr++, cc, "FM6363");
tableChipType->setText(rr++, cc, "FM6555");
tableChipType->setText(rr++, cc, "FM6565/6569");
tableChipType->setText(rr++, cc, "FM6565CE");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "DP系列");
tableChipType->setText(rr++, cc, "DP5135");
tableChipType->setText(rr++, cc, "DP5220X");
tableChipType->setText(rr++, cc, "DP5525");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "MY系列");
tableChipType->setText(rr++, cc, "MY9758");
tableChipType->setText(rr++, cc, "MY9862");
tableChipType->setText(rr++, cc, "MY9866");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "LYD系列");
tableChipType->setText(rr++, cc, "LYD6168B");
tableChipType->setText(rr++, cc, "LYD6168C");
tableChipType->setText(rr++, cc, "LYD6168D");
tableChipType->setText(rr++, cc, "LYD6168E");
tableChipType->setText(rr++, cc, "LYD6188");
tableChipType->setText(rr++, cc, "LYD6188PC");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableChipType->setHeaderText(cc, "其他系列");
tableChipType->setText(rr++, cc, "通用");
tableChipType->setText(rr++, cc, "A5065");
tableChipType->setText(rr++, cc, "AXS6018");
tableChipType->setText(rr++, cc, "CFD135A");
tableChipType->setText(rr++, cc, "CFD455A");
tableChipType->setText(rr++, cc, "CNS7153");
tableChipType->setText(rr++, cc, "CNS7253");
tableChipType->setText(rr++, cc, "CNS7263");
tableChipType->setText(rr++, cc, "CS2017");
tableChipType->setText(rr++, cc, "CS2033");
tableChipType->setText(rr++, cc, "D26188");
tableChipType->setText(rr++, cc, "HX8055");
tableChipType->setText(rr++, cc, "HX8864");
tableChipType->setText(rr++, cc, "HX8896");
tableChipType->setText(rr++, cc, "RT5965");
tableChipType->setText(rr++, cc, "RT5967");
tableChipType->setText(rr++, cc, "SCL8081A");
tableChipType->setText(rr++, cc, "XM11202G");
connect(tableChipType, &Table::cellDoubleClicked, dlgChipType, [=](int row, int column) {
auto text = tableChipType->text(row, column);
2023-05-27 17:43:57 +08:00
if(text.isEmpty()) return;
fdChipType->setText(text);
2023-06-06 12:13:33 +08:00
ChipTypeCode = (column<<8) | row;
dlgChipType->accept();
2023-05-27 17:43:57 +08:00
});
2023-06-06 12:13:33 +08:00
vBox->addWidget(tableChipType);
2022-08-25 22:52:52 +08:00
2023-05-27 17:43:57 +08:00
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close);
2023-06-06 12:13:33 +08:00
connect(btnBox, &QDialogButtonBox::rejected, dlgChipType, &QDialog::reject);
connect(btnBox, &QDialogButtonBox::accepted, dlgChipType, [=] {
auto items = tableChipType->selectedItems();
2023-05-27 17:43:57 +08:00
if(items.isEmpty()) {
2023-06-06 12:13:33 +08:00
QMessageBox::warning(dlgChipType, "Warning", "请选择芯片类型");
2023-05-27 17:43:57 +08:00
return;
}
fdChipType->setText(items[0]->text());
2023-06-06 12:13:33 +08:00
auto ranges = tableChipType->selectedRanges();
ChipTypeCode = (ranges[0].leftColumn()<<8) | ranges[0].topRow();
dlgChipType->accept();
2023-05-27 17:43:57 +08:00
});
vBox->addWidget(btnBox);
2023-06-06 12:13:33 +08:00
}
{
dlgDecodeMode = new QDialog(this);
dlgDecodeMode->setWindowFlag(Qt::WindowMaximizeButtonHint);
dlgDecodeMode->setWindowTitle("选择译码方式");
dlgDecodeMode->resize(600, 400);
2022-08-25 22:52:52 +08:00
2023-06-06 12:13:33 +08:00
auto vBox = new VBox(dlgDecodeMode);
2023-05-27 17:43:57 +08:00
vBox->setContentsMargins(0,0,0,0);
2022-08-25 22:52:52 +08:00
2023-06-06 12:13:33 +08:00
tableDecodeMode = new Table(9, 7);
2023-08-24 16:55:38 +08:00
tableDecodeMode->verticalHeader()->setMinimumWidth(30); //added by alahover 20230822
2023-06-06 12:13:33 +08:00
tableDecodeMode->setColFit();
tableDecodeMode->setRowFit();
tableDecodeMode->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableDecodeMode->setAlternatingRowColors(true);
tableDecodeMode->setSelectionMode(QAbstractItemView::SingleSelection);
2023-05-27 17:43:57 +08:00
int rr = 0, cc = 0;
2023-06-06 12:13:33 +08:00
tableDecodeMode->setHeaderText(cc, "系列"+QString::number(cc+1));
tableDecodeMode->setText(rr++, cc, "138译码");
tableDecodeMode->setText(rr++, cc, "ICN2012");
tableDecodeMode->setText(rr++, cc, "MW4958");
tableDecodeMode->setText(rr++, cc, "SM5166P");
tableDecodeMode->setText(rr++, cc, "TC7260");
tableDecodeMode->setText(rr++, cc, "TC7258E");
tableDecodeMode->setText(rr++, cc, "TC7258EN");
tableDecodeMode->setText(rr++, cc, "HX6012");
tableDecodeMode->setText(rr++, cc, "ICN2016");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableDecodeMode->setHeaderText(cc, "系列"+QString::number(cc+1));
tableDecodeMode->setText(rr++, cc, "595译码");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableDecodeMode->setHeaderText(cc, "系列"+QString::number(cc+1));
tableDecodeMode->setText(rr++, cc, "5958译码");
tableDecodeMode->setText(rr++, cc, "5960译码");
tableDecodeMode->setText(rr++, cc, "TC7558");
tableDecodeMode->setText(rr++, cc, "RT5957");
tableDecodeMode->setText(rr++, cc, "HX6058");
tableDecodeMode->setText(rr++, cc, "HX6158H");
tableDecodeMode->setText(rr++, cc, "MBI5988");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableDecodeMode->setHeaderText(cc, "系列"+QString::number(cc+1));
tableDecodeMode->setText(rr++, cc, "直接输出 (低)");
tableDecodeMode->setText(rr++, cc, "直接输出 (高)");
tableDecodeMode->setText(rr++, cc, "静态无译码");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableDecodeMode->setHeaderText(cc, "系列"+QString::number(cc+1));
tableDecodeMode->setText(rr++, cc, "ICND2018");
tableDecodeMode->setText(rr++, cc, "ICND3018");
tableDecodeMode->setText(rr++, cc, "ICND2019");
tableDecodeMode->setText(rr++, cc, "TC7559");
tableDecodeMode->setText(rr++, cc, "TC7519");
tableDecodeMode->setText(rr++, cc, "SM5366");
tableDecodeMode->setText(rr++, cc, "DP32020");
tableDecodeMode->setText(rr++, cc, "DP7298A");
tableDecodeMode->setText(rr++, cc, "SM5368");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableDecodeMode->setHeaderText(cc, "系列"+QString::number(cc+1));
tableDecodeMode->setText(rr++, cc, "ICND2013");
tableDecodeMode->setText(rr++, cc, "TC7262");
tableDecodeMode->setText(rr++, cc, "ICND2017");
tableDecodeMode->setText(rr++, cc, "DP7268E");
tableDecodeMode->setText(rr++, cc, "DP32019");
tableDecodeMode->setText(rr++, cc, "HX6013");
2023-05-27 17:43:57 +08:00
rr = 0; cc++;
2023-06-06 12:13:33 +08:00
tableDecodeMode->setHeaderText(cc, "系列"+QString::number(cc+1));
tableDecodeMode->setText(rr++, cc, "SM5266P");
tableDecodeMode->setText(rr++, cc, "FM7239");
tableDecodeMode->setText(rr++, cc, "LS9736");
tableDecodeMode->setText(rr++, cc, "D7266");
tableDecodeMode->setText(rr++, cc, "CFD21338SPC");
tableDecodeMode->setText(rr++, cc, "LS9737_1");
connect(tableDecodeMode, &Table::cellDoubleClicked, dlgDecodeMode, [=](int row, int column) {
auto text = tableDecodeMode->text(row, column);
2023-05-27 17:43:57 +08:00
if(text.isEmpty()) return;
fdDecodeMode->setText(text);
2023-06-06 12:13:33 +08:00
DecodeModeCode = (column<<8) | row;
dlgDecodeMode->accept();
2023-05-27 17:43:57 +08:00
});
2023-06-06 12:13:33 +08:00
vBox->addWidget(tableDecodeMode);
2023-05-27 17:43:57 +08:00
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close);
2023-06-06 12:13:33 +08:00
connect(btnBox, &QDialogButtonBox::rejected, dlgDecodeMode, &QDialog::reject);
connect(btnBox, &QDialogButtonBox::accepted, dlgDecodeMode, [=] {
auto items = tableDecodeMode->selectedItems();
2023-05-27 17:43:57 +08:00
if(items.isEmpty()) {
2023-06-06 12:13:33 +08:00
QMessageBox::warning(dlgDecodeMode, "Warning", "请选择译码方式");
2023-05-27 17:43:57 +08:00
return;
}
fdDecodeMode->setText(items[0]->text());
2023-06-06 12:13:33 +08:00
auto ranges = tableDecodeMode->selectedRanges();
DecodeModeCode = (ranges[0].leftColumn()<<8) | ranges[0].topRow();
dlgDecodeMode->accept();
2023-05-27 17:43:57 +08:00
});
vBox->addWidget(btnBox);
2023-06-06 12:13:33 +08:00
}
2023-05-27 17:43:57 +08:00
2023-06-06 12:13:33 +08:00
lb = new QLabel(tr("驱动芯片: "));
grid->addWidget(lb, 0, 4);
auto hhhh = new HBox;
hhhh->setSpacing(0);
fdChipType = new QLineEdit("ICND2153");
fdChipType->setMinimumWidth(150);
fdChipType->setReadOnly(true);
hhhh->addWidget(fdChipType);
auto def = fdChipType->text();
QTableWidgetItem *item;
if(! def.isEmpty()) for(int r=0; r<tableChipType->rowCount(); r++) for(int c=0; c<tableChipType->columnCount(); c++) if((item = tableChipType->item(r, c)) && item->text()==def) item->setSelected(true);
auto btn = new QPushButton("...");
btn->setMaximumWidth(30);
connect(btn, &QPushButton::clicked, dlgChipType, &QDialog::exec);
hhhh->addWidget(btn);
grid->addLayout(hhhh, 0, 5);
lb = new QLabel(tr("译码方式: "));
grid->addWidget(lb, 1, 4);
hhhh = new HBox;
hhhh->setSpacing(0);
fdDecodeMode = new QLineEdit(tr("138译码"));
fdDecodeMode->setReadOnly(true);
hhhh->addWidget(fdDecodeMode);
def = fdDecodeMode->text();
if(! def.isEmpty()) for(int r=0; r<tableDecodeMode->rowCount(); r++) for(int c=0; c<tableDecodeMode->columnCount(); c++) if((item = tableDecodeMode->item(r, c)) && item->text()==def) item->setSelected(true);
btn = new QPushButton("...");
btn->setMaximumWidth(30);
connect(btn, &QPushButton::clicked, dlgDecodeMode, &QDialog::exec);
2023-05-27 17:43:57 +08:00
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
2023-06-07 19:11:03 +08:00
2023-06-13 18:00:19 +08:00
vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6);
lb = new QLabel(tr("数据极性选择"));
gFont(lb, 16);
lb->setPalette(bkBlue);
vv->addWidget(lb);
vv->addSpacing(50);
auto hh = new HBox(vv);
hh->addStretch();
auto vvv = new VBox(hh);
lb = new QLabel(tr("点击状态 1状态 2观察 LED 模块,选择全亮状态: "));
vvv->addWidget(lb);
vvv->addSpacing(30);
hhhh = new HBox(vvv);
hhhh->addStretch();
auto fdPolaStat1 = new QRadioButton(tr("状态 1"));
fdPolaStat1->setChecked(true);
hhhh->addWidget(fdPolaStat1);
hhhh->addStretch();
auto fdPolaStat2 = new QRadioButton(tr("状态 2"));
hhhh->addWidget(fdPolaStat2);
hhhh->addStretch();
2023-07-28 14:48:41 +08:00
auto fdDataPolarity = new QButtonGroup(fdPolaStat1);
fdDataPolarity->addButton(fdPolaStat1, 1);
fdDataPolarity->addButton(fdPolaStat2, 0);
connect(fdDataPolarity, &QButtonGroup::idClicked, this, [this] (int id) {
2023-06-13 18:00:19 +08:00
send(0x11, {0x01000000u | id});
});
vvv->addStretch();
hh->addStretch();
vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6);
lb = new QLabel(tr("OE极性选择"));
gFont(lb, 16);
lb->setPalette(bkBlue);
vv->addWidget(lb);
vv->addSpacing(50);
hh = new HBox(vv);
hh->addStretch();
vvv = new VBox(hh);
lb = new QLabel(tr("点击状态 1状态 2观察 LED 模块,选择高亮状态: "));
vvv->addWidget(lb);
vvv->addSpacing(30);
hhhh = new HBox(vvv);
hhhh->addStretch();
auto fdOEStat1 = new QRadioButton(tr("状态 1"));
fdOEStat1->setChecked(true);
hhhh->addWidget(fdOEStat1);
hhhh->addStretch();
auto fdOEStat2 = new QRadioButton(tr("状态 2"));
hhhh->addWidget(fdOEStat2);
hhhh->addStretch();
2023-07-28 14:48:41 +08:00
auto fdOePolarity = new QButtonGroup(fdOEStat1);
fdOePolarity->addButton(fdOEStat1, 0);
fdOePolarity->addButton(fdOEStat2, 1);
connect(fdOePolarity, &QButtonGroup::idClicked, this, [this] (int id) {
2023-06-13 18:00:19 +08:00
send(0x11, {0x01100000u | id});
});
vvv->addStretch();
hh->addStretch();
2023-06-07 19:11:03 +08:00
vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6);
lb = new QLabel(tr("扫描行数"));
gFont(lb, 16);
lb->setPalette(bkBlue);
vv->addWidget(lb);
vv->addSpacing(50);
2023-06-13 18:00:19 +08:00
hh = new HBox(vv);
hh->addStretch();
2023-06-07 19:11:03 +08:00
2023-06-13 18:00:19 +08:00
vvv = new VBox(hh);
2023-06-07 19:11:03 +08:00
lb = new QLabel(tr("根据亮线的行/列数确定扫描行/列数: "));
vvv->addWidget(lb);
vvv->addSpacing(30);
hhhh = new HBox(vvv);
hhhh->addStretch();
fdRow = new QRadioButton(tr(""));
fdRow->setChecked(true);
hhhh->addWidget(fdRow);
hhhh->addStretch();
fdCol = new QRadioButton(tr(""));
hhhh->addWidget(fdCol);
hhhh->addStretch();
2023-06-13 18:00:19 +08:00
auto grp = new QButtonGroup(fdRow);
2023-06-07 19:11:03 +08:00
grp->addButton(fdRow, 0);
grp->addButton(fdCol, 1);
vvv->addSpacing(20);
hhhh = new HBox(vvv);
hhhh->addStretch();
lb = new QLabel(tr("亮线的行/列数: "));
hhhh->addWidget(lb);
2023-06-13 18:00:19 +08:00
auto fdLightNum = new QSpinBox;
fdLightNum->setRange(0, 9999);
2023-07-28 14:48:41 +08:00
fdLightNum->setValue(1);
2023-06-13 18:00:19 +08:00
hhhh->addWidget(fdLightNum);
2023-06-07 19:11:03 +08:00
hhhh->addStretch();
vvv->addStretch();
2023-06-13 18:00:19 +08:00
hh->addStretch();
2023-06-07 19:11:03 +08:00
2023-06-13 18:00:19 +08:00
vvv = new VBox(hh);
2023-06-07 19:11:03 +08:00
lb = new QLabel(tr("芯片245版本: "));
vvv->addWidget(lb);
vvv->addSpacing(30);
hhhh = new HBox(vvv);
hhhh->addStretch();
auto fdA = new QRadioButton("A");
hhhh->addWidget(fdA);
hhhh->addStretch();
auto fdD = new QRadioButton("D");
hhhh->addWidget(fdD);
hhhh->addStretch();
vvv->addStretch();
2023-06-13 18:00:19 +08:00
hh->addStretch();
2023-06-07 19:11:03 +08:00
vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6);
lb = new QLabel(tr("数据线颜色"));
gFont(lb, 16);
lb->setPalette(bkBlue);
vv->addWidget(lb);
vv->addSpacing(50);
lb = new QLabel(tr("依次点击以下状态, 根据模组颜色选择对应颜色"));
vv->addWidget(lb, 0, Qt::AlignCenter);
vv->addSpacing(30);
grid = new Grid(vv);
grid->setVerticalSpacing(20);
grid->setColumnStretch(0, 1);
grid->setColumnStretch(2, 1);
grid->setColumnStretch(7, 1);
2023-06-13 18:00:19 +08:00
auto fdRGBStat = new QButtonGroup(grid);
QButtonGroup *fdRGBs[3];
2023-06-07 19:11:03 +08:00
for(int rr = 0; rr < 3; ++rr) {
2023-06-13 18:00:19 +08:00
fdRGBStat->addButton(new QRadioButton(tr("状态")+QString::number(rr+1)), rr);
fdRGBs[rr] = new QButtonGroup(grid);
fdRGBs[rr]->addButton(new QRadioButton(tr("")), 1);
fdRGBs[rr]->addButton(new QRadioButton(tr("绿")), 2);
fdRGBs[rr]->addButton(new QRadioButton(tr("")), 3);
fdRGBs[rr]->addButton(new QRadioButton(tr("")), 0);
fdRGBs[rr]->button(rr+1)->setChecked(true);
grid->addWidget(fdRGBStat->button(rr), rr, 1);
grid->addWidget(fdRGBs[rr]->button(1), rr, 3);
grid->addWidget(fdRGBs[rr]->button(2), rr, 4);
grid->addWidget(fdRGBs[rr]->button(3), rr, 5);
grid->addWidget(fdRGBs[rr]->button(0), rr, 6);
2022-08-25 18:43:03 +08:00
}
2023-06-13 18:00:19 +08:00
fdRGBStat->button(0)->setChecked(true);
connect(fdRGBStat, &QButtonGroup::idClicked, this, [this] (int id) {
send(0x11, {0x01200000u | id});
2023-06-07 19:11:03 +08:00
});
vv->addStretch();
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;
2023-06-07 19:11:03 +08:00
scans.clear();
2022-09-07 23:10:35 +08:00
});
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-08-21 11:21:00 +08:00
table->setEditTriggers(Table::NoEditTriggers);
table->setSelectionMode(QTableWidget::SingleSelection);
2023-06-07 19:11:03 +08:00
table->setColWidth(35)->setRowHeight(24, QHeaderView::Fixed);
2022-08-25 22:52:52 +08:00
table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
2023-06-07 19:11:03 +08:00
table->verticalHeader()->setMinimumWidth(35);
2022-08-25 22:52:52 +08:00
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);
2023-06-07 19:11:03 +08:00
if(realCnt!=ModuleWidth) {
2023-06-13 18:00:19 +08:00
if(send(0x11, {0x01400000u | cnt}) == 0) qDebug()<<"resp back. col:"<<QString::number(cnt, 16);
2023-06-07 19:11:03 +08:00
} else {
2022-12-16 15:08:53 +08:00
QMessageBox::information(this, tr("提示"), tr("列走完"));
2023-06-13 18:00:19 +08:00
scans.append({col, row});
send(0x11, {0x01400000u | (1<<10)});
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);
2023-06-13 18:00:19 +08:00
if(size!=ScanNum) {
if(send(0x11, {0x01400000u | (size<<10)}) == 0) qDebug()<<"resp back. row:"<<QString::number(size, 16);
} else {
2022-12-16 15:08:53 +08:00
QMessageBox::information(this, tr("提示"), tr("行走完"));
2023-06-13 18:00:19 +08:00
send(0x11, {0});
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-08-21 11:21:00 +08:00
tableRow->setEditTriggers(Table::NoEditTriggers);
2022-09-07 23:10:35 +08:00
tableRow->setSelectionMode(QTableWidget::NoSelection);
2023-06-07 19:11:03 +08:00
tableRow->setColWidth(35);
tableRow->setRowHeight(24);
2022-09-07 23:10:35 +08:00
tableRow->horizontalHeader()->setVisible(false);
tableRow->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
tableRow->verticalHeader()->setMinimumWidth(120);
2023-06-07 19:11:03 +08:00
tableRow->setMaximumHeight(50);
tableRow->setVHeaderText(0, tr("第一扫灯数:"));
tableRow->setVHeaderText(1, tr("实: 虚:"));
2022-09-07 23:10:35 +08:00
vBox->addWidget(tableRow);
2022-08-25 22:52:52 +08:00
}
2023-06-13 18:00:19 +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-06-06 12:13:33 +08:00
// 开始标识 保留 长度 换行间/刻 OE宽 放电间 芯片通道数 模组类型数
2023-06-07 19:11:03 +08:00
auto msg = QByteArray::fromHex("5555 01AD 0062 FFFFFFFF 0000ABCD B1000000 0000 415F94A7 AD000000 005C AA55AA55 0000 0036 1770 0000 0280 0000 32 10 00 00 0A 01 00 00 001000 01 "
2023-06-13 18:00:19 +08:00
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 00000000 00000008 00200020 00001400 FF00FF00 3C000000 01000000 1B020010 00000020 55AA55AA 00000000 39F424F6 351B0E53");
2023-06-06 12:13:33 +08:00
// UUID type len w h ex1 chip/decode ex3 smartset smartset2 走点len endFlag
2023-05-27 17:43:57 +08:00
auto unitptr = msg.data()+headMap.end+modMap.Unit;
auto w = (quint16_be*)(unitptr+modUnitMap.w);
*w = ModuleWidth;
auto h = (quint16_be*)(unitptr+modUnitMap.h);
*h = ModuleHeight;
2023-06-06 12:13:33 +08:00
auto chipType = (quint16_be*)(unitptr+modUnitMap.chipType);
*chipType = ChipTypeCode;
auto decodeMode = (quint16_be*)(unitptr+modUnitMap.decodeMode);
*decodeMode = DecodeModeCode;
2023-06-13 18:00:19 +08:00
auto smartset = unitptr+modUnitMap.smartset+3;
2023-07-28 14:48:41 +08:00
*smartset = fdDataPolarity->checkedId();
2023-06-13 18:00:19 +08:00
auto groupNum = unitptr+modUnitMap.smartsetRes + 1;
*groupNum = GroupNum;
auto scanNum = unitptr+modUnitMap.smartsetRes + 3;
*scanNum = ModuleHeight / GroupNum;
auto len = (quint32_be*)(unitptr+modUnitMap.len);
*len = (ModuleWidth+15) / 16 * 16;
2023-06-06 12:13:33 +08:00
auto check = (quint32_be*)(msg.data()+headMap.end+modMap.check);
*check = crc32_calc((byte*)msg.data()+headMap.end+modMap., modMap.check - modMap.);
check = (quint32_be*)(msg.data()+headMap.end+modMap.end);
*check = crc32_calc((byte*)msg.data()+headMap.body, modMap.end+6);
2023-06-13 18:00:19 +08:00
res12 = *(quint32_be*)(unitptr+modUnitMap.smartsetRes);
2023-06-06 12:13:33 +08:00
2023-06-07 19:11:03 +08:00
auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ...");
2023-06-13 18:00:19 +08:00
auto res = sendMsgSync(msg, 0x1EA, 10000, waitingDlg);
if(res==5) {QMessageBox::critical(this, "Error", tr("请求超时")); return;}
else if(res) {QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;}
waitingDlg->close();
2023-06-07 19:11:03 +08:00
} else if(idx==1) {
2023-07-28 14:48:41 +08:00
DataPolarity = fdDataPolarity->checkedId();
2023-06-13 18:00:19 +08:00
res12 &= ~(1u<<31);
2023-07-28 14:48:41 +08:00
res12 |= (uint)DataPolarity<<31;
if(send(0x11, {0x01100000u | fdOePolarity->checkedId(), res12})) return;
2022-08-25 22:52:52 +08:00
} else if(idx==2) {
2023-07-28 14:48:41 +08:00
OePolarity = fdOePolarity->checkedId();
2023-06-13 18:00:19 +08:00
res12 &= ~(1u<<30);
2023-07-28 14:48:41 +08:00
res12 |= (uint)OePolarity<<30;
2023-06-13 18:00:19 +08:00
if(send(0x11, {0x01300000u, res12})) return;
} else if(idx==3) {
2023-07-28 14:48:41 +08:00
RowPerScan = fdLightNum->value();
2023-06-13 18:00:19 +08:00
res12 &= ~0xffffu;
2023-07-28 14:48:41 +08:00
res12 |= (uint)(RowPerScan - 1)<<8; //折返次数
res12 |= (uint)(ModuleHeight / (RowPerScan*GroupNum)); //扫描类型
if(send(0x11, {0x01200000u | fdRGBStat->checkedId(), res12, ((uint)ModuleWidth+15) / 16 * 16 * RowPerScan})) return;
2023-06-13 18:00:19 +08:00
} else if(idx==4) {
bool hases[4]{true,true,true,true};
uint ids[4];
for(int i=0; i<3; ++i) {
ids[i] = fdRGBs[i]->checkedId();
hases[ids[i]] = false;
}
for(int i=0; i<4; ++i) if(hases[i]) {
ids[3] = i;
break;
}
res12 &= ~(0xffu<<22);
2023-07-28 14:48:41 +08:00
ColorMap = ids[0]<<6 | ids[1]<<4 | ids[2]<<2 | ids[3];
res12 |= (uint)ColorMap << 22;
2023-06-13 18:00:19 +08:00
if(send(0x11, {0x01400000u, res12})) return;
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
}
2023-06-13 18:00:19 +08:00
stack->setCurrentIndex(++idx);
btnPrev->setEnabled(idx > 0);
btnNext->setEnabled(idx < stack->count()-1);
2022-08-25 18:43:03 +08:00
});
auto btnCcl = new QPushButton("取消");
2023-06-13 18:00:19 +08:00
connect(btnCcl, &QPushButton::clicked, this, [=] {
send(0x11, {0});
close();
});
2022-08-25 18:43:03 +08:00
btnCcl->setMinimumSize(90, 30);
hBox->addWidget(btnCcl);
hBox->addSpacing(30);
}
2023-06-13 18:00:19 +08:00
int ExpertSmartPointSetWin::send(uint ptr, const std::initializer_list<uint> &data) {
auto msg = QByteArray::fromHex("5555 01AD 0000 FFFFFFFF 0000ABCD B1000000 0000 00000000 AD000000 0000");
msg.append((data.size()+1)<<2, 0);
auto plen = (quint16_be*)(msg.data()+headMap.len);
*plen |= (data.size()<<2)+6;
plen = (quint16_be*)(msg.data()+headMap.bodylen);
*plen |= data.size()<<2;
auto pptr = (quint32_be*)(msg.data()+headMap.ptr);
*pptr |= ptr;
pptr = (quint32_be*)(msg.data()+headMap.body);
*pptr |= ptr;
auto pdata = (quint32_be*) (msg.data()+headMap.end);
for(auto dat : data) {
*pdata = dat;
pdata++;
2023-06-07 19:11:03 +08:00
}
2023-06-13 18:00:19 +08:00
auto check = (quint32_be*)(msg.data()+headMap.chk);
*check = crc32_calc((byte*)msg.data()+2, headMap.chk-2);
check = (quint32_be*)(msg.data()+msg.size()-4);
*check = crc32_calc((byte*)msg.data()+headMap.body, msg.size()-4-headMap.body);
2023-06-07 19:11:03 +08:00
auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ...");
auto res = sendMsgSync(msg, 0x1EA, 10000, waitingDlg);
if(res==5) QMessageBox::critical(this, "Error", tr("请求超时"));
else if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend)));
else waitingDlg->close();
return res;
}
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;
}
2023-07-28 14:48:41 +08:00
JObj obj;
2022-09-09 23:25:49 +08:00
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);
2023-07-28 14:48:41 +08:00
obj.insert("DataPolarity", DataPolarity);
obj.insert("OePolarity", OePolarity);
obj.insert("ColorMap", ColorMap);
obj.insert("RowPerScan", RowPerScan);
JArray points;
2022-12-16 15:08:53 +08:00
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);
2023-07-28 14:48:41 +08:00
JArray Scans;
for(QPoint scan : scans) Scans.append(scan.y());
2022-09-09 23:25:49 +08:00
obj.insert("Scans", Scans);
2023-07-28 14:48:41 +08:00
auto data = JToBytes(obj, " ");
2022-12-16 15:08:53 +08:00
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
}