ledset 走点设置

This commit is contained in:
Gangphon 2023-06-07 19:11:03 +08:00
parent d0e9813585
commit 8a1cee9e82
10 changed files with 256 additions and 203 deletions

View File

@ -77,6 +77,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
vBox->addLayout(addBtns(new QHBoxLayout())); vBox->addLayout(addBtns(new QHBoxLayout()));
auto stack = new QStackedLayout(vBox); auto stack = new QStackedLayout(vBox);
auto vv = new VBox(stack); auto vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6); vv->setContentsMargins(50, 50, 6, 6);
@ -451,39 +452,44 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
vv->addStretch(); vv->addStretch();
{
auto vBox = new VBox(stack);
vBox->setContentsMargins(50, 50, 6, 6);
auto lb = new QLabel(tr("扫描行数")); vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6);
lb = new QLabel(tr("扫描行数"));
gFont(lb, 16); gFont(lb, 16);
lb->setPalette(bkBlue); lb->setPalette(bkBlue);
vBox->addWidget(lb); vv->addWidget(lb);
vBox->addSpacing(50); vv->addSpacing(50);
auto hBox = new QHBoxLayout; auto hBox = new HBox(vv);
vBox->addLayout(hBox);
hBox->addStretch(); hBox->addStretch();
auto vvv = new QVBoxLayout; auto vvv = new VBox(hBox);
hBox->addLayout(vvv);
lb = new QLabel(tr("根据亮线的行/列数确定扫描行/列数: ")); lb = new QLabel(tr("根据亮线的行/列数确定扫描行/列数: "));
vvv->addWidget(lb); vvv->addWidget(lb);
vvv->addSpacing(30); vvv->addSpacing(30);
auto hhhh = new QHBoxLayout; hhhh = new HBox(vvv);
hhhh->addStretch(); hhhh->addStretch();
auto fdRow = new QRadioButton(tr(""));
fdRow = new QRadioButton(tr(""));
fdRow->setChecked(true);
hhhh->addWidget(fdRow); hhhh->addWidget(fdRow);
hhhh->addStretch(); hhhh->addStretch();
auto fdCol = new QRadioButton(tr(""));
fdCol = new QRadioButton(tr(""));
hhhh->addWidget(fdCol); hhhh->addWidget(fdCol);
hhhh->addStretch(); hhhh->addStretch();
vvv->addLayout(hhhh);
auto grp = new QButtonGroup;
grp->addButton(fdRow, 0);
grp->addButton(fdCol, 1);
vvv->addSpacing(20); vvv->addSpacing(20);
hhhh = new QHBoxLayout; hhhh = new HBox(vvv);
hhhh->addStretch(); hhhh->addStretch();
lb = new QLabel(tr("亮线的行/列数: ")); lb = new QLabel(tr("亮线的行/列数: "));
@ -495,141 +501,94 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
hhhh->addWidget(fdNum); hhhh->addWidget(fdNum);
hhhh->addStretch(); hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addStretch(); vvv->addStretch();
hBox->addStretch(); hBox->addStretch();
vvv = new QVBoxLayout; vvv = new VBox(hBox);
hBox->addLayout(vvv);
lb = new QLabel(tr("芯片245版本: ")); lb = new QLabel(tr("芯片245版本: "));
vvv->addWidget(lb); vvv->addWidget(lb);
vvv->addSpacing(30); vvv->addSpacing(30);
hhhh = new QHBoxLayout; hhhh = new HBox(vvv);
hhhh->addStretch(); hhhh->addStretch();
auto fdA = new QRadioButton("A"); auto fdA = new QRadioButton("A");
hhhh->addWidget(fdA); hhhh->addWidget(fdA);
hhhh->addStretch(); hhhh->addStretch();
auto fdD = new QRadioButton("D"); auto fdD = new QRadioButton("D");
hhhh->addWidget(fdD); hhhh->addWidget(fdD);
hhhh->addStretch(); hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addStretch(); vvv->addStretch();
hBox->addStretch(); hBox->addStretch();
}
{
auto vBox = new VBox(stack);
vBox->setContentsMargins(50, 50, 6, 6);
auto lb = new QLabel(tr("数据线颜色"));
vv = new VBox(stack);
vv->setContentsMargins(50, 50, 6, 6);
lb = new QLabel(tr("数据线颜色"));
gFont(lb, 16); gFont(lb, 16);
lb->setPalette(bkBlue); lb->setPalette(bkBlue);
vBox->addWidget(lb); vv->addWidget(lb);
vBox->addSpacing(50); vv->addSpacing(50);
lb = new QLabel(tr("依次点击以下状态, 根据模组颜色选择对应颜色")); lb = new QLabel(tr("依次点击以下状态, 根据模组颜色选择对应颜色"));
vBox->addWidget(lb, 0, Qt::AlignCenter); vv->addWidget(lb, 0, Qt::AlignCenter);
vBox->addSpacing(30); vv->addSpacing(30);
auto hhhh = new QHBoxLayout; grid = new Grid(vv);
hhhh->addStretch(); grid->setVerticalSpacing(20);
auto fdSta1 = new QRadioButton(tr("状态1")); grid->setColumnStretch(0, 1);
fdSta1->setChecked(true); grid->setColumnStretch(2, 1);
hhhh->addWidget(fdSta1); grid->setColumnStretch(7, 1);
hhhh->addStretch();
auto fdR1 = new QRadioButton(tr("")); auto fdStas = new QButtonGroup(grid);
fdR1->setChecked(true); auto fdRs = new QButtonGroup(grid);
hhhh->addWidget(fdR1); auto fdGs = new QButtonGroup(grid);
hhhh->addSpacing(20); auto fdBs = new QButtonGroup(grid);
auto fdNos = new QButtonGroup(grid);
auto fdG1 = new QRadioButton(tr("绿")); for(int rr = 0; rr < 3; ++rr) {
hhhh->addWidget(fdG1); fdStas->addButton(new QRadioButton(tr("状态")+QString::number(rr+1)), rr);
hhhh->addSpacing(20); fdRs->addButton(new QRadioButton(tr("")), rr);
fdGs->addButton(new QRadioButton(tr("绿")), rr);
auto fdB1 = new QRadioButton(tr("")); fdBs->addButton(new QRadioButton(tr("")), rr);
hhhh->addWidget(fdB1); fdNos->addButton(new QRadioButton(tr("")), rr);
hhhh->addSpacing(20); grid->addWidget(fdStas->button(rr), rr, 1);
grid->addWidget(fdRs->button(rr), rr, 3);
auto fdNo1 = new QRadioButton(tr("")); grid->addWidget(fdGs->button(rr), rr, 4);
hhhh->addWidget(fdNo1); grid->addWidget(fdBs->button(rr), rr, 5);
hhhh->addStretch(); grid->addWidget(fdNos->button(rr), rr, 6);
vBox->addLayout(hhhh);
vBox->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
auto fdSta2 = new QRadioButton(tr("状态2"));
hhhh->addWidget(fdSta2);
hhhh->addStretch();
auto fdR2 = new QRadioButton(tr(""));
hhhh->addWidget(fdR2);
hhhh->addSpacing(20);
auto fdG2 = new QRadioButton(tr("绿"));
fdG2->setChecked(true);
hhhh->addWidget(fdG2);
hhhh->addSpacing(20);
auto fdB2 = new QRadioButton(tr(""));
hhhh->addWidget(fdB2);
hhhh->addSpacing(20);
auto fdNo2 = new QRadioButton(tr(""));
hhhh->addWidget(fdNo2);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
auto fdSta3 = new QRadioButton(tr("状态3"));
hhhh->addWidget(fdSta3);
hhhh->addStretch();
auto fdR3 = new QRadioButton(tr(""));
hhhh->addWidget(fdR3);
hhhh->addSpacing(20);
auto fdG3 = new QRadioButton(tr("绿"));
hhhh->addWidget(fdG3);
hhhh->addSpacing(20);
auto fdB3 = new QRadioButton(tr(""));
fdB3->setChecked(true);
hhhh->addWidget(fdB3);
hhhh->addSpacing(20);
auto fdNo3 = new QRadioButton(tr(""));
hhhh->addWidget(fdNo3);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addStretch();
auto btnGrp = new QButtonGroup(fdNo1);
btnGrp->addButton(fdR1);
btnGrp->addButton(fdG1);
btnGrp->addButton(fdB1);
btnGrp->addButton(fdNo1);
btnGrp = new QButtonGroup(fdNo2);
btnGrp->addButton(fdR2);
btnGrp->addButton(fdG2);
btnGrp->addButton(fdB2);
btnGrp->addButton(fdNo2);
btnGrp = new QButtonGroup(fdNo3);
btnGrp->addButton(fdR3);
btnGrp->addButton(fdG3);
btnGrp->addButton(fdB3);
btnGrp->addButton(fdNo3);
} }
fdStas->button(0)->setChecked(true);
fdRs->button(0)->setChecked(true);
fdGs->button(1)->setChecked(true);
fdBs->button(2)->setChecked(true);
connect(fdStas, &QButtonGroup::idClicked, this, [this] (int id) {
auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01200000 0BF4F928");
msg[msg.size()-5] = id;
auto check = (quint32_be*)(msg.data()+msg.size()-4);
*check = crc32_calc((byte*)msg.data()+headMap.body, msg.size()-4-headMap.body);
qDebug()<<"check"<<QString::number(*check, 16);
auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ...");
auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) {
if(code==5) {
waitingDlg->close();
QMessageBox::critical(this, "Error", tr("请求超时"));
return;
}
waitingDlg->close();
qDebug()<<"resp back. RGB status:"<<id;
}, waitingDlg);
if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend)));
});
vv->addStretch();
{ {
auto vBox = new VBox(stack); auto vBox = new VBox(stack);
vBox->setContentsMargins(0,0,0,0); vBox->setContentsMargins(0,0,0,0);
@ -677,6 +636,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
table->clearContents(); table->clearContents();
tableRow->setColumnCount(0); tableRow->setColumnCount(0);
virtualCnt = 0; virtualCnt = 0;
scans.clear();
}); });
hhh->addWidget(btnReset); hhh->addWidget(btnReset);
@ -689,11 +649,10 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
vBox->addLayout(hhh); vBox->addLayout(hhh);
table = new Table; table = new Table;
table->setNoEdit(); table->setNoEdit()->setSelectionMode(QTableWidget::SingleSelection);
table->setSelectionMode(QTableWidget::SingleSelection); table->setColWidth(35)->setRowHeight(24, QHeaderView::Fixed);
table->setColWidth(40);
table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
table->verticalHeader()->setMinimumWidth(40); table->verticalHeader()->setMinimumWidth(35);
table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter); table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
connect(table, &QTableWidget::currentCellChanged, this, [=](int row, int col) { connect(table, &QTableWidget::currentCellChanged, this, [=](int row, int col) {
if(row < 0) return; if(row < 0) return;
@ -707,42 +666,49 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
tableRow->setData(1, cnt-1, QPoint{col, row}); tableRow->setData(1, cnt-1, QPoint{col, row});
auto realCnt = cnt - virtualCnt; auto realCnt = cnt - virtualCnt;
table->setText(row, col, QString::number(realCnt))->setTextAlignment(Qt::AlignCenter); table->setText(row, col, QString::number(realCnt))->setTextAlignment(Qt::AlignCenter);
if(realCnt==ModuleWidth) { if(realCnt!=ModuleWidth) {
sendPoint(cnt);
} else {
scans.append({col, row}); scans.append({col, row});
QMessageBox::information(this, tr("提示"), tr("列走完")); QMessageBox::information(this, tr("提示"), tr("列走完"));
sendPoint(1<<10);
} }
} else if(scans.size() < ScanNum) { } else if(scans.size() < ScanNum) {
scans.append({col, row}); scans.append({col, row});
auto size = scans.size(); auto size = scans.size();
table->setText(row, col, "S"+QString::number(size))->setTextAlignment(Qt::AlignCenter); table->setText(row, col, "S"+QString::number(size))->setTextAlignment(Qt::AlignCenter);
if(size==ScanNum) { if(size!=ScanNum) sendPoint(size<<10);
else {
QMessageBox::information(this, tr("提示"), tr("行走完")); QMessageBox::information(this, tr("提示"), tr("行走完"));
auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 00000000 8b05d8ad");
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();
qDebug()<<"resp back. point end.";
save(); save();
} }
} }
}); });
vBox->addWidget(table); vBox->addWidget(table);
tableRow = new Table(2, 0); tableRow = new Table(2, 0);
tableRow->setNoEdit(); tableRow->setNoEdit();
tableRow->setSelectionMode(QTableWidget::NoSelection); tableRow->setSelectionMode(QTableWidget::NoSelection);
tableRow->horizontalHeader()->setDefaultSectionSize(40); tableRow->setColWidth(35);
tableRow->setRowHeight(24);
tableRow->horizontalHeader()->setVisible(false); tableRow->horizontalHeader()->setVisible(false);
tableRow->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); tableRow->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
tableRow->verticalHeader()->setMinimumWidth(120); tableRow->verticalHeader()->setMinimumWidth(120);
tableRow->setMaximumHeight(80); tableRow->setMaximumHeight(50);
auto item = tableRow->verticalHeaderItem(0); tableRow->setVHeaderText(0, tr("第一扫灯数:"));
if(item==0) tableRow->setVerticalHeaderItem(0, item = new QTableWidgetItem()); tableRow->setVHeaderText(1, tr("实: 虚:"));
item->setText(tr("第一扫灯数:"));
item = tableRow->verticalHeaderItem(1);
if(item==0) tableRow->setVerticalHeaderItem(1, item = new QTableWidgetItem());
item->setText(tr("实: 虚:"));
vBox->addWidget(tableRow); vBox->addWidget(tableRow);
} }
auto hBox = new HBox(vBox); hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();
auto btnPrev = new QPushButton(tr("上一步")); auto btnPrev = new QPushButton(tr("上一步"));
@ -775,29 +741,55 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
// UUID type len w h ex1 chip/decode ex3 smartset smartset2 走点len endFlag // UUID type len w h ex1 chip/decode ex3 smartset smartset2 走点len endFlag
auto unitptr = msg.data()+headMap.end+modMap.Unit; auto unitptr = msg.data()+headMap.end+modMap.Unit;
auto w = (quint16_be*)(unitptr+modUnitMap.w); auto w = (quint16_be*)(unitptr+modUnitMap.w);
qDebug()<<"w"<<QString::number(*w, 16);
*w = ModuleWidth; *w = ModuleWidth;
auto h = (quint16_be*)(unitptr+modUnitMap.h); auto h = (quint16_be*)(unitptr+modUnitMap.h);
qDebug()<<"h"<<QString::number(*h, 16);
*h = ModuleHeight; *h = ModuleHeight;
auto groupNum = unitptr+modUnitMap.smartset2 + 1; auto groupNum = unitptr+modUnitMap.smartset2 + 1;
qDebug()<<"groupNum"<<QString::number(*groupNum, 16);
*groupNum = GroupNum; *groupNum = GroupNum;
auto chipType = (quint16_be*)(unitptr+modUnitMap.chipType); auto chipType = (quint16_be*)(unitptr+modUnitMap.chipType);
qDebug()<<"chipType"<<QString::number(*chipType, 16);
*chipType = ChipTypeCode; *chipType = ChipTypeCode;
auto decodeMode = (quint16_be*)(unitptr+modUnitMap.decodeMode); auto decodeMode = (quint16_be*)(unitptr+modUnitMap.decodeMode);
qDebug()<<"decodeMode"<<QString::number(*decodeMode, 16);
*decodeMode = DecodeModeCode; *decodeMode = DecodeModeCode;
auto check = (quint32_be*)(msg.data()+headMap.end+modMap.check); auto check = (quint32_be*)(msg.data()+headMap.end+modMap.check);
*check = crc32_calc((byte*)msg.data()+headMap.end+modMap., modMap.check - modMap.); *check = crc32_calc((byte*)msg.data()+headMap.end+modMap., modMap.check - modMap.);
qDebug()<<"check"<<QString::number(*check, 16);
check = (quint32_be*)(msg.data()+headMap.end+modMap.end); check = (quint32_be*)(msg.data()+headMap.end+modMap.end);
*check = crc32_calc((byte*)msg.data()+headMap.body, modMap.end+6); *check = crc32_calc((byte*)msg.data()+headMap.body, modMap.end+6);
qDebug()<<"check"<<QString::number(*check, 16); qDebug()<<"check"<<QString::number(*check, 16);
auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ...");
auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) {
if(code==5) {
waitingDlg->close();
QMessageBox::critical(this, "Error", tr("请求超时"));
return;
}
auto msg = QByteArray::fromHex(QByteArray("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01300000 17D25A58"));
auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) {
if(code==5) {
waitingDlg->close();
QMessageBox::critical(this, "Error", tr("请求超时"));
return;
}
waitingDlg->close();
auto iii = idx+1;
stack->setCurrentIndex(iii);
btnPrev->setEnabled(iii > 0);
btnNext->setEnabled(iii < stack->count()-1);
}, waitingDlg);
if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend)));
}, waitingDlg);
if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend)));
} else if(idx==1) {
//GroupMode = fdNum->value();
auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01200000 0BF4F928");
auto id = fdStas->checkedId();
if(id) {
msg[msg.size()-5] = id;
auto check = (quint32_be*)(msg.data()+msg.size()-4);
*check = crc32_calc((byte*)msg.data()+headMap.body, msg.size()-4-headMap.body);
}
auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ...");
auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) { auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) {
if(code==5) { if(code==5) {
@ -813,6 +805,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
}, waitingDlg); }, waitingDlg);
if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend)));
} else if(idx==2) { } else if(idx==2) {
if(sendPoint(0)) return;
table->setColumnCount(ModuleWidth); table->setColumnCount(ModuleWidth);
table->setRowCount(ModuleHeight); table->setRowCount(ModuleHeight);
QColor altColor(0x445566); QColor altColor(0x445566);
@ -820,9 +813,10 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
if((r&7)!=7) for(int c=7; c<ModuleWidth; c+=8) table->itemValid(r, c)->setBackground(altColor); 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); else for(int c=0; c<ModuleWidth; c++) table->itemValid(r, c)->setBackground(altColor);
} }
stack->setCurrentIndex(++idx); auto iii = idx+1;
btnPrev->setEnabled(idx > 0); stack->setCurrentIndex(iii);
btnNext->setEnabled(idx < stack->count()-1); btnPrev->setEnabled(iii > 0);
btnNext->setEnabled(iii < stack->count()-1);
} }
}); });
@ -832,6 +826,22 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
hBox->addSpacing(30); hBox->addSpacing(30);
} }
int ExpertSmartPointSetWin::sendPoint(uint cnt) {
auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01400000 43233208");
if(cnt) {
auto idx = (quint32_be*)(msg.data()+msg.size()-8);
*idx |= cnt;
auto check = (quint32_be*)(msg.data()+msg.size()-4);
*check = crc32_calc((byte*)msg.data()+headMap.body, msg.size()-4-headMap.body);
}
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();
qDebug()<<"resp back. point:"<<QString::number(cnt, 16);
return res;
}
void ExpertSmartPointSetWin::save() { void ExpertSmartPointSetWin::save() {
auto file = QApplication::applicationDirPath()+"/temp.module"; auto file = QApplication::applicationDirPath()+"/temp.module";

View File

@ -5,11 +5,13 @@
#include "gutil/qgui.h" #include "gutil/qgui.h"
#include <QSpinBox> #include <QSpinBox>
#include <QComboBox> #include <QComboBox>
#include <QRadioButton>
class ExpertSmartPointSetWin : public BaseWin { class ExpertSmartPointSetWin : public BaseWin {
Q_OBJECT Q_OBJECT
public: public:
explicit ExpertSmartPointSetWin(ExpertWin *parent = nullptr); explicit ExpertSmartPointSetWin(ExpertWin *parent = nullptr);
int sendPoint(uint);
void save(); void save();
ExpertWin *expertWin; ExpertWin *expertWin;
@ -19,6 +21,7 @@ public:
int virtualCnt = 0; int virtualCnt = 0;
QList<QPoint> scans; QList<QPoint> scans;
QRadioButton *fdRow, *fdCol;
QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGroupNum; QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGroupNum;
QLineEdit *fdChipType, *fdDecodeMode; QLineEdit *fdChipType, *fdDecodeMode;
Table *tableChipType, *tableDecodeMode; Table *tableChipType, *tableDecodeMode;

View File

@ -4,11 +4,22 @@
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QEventLoop>
HeadMap headMap; HeadMap headMap;
pcap_t *pcapSend{0}; pcap_t *pcapSend{0};
PcapReThread *reThd{0}; PcapReThread *reThd{0};
int sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg) {
QEventLoop loop;
auto res = sendMsg(msg, id, timeout, [=, &loop](int code, const QByteArray data) {
loop.exit(code);
}, waitingDlg);
if(res==0) res = loop.exec(QEventLoop::ExcludeUserInputEvents);
if(res && waitingDlg) waitingDlg->close();
return res;
}
QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) { QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) {
char errbuf[PCAP_ERRBUF_SIZE]; char errbuf[PCAP_ERRBUF_SIZE];
pcap_if_t *devs; pcap_if_t *devs;

View File

@ -58,5 +58,5 @@ inline int sendMsg(const byte *msg, int size, int id, qint64 timeout, std::funct
inline int sendMsg(QByteArray &msg, int id, qint64 timeout, std::function<void(int code, const QByteArray)> callback, WaitingDlg *waitingDlg = 0) { inline int sendMsg(QByteArray &msg, int id, qint64 timeout, std::function<void(int code, const QByteArray)> callback, WaitingDlg *waitingDlg = 0) {
return sendMsg((byte*)msg.data(), msg.size(), id, timeout, callback, waitingDlg); return sendMsg((byte*)msg.data(), msg.size(), id, timeout, callback, waitingDlg);
} }
int sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg = 0);
#endif // GLOBALFUNC_H #endif // GLOBALFUNC_H

View File

@ -158,12 +158,16 @@ public:
verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
return this; return this;
} }
inline auto setColWidth(int value) { inline auto setColWidth(int value, QHeaderView::ResizeMode mode = QHeaderView::Interactive) {
horizontalHeader()->setDefaultSectionSize(value); auto header = horizontalHeader();
header->setDefaultSectionSize(value);
if(mode!=QHeaderView::Interactive) header->setSectionResizeMode(mode);
return this; return this;
} }
inline auto setRowHeight(int value) { inline auto setRowHeight(int value, QHeaderView::ResizeMode mode = QHeaderView::Interactive) {
verticalHeader()->setDefaultSectionSize(value); auto header = verticalHeader();
header->setDefaultSectionSize(value);
if(mode!=QHeaderView::Interactive) header->setSectionResizeMode(mode);
return this; return this;
} }
@ -178,6 +182,13 @@ public:
return setHeaderText(col, text); return setHeaderText(col, text);
} }
inline auto setVHeaderText(int row, QString text) {
auto item = verticalHeaderItem(row);
if(item==0) setVerticalHeaderItem(row, item = new QTableWidgetItem());
item->setText(text);
return item;
}
inline auto appendRow() { inline auto appendRow() {
auto value = rowCount(); auto value = rowCount();
setRowCount(value + 1); setRowCount(value + 1);

View File

@ -9,6 +9,8 @@ CONFIG += embed_translations
# In order to do so, uncomment the following line. # In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
TARGET = $$quote(LedSet Express)
msvc { msvc {
contains(QT_ARCH, i386) { contains(QT_ARCH, i386) {
QMAKE_LFLAGS += /LARGEADDRESSAWARE QMAKE_LFLAGS += /LARGEADDRESSAWARE

View File

@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QApplication::setOrganizationName("Shanghai Xixun Electronic Technology"); QApplication::setOrganizationName("Shanghai Xixun Electronic Technology");
QApplication::setOrganizationDomain("www.ledok.cn"); QApplication::setOrganizationDomain("ledok.cn");
QApplication::setApplicationName("LedSet Express"); QApplication::setApplicationName("LedSet Express");
QApplication a(argc, argv); QApplication a(argc, argv);
a.setStyle(QStyleFactory::create("Fusion")); a.setStyle(QStyleFactory::create("Fusion"));
@ -49,6 +49,8 @@ QRadioButton::indicator:checked {border-image: url(:/imgs/radio-check.png);}
QCheckBox::indicator {border-image: url(:/imgs/checkbox-un.png); width: 1em; height: 1em;} QCheckBox::indicator {border-image: url(:/imgs/checkbox-un.png); width: 1em; height: 1em;}
QCheckBox::indicator:checked {border-image: url(:/imgs/checkbox-check.png);} QCheckBox::indicator:checked {border-image: url(:/imgs/checkbox-check.png);}
QPushButton:disabled {color: #777;}
QPushButton[ss="min"]{padding: 0; width: 30px; height: 25px; } QPushButton[ss="min"]{padding: 0; width: 30px; height: 25px; }
QPushButton[ss="close"]{padding: 0; width: 30px; height: 25px; } QPushButton[ss="close"]{padding: 0; width: 30px; height: 25px; }
@ -61,7 +63,6 @@ QPushButton[ss="blue"] {background: #059;}
*/ */
QFont font; QFont font;
font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"}); font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"});
//font.setPixelSize(14);
a.setFont(font); a.setFont(font);
QPalette plt = a.palette(); QPalette plt = a.palette();
plt.setBrush(QPalette::Window, QColor(0x333333)); plt.setBrush(QPalette::Window, QColor(0x333333));

View File

@ -157,10 +157,7 @@ MainWin::MainWin() {
pcapSend = pcapS; pcapSend = pcapS;
reThd = new PcapReThread(pcapR); reThd = new PcapReThread(pcapR);
reThd->start(); reThd->start();
QSettings config(QApplication::applicationDirPath()+"/ledset.config", QSettings::IniFormat);//QDir::currentPath()为exe位置 QSettings().setValue("net_name", net_name = name);
config.beginGroup("GLOBAL");
config.setValue("net_name", net_name = name);
config.endGroup();
}); });
hstatus->addWidget(btnNetSelect); hstatus->addWidget(btnNetSelect);
@ -172,8 +169,7 @@ MainWin::MainWin() {
show(); show();
QSettings config(QApplication::applicationDirPath()+"/ledset.config", QSettings::IniFormat); QSettings config;
config.beginGroup("GLOBAL");//保存数据
auto name = config.value("net_name").toByteArray(); auto name = config.value("net_name").toByteArray();
name = getNetDev(this, name, true); name = getNetDev(this, name, true);
if(! name.isEmpty()) { if(! name.isEmpty()) {
@ -190,7 +186,6 @@ MainWin::MainWin() {
} }
} }
} }
config.endGroup();
getCard(); getCard();
} }

