ledok 修改指定ip功能

This commit is contained in:
gangphon 2022-09-28 18:21:57 +08:00
parent 757655024d
commit d145c6128e
14 changed files with 249 additions and 447 deletions

View File

@ -62,7 +62,6 @@ SOURCES += \
basewin.cpp \ basewin.cpp \
cfg.cpp \ cfg.cpp \
communication/hpptclient.cpp \ communication/hpptclient.cpp \
communication/network.cpp \
communication/taserialthread.cpp \ communication/taserialthread.cpp \
devicectrlpanel.cpp \ devicectrlpanel.cpp \
deviceitem.cpp \ deviceitem.cpp \
@ -106,7 +105,6 @@ SOURCES += \
wDevicesManager/ctrladvancedpanel.cpp \ wDevicesManager/ctrladvancedpanel.cpp \
wDevicesManager/ctrlbrightpanel.cpp \ wDevicesManager/ctrlbrightpanel.cpp \
wDevicesManager/ledcard.cpp \ wDevicesManager/ledcard.cpp \
wDevicesManager/specialdlg.cpp \
wDevicesManager/threadupgradeapk.cpp \ wDevicesManager/threadupgradeapk.cpp \
wDevicesManager/upgradeapkdialog.cpp \ wDevicesManager/upgradeapkdialog.cpp \
wDevicesManager/wupgradeapkitem.cpp \ wDevicesManager/wupgradeapkitem.cpp \
@ -164,7 +162,6 @@ HEADERS += \
basewin.h \ basewin.h \
cfg.h \ cfg.h \
communication/hpptclient.h \ communication/hpptclient.h \
communication/network.h \
communication/taserialthread.h \ communication/taserialthread.h \
devicectrlpanel.h \ devicectrlpanel.h \
deviceitem.h \ deviceitem.h \
@ -207,7 +204,6 @@ HEADERS += \
wDevicesManager/ctrladvancedpanel.h \ wDevicesManager/ctrladvancedpanel.h \
wDevicesManager/ctrlbrightpanel.h \ wDevicesManager/ctrlbrightpanel.h \
wDevicesManager/ledcard.h \ wDevicesManager/ledcard.h \
wDevicesManager/specialdlg.h \
wDevicesManager/threadupgradeapk.h \ wDevicesManager/threadupgradeapk.h \
wDevicesManager/upgradeapkdialog.h \ wDevicesManager/upgradeapkdialog.h \
wDevicesManager/wupgradeapkitem.h \ wDevicesManager/wupgradeapkitem.h \
@ -247,7 +243,6 @@ FORMS += \
tipdialog.ui \ tipdialog.ui \
wDevicesManager/controlencryptwidget.ui \ wDevicesManager/controlencryptwidget.ui \
wDevicesManager/controlhdmischedule.ui \ wDevicesManager/controlhdmischedule.ui \
wDevicesManager/controlhdmiwidget.ui \
wDevicesManager/controlpowermanual.ui \ wDevicesManager/controlpowermanual.ui \
wDevicesManager/controlpowerschedule.ui \ wDevicesManager/controlpowerschedule.ui \
wDevicesManager/controlpowerwidget.ui \ wDevicesManager/controlpowerwidget.ui \

View File

