865 lines
32 KiB
C++
865 lines
32 KiB
C++
#include "expertwin.h"
|
|
#include "gutil/qgui.h"
|
|
#include "screenunit.h"
|
|
#include "expertboxlayoutwin.h"
|
|
#include "expertsmartpointsetwin.h"
|
|
#include "expertscreenconnwin.h"
|
|
#include "globalfunc.h"
|
|
#include <QTabWidget>
|
|
#include <QLineEdit>
|
|
#include <QPushButton>
|
|
#include <QGroupBox>
|
|
#include <QStackedWidget>
|
|
#include <QRadioButton>
|
|
#include <QCheckBox>
|
|
#include <QApplication>
|
|
#include <QFile>
|
|
#include <QJsonDocument>
|
|
#include <QJsonArray>
|
|
#include <QMessageBox>
|
|
#include <QFileDialog>
|
|
#include <QSplitter>
|
|
|
|
//added by alahover -s 20230817
|
|
auto zrf_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 aa ff ff 00 11 11 11 11 00 00 00 00 00 00 00 00 00 00 00 00"
|
|
"00 00 06 20 10 10 00 E4 06 FF FF FF FF 00 00 80 80 80 00 00 00 1F 00 00 00 3C 01 33 00 00 00 80 00 00 12 05 00 00 00 01 02 "
|
|
"03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 01 00 00 00 00 10 00 00 20 00 00 30 "
|
|
"00 00 40 00 00 50 00 00 60 00 00 70 00 00 80 00 00 90 00 00 A0 00 00 B0 00 00 C0 00 00 D0 00 00 F0 00 00 00 01 00 10 01 00 "
|
|
"20 01 00 30 01 00 40 01 00 50 01 00 60 01 00 70 01 00 80 01 00 90 01 00 A0 01 00 B0 01 00 C0 01 00 D0 01 00 F0 01 00 00 02 "
|
|
"00 10 02 05 00 1F F8 7F 01 40 07 1F F8 73 01 40 07 1F F8 5F 01 40 07 40 10 40 10 40 10 00 00 00 00 00 00 00 00 00 00 00 00 "
|
|
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "
|
|
"00 00 00 00 00 00 00 00 00 00 ");//297
|
|
void ExpertWin::claseToStruct() {
|
|
zrfBaseParam.b0 = (zrfBaseParam.b0_7 << 7 & 0b10000000)| (zrfBaseParam.b0_6 << 6 & 0b01000000)| (zrfBaseParam.b0_5 << 5 & 0b00100000)| (zrfBaseParam.b0_4 << 4 & 0b00010000)| (zrfBaseParam.b0_3_1 << 1 & 0b00001110) | (zrfBaseParam.b0_0 & 0b00000001);
|
|
auto unitptr = zrf_msg.data();
|
|
unsigned char * bytePrt = (unsigned char*)(unitptr);
|
|
*bytePrt=zrfBaseParam.b0;
|
|
bytePrt ++;
|
|
zrfBaseParam.b1 = (zrfBaseParam.b1_7_6<< 6 & 0b11000000) | (zrfBaseParam.b1_5<<5 & 0b00100000) | (zrfBaseParam.b1_4<<4 & 0b00010000) | (zrfBaseParam.b1_3_2<<2 & 0b00001100) | (zrfBaseParam.b1_1<<1 & 0b00000010) |(zrfBaseParam.b1_0&0b00000001);
|
|
*bytePrt=zrfBaseParam.b1;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b2;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b3;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b4;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b5;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b6;
|
|
bytePrt ++;
|
|
zrfBaseParam.b7 = (zrfBaseParam.b7_7_6 << 6 & 0b11000000) | (zrfBaseParam.b7_5_4<<4 & 0b00110000) | (zrfBaseParam.b7_3_2 << 2 & 0b00001100) | (zrfBaseParam.b7_1_0 & 0b00000011) ;
|
|
*bytePrt=zrfBaseParam.b7;
|
|
bytePrt ++;
|
|
zrfBaseParam.b8 = (zrfBaseParam.b8_7<<7 &0b10000000) | (zrfBaseParam.b8_6<<6 & 0b01000000) | (zrfBaseParam.b8_5_4<<4 & 0b00110000) | (zrfBaseParam.b8_3_0 & 0b00001111) ;
|
|
*bytePrt=zrfBaseParam.b8;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b9 ;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b10;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b11;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b12;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b13;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b14;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b15;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b16;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b17;
|
|
bytePrt ++;
|
|
zrfBaseParam.b18 = (zrfBaseParam.b18_7_4<<4 & 0b11110000) | (zrfBaseParam.b18_3_0 & 0b00001111);
|
|
*bytePrt=zrfBaseParam.b18;
|
|
bytePrt ++;
|
|
zrfBaseParam.b19 = (zrfBaseParam.b19_7_4<<4 & 0b11110000) | (zrfBaseParam.b19_3_0 & 0b00001111);
|
|
*bytePrt=zrfBaseParam.b19;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b20;
|
|
bytePrt ++;
|
|
zrfBaseParam.b21 = (zrfBaseParam.b21_7_5 << 5 & 0b11100000) | (zrfBaseParam.b21_4_0 & 0b00011111);
|
|
*bytePrt=zrfBaseParam.b21;
|
|
bytePrt ++;
|
|
zrfBaseParam.b22 = (zrfBaseParam.b22_7_6 << 6 & 0b11000000) | (zrfBaseParam.b22_5_2<<2 & 0b00111100) | (zrfBaseParam.b22_1_0 & 0b00000011);
|
|
*bytePrt=zrfBaseParam.b22;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b23;
|
|
bytePrt ++;
|
|
zrfBaseParam.b24 = (zrfBaseParam.b24_7_5<<5 & 0b11100000) | (zrfBaseParam.b24_4_0 & 0b00011111);
|
|
*bytePrt=zrfBaseParam.b24;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b25;
|
|
bytePrt ++;
|
|
zrfBaseParam.b26 = (zrfBaseParam.b26_7<<7 & 0b10000000) | (zrfBaseParam.b26_6<<6 & 0b01000000) | (zrfBaseParam.b26_5_0 & 0b00111111);
|
|
*bytePrt=zrfBaseParam.b26;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b27_28[0];
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b27_28[1];
|
|
bytePrt ++;
|
|
zrfBaseParam.b29 = (zrfBaseParam.b29_7_4<<4 & 0b11110000) | (zrfBaseParam.b29_3_2<<2 &0b00001100) | (zrfBaseParam.b29_1_0 & 0b00000011);
|
|
*bytePrt=zrfBaseParam.b29;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b30;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b31;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b32;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b33 = (zrfBaseParam.b33_7_4<<4 & 0b11110000) | (zrfBaseParam.b33_3_0 & 0b00001111);
|
|
*bytePrt=zrfBaseParam.b33;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b34 = (zrfBaseParam.b34_7_4<<5 & 0b11110000) | (zrfBaseParam.b34_3_0 & 0b00001111);
|
|
*bytePrt=zrfBaseParam.b34;
|
|
bytePrt ++;
|
|
*bytePrt=zrfBaseParam.b35;
|
|
bytePrt ++;
|
|
zrfBaseParam.b36 = (zrfBaseParam.b36_7_6<<6 & 0b11000000) | (zrfBaseParam.b36_5_0 & 0b00111111);
|
|
*bytePrt=zrfBaseParam.b36;
|
|
bytePrt ++;
|
|
zrfBaseParam. b37 = (zrfBaseParam.b37_7_5<<5 & 0b11100000) | (zrfBaseParam.b37_4_3<<3 & 0b00011000) | (zrfBaseParam.b37_2<<2 & 0b00000100) | (zrfBaseParam.b37_1 <<1 & 0b00000010) | (zrfBaseParam.b37_0 & 0b00000001);
|
|
*bytePrt=zrfBaseParam.b37;
|
|
bytePrt ++;
|
|
memcpy(bytePrt,&zrfBaseParam.b38_69[32],32);
|
|
bytePrt +=32;
|
|
zrfBaseParam.b70 = (zrfBaseParam.b70_7<<7 & 0b10000000) | (zrfBaseParam.b70_6<<6 & 0b01000000) | (zrfBaseParam.b70_5_2<<2 & 0b00111100) | (zrfBaseParam.b70_1<<1 & 0b00000010) | (zrfBaseParam.b70_0 & 0b00000001);
|
|
*bytePrt=zrfBaseParam.b70;
|
|
bytePrt ++;
|
|
for(int i=0;i<32;i++)
|
|
{
|
|
memcpy(bytePrt,&zrfBaseParam.b71_166[i][0],3);
|
|
bytePrt +=3;
|
|
}
|
|
*bytePrt=zrfBaseParam.b167;
|
|
bytePrt ++;
|
|
zrfBaseParam.b168 = (zrfBaseParam.b168_7_5<<5 & 0b11100000) | (zrfBaseParam.b168_4_0 & 0b00011111);
|
|
*bytePrt=zrfBaseParam.b168;
|
|
bytePrt ++;
|
|
memcpy(bytePrt,(unsigned char *)&zrfBaseParam.b169_192[0],24);
|
|
bytePrt +=12;
|
|
*bytePrt=zrfBaseParam.b193;
|
|
}
|
|
//added by alahover -o 20230817
|
|
|
|
QColor colors[] {QColor(0xdd0000), QColor(0xdd6600), QColor(0x008800), QColor(0x008888), QColor(0x0000ff), QColor(0x777777), QColor(0xaaaaaa)};
|
|
|
|
ExpertWin::ExpertWin(QWidget *parent, int rcvCardType) : BaseWin{parent}, m_iRcvCardType{rcvCardType} {
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
|
setWindowTitle("专家调屏");
|
|
resize(900, 720);
|
|
|
|
auto vBox = new QVBoxLayout(center);
|
|
vBox->setContentsMargins(0,0,0,0);
|
|
vBox->setSpacing(3);
|
|
vBox->addLayout(addBtns(new QHBoxLayout()));
|
|
|
|
auto tab = new QTabWidget;
|
|
tab->setStyleSheet(R"rrr(
|
|
QTabWidget::pane {border: 1px solid #888; margin-top:-1px;}
|
|
QTabBar::tab {margin-top: 4px; padding: 6px 20px; border: 1px solid #888; border-radius: 0 0 3px 3px;}
|
|
QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; background-color: #000;}
|
|
)rrr");
|
|
vBox->addWidget(tab);
|
|
|
|
auto splitter = new QSplitter;
|
|
tab->addTab(splitter, "发送设备");
|
|
{
|
|
auto vLeft = new VBox(splitter);
|
|
|
|
auto hBox = new HBox(vLeft);
|
|
hBox->addWidget(new QLabel("分辨率: "));
|
|
|
|
auto fdW = new QLineEdit(QString::number(screenWidth));
|
|
hBox->addWidget(fdW);
|
|
|
|
hBox->addWidget(new QLabel("X"));
|
|
|
|
auto fdH = new QLineEdit(QString::number(screenHeight));
|
|
hBox->addWidget(fdH);
|
|
|
|
|
|
hBox = new HBox(vLeft);
|
|
hBox->addStretch();
|
|
|
|
auto btnGet = new QPushButton("刷新");
|
|
btnGet->setMinimumWidth(80);
|
|
hBox->addWidget(btnGet);
|
|
|
|
hBox->addSpacing(40);
|
|
|
|
auto btnSet = new QPushButton("设置");
|
|
btnSet->setMinimumWidth(80);
|
|
hBox->addWidget(btnSet);
|
|
|
|
hBox->addStretch();
|
|
|
|
auto table = new Table{
|
|
{"face", "网口", 40},
|
|
{"x", "X", 0, QHeaderView::Stretch},
|
|
{"y", "Y", 0, QHeaderView::Stretch},
|
|
{"w", "宽度", 0, QHeaderView::Stretch},
|
|
{"h", "高度", 0, QHeaderView::Stretch},
|
|
{"audio", "音频开关", 0, QHeaderView::Stretch},
|
|
{"backup", "备份开关", 0, QHeaderView::Stretch}
|
|
};
|
|
table->verticalHeader()->setMinimumWidth(20);//added by alahover 20230822
|
|
table->setDefs();
|
|
vLeft->addWidget(table);
|
|
table->setRowCount(4);
|
|
|
|
auto canvas = new ResizeEmitedWgt;
|
|
auto screen = new QWidget(canvas);
|
|
screen->setGeometry(0, 0, screenWidth, screenHeight);
|
|
screen->setAutoFillBackground(true);
|
|
auto pal = palette();
|
|
pal.setColor(QPalette::Window, QColor(0, 0, 0));
|
|
screen->setPalette(pal);
|
|
connect(canvas, &ResizeEmitedWgt::resized, this, [this, canvas, screen] {
|
|
rate = qMin(canvas->width()/(double)screenWidth, canvas->height()/(double)screenHeight);
|
|
if(rate==0) return;
|
|
screen->resize(qRound(screenWidth*rate), qRound(screenHeight*rate));
|
|
auto children = screen->children();
|
|
foreach(auto childObj, children) {
|
|
auto unit = static_cast<ScreenUnit*>(childObj);
|
|
unit->setGeometry(qRound(unit->mX*rate), qRound(unit->mY*rate), qRound(unit->mW*rate), qRound(unit->mH*rate));
|
|
}
|
|
});
|
|
splitter->addWidget(canvas);
|
|
|
|
splitter->setStretchFactor(0,0);
|
|
splitter->setStretchFactor(1,1);
|
|
splitter->setSizes({320, 1});
|
|
|
|
|
|
int idx = 0;
|
|
for(int rr=0; rr<4; rr++) {
|
|
QString name = "P"+QString::number(rr+1);
|
|
table->setText(rr, "name", name);
|
|
table->setText(rr, "x", QString::number(idx));
|
|
table->setText(rr, "y", "0");
|
|
table->setText(rr, "w", "128");
|
|
table->setText(rr, "h", "128");
|
|
table->setText(rr, "audio", "0");
|
|
table->setText(rr, "backup", "0");
|
|
|
|
auto unit = new ScreenUnit(this, name, idx, 0, 128, 128, screen);
|
|
unit->setAutoFillBackground(true);
|
|
pal.setColor(QPalette::Window, colors[rr]);
|
|
unit->setPalette(pal);
|
|
idx += 128;
|
|
}
|
|
}
|
|
{
|
|
auto file = QApplication::applicationDirPath()+"/temp.screen";
|
|
QFile qFile(file);
|
|
if(qFile.open(QFile::ReadOnly)) {
|
|
auto data = qFile.readAll();
|
|
qFile.close();
|
|
auto json = JFrom(data).toObj();
|
|
if(! json.empty()) {
|
|
cfg = json;
|
|
mBox = json["ModuleConnectionInfo"].toObj();
|
|
mModule = mBox["ModuleInfo"].toObj();
|
|
}
|
|
} else {
|
|
auto file = QApplication::applicationDirPath()+"/temp.module";
|
|
QFile qFile(file);
|
|
if(qFile.open(QFile::ReadOnly)) {
|
|
auto data = qFile.readAll();
|
|
qFile.close();
|
|
auto json = JFrom(data).toObj();
|
|
if(! json.empty()) mModule = json;
|
|
}
|
|
}
|
|
}
|
|
|
|
auto receivePanel = new QWidget;
|
|
tab->addTab(receivePanel, "接收卡");
|
|
{
|
|
auto vBox = new VBox(receivePanel);
|
|
auto gBox = new QGroupBox("模组信息");
|
|
vBox->addWidget(gBox);
|
|
{
|
|
auto hh = new HBox(gBox);
|
|
hh->addSpacing(20);
|
|
auto vvv = new VBox(hh);
|
|
|
|
auto lb = new QLabel("驱动芯片: ");
|
|
vvv->addWidget(lb);
|
|
|
|
lb = new QLabel("译码方式: ");
|
|
vvv->addWidget(lb);
|
|
|
|
vvv = new VBox(hh);
|
|
|
|
fdChipType = new QLabel(mModule["ChipType"].toStr());
|
|
vvv->addWidget(fdChipType);
|
|
|
|
fdDecodeMode = new QLabel(mModule["DecodeMode"].toStr());//译码方式
|
|
vvv->addWidget(fdDecodeMode);
|
|
|
|
hh->addSpacing(20);
|
|
vvv = new VBox(hh);
|
|
|
|
lb = new QLabel("模组宽度: ");
|
|
vvv->addWidget(lb);
|
|
|
|
lb = new QLabel("模组高度: ");
|
|
vvv->addWidget(lb);
|
|
|
|
vvv = new VBox(hh);
|
|
|
|
fdModuleWidth = new QLabel(QString::number(mModule["ModuleWidth"].toInt()));
|
|
vvv->addWidget(fdModuleWidth);
|
|
|
|
fdModuleHeight = new QLabel(QString::number(mModule["ModuleHeight"].toInt()));
|
|
vvv->addWidget(fdModuleHeight);
|
|
|
|
hh->addSpacing(20);
|
|
vvv = new VBox(hh);
|
|
|
|
lb = new QLabel("扫描数: ");
|
|
vvv->addWidget(lb);
|
|
|
|
lb = new QLabel("数据数组: ");
|
|
vvv->addWidget(lb);
|
|
|
|
vvv = new VBox(hh);
|
|
|
|
fdScanNum = new QLabel(QString::number(mModule["ScanNum"].toInt()));
|
|
vvv->addWidget(fdScanNum);
|
|
|
|
fdGroupNum = new QLabel(QString::number(mModule["GroupNum"].toInt()));
|
|
vvv->addWidget(fdGroupNum);
|
|
|
|
hh->addSpacing(20);
|
|
vvv = new VBox(hh);
|
|
|
|
auto btn = new QPushButton(tr("数据线颜色"));
|
|
btn->setStyleSheet("QPushButton {border: none; }");
|
|
vvv->addWidget(btn);
|
|
|
|
btn = new QPushButton(tr("模组抽行设置"));
|
|
btn->setStyleSheet("QPushButton {border: none; }");
|
|
vvv->addWidget(btn);
|
|
|
|
|
|
hh->addStretch();
|
|
vvv = new VBox(hh);
|
|
|
|
btn = new QPushButton("模组选择");
|
|
btn->setProperty("ss","blue");
|
|
vvv->addWidget(btn);
|
|
|
|
btn = new QPushButton("智能设置");
|
|
btn->setProperty("ss","blue");
|
|
connect(btn, &QPushButton::clicked, this, [this] {
|
|
(new ExpertSmartPointSetWin(this))->show();
|
|
});
|
|
vvv->addWidget(btn);
|
|
}
|
|
|
|
|
|
gBox = new QGroupBox("单卡带载");
|
|
vBox->addWidget(gBox);
|
|
{
|
|
auto hh = new HBox(gBox);
|
|
hh->addSpacing(20);
|
|
auto vvv = new VBox(hh);
|
|
|
|
auto fdNormal = new QRadioButton("常规设计");
|
|
fdNormal->setChecked(true);
|
|
vvv->addWidget(fdNormal);
|
|
|
|
fdAdvacned = new QRadioButton("高级设计");
|
|
vvv->addWidget(fdAdvacned);
|
|
|
|
hh->addSpacing(20);
|
|
|
|
auto line = new QFrame;
|
|
line->setFrameShadow(QFrame::Sunken);
|
|
line->setFrameShape(QFrame::VLine);
|
|
hh->addWidget(line);
|
|
|
|
auto stack = new QStackedWidget;
|
|
auto poli = stack->sizePolicy();
|
|
poli.setVerticalPolicy(QSizePolicy::Maximum);
|
|
stack->setSizePolicy(poli);
|
|
hh->addWidget(stack);
|
|
|
|
auto normalPanel = new QWidget;
|
|
stack->addWidget(normalPanel);
|
|
{
|
|
auto hh = new HBox(normalPanel);
|
|
hh->setContentsMargins(0,0,0,0);
|
|
auto vvv = new VBox(hh);
|
|
|
|
auto lb = new QLabel(tr("宽度"));
|
|
vvv->addWidget(lb);
|
|
|
|
lb = new QLabel(tr("高度"));
|
|
vvv->addWidget(lb);
|
|
|
|
vvv = new VBox(hh);
|
|
|
|
fdCardWidth = new QSpinBox;
|
|
fdCardWidth->setRange(0, 99999);
|
|
fdCardWidth->setValue(mBox["ModuleRow"].toInt() * mModule["ModuleWidth"].toInt());
|
|
vvv->addWidget(fdCardWidth);
|
|
|
|
fdCardHeight = new QSpinBox;
|
|
fdCardHeight->setRange(0, 99999);
|
|
fdCardHeight->setValue(mBox["ModuleCol"].toInt() * mModule["ModuleHeight"].toInt());
|
|
vvv->addWidget(fdCardHeight);
|
|
hh->addSpacing(20);
|
|
|
|
vvv = new VBox(hh);
|
|
|
|
lb = new QLabel(tr("多开设置"));
|
|
vvv->addWidget(lb);
|
|
|
|
lb = new QLabel(tr("级联方向"));
|
|
vvv->addWidget(lb);
|
|
|
|
vvv = new VBox(hh);
|
|
|
|
fdSectorCount = new QComboBox;
|
|
fdSectorCount->addItem(tr("无"), 1);
|
|
fdSectorCount->addItem(tr("双开"), 2);
|
|
fdSectorCount->addItem(tr("三开"), 3);
|
|
fdSectorCount->addItem(tr("四开"), 4);
|
|
fdSectorCount->addItem(tr("五开"), 5);
|
|
fdSectorCount->addItem(tr("六开"), 6);
|
|
fdSectorCount->addItem(tr("七开"), 7);
|
|
fdSectorCount->addItem(tr("八开"), 8);
|
|
SetCurData(fdSectorCount, mBox["SectorCount"].toInt());
|
|
vvv->addWidget(fdSectorCount);
|
|
|
|
fdDirection = new QComboBox();
|
|
fdDirection->addItem(tr("从左到右"));
|
|
fdDirection->addItem(tr("从右到左"));
|
|
fdDirection->addItem(tr("从上到下"));
|
|
fdDirection->addItem(tr("从下到上"));
|
|
fdDirection->setCurrentIndex(mBox["ModuleDirection"].toInt());
|
|
vvv->addWidget(fdDirection);
|
|
|
|
hh->addStretch();
|
|
|
|
vvv = new VBox(hh);
|
|
|
|
auto cb = new QCheckBox(tr("旋转180°"));
|
|
vvv->addWidget(cb);
|
|
|
|
auto btn = new QPushButton(tr("数据交换"));
|
|
btn->setProperty("ss","blue");
|
|
vvv->addWidget(btn);
|
|
}
|
|
|
|
auto advacnedPanel = new QWidget;
|
|
stack->addWidget(advacnedPanel);
|
|
{
|
|
auto hh = new HBox(advacnedPanel);
|
|
hh->setContentsMargins(0,0,0,0);
|
|
vvv = new VBox(hh);
|
|
|
|
auto btn = new QPushButton(tr("平面造型"));
|
|
btn->setProperty("ss","blue");
|
|
btn->setMaximumWidth(100);
|
|
connect(btn, &QPushButton::clicked, this, [=] {
|
|
auto win = new ExpertBoxLayoutWin(this);
|
|
win->show();
|
|
win->raise();
|
|
win->activateWindow();
|
|
});
|
|
vvv->addWidget(btn);
|
|
}
|
|
connect(fdNormal, &QRadioButton::toggled, this, [=](bool checked) {
|
|
stack->setCurrentWidget(checked ? normalPanel : advacnedPanel);
|
|
});
|
|
if(cfg["is_irr"].toBool()) fdAdvacned->setChecked(true);
|
|
}
|
|
|
|
gBox = new QGroupBox(tr("效果测试"));
|
|
vBox->addWidget(gBox);
|
|
{
|
|
auto hh = new HBox(gBox);
|
|
hh->addSpacing(20);
|
|
|
|
auto vvv = new VBox(hh);
|
|
auto hhh = new HBox(vvv);
|
|
auto lb = new QLabel(tr("视觉刷新率:"));
|
|
hhh->addWidget(lb);
|
|
|
|
auto cbFresh = new QComboBox();
|
|
cbFresh->addItem("960");
|
|
cbFresh->addItem("1920");
|
|
cbFresh->addItem("2880");
|
|
cbFresh->addItem("3840");
|
|
hhh->addWidget(cbFresh);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("DCLK频率:"));
|
|
hhh->addWidget(lb);
|
|
auto cbDCLKf = new QComboBox();
|
|
cbDCLKf->addItem("25M");
|
|
cbDCLKf->addItem("20.83M");
|
|
cbDCLKf->addItem("17.86M");
|
|
cbDCLKf->addItem("15.63M");
|
|
cbDCLKf->addItem("13.89M");
|
|
cbDCLKf->addItem("12.5M");
|
|
cbDCLKf->addItem("11.36M");
|
|
cbDCLKf->addItem("10.42M");
|
|
cbDCLKf->addItem("9.62M");
|
|
hhh->addWidget(cbDCLKf);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("DCLK相位:"));
|
|
hhh->addWidget(lb);
|
|
auto spinDclkXw = new QSpinBox;
|
|
spinDclkXw->setRange(0, 99999);
|
|
hhh->addWidget(spinDclkXw);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("DCLK占空比:"));
|
|
hhh->addWidget(lb);
|
|
auto spinDclkZkb = new QSpinBox;
|
|
spinDclkZkb->setRange(20, 80);
|
|
hhh->addWidget(spinDclkZkb);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("换行时间(ns):"));
|
|
hhh->addWidget(lb);
|
|
auto spinLineNs = new QSpinBox;
|
|
spinLineNs->setRange(2, 9999);
|
|
hhh->addWidget(spinLineNs);
|
|
|
|
hh->addSpacing(20);
|
|
vvv = new VBox(hh);
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("亮度有效率:"));
|
|
hhh->addWidget(lb);
|
|
lb = new QLabel(tr("100%"));
|
|
hhh->addWidget(lb);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("GCLK频率:"));
|
|
hhh->addWidget(lb);
|
|
auto cbGCLKf = new QComboBox();
|
|
cbGCLKf->addItem("25M");
|
|
cbGCLKf->addItem("20.83M");
|
|
cbGCLKf->addItem("17.86M");
|
|
cbGCLKf->addItem("15.63M");
|
|
cbGCLKf->addItem("13.89M");
|
|
cbGCLKf->addItem("12.5M");
|
|
cbGCLKf->addItem("11.36M");
|
|
cbGCLKf->addItem("10.42M");
|
|
cbGCLKf->addItem("9.62M");
|
|
hhh->addWidget(cbGCLKf);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("灰度级数:"));
|
|
hhh->addWidget(lb);
|
|
auto cbGryLevel = new QComboBox();
|
|
cbGryLevel->addItem("256");
|
|
cbGryLevel->addItem("1024");
|
|
cbGryLevel->addItem("4096");
|
|
cbGryLevel->addItem("8192");
|
|
cbGryLevel->addItem("16384");
|
|
cbGryLevel->addItem("32768");
|
|
cbGryLevel->addItem("65536");
|
|
hhh->addWidget(cbGryLevel);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("GCLK占空比:"));
|
|
hhh->addWidget(lb);
|
|
auto spinGclkZkb = new QSpinBox;
|
|
spinGclkZkb->setRange(20, 80);
|
|
hhh->addWidget(spinGclkZkb);
|
|
|
|
hhh = new HBox(vvv);
|
|
lb = new QLabel(tr("换行位置(ns):"));
|
|
hhh->addWidget(lb);
|
|
auto spinLineWz = new QSpinBox;
|
|
spinLineWz->setRange(2, 9999);
|
|
hhh->addWidget(spinLineWz);
|
|
|
|
hh->addStretch();
|
|
|
|
vvv = new VBox(hh);
|
|
hhh = new HBox(vvv);
|
|
|
|
auto btn = new QPushButton(tr("更多设置"));
|
|
btn->setProperty("ss","blue");
|
|
hhh->addWidget(btn);
|
|
|
|
}
|
|
vBox->addStretch();
|
|
|
|
//保存,发送,固话,回读区
|
|
auto hBox = new HBox(vBox);
|
|
hBox->addSpacing(20);
|
|
|
|
auto btn = new QPushButton(tr("打开配置"));
|
|
btn->setProperty("ss","blue");
|
|
hBox->addWidget(btn);
|
|
hBox->addSpacing(20);
|
|
|
|
btn = new QPushButton(tr("保存配置"));
|
|
btn->setProperty("ss","blue");
|
|
connect(btn, &QPushButton::clicked, this, [=] {
|
|
auto dir = QApplication::applicationDirPath()+"/BoxFiles";
|
|
QDir(dir).mkdir(".");
|
|
auto file = QFileDialog::getSaveFileName(this, tr("保存文件"), dir, tr("Box file (*.box)"));
|
|
if(file.isEmpty()) return;
|
|
QFile qFile(file);
|
|
if(! qFile.open(QFile::WriteOnly)) {
|
|
QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file));
|
|
return;
|
|
}
|
|
auto res = qFile.write(savedData());
|
|
qFile.close();
|
|
if(res < 0) {
|
|
QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file));
|
|
return;
|
|
}
|
|
QMessageBox::information(this, tr("保存成功"), tr("保存成功"));
|
|
});
|
|
hBox->addWidget(btn);
|
|
hBox->addStretch();
|
|
|
|
btn = new QPushButton(tr("保存Map"));
|
|
btn->setProperty("ss","blue");
|
|
connect(btn, &QPushButton::clicked, this, [=] {
|
|
auto dir = QApplication::applicationDirPath();
|
|
auto file = QFileDialog::getSaveFileName(this, tr("保存文件"), dir);
|
|
if(file.isEmpty()) return;
|
|
QFile qFile(file);
|
|
if(! qFile.open(QFile::WriteOnly)) {
|
|
QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file));
|
|
return;
|
|
}
|
|
QByteArray data;
|
|
addMapData(data);
|
|
auto res = qFile.write(data);
|
|
qFile.close();
|
|
if(res < 0) {
|
|
QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file));
|
|
return;
|
|
}
|
|
QMessageBox::information(this, tr("保存成功"), tr("保存成功"));
|
|
|
|
});
|
|
hBox->addWidget(btn);
|
|
hBox->addSpacing(20);
|
|
|
|
btn = new QPushButton(tr("发送数据"));
|
|
btn->setProperty("ss","blue");
|
|
connect(btn, &QPushButton::clicked, this, [=] {
|
|
//modified by alahover -s 20230817
|
|
if(m_iRcvCardType == enum_xixun_sync) {
|
|
QByteArray data;
|
|
addMapData(data);
|
|
QMessageBox::information(this, tr("提示"), tr("发送成功"));
|
|
} else if(m_iRcvCardType == enum_zrf) {
|
|
claseToStruct();
|
|
auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ...");
|
|
auto res = sendMsgSync(zrf_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();
|
|
QMessageBox::information(this, tr("提示"), tr("发送成功"));
|
|
}
|
|
}
|
|
else if(m_iRcvCardType == enum_xixun_async) QMessageBox::information(this, tr("提示"), tr("异步卡发送成功"));
|
|
else QMessageBox::information(this, tr("提示"), tr("未能识别的控制卡类型"));
|
|
});
|
|
hBox->addWidget(btn);
|
|
hBox->addSpacing(20);
|
|
|
|
btn = new QPushButton(tr("固化数据"));
|
|
btn->setProperty("ss","blue");
|
|
hBox->addWidget(btn);
|
|
hBox->addSpacing(20);
|
|
|
|
btn = new QPushButton(tr("回读数据"));
|
|
btn->setProperty("ss","blue");
|
|
hBox->addWidget(btn);
|
|
|
|
vBox->addStretch();
|
|
|
|
//状态栏
|
|
auto statusWgt = new QWidget;
|
|
statusWgt->setStyleSheet("QWidget{background-color:#222;}");
|
|
vBox->addWidget(statusWgt);
|
|
{
|
|
auto hh = new HBox(statusWgt);
|
|
auto lb = new QLabel(tr("状态:"));
|
|
hh->addWidget(lb);
|
|
}
|
|
}
|
|
|
|
auto connPanel = new QWidget;
|
|
tab->addTab(connPanel, tr("显示屏连接(正面看屏)"));
|
|
{
|
|
auto vBox = new QVBoxLayout(connPanel);
|
|
vBox->setContentsMargins(4, 4, 4, 4);
|
|
|
|
auto hhh = new QHBoxLayout;
|
|
vBox->addLayout(hhh);
|
|
|
|
auto bnScreen = new QPushButton("屏1");
|
|
hhh->addWidget(bnScreen);
|
|
|
|
hhh->addStretch();
|
|
|
|
auto lb = new QLabel("显示屏数目:");
|
|
hhh->addWidget(lb);
|
|
|
|
auto fdScreenCnt = new QSpinBox;
|
|
fdScreenCnt->setRange(1, 99);
|
|
fdScreenCnt->setValue(1);
|
|
hhh->addWidget(fdScreenCnt);
|
|
|
|
auto stack = new QStackedLayout;
|
|
vBox->addLayout(stack);
|
|
|
|
stack->addWidget(new ExpertScreenConnWin());
|
|
}
|
|
}
|
|
void ExpertWin::closeEvent(QCloseEvent *event) {
|
|
BaseWin::closeEvent(event);
|
|
QFile qFile("temp.screen");
|
|
if(! qFile.open(QFile::WriteOnly)) return;
|
|
qFile.write(savedData());
|
|
qFile.close();
|
|
}
|
|
QByteArray ExpertWin::savedData() {
|
|
mBox.insert("ModuleInfo", mModule);
|
|
auto ModuleWidth = mModule["ModuleWidth"].toInt();
|
|
auto ModuleHeight = mModule["ModuleHeight"].toInt();
|
|
mBox.insert("ModuleRow", (fdCardWidth->value() + ModuleWidth - 1) / ModuleWidth);
|
|
mBox.insert("ModuleCol", (fdCardHeight->value() + ModuleHeight - 1) / ModuleHeight);
|
|
mBox.insert("ModuleDirection", fdDirection->currentIndex());
|
|
mBox.insert("SectorCount", fdSectorCount->currentData().toInt());
|
|
JObj obj{
|
|
{"ModuleConnectionInfo", mBox},
|
|
{"is_irr", fdAdvacned->isChecked()},
|
|
};
|
|
return JToBytes(obj, " ");
|
|
}
|
|
void ExpertWin::addMapData(QByteArray &data) {
|
|
auto ModuleWidth = mModule["ModuleWidth"].toInt();
|
|
auto ModuleHeight = mModule["ModuleHeight"].toInt();
|
|
auto ModuleRow = (fdCardWidth->value() + ModuleWidth - 1) / ModuleWidth;
|
|
auto ModuleCol = (fdCardHeight->value() + ModuleHeight - 1) / ModuleHeight;
|
|
auto CardWidth = ModuleRow * ModuleWidth;
|
|
auto CardHeight = ModuleCol * ModuleHeight;
|
|
auto ModuleDirection = fdDirection->currentIndex();
|
|
//auto SectorCount = fdSectorCount->currentData().toInt();
|
|
QMap<uint, uint> map;
|
|
int memY = 0, memX = 0;
|
|
for(int boxY=0; boxY<CardHeight; boxY++) {
|
|
for(int boxX=0; boxX<CardWidth; boxX++) {
|
|
if(memX > 255) {
|
|
memX = 0;
|
|
memY++;
|
|
}
|
|
map.insert(boxY<<16|boxX, memY<<16|memX);
|
|
memX++;
|
|
}
|
|
memX = 0;
|
|
memY++;
|
|
}
|
|
|
|
auto points = mModule["Points"].toArray();
|
|
auto scans = mModule["Scans"].toArray();
|
|
auto GroupNum = mModule["GroupNum"].toInt();
|
|
auto jCnt = ModuleCol * GroupNum;
|
|
|
|
for(auto scan : scans) {
|
|
QList<QList<QByteArray>> chunkses;
|
|
for(int j=0; j<jCnt; j++) {
|
|
int lastMemY = INT_MIN;
|
|
int lastMemX = -1;
|
|
int cnt = 1, ttl = 1;
|
|
bool isAnti = false;
|
|
QList<QByteArray> chunks;
|
|
QByteArray chunk;
|
|
QString chstr;
|
|
for(int mm=0; mm<ModuleRow; mm++) {
|
|
int m = ModuleDirection==0 ? ModuleRow-1-mm : mm;
|
|
for(auto point : points) {
|
|
uint boxY = j * scans.size() + scan.toInt();
|
|
uint boxX = m * ModuleWidth + point.toInt();
|
|
if(boxX < 0) { //虚点
|
|
if(lastMemY==-1) memX = lastMemX + 1;
|
|
else {
|
|
memY = -1;
|
|
memX = 0;
|
|
}
|
|
} else {
|
|
auto mem = map[boxY<<16 | boxX];
|
|
memY = mem >> 16;
|
|
memX = mem & 0xffff;
|
|
}
|
|
if(memY==lastMemY && ttl < 64 && qAbs(memX-lastMemX)==1) {
|
|
if(cnt==1) {
|
|
isAnti = memX < lastMemX;
|
|
cnt++;
|
|
ttl++;
|
|
lastMemX = memX;
|
|
continue;
|
|
} else if(memX < lastMemX == isAnti) {
|
|
cnt++;
|
|
ttl++;
|
|
lastMemX = memX;
|
|
continue;
|
|
}
|
|
}
|
|
if(lastMemY > INT_MIN) {
|
|
uint y = lastMemY==-1 ? 0 : lastMemY;
|
|
uint x = isAnti ? lastMemX : lastMemX-cnt+1;
|
|
chunk.append((j << 2) + (y >> 8)).append(y).append(x).append((isAnti << 7)+cnt);
|
|
chstr += QString("j%1 行%2 列%3 序%4 长%5").arg(j).arg(y).arg(x).arg(isAnti).arg(cnt);
|
|
}
|
|
if(ttl>=64) {
|
|
chunks.append(chunk);
|
|
chunk = QByteArray();
|
|
qDebug() << chstr;
|
|
chstr.clear();
|
|
ttl = 1;
|
|
}
|
|
cnt = 1;
|
|
lastMemY = memY;
|
|
lastMemX = lastMemY==-1 ? 0 : memX;
|
|
}
|
|
}
|
|
uint y = lastMemY==-1 ? 0 : lastMemY;
|
|
uint x = isAnti ? lastMemX : lastMemX-cnt+1;
|
|
chunk.append((j << 2) + (y >> 8)).append(y).append(x).append((isAnti << 7)+cnt);
|
|
chstr += QString("j%1 行%2 列%3 序%4 长%5").arg(j).arg(y).arg(x).arg(isAnti).arg(cnt);
|
|
chunks.append(chunk);
|
|
chunkses.append(chunks);
|
|
qDebug() << chstr;
|
|
}
|
|
data.append(0xAA).append(scan.toInt()).append(2, 0);
|
|
auto chend = chunkses[0].size()-1;
|
|
auto start = data.size();
|
|
for(int ch=0; ch<=chend; ch++) {
|
|
data.append(0x55).append(ch==chend ? (char)(1<<7) : 0).append(2, 0);
|
|
auto start = data.size();
|
|
foreach(auto chunks, chunkses) data.append(chunks[ch]);
|
|
auto num = (data.size() - start) / 4;
|
|
data[start-2] = num;
|
|
data[start-3] = num>>8;
|
|
}
|
|
auto len = data.size() - start;
|
|
data[start-1] = len;
|
|
data[start-2] = len>>8;
|
|
}
|
|
}
|