|
|
@ -21,6 +21,7 @@ QTimer *timer1; |
|
|
|
QTimer *timer2; |
|
|
|
QTimer *timer3; |
|
|
|
QTimer *checkConnectTimer0; |
|
|
|
static bool m_connected = false; |
|
|
|
|
|
|
|
ZQThread *m_zqthread; |
|
|
|
#define TAG "MainWindow"
|
|
|
@ -57,7 +58,7 @@ static QTDataChannel G_QTDataChannel; |
|
|
|
|
|
|
|
static const QString zaferror_to_str(zaf_error_code_t value) { |
|
|
|
if (value == kaf_ec_overtime) { |
|
|
|
return "操作超时"; |
|
|
|
return "通信超时"; |
|
|
|
} else if (value == kaf_ec_device_notopen) { |
|
|
|
return "设备未打开"; |
|
|
|
} else { |
|
|
@ -70,6 +71,7 @@ static const QString zaferror_to_str(zaf_error_code_t value) { |
|
|
|
zaf_error_code_t ecode = action; \ |
|
|
|
if (ecode != kaf_ec_success) { \ |
|
|
|
dumpLog("do %s fail,%s", #action, zaferror_to_str(ecode).toStdString().c_str()); \ |
|
|
|
displayInfo(false, zaferror_to_str(ecode)); \ |
|
|
|
return; \ |
|
|
|
} \ |
|
|
|
} |
|
|
@ -153,7 +155,7 @@ void MainWindow::updatePage() { |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
@ -185,7 +187,7 @@ void MainWindow::updatePage() { |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -257,7 +259,7 @@ void MainWindow::refreshReadonlyPage2() { |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::refreshReadonlyPage3() { |
|
|
@ -372,7 +374,7 @@ void MainWindow::refreshPage() { |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
@ -406,7 +408,7 @@ void MainWindow::refreshPage() { |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -479,12 +481,16 @@ void MainWindow::constructUI() { |
|
|
|
connect(ui->refreshPageKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
refreshPage(); |
|
|
|
dumpLog("刷新成功"); |
|
|
|
displayInfo(true, "刷新成功"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
connect(ui->UpdateCfg_Key, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
updatePage(); |
|
|
|
refreshPage(); |
|
|
|
dumpLog("提交成功"); |
|
|
|
displayInfo(true, "提交成功"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
@ -493,6 +499,8 @@ void MainWindow::constructUI() { |
|
|
|
connect(ui->storageConfigKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO(m_clstc->storageConfigs()); |
|
|
|
dumpLog("保存配置成功"); |
|
|
|
displayInfo(true, "保存配置成功"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
@ -501,6 +509,7 @@ void MainWindow::constructUI() { |
|
|
|
connect(ui->rebootDeviceKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO(m_clstc->reboot()); |
|
|
|
dumpLog("重启设备成功"); |
|
|
|
displayInfo(true, "重启设备成功"); |
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
@ -509,6 +518,8 @@ void MainWindow::constructUI() { |
|
|
|
connect(ui->factoryResetKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO(m_clstc->factoryReset()); |
|
|
|
dumpLog("恢复出厂设置成功"); |
|
|
|
displayInfo(true, "恢复出厂设置成功"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
@ -693,21 +704,21 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi |
|
|
|
|
|
|
|
m_zqthread = new ZQThread("", [this]() { |
|
|
|
while (true) { |
|
|
|
static bool connected = false; |
|
|
|
static bool first = true; |
|
|
|
bool connect = checkConnected(); |
|
|
|
if (connected != connect || first) { |
|
|
|
first = false; |
|
|
|
connected = connect; |
|
|
|
static bool first = true; |
|
|
|
bool connect = checkConnected(); |
|
|
|
if (m_connected != connect || first) { |
|
|
|
first = false; |
|
|
|
m_connected = connect; |
|
|
|
emit doinui_signal(QFunction([this, connect]() { |
|
|
|
if (connect) { |
|
|
|
ui->DeviceConnectStateTB->setText("已连接"); |
|
|
|
ui->DeviceConnectStateTB->setStyleSheet("color: green"); |
|
|
|
displayInfo(true, "连接成功"); |
|
|
|
} else { |
|
|
|
ui->DeviceConnectStateTB->setText("未连接"); |
|
|
|
ui->DeviceConnectStateTB->setStyleSheet("color: red"); |
|
|
|
} |
|
|
|
if (connected) { |
|
|
|
if (m_connected) { |
|
|
|
refreshPage(); |
|
|
|
} |
|
|
|
})); |
|
|
@ -796,6 +807,10 @@ void MainWindow::dumpLog(const char *fmt, ...) { |
|
|
|
info.append(" [Info]:"); |
|
|
|
info.append(text); |
|
|
|
|
|
|
|
static int id; |
|
|
|
|
|
|
|
// informationBrowser
|
|
|
|
|
|
|
|
emit doinui_signal(QFunction([this, info]() { |
|
|
|
if (ui->instructionPreview->document()->lineCount() > 100) { |
|
|
|
ui->instructionPreview->document()->clear(); |
|
|
@ -804,4 +819,25 @@ void MainWindow::dumpLog(const char *fmt, ...) { |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::displayInfo(bool suc, QString info) { |
|
|
|
emit doinui_signal(QFunction([this, info, suc]() { |
|
|
|
static int cnt = 0; |
|
|
|
cnt++; |
|
|
|
|
|
|
|
QString _info; |
|
|
|
_info.append("["); |
|
|
|
_info.append(QString::number(cnt)); |
|
|
|
_info.append("] "); |
|
|
|
_info.append(info); |
|
|
|
|
|
|
|
if (suc) { |
|
|
|
ui->informationBrowser->setStyleSheet("color: green"); |
|
|
|
} else { |
|
|
|
ui->informationBrowser->setStyleSheet("color: red"); |
|
|
|
} |
|
|
|
|
|
|
|
ui->informationBrowser->setText(_info); |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
MainWindow::~MainWindow() { delete ui; } |