@ -1,126 +0,0 @@
#include "network.h"
#include <QMessageBox>
#include <QTime>
#include "string"
#include <QJsonObject>
#include <QJsonDocument>
#include <QMetaEnum>
#include <QNetworkDatagram>
NetComm::NetComm(QObject *p) : QObject(p) {
}
STREAM_PACKET NetComm::LedOkMakeStreamPacket(int iComType,int iLen,unsigned char *ucBuf,QString str)
{
STREAM_PACKET Temp;
memset(&Temp,0x00,sizeof(STREAM_PACKET));
if(iLen>2048)
return Temp;
memset(Temp.SyncHead,STREAM_SYNC_HEAD,STREAM_SYNC_HEAD_NUM);
memset(Temp.ucSerialCode,0x00,20);
char* ch;
QByteArray ba = str.toLatin1(); // must
ch=ba.data();
memcpy(Temp.ucSerialCode,ch,ba.size());
Temp.iLength=iLen;
Temp.ucCommType=iComType;
memcpy(Temp.pDataBuffer,ucBuf,iLen);
Temp.pDataBuffer[Temp.iLength]=
GetCheckCodeIn8(&Temp.ucCommType,Temp.iLength+sizeof(Temp.ucCommType)+sizeof(char)*20+sizeof(Temp.iLength));
return Temp;
}
void NetComm::RestoreLedCardIpByUdpCmd() {
//UDP多网卡广播
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
foreach (QNetworkInterface interfaces, networkinterfaces) //networkinterfaces负责提供主机的IP地址和网络接口的列表
{
{
foreach (QNetworkAddressEntry entry, interfaces.addressEntries())//QNetworkAddressEntry存储了一个IP地址子网掩码和广播地址
{
entry.setBroadcast(QHostAddress::Broadcast);
QHostAddress broadcastAddress("255.255.255.255");
{
entry.setBroadcast(QHostAddress::Broadcast);
RESTORE_IP stTempIp;
memset(&stTempIp,0x00,sizeof(RESTORE_IP));
QString strNew=entry.ip().toString();
int itempOffset = strNew.lastIndexOf(".");
QString sstrNew=strNew.left(itempOffset)+".254";
if(sstrNew.length()<=20)
memcpy(stTempIp.cNewIp,sstrNew.toLatin1().data(),sstrNew.length());
QString strMask=entry.netmask().toString();
if(strMask.length()<=20)
memcpy(stTempIp.cMask,strMask.toLatin1().data(),strMask.length());
QString strGateway=entry.ip().toString();
if(strGateway.length()<=20)
memcpy(stTempIp.cGateway,strGateway.toLatin1().data(),strGateway.length());
if(strGateway.length()<=20)
memcpy(stTempIp.cDns,strGateway.toLatin1().data(),strGateway.length());
STREAM_PACKET tempStreadPacket=LedOkMakeStreamPacket(COMMAND_ONLY_RESET_CARD_IP,80,(unsigned char *)&stTempIp,"Broadcast!");
int iLenPacket=tempStreadPacket.iLength+sizeof(int)+STREAM_SYNC_HEAD_NUM*sizeof(unsigned char)+sizeof(char)+20*sizeof(char)+sizeof(char);/////除正文外的协议结构大小;
QUdpSocket *tempUdpSocket= new QUdpSocket(this);
if(!tempUdpSocket->bind(entry.ip())) break;
tempUdpSocket->writeDatagram((char *)&tempStreadPacket,iLenPacket,broadcastAddress,m_port);
}
}
}
}
}
void NetComm::JieXiQJsonObjectOfLedCardInfoOld(const QString &strId,const QString &strIp){
LedCard *pLedCard = new LedCard(this);//alahover 没有释放
pLedCard->m_strCardId=strId;
pLedCard->m_strCardIp=strIp;
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) {//如果已经存在在列表中
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针
pOldLedCard->m_bOnLine = true;
if(pOldLedCard->CompareHTTPGetParam(pLedCard)==false) {//如果ip地址变化了
pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
emit addLedCard(pOldLedCard);//发送信号到界面
} else {
//post失败的概率比较小所以这里是否需要平凡的更新不需要刻意屏蔽该操作改为在其他点击操作中进行
emit ClearHeartbeatFlagByUdp(pOldLedCard);
}
delete pLedCard;
return;
}
LedCardList.append(pLedCard);
emit addLedCard(pLedCard);//发送信号到界面
}
void NetComm::JieXiQJsonObjectOfLedCardInfo(const QJsonObject &subObj, const QString &strIp){
LedCard *pLedCard = new LedCard(this);//alahover 没有释放
pLedCard->m_strCardId=subObj["cardId"].toString();
if(! strIp.isEmpty()) pLedCard->m_strCardIp = strIp;
else {
pLedCard->m_strCardIp = subObj["newIp"].toString();
if(pLedCard->m_strCardIp.isEmpty()) pLedCard->m_strCardIp = subObj["ip"].toString();
}
pLedCard->m_iWidth=subObj["width"].toInt();
pLedCard->m_iHeight=subObj["height"].toInt();
pLedCard->starterversionName=subObj["versionName"].toString();
pLedCard->starterPort=subObj["starterPort"].toInt();
pLedCard->androidVersion=subObj["androidVersion"].toString();
pLedCard->iHttpGetId=subObj["id"].toInt();
pLedCard->androidHeight=subObj["androidHeight"].toInt();
pLedCard->androidWidth=subObj["androidWidth"].toInt();
pLedCard->lastActive=subObj["lastActive"].toInt();
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) { //如果已经存在在列表中
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针
pOldLedCard->m_bOnLine = true;
if(! pOldLedCard->CompareHTTPGetParam(pLedCard)) {//如果ip地址变化了
pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
emit addLedCard(pOldLedCard);//发送信号到界面
} else {
//post失败的概率比较小所以这里是否需要平凡的更新不需要刻意屏蔽该操作改为在其他点击操作中进行
emit ClearHeartbeatFlagByUdp(pOldLedCard);
}
delete pLedCard;
return;
}
LedCardList.append(pLedCard);
emit addLedCard(pLedCard);//发送信号到界面
}

View File

@ -1,41 +0,0 @@
#ifndef NETWORK_H
#define NETWORK_H
#include <QObject>
#include <QUdpSocket>
#include <QNetworkInterface>
#include <QList>
#include <wDevicesManager/ledcard.h>
#include <communication/hpptclient.h>
#include <globaldefine.h>
#include <QTimer>
#include <windows.h>
class NetComm : public QObject {
Q_OBJECT
public:
NetComm(QObject *p = nullptr);
STREAM_PACKET LedOkMakeStreamPacket(int iComType,int iLen,unsigned char *ucBuf,QString str);
static DWORD WINAPI send(void *);
void JieXiQJsonObjectOfLedCardInfo(const QJsonObject &subObj,const QString &strIp);
void JieXiQJsonObjectOfLedCardInfoOld(const QString &strId,const QString &strIp);
QList<LedCard *> LedCardList;
QTimer mUdpTimer;
QUdpSocket mUdpSocket;
signals:
void addLedCard(LedCard *);
void ClearHeartbeatFlagByUdp(LedCard *);
public slots:
void RestoreLedCardIpByUdpCmd();
private:
QString m_strCardId;
qint32 m_iWidth;
LedCard *m_pLedCard;
int m_port = 31296;
};
extern NetComm *gUdp;
#endif // NETWORK_H

View File