View File

@ -22,11 +22,24 @@ WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : QDialog
vBox->addWidget(fdText); vBox->addWidget(fdText);
} }
void WaitingDlg::closeEvent(QCloseEvent *event) {
if(showTimerId) {
killTimer(showTimerId);
showTimerId = 0;
}
if(closeTimerId) {
killTimer(closeTimerId);
closeTimerId = 0;
}
QDialog::closeEvent(event);
}
void WaitingDlg::timerEvent(QTimerEvent *event) { void WaitingDlg::timerEvent(QTimerEvent *event) {
if(showTimerId==event->timerId()) { if(showTimerId==event->timerId()) {
killTimer(showTimerId); killTimer(showTimerId);
showTimerId = 0; showTimerId = 0;
show(); show();
raise();
activateWindow();
} else if(closeTimerId==event->timerId()) { } else if(closeTimerId==event->timerId()) {
killTimer(closeTimerId); killTimer(closeTimerId);
closeTimerId = 0; closeTimerId = 0;
@ -34,12 +47,18 @@ void WaitingDlg::timerEvent(QTimerEvent *event) {
} else QDialog::timerEvent(event); } else QDialog::timerEvent(event);
} }
void WaitingDlg::showLater() { void WaitingDlg::showLater() {
if(isVisible()) return;
if(showTimerId) killTimer(showTimerId); if(showTimerId) killTimer(showTimerId);
showTimerId = startTimer(250); showTimerId = startTimer(200);
} }
void WaitingDlg::success() { void WaitingDlg::success() {
fdText->setText(sucText.isEmpty() ? tr("Success") : sucText); fdText->setText(sucText.isEmpty() ? tr("Success") : sucText);
mIndicator->success(); mIndicator->success();
if(showTimerId) {
killTimer(showTimerId);
showTimerId = 0;
}
if(! isVisible()) show();
if(closeTimerId) killTimer(closeTimerId); if(closeTimerId) killTimer(closeTimerId);
closeTimerId = startTimer(1000); closeTimerId = startTimer(1000);
} }

View File

@ -42,6 +42,7 @@ public slots:
void success(); void success();
protected: protected:
void timerEvent(QTimerEvent *) override; void timerEvent(QTimerEvent *) override;
void closeEvent(QCloseEvent *) override;
private: private:
int closeTimerId{0}, showTimerId{0}; int closeTimerId{0}, showTimerId{0};
}; };