Browse Source

update

master
zhaohe 1 year ago
parent
commit
0bd4f649ff
  1. 39
      mainwindow.cpp
  2. 6
      mainwindow.h
  3. 2
      mainwindow.ui

39
mainwindow.cpp

@ -20,6 +20,7 @@ QTimer *timer0;
QTimer *timer1; QTimer *timer1;
QTimer *timer2; QTimer *timer2;
QTimer *timer3; QTimer *timer3;
QTimer *checkConnectTimer0;
#define TAG "MainWindow" #define TAG "MainWindow"
static const char *fmt(const char *fmt, ...) { static const char *fmt(const char *fmt, ...) {
@ -245,6 +246,19 @@ void MainWindow::refreshReadonlyPage2() {
UPDATE(4); UPDATE(4);
} }
} }
bool MainWindow::checkConnected() {
if (!G_QTDataChannel.isOpen()) {
return false;
}
uint32_t val;
zaf_error_code_t ecode = m_clstc->reg_read(kreg_software_version, val);
if (ecode != kaf_ec_success) {
return false;
}
return true;
}
void MainWindow::refreshReadonlyPage3() { void MainWindow::refreshReadonlyPage3() {
if (!G_QTDataChannel.isOpen()) { if (!G_QTDataChannel.isOpen()) {
return; return;
@ -632,6 +646,8 @@ void MainWindow::constructUI() {
ui->ShutterX_InSigSelect_2->addItems(LightSrcX_TriSrc_QStringList); ui->ShutterX_InSigSelect_2->addItems(LightSrcX_TriSrc_QStringList);
ui->ShutterX_InSigSelect_3->addItems(LightSrcX_TriSrc_QStringList); ui->ShutterX_InSigSelect_3->addItems(LightSrcX_TriSrc_QStringList);
ui->ShutterX_InSigSelect_4->addItems(LightSrcX_TriSrc_QStringList); ui->ShutterX_InSigSelect_4->addItems(LightSrcX_TriSrc_QStringList);
ui->InterClk_TriOutSignalFreq_Text->setDisabled(true);
} }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
@ -658,18 +674,41 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
timer1 = new QTimer(this); timer1 = new QTimer(this);
timer2 = new QTimer(this); timer2 = new QTimer(this);
timer3 = new QTimer(this); timer3 = new QTimer(this);
checkConnectTimer0 = new QTimer(this);
connect(timer0, &QTimer::timeout, this, [this]() { refreshReadonlyPage0(); }); connect(timer0, &QTimer::timeout, this, [this]() { refreshReadonlyPage0(); });
connect(timer1, &QTimer::timeout, this, [this]() { refreshReadonlyPage1(); }); connect(timer1, &QTimer::timeout, this, [this]() { refreshReadonlyPage1(); });
connect(timer2, &QTimer::timeout, this, [this]() { refreshReadonlyPage2(); }); connect(timer2, &QTimer::timeout, this, [this]() { refreshReadonlyPage2(); });
connect(timer3, &QTimer::timeout, this, [this]() { refreshReadonlyPage3(); }); connect(timer3, &QTimer::timeout, this, [this]() { refreshReadonlyPage3(); });
connect(checkConnectTimer0, &QTimer::timeout, this, [this]() { //
static bool connected = false;
bool connect = checkConnected();
if (connect) {
ui->DeviceConnectStateTB->setText("已连接");
ui->DeviceConnectStateTB->setStyleSheet("color: green");
} else {
ui->DeviceConnectStateTB->setText("未连接");
ui->DeviceConnectStateTB->setStyleSheet("color: red");
}
if (connected != connect) {
connected = connect;
if (connected) {
refreshPage();
}
}
});
timer0->setInterval(1100); // 每隔一秒触发一次 timer0->setInterval(1100); // 每隔一秒触发一次
timer1->setInterval(1200); // 每隔一秒触发一次 timer1->setInterval(1200); // 每隔一秒触发一次
timer2->setInterval(900); // 每隔一秒触发一次 timer2->setInterval(900); // 每隔一秒触发一次
timer3->setInterval(1000); // 每隔一秒触发一次 timer3->setInterval(1000); // 每隔一秒触发一次
checkConnectTimer0->setInterval(100);
timer0->start(); timer0->start();
timer1->start(); timer1->start();
timer2->start(); timer2->start();
timer3->start(); timer3->start();
checkConnectTimer0->start();
// m_clstc->regRawDataListener([this](uart_message_type_t type, uint8_t *data, size_t len) { // m_clstc->regRawDataListener([this](uart_message_type_t type, uint8_t *data, size_t len) {
// QString text; // QString text;

6
mainwindow.h

@ -81,6 +81,7 @@ class MainWindow : public QMainWindow {
void refreshReadonlyPage2(); void refreshReadonlyPage2();
void refreshReadonlyPage3(); void refreshReadonlyPage3();
bool checkConnected();
private slots: private slots:
/** /**
@ -90,14 +91,9 @@ class MainWindow : public QMainWindow {
signals: signals:
void doinui_signal(QFunction); void doinui_signal(QFunction);
private: private:
static void log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg); static void log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg);
void constructUI(); void constructUI();
void dumpLog(const char *fmt, ...); void dumpLog(const char *fmt, ...);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

2
mainwindow.ui

@ -449,7 +449,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number>
<number>0</number>
</property> </property>
<property name="tabBarAutoHide"> <property name="tabBarAutoHide">
<bool>true</bool> <bool>true</bool>

Loading…
Cancel
Save