@ -1,18 +1,19 @@
#include "devicepanel.h" #include "devicepanel.h"
#include "devicectrlpanel.h" #include "devicectrlpanel.h"
#include "tools.h" #include "tools.h"
#include "communication/network.h" #include "gqt.h"
#include "wDevicesManager/specialdlg.h"
#include <QAction> #include <QAction>
#include <QBoxLayout> #include <QBoxLayout>
#include <QEvent> #include <QEvent>
#include <QHeaderView> #include <QHeaderView>
#include <QLineEdit> #include <QLineEdit>
#include <QNetworkDatagram> #include <QNetworkDatagram>
#include <QNetworkInterface>
#include <QMessageBox>
#include <QSettings>
DevicePanel *gDevicePanel; DevicePanel *gDevicePanel;
QList<LedCard*> *gSelCards; QList<LedCard*> *gSelCards;
NetComm *gUdp;
//设备管理响应页面 //设备管理响应页面
DevicePanel::DevicePanel(QWidget *parent) : QWidget(parent) { DevicePanel::DevicePanel(QWidget *parent) : QWidget(parent) {
gDevicePanel = this; gDevicePanel = this;
@ -68,10 +69,54 @@ DevicePanel::DevicePanel(QWidget *parent) : QWidget(parent) {
bnSpecifyIP->setGeometry(0, 0, areaFlash->width(), areaFlash->height()); bnSpecifyIP->setGeometry(0, 0, areaFlash->width(), areaFlash->height());
bnSpecifyIP->setItemDelegate(new QStyledItemDelegate); bnSpecifyIP->setItemDelegate(new QStyledItemDelegate);
connect(bnSpecifyIP, &QComboBox::textActivated, this, [this] { connect(bnSpecifyIP, &QComboBox::textActivated, this, [this] {
pNetComm->mUdpTimer.stop(); if(specifyIPDlg==0) {
SpecialDlg pDlg(this, pNetComm); specifyIPDlg = new QDialog(this);
pDlg.exec(); specifyIPDlg->setWindowTitle(tr("Specify IP"));
pNetComm->mUdpTimer.start(30000);
auto vBox = new VBox(specifyIPDlg);
vBox->addStretch();
auto label = new QLabel(tr("Specify IP list"));
label->setAlignment(Qt::AlignCenter);
vBox->addWidget(label);
fdIP = new QTextEdit(QSettings().value("SpecifyIP").toString());
fdIP->setPlaceholderText("192.168.1.1\n192.168.1.2\n ...");
fdIP->setMinimumWidth(160);
vBox->addWidget(fdIP);
auto hBox = new HBox(vBox);
hBox->addStretch();
auto bnSearch = new QPushButton(tr("Search"));
connect(bnSearch, &QPushButton::clicked, this, [this] {
QString ipsStr = fdIP->toPlainText();
if(ipsStr.isEmpty()) {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input IP address!"));
return;
}
auto ips = ipsStr.split("\n", Qt::SkipEmptyParts);
if(ips.isEmpty()) {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input IP address!"));
return;
}
QByteArray data = QJsonDocument({{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
foreach(auto ip, ips) {
if(gDevicePanel->mUdpSocket.writeDatagram(data, QHostAddress(ip), 22222) != data.length()) qDebug() << "Specify IP write Failed." << ip;
}
specifyIPDlg->accept();
});
hBox->addWidget(bnSearch);
auto btnCancel = new QPushButton(tr("Cancel"));
connect(btnCancel, &QPushButton::clicked, specifyIPDlg, &QDialog::reject);
hBox->addWidget(btnCancel);
hBox->addStretch();
}
mUdpTimer.stop();
specifyIPDlg->exec();
mUdpTimer.start(30000);
}); });
bnSpecifyIP->setStyleSheet(R"rrr( bnSpecifyIP->setStyleSheet(R"rrr(
QComboBox { QComboBox {
@ -89,16 +134,16 @@ QComboBox QAbstractItemView::item {
QComboBox QAbstractItemView::item:selected {background-color: #09c;} QComboBox QAbstractItemView::item:selected {background-color: #09c;}
)rrr"); )rrr");
btnRefrash = new QPushButton(tr("Refresh"), areaFlash); btnRefresh = new QPushButton(tr("Refresh"), areaFlash);
btnRefrash->setGeometry(0, 0, 75, areaFlash->height()); btnRefresh->setGeometry(0, 0, 75, areaFlash->height());
connect(btnRefrash, &QPushButton::clicked, this, [this] { connect(btnRefresh, &QPushButton::clicked, this, [this] {
pNetComm->LedCardList.clear(); LedCardList.clear();
mDeviceTable->onCheckAll(false); mDeviceTable->onCheckAll(false);
mDeviceTable->clear(); mDeviceTable->clear();
nDeviceNum->setText("0"); nDeviceNum->setText("0");
sendGetInfo(); sendGetInfo();
}); });
btnRefrash->setStyleSheet(R"rrr( btnRefresh->setStyleSheet(R"rrr(
QPushButton { QPushButton {
border-radius: 5px; border-radius: 5px;
background-color: #19c; background-color: #19c;
@ -120,14 +165,12 @@ QPushButton:hover {background-color: #08b;}
vBox->addLayout(mHBox); vBox->addLayout(mHBox);
pNetComm = new NetComm(this); connect(&mUdpTimer, &QTimer::timeout, this, &DevicePanel::sendGetInfo);
connect(&pNetComm->mUdpTimer, &QTimer::timeout, this, &DevicePanel::sendGetInfo); connect(&mUdpSocket, &QUdpSocket::readyRead, this, [this] {
connect(&pNetComm->mUdpSocket, &QUdpSocket::readyRead, this, [this] { while(mUdpSocket.hasPendingDatagrams()) {
while(pNetComm->mUdpSocket.hasPendingDatagrams()) { auto gram = mUdpSocket.receiveDatagram();
auto gram = pNetComm->mUdpSocket.receiveDatagram();
auto data = gram.data(); auto data = gram.data();
if(data.isEmpty()) continue; if(data.isEmpty()) continue;
qDebug() << "data" << data;
auto senderAddress = gram.senderAddress(); auto senderAddress = gram.senderAddress();
bool ok = true; bool ok = true;
if(senderAddress.protocol()==QUdpSocket::IPv6Protocol) senderAddress.setAddress(senderAddress.toIPv4Address(&ok)); if(senderAddress.protocol()==QUdpSocket::IPv6Protocol) senderAddress.setAddress(senderAddress.toIPv4Address(&ok));
@ -139,42 +182,31 @@ QPushButton:hover {background-color: #08b;}
qDebug()<<"DeviceItem OnProHttpResponse 解析json文件错误"; qDebug()<<"DeviceItem OnProHttpResponse 解析json文件错误";
continue; continue;
} }
pNetComm->JieXiQJsonObjectOfLedCardInfo(document.object(), addr); parseInfo(document.object(), addr);
} else { } else {
STREAM_PACKET *pStreamPacket = (STREAM_PACKET *)gram.data().data(); STREAM_PACKET *pStreamPacket = (STREAM_PACKET *)gram.data().data();
pNetComm->JieXiQJsonObjectOfLedCardInfoOld(pStreamPacket->ucSerialCode, addr); LedCard *pLedCard = new LedCard(this);//alahover 没有释放
pLedCard->m_strCardId = pStreamPacket->ucSerialCode;
pLedCard->m_strCardIp = addr;
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) {//如果已经存在在列表中
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针
pOldLedCard->m_bOnLine = true;
if(pOldLedCard->CompareHTTPGetParam(pLedCard)==false) {//如果ip地址变化了
pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
emit addLedCard(pOldLedCard);//发送信号到界面
} else {
//post失败的概率比较小所以这里是否需要平凡的更新不需要刻意屏蔽该操作改为在其他点击操作中进行
emit clearUdpHeartbeat(pOldLedCard);
}
delete pLedCard;
return;
}
LedCardList.append(pLedCard);
emit addLedCard(pLedCard);//发送信号到界面
} }
} }
}); });
gUdp = pNetComm;
connect(pNetComm, &NetComm::addLedCard, this, [this](LedCard *p){
int cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) {
auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
if(item->m_pLedCard->m_strCardId != p->m_strCardId) continue;
item->setData(DeviceTable_ID, 0, p->m_strCardId);
item->setData(DeviceTable_IP, 0, p->m_strCardIp);
item->setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(p->m_iWidth).arg(p->m_iHeight));
return;
}
new DeviceItem(p, mDeviceTable, this);
nDeviceNum->setText(QString::number(mDeviceTable->topLevelItemCount()));
});
connect(pNetComm, &NetComm::ClearHeartbeatFlagByUdp, this, [this](LedCard *p) {
int cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) {
auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
if(item->m_pLedCard->m_strCardId != p->m_strCardId) continue;
item->m_HeartbeatCount = 0;
if(item->m_ImageOnline) {
item->m_pLedCard->m_bOnLine = true;
item->m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png"));
}
return;
}
});
m_headerItem = new QTreeWidgetItem(); m_headerItem = new QTreeWidgetItem();
for(int i=1; i<DeviceTable_End; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter); for(int i=1; i<DeviceTable_End; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
mDeviceTable->setHeaderItem(m_headerItem); mDeviceTable->setHeaderItem(m_headerItem);
@ -203,20 +235,20 @@ QPushButton:hover {background-color: #08b;}
//开始轮训查找局域网内的控制卡 //开始轮训查找局域网内的控制卡
sendGetInfo(); sendGetInfo();
pNetComm->mUdpTimer.start(30000); mUdpTimer.start(30000);
mDeviceTable->hideColumn(0); mDeviceTable->hideColumn(0);
mDeviceTable->fdIsSelAll->hide(); mDeviceTable->fdIsSelAll->hide();
transUi(); transUi();
} }
DevicePanel::~DevicePanel() { DevicePanel::~DevicePanel() {
pNetComm->mUdpSocket.close(); mUdpSocket.close();
pNetComm->mUdpTimer.stop(); mUdpTimer.stop();
} }
void DevicePanel::sendGetInfo() { void DevicePanel::sendGetInfo() {
QByteArray data = QJsonDocument({{"action", "getInfo"}}).toJson(QJsonDocument::Compact); QByteArray data = QJsonDocument({{"action", "getInfo"}}).toJson(QJsonDocument::Compact);
// if(pNetComm->mUdpSocket.writeDatagram(data, QHostAddress("255.255.255.255"), 22222) != data.length()) { // if(mUdpSocket.writeDatagram(data, QHostAddress("255.255.255.255"), 22222) != data.length()) {
// qDebug() << "getInfo writeDatagram to 255.255.255.255 Failed"; // qDebug() << "getInfo writeDatagram to 255.255.255.255 Failed";
// } // }
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces(); QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
@ -230,7 +262,7 @@ void DevicePanel::sendGetInfo() {
auto ip = addrEntry.ip(); auto ip = addrEntry.ip();
if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue; if(ip.protocol()!=QAbstractSocket::IPv4Protocol) continue;
auto broadcast = addrEntry.broadcast(); auto broadcast = addrEntry.broadcast();
if(pNetComm->mUdpSocket.writeDatagram(data, broadcast, 22222) != data.length()) qDebug() << "getInfo writeDatagram Failed." << ip.toString() << "->" << broadcast.toString(); if(mUdpSocket.writeDatagram(data, broadcast, 22222) != data.length()) qDebug() << "getInfo writeDatagram Failed." << ip.toString() << "->" << broadcast.toString();
} }
} }
} }
@ -266,7 +298,7 @@ void DevicePanel::changeEvent(QEvent *event) {
if(event->type() == QEvent::LanguageChange) transUi(); if(event->type() == QEvent::LanguageChange) transUi();
} }
void DevicePanel::transUi() { void DevicePanel::transUi() {
btnRefrash->setText(tr("Refresh")); btnRefresh->setText(tr("Refresh"));
bnSpecifyIP->setItemText(0,tr("Specify IP")); bnSpecifyIP->setItemText(0,tr("Specify IP"));
label_3->setText(tr("All")); label_3->setText(tr("All"));
@ -348,12 +380,7 @@ void DevicePanel::FilterProgram(const QString &strtemp){
void DevicePanel::OnControlTcpSend(int iProgramIndex){ void DevicePanel::OnControlTcpSend(int iProgramIndex){
int cnt = mDeviceTable->topLevelItemCount(); int cnt = mDeviceTable->topLevelItemCount();
QList<DeviceItem*> list; for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->OnControlTcpSend(iProgramIndex);
int iSelectCount=0;
for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) {
iSelectCount++;
static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->OnControlTcpSend(iProgramIndex);
}
} }
void DevicePanel::OnControlSendJson(QJsonObject &json,QString strFanYi){ void DevicePanel::OnControlSendJson(QJsonObject &json,QString strFanYi){
@ -387,3 +414,112 @@ void DevicePanel::onCheckStateChanged(int f){
emit sigSelectedDeviceList(&mSelCards); emit sigSelectedDeviceList(&mSelCards);
} }
} }
void DevicePanel::addLedCard(LedCard *p){
int cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) {
auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
if(item->m_pLedCard->m_strCardId != p->m_strCardId) continue;
item->setData(DeviceTable_ID, 0, p->m_strCardId);
item->setData(DeviceTable_IP, 0, p->m_strCardIp);
item->setData(DeviceTable_ScreenSize, 0, QString("%1 x %2").arg(p->m_iWidth).arg(p->m_iHeight));
return;
}
new DeviceItem(p, mDeviceTable, this);
nDeviceNum->setText(QString::number(mDeviceTable->topLevelItemCount()));
}
void DevicePanel::clearUdpHeartbeat(LedCard *p) {
int cnt = mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) {
auto item = static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i));
if(item->m_pLedCard->m_strCardId != p->m_strCardId) continue;
item->m_HeartbeatCount = 0;
if(item->m_ImageOnline) {
item->m_pLedCard->m_bOnLine = true;
item->m_ImageOnline->setPixmap(QPixmap(":/res/DeviceManager/O_Online.png"));
}
return;
}
}
void DevicePanel::parseInfo(const QJsonObject &subObj, const QString &strIp) {
LedCard *pLedCard = new LedCard(this);//alahover 没有释放
pLedCard->m_strCardId=subObj["cardId"].toString();
if(! strIp.isEmpty()) pLedCard->m_strCardIp = strIp;
else {
pLedCard->m_strCardIp = subObj["newIp"].toString();
if(pLedCard->m_strCardIp.isEmpty()) pLedCard->m_strCardIp = subObj["ip"].toString();
}
pLedCard->m_iWidth=subObj["width"].toInt();
pLedCard->m_iHeight=subObj["height"].toInt();
pLedCard->starterversionName=subObj["versionName"].toString();
pLedCard->starterPort=subObj["starterPort"].toInt();
pLedCard->androidVersion=subObj["androidVersion"].toString();
pLedCard->iHttpGetId=subObj["id"].toInt();
pLedCard->androidHeight=subObj["androidHeight"].toInt();
pLedCard->androidWidth=subObj["androidWidth"].toInt();
pLedCard->lastActive=subObj["lastActive"].toInt();
for(int i=0;i<LedCardList.count();i++) if(LedCardList.at(i)->m_strCardId==pLedCard->m_strCardId ) { //如果已经存在在列表中
auto pOldLedCard = LedCardList.at(i);//获取到旧的对象指针
pOldLedCard->m_bOnLine = true;
if(! pOldLedCard->CompareHTTPGetParam(pLedCard)) {//如果ip地址变化了
pOldLedCard->copyLedCardHTTPGetParam(pLedCard);
addLedCard(pOldLedCard);//发送信号到界面
} else {
//post失败的概率比较小所以这里是否需要平凡的更新不需要刻意屏蔽该操作改为在其他点击操作中进行
clearUdpHeartbeat(pOldLedCard);
}
delete pLedCard;
return;
}
LedCardList.append(pLedCard);
addLedCard(pLedCard);//发送信号到界面
}
STREAM_PACKET LedOkMakeStreamPacket(int iComType,int iLen,unsigned char *ucBuf,QString str) {
STREAM_PACKET Temp;
memset(&Temp, 0, sizeof(STREAM_PACKET));
if(iLen>2048) return Temp;
memset(Temp.SyncHead,STREAM_SYNC_HEAD,STREAM_SYNC_HEAD_NUM);
memset(Temp.ucSerialCode,0x00,20);
char* ch;
QByteArray ba = str.toLatin1(); // must
ch=ba.data();
memcpy(Temp.ucSerialCode,ch,ba.size());
Temp.iLength=iLen;
Temp.ucCommType=iComType;
memcpy(Temp.pDataBuffer,ucBuf,iLen);
Temp.pDataBuffer[Temp.iLength] = GetCheckCodeIn8(&Temp.ucCommType,Temp.iLength+sizeof(Temp.ucCommType)+sizeof(char)*20+sizeof(Temp.iLength));
return Temp;
}
//UDP多网卡广播
void DevicePanel::RestoreLedCardIpByUdpCmd() {
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
foreach (QNetworkInterface interfaces, networkinterfaces) {//networkinterfaces负责提供主机的IP地址和网络接口的列表
foreach (QNetworkAddressEntry entry, interfaces.addressEntries()) {//QNetworkAddressEntry存储了一个IP地址子网掩码和广播地址
entry.setBroadcast(QHostAddress::Broadcast);
QHostAddress broadcastAddress("255.255.255.255");
entry.setBroadcast(QHostAddress::Broadcast);
RESTORE_IP stTempIp;
memset(&stTempIp,0x00,sizeof(RESTORE_IP));
QString strNew=entry.ip().toString();
int itempOffset = strNew.lastIndexOf(".");
QString sstrNew=strNew.left(itempOffset)+".254";
if(sstrNew.length()<=20) memcpy(stTempIp.cNewIp,sstrNew.toLatin1().data(),sstrNew.length());
QString strMask=entry.netmask().toString();
if(strMask.length()<=20)
memcpy(stTempIp.cMask,strMask.toLatin1().data(),strMask.length());
QString strGateway=entry.ip().toString();
if(strGateway.length()<=20)
memcpy(stTempIp.cGateway,strGateway.toLatin1().data(),strGateway.length());
if(strGateway.length()<=20)
memcpy(stTempIp.cDns,strGateway.toLatin1().data(),strGateway.length());
STREAM_PACKET tempStreadPacket = LedOkMakeStreamPacket(COMMAND_ONLY_RESET_CARD_IP, 80, (unsigned char *)&stTempIp,"Broadcast!");
int iLenPacket=tempStreadPacket.iLength+sizeof(int)+STREAM_SYNC_HEAD_NUM*sizeof(unsigned char)+sizeof(char)+20*sizeof(char)+sizeof(char);/////除正文外的协议结构大小;
QUdpSocket *tempUdpSocket = new QUdpSocket(this);
if(!tempUdpSocket->bind(entry.ip())) break;
tempUdpSocket->writeDatagram((char *)&tempStreadPacket,iLenPacket,broadcastAddress, 31296);
}
}
}

View File

@ -2,16 +2,15 @@
#define DEVICEPANEL_H #define DEVICEPANEL_H
#include "deviceitem.h" #include "deviceitem.h"
#include <QWidget>
#include <QFile> #include <QFile>
#include <QBoxLayout> #include <QBoxLayout>
#include <QPainter> #include <QPainter>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <communication/network.h> #include <QUdpSocket>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
#include <wDevicesManager/ctrlbrightpanel.h> #include <QTextEdit>
class DeviceCtrlPanel; class DeviceCtrlPanel;
class DevicePanel : public QWidget { class DevicePanel : public QWidget {
@ -24,7 +23,15 @@ public:
QLabel *fdCardNumInfo; QLabel *fdCardNumInfo;
LoQTreeWidget *mDeviceTable; LoQTreeWidget *mDeviceTable;
NetComm *pNetComm; QUdpSocket mUdpSocket;
QTimer mUdpTimer;
QDialog *specifyIPDlg{0};
QTextEdit *fdIP{0};
void addLedCard(LedCard *);
void clearUdpHeartbeat(LedCard *);
void parseInfo(const QJsonObject &subObj,const QString &strIp);
void RestoreLedCardIpByUdpCmd();
QList<LedCard *> LedCardList;
protected: protected:
void changeEvent(QEvent *) override; void changeEvent(QEvent *) override;
void transUi(); void transUi();
@ -42,7 +49,7 @@ signals:
private: private:
QLabel *label_3, *nDeviceNum; QLabel *label_3, *nDeviceNum;
QComboBox *bnSpecifyIP; QComboBox *bnSpecifyIP;
QPushButton *btnRefrash; QPushButton *btnRefresh;
QTreeWidgetItem *m_headerItem; QTreeWidgetItem *m_headerItem;
QHBoxLayout *mHBox{0}; QHBoxLayout *mHBox{0};
DeviceCtrlPanel *mDeviceCtrlPanel{0}; DeviceCtrlPanel *mDeviceCtrlPanel{0};

View File

@ -157,9 +157,9 @@ bool copyDir(const QString &source, const QString &destination, bool override)
return !error; return !error;
} }
unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize) unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize) {
{ unsigned int i=0; unsigned int i=0;
unsigned char ucCheckCode=0; unsigned char ucCheckCode=0;
for (i=0;i<uiSize;i++) ucCheckCode+=pBuffer[i]; for (i=0;i<uiSize;i++) ucCheckCode+=pBuffer[i];
return (~ucCheckCode)&0x0ff; return (~ucCheckCode)&0x0ff;
} }

View File

@ -12,6 +12,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
#include <QSettings> #include <QSettings>
#include <QButtonGroup>
QWidget *gMainWin; QWidget *gMainWin;
extern QPoint gPlayPos; extern QPoint gPlayPos;
@ -271,7 +272,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
curIndex = id; curIndex = id;
if(curIndex == MainPage_DeviceManager || curIndex == MainPage_Setting) { if(curIndex == MainPage_DeviceManager || curIndex == MainPage_Setting) {
//开启UDP定时器 //开启UDP定时器
gUdp->mUdpTimer.start(60000); mDevicePanel->mUdpTimer.start(60000);
int cnt = mDevicePanel->mDeviceTable->topLevelItemCount(); int cnt = mDevicePanel->mDeviceTable->topLevelItemCount();
for(int i=0; i<cnt; i++) { for(int i=0; i<cnt; i++) {
auto item = static_cast<DeviceItem*>(mDevicePanel->mDeviceTable->topLevelItem(i)); auto item = static_cast<DeviceItem*>(mDevicePanel->mDeviceTable->topLevelItem(i));
@ -289,7 +290,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
m_pOneKeyCheckCard->setProperty("ssType", "progManageTool"); m_pOneKeyCheckCard->setProperty("ssType", "progManageTool");
connect(m_pOneKeyCheckCard, &QPushButton::clicked, this, [this] { connect(m_pOneKeyCheckCard, &QPushButton::clicked, this, [this] {
auto res = QMessageBox::warning(this, tr("Tip Info"), tr("RestoreLedCardIpByUdpTip"), QMessageBox::Ok, QMessageBox::Cancel); auto res = QMessageBox::warning(this, tr("Tip Info"), tr("RestoreLedCardIpByUdpTip"), QMessageBox::Ok, QMessageBox::Cancel);
if(res == QMessageBox::Ok) mDevicePanel->pNetComm->RestoreLedCardIpByUdpCmd(); if(res == QMessageBox::Ok) mDevicePanel->RestoreLedCardIpByUdpCmd();
}); });
hBox->addWidget(m_pOneKeyCheckCard); hBox->addWidget(m_pOneKeyCheckCard);
hBox->addStretch(); hBox->addStretch();
@ -396,7 +397,10 @@ MainWindow::~MainWindow() {
settings.setValue("MainGeo", normalGeometry()); settings.setValue("MainGeo", normalGeometry());
settings.setValue("MainIsMax", isMaximized()); settings.setValue("MainIsMax", isMaximized());
settings.setValue("PlayPos", gPlayPos); settings.setValue("PlayPos", gPlayPos);
if(mDevicePanel->fdIP) {
auto ips = mDevicePanel->fdIP->toPlainText();
if(! ips.isEmpty()) settings.setValue("SpecifyIP", ips);
}
if(m_pTimerSendResoreIpOneKey!=nullptr) { if(m_pTimerSendResoreIpOneKey!=nullptr) {
if(m_pTimerSendResoreIpOneKey->isActive()) m_pTimerSendResoreIpOneKey->stop(); if(m_pTimerSendResoreIpOneKey->isActive()) m_pTimerSendResoreIpOneKey->stop();
delete m_pTimerSendResoreIpOneKey; delete m_pTimerSendResoreIpOneKey;

View File

@ -765,35 +765,23 @@ void mGuangYingPinWidget::MWSendCmdByUdp(unsigned char cmd,unsigned char *pUcVal
QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces(); QList<QNetworkInterface> networkinterfaces = QNetworkInterface::allInterfaces();
foreach (QNetworkInterface interfaces, networkinterfaces) //networkinterfaces负责提供主机的IP地址和网络接口的列表 foreach (QNetworkInterface interfaces, networkinterfaces) //networkinterfaces负责提供主机的IP地址和网络接口的列表
{ {
foreach (QNetworkAddressEntry entry, interfaces.addressEntries())//QNetworkAddressEntry存储了一个IP地址子网掩码和广播地址 foreach (QNetworkAddressEntry entry, interfaces.addressEntries())//QNetworkAddressEntry存储了一个IP地址子网掩码和广播地址
{ {
QHostAddress broadcastAddress("255.255.255.255"); QHostAddress broadcastAddress("255.255.255.255");
entry.setBroadcast(QHostAddress::Broadcast);
{ QUdpSocket *tempUdpSocket= new QUdpSocket(this);
entry.setBroadcast(QHostAddress::Broadcast); if(!tempUdpSocket->bind(entry.ip()))
QUdpSocket *tempUdpSocket= new QUdpSocket(this); break;
if(!tempUdpSocket->bind(entry.ip())) int iSendLength=tempUdpSocket->writeDatagram((char *)&tempStreadPakcet,iLenPacket,broadcastAddress,31296);
break; if(iSendLength != iLenPacket) {
int iSendLength=tempUdpSocket->writeDatagram((char *)&tempStreadPakcet,iLenPacket,broadcastAddress,31296); char *aa=reinterpret_cast<char*>(&tempStreadPakcet);
if( iSendLength != iLenPacket) tempUdpSocket->writeDatagram(&aa[iSendLength],iLenPacket-iSendLength,broadcastAddress,31296);
{ }
// qDebug() << "error" << "RestoreLedCardIpByUdpCmd error!send restore led card ip by udp cmd"; delete tempUdpSocket;
// // return;
char *aa=reinterpret_cast<char*>(&tempStreadPakcet);
tempUdpSocket->writeDatagram(&aa[iSendLength],iLenPacket-iSendLength,broadcastAddress,31296);
}
else {
// strIpAddress =entry.ip().toString();// broadcastAddress.toString();
// qDebug() << strIpAddress << "send restore led card ip by udp cmd" ;
}
delete tempUdpSocket;
}
} }
} }
if(ui->checkBoxDebug->isChecked()) if(ui->checkBoxDebug->isChecked()) {
{ ui->textEditReadBuf->append("udp:"+tr(databuf.toHex()));
ui->textEditReadBuf->append("udp:"+tr(databuf.toHex()));
} }
} }
void mGuangYingPinWidget::MWSendCmd(uint8_t iComIndex,unsigned char cmd,unsigned char *pUcValue,unsigned int iLength,int iCountCmd) void mGuangYingPinWidget::MWSendCmd(uint8_t iComIndex,unsigned char cmd,unsigned char *pUcValue,unsigned int iLength,int iCountCmd)

View File

@ -1,8 +1,10 @@
#include "controlhdmiwidget.h" #include "controlhdmiwidget.h"
#include "gqt.h" #include "gqt.h"
#include "tools.h" #include "tools.h"
#include "globaldefine.h"
#include "base/waitingdlg.h" #include "base/waitingdlg.h"
#include <QMessageBox> #include <QMessageBox>
#include <QButtonGroup>
ControlHdmiWidget::ControlHdmiWidget(QWidget *parent,QList<LedCard *> *list) : QWidget(parent) { ControlHdmiWidget::ControlHdmiWidget(QWidget *parent,QList<LedCard *> *list) : QWidget(parent) {
auto vBox = new QVBoxLayout(this); auto vBox = new QVBoxLayout(this);

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ControlHdmiWidget</class>
<widget class="QWidget" name="ControlHdmiWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>381</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QFrame" name="frame">
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="labelHdmiConfiguration">
<property name="text">
<string>HDMI Configuration</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radioButtonManual">
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color:transparent</string>
</property>
<property name="text">
<string>Manual</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSchedule">
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color:transparent</string>
</property>
<property name="text">
<string>Schedule</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -6,7 +6,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QMetaEnum> #include <QMetaEnum>
SpecialDlg::SpecialDlg(QWidget *parent, NetComm *netComm) : QDialog(parent) { SpecialDlg::SpecialDlg(QWidget *parent) : QDialog(parent) {
resize(300, 100); resize(300, 100);
setWindowTitle(tr("Specify IP")); setWindowTitle(tr("Specify IP"));
@ -44,7 +44,7 @@ SpecialDlg::SpecialDlg(QWidget *parent, NetComm *netComm) : QDialog(parent) {
vBox->addLayout(hBox); vBox->addLayout(hBox);
//绑定信号和槽函数 //绑定信号和槽函数
connect(bnSearch, &QPushButton::clicked, this, [this, fdIP, netComm] { connect(bnSearch, &QPushButton::clicked, this, [this, fdIP] {
QString strTempIp = fdIP->text(); QString strTempIp = fdIP->text();
if(strTempIp=="...") { if(strTempIp=="...") {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input IP address!")); QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input IP address!"));
@ -57,7 +57,7 @@ SpecialDlg::SpecialDlg(QWidget *parent, NetComm *netComm) : QDialog(parent) {
waitingDlg->show(); waitingDlg->show();
auto reply = Tools::netManager().get(reqForJson("http://"+strTempIp+":3000/deviceList?fromDetector=true")); auto reply = Tools::netManager().get(reqForJson("http://"+strTempIp+":3000/deviceList?fromDetector=true"));
//在该ip的3000端口get方法deviceList可以一次性获取到局域网中设备列表的详细信息 //在该ip的3000端口get方法deviceList可以一次性获取到局域网中设备列表的详细信息
connect(reply, &QNetworkReply::finished, this, [reply, this, waitingDlg, netComm] { connect(reply, &QNetworkReply::finished, this, [reply, this, waitingDlg] {
QJsonDocument json; QJsonDocument json;
QString err = parseReplyJson(reply); QString err = parseReplyJson(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
@ -69,7 +69,7 @@ SpecialDlg::SpecialDlg(QWidget *parent, NetComm *netComm) : QDialog(parent) {
close(); close();
QStringList keys = json.object().keys(); QStringList keys = json.object().keys();
qDebug()<<"json size"<<keys.size(); qDebug()<<"json size"<<keys.size();
for(auto key : keys) netComm->JieXiQJsonObjectOfLedCardInfo(json[key].toObject(), ""); for(auto key : keys) gDevicePanel->parseInfo(json[key].toObject(), "");
}); });
}); });
} }

View File

@ -2,12 +2,11 @@
#define SPECIALDLG_H #define SPECIALDLG_H
#include <QDialog> #include <QDialog>
#include <communication/network.h>
class SpecialDlg : public QDialog { class SpecialDlg : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit SpecialDlg(QWidget *, NetComm *); explicit SpecialDlg(QWidget *);
}; };
#endif // SPECIALDLG_H #endif // SPECIALDLG_H

View File

@ -2,7 +2,6 @@
#include "tools.h" #include "tools.h"
#include "ui_upgradeapkdialog.h" #include "ui_upgradeapkdialog.h"
#include <QAction> #include <QAction>
#include <communication/network.h>
#include <QFileDialog> #include <QFileDialog>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMessageBox> #include <QMessageBox>
@ -190,11 +189,10 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
pushButtonPublish->setEnabled(false); pushButtonPublish->setEnabled(false);
pushButtonUpgradeFpga->setEnabled(false); pushButtonUpgradeFpga->setEnabled(false);
connect(pushButtonRefresh, &QPushButton::clicked, this, [this, label] { connect(pushButtonRefresh, &QPushButton::clicked, this, [this, label] {
if(gUdp==nullptr) return;
wDevicePublishList->clear(); wDevicePublishList->clear();
wDevicePublishList->onCheckAll(false); wDevicePublishList->onCheckAll(false);
int iCount=gUdp->LedCardList.count(); int iCount = gDevicePanel->LedCardList.count();
for(int i=0;i<iCount;i++) onAddLedCard(gUdp->LedCardList.at(i)); for(int i=0;i<iCount;i++) onAddLedCard(gDevicePanel->LedCardList.at(i));
label->setText(tr("All")+":"+QString::number(iCount)); label->setText(tr("All")+":"+QString::number(iCount));
}); });
connect(pushButtonPublish, &QPushButton::clicked, this, [this, label_ApkPath] { connect(pushButtonPublish, &QPushButton::clicked, this, [this, label_ApkPath] {
@ -241,16 +239,14 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
} else lineEditPackageName->setVisible(false); } else lineEditPackageName->setVisible(false);
}); });
if(gUdp==nullptr) return; int iCount = gDevicePanel->LedCardList.count();
int iCount=gUdp->LedCardList.count(); for(int i=0; i<iCount; i++) onAddLedCard(gDevicePanel->LedCardList.at(i));
for(int i=0;i<iCount;i++) onAddLedCard(gUdp->LedCardList.at(i));
label->setText(tr("All")+":"+QString::number(iCount)); label->setText(tr("All")+":"+QString::number(iCount));
auto timer = new QTimer(this); auto timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, [this, label] { connect(timer, &QTimer::timeout, this, [this, label] {
if(gUdp==nullptr) return; int iCount = gDevicePanel->LedCardList.count();
int iCount=gUdp->LedCardList.count(); for(int i=0;i<iCount;i++) onAddLedCard(gDevicePanel->LedCardList.at(i));
for(int i=0;i<iCount;i++) onAddLedCard(gUdp->LedCardList.at(i));
label->setText(tr("All")+":"+QString::number(iCount)); label->setText(tr("All")+":"+QString::number(iCount));
}); });
timer->start(500000); timer->start(500000);

View File

@ -1,5 +1,5 @@
#include "sendprogramdialog.h" #include "sendprogramdialog.h"
#include "communication/network.h" #include "tools.h"
#include <QAction> #include <QAction>
#include <QLineEdit> #include <QLineEdit>
#include <QHeaderView> #include <QHeaderView>
@ -171,9 +171,8 @@ void SendProgramDialog::sendNext() {
} }
void SendProgramDialog::onRefresh() { void SendProgramDialog::onRefresh() {
if(gUdp==0) return; int iCount = gDevicePanel->LedCardList.count();
int iCount = gUdp->LedCardList.count(); for(int i=0; i<iCount; i++) onAddLedCard(gDevicePanel->LedCardList.at(i));
for(int i=0; i<iCount; i++) onAddLedCard(gUdp->LedCardList.at(i));
label->setText(tr("All")+":"+QString::number(iCount)); label->setText(tr("All")+":"+QString::number(iCount));
} }
void SendProgramDialog::onAddLedCard(LedCard *p) { void SendProgramDialog::onAddLedCard(LedCard *p) {