From 0cd26248969fcd248330f6aabae6e1dd82aeb1ba Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 11 Mar 2024 10:54:59 +0800 Subject: [PATCH] V1 --- mainwindow.cpp | 129 ++- mainwindow.h | 7 +- mainwindow.ui | 1194 +++++++++++++++++--- .../qt_serial_datachannel.cpp | 2 +- 4 files changed, 1174 insertions(+), 158 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 13c126a..e74c5b6 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -16,7 +16,10 @@ using namespace std; static MainWindow *m_mainWindow; static CLSTControler *m_clstc; -QTimer *timer; +QTimer *timer0; +QTimer *timer1; +QTimer *timer2; +QTimer *timer3; #define TAG "MainWindow" static const char *fmt(const char *fmt, ...) { @@ -148,8 +151,40 @@ void MainWindow::updatePage() { UPDATE(3); UPDATE(4); } + + { + SigProcessMode mode; + uint32_t offset; + uint32_t bindstate1; + uint32_t bindstate2; + uint32_t bindstate3; + uint32_t bindstate4; + InternalSig sig; + +#define UPDATE(index) \ + mode = SigProcessMode(ui->ShutterX_OutputCtrlMode_##index->currentText().toStdString()); \ + offset = ui->ShutterX_LtEnOffset_##index->text().toUInt(); \ + bindstate1 = ui->ShutterX_LtEnBind_val1_##index->checkState() == Qt::CheckState::Checked; \ + bindstate2 = ui->ShutterX_LtEnBind_val2_##index->checkState() == Qt::CheckState::Checked; \ + bindstate3 = ui->ShutterX_LtEnBind_val3_##index->checkState() == Qt::CheckState::Checked; \ + bindstate4 = ui->ShutterX_LtEnBind_val4_##index->checkState() == Qt::CheckState::Checked; \ + sig = InternalSig(ui->ShutterX_InSigSelect_##index->currentText().toStdString()); \ + DO(m_clstc->ShutterX_setOutputCtrlMode(index, mode)); \ + DO(m_clstc->ShutterX_setLtEnOffset(index, offset)); \ + DO(m_clstc->ShutterX_setLtEnBind(index, 1, bindstate1)); \ + DO(m_clstc->ShutterX_setLtEnBind(index, 2, bindstate2)); \ + DO(m_clstc->ShutterX_setLtEnBind(index, 3, bindstate3)); \ + DO(m_clstc->ShutterX_setLtEnBind(index, 4, bindstate4)); \ + DO(m_clstc->ShutterX_setInSigSelect(index, sig)); + + UPDATE(1); + UPDATE(2); + UPDATE(3); + UPDATE(4); + } } -void MainWindow::refreshReadonlyPage() { + +void MainWindow::refreshReadonlyPage0() { zaf_error_code_t ecode; if (!G_QTDataChannel.isOpen()) { @@ -161,6 +196,11 @@ void MainWindow::refreshReadonlyPage() { DO(m_clstc->InterClk_readTriOutSignalFreq(TriOutSignalFreq)); ui->InterClk_TriOutSignalFreq_Text->setText(QString::number(TriOutSignalFreq, 'f', 2)); } +} +void MainWindow::refreshReadonlyPage1() { + if (!G_QTDataChannel.isOpen()) { + return; + } { float infreq; @@ -179,6 +219,11 @@ void MainWindow::refreshReadonlyPage() { #undef UPDATE } +} +void MainWindow::refreshReadonlyPage2() { + if (!G_QTDataChannel.isOpen()) { + return; + } // 刷新光源时序控制页面 { @@ -200,6 +245,11 @@ void MainWindow::refreshReadonlyPage() { UPDATE(4); } } +void MainWindow::refreshReadonlyPage3() { + if (!G_QTDataChannel.isOpen()) { + return; + } +} void MainWindow::refreshPage() { /******************************************************************************* @@ -297,6 +347,39 @@ void MainWindow::refreshPage() { UPDATE(3); UPDATE(4); } + + { + SigProcessMode mode; + uint32_t offset; + uint32_t bindstate1; + uint32_t bindstate2; + uint32_t bindstate3; + uint32_t bindstate4; + InternalSig sig; + +#define UPDATE(index) \ + DO(m_clstc->ShutterX_getOutputCtrlMode(index, mode)); \ + DO(m_clstc->ShutterX_getLtEnOffset(index, offset)); \ + DO(m_clstc->ShutterX_getLtEnBind(index, 1, bindstate1)); \ + DO(m_clstc->ShutterX_getLtEnBind(index, 2, bindstate2)); \ + DO(m_clstc->ShutterX_getLtEnBind(index, 3, bindstate3)); \ + DO(m_clstc->ShutterX_getLtEnBind(index, 4, bindstate4)); \ + DO(m_clstc->ShutterX_getInSigSelect(index, sig)); \ + ui->ShutterX_OutputCtrlMode_##index->setCurrentText(QString::fromStdString(mode.toString())); \ + ui->ShutterX_LtEnOffset_##index->setText(QString::number(offset)); \ + ui->ShutterX_LtEnBind_val1_##index->setChecked(bindstate1 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ + ui->ShutterX_LtEnBind_val2_##index->setChecked(bindstate2 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ + ui->ShutterX_LtEnBind_val3_##index->setChecked(bindstate3 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ + ui->ShutterX_LtEnBind_val4_##index->setChecked(bindstate4 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ + ui->ShutterX_InSigSelect_##index->setCurrentText(QString::fromStdString(sig.toString())); + + // ui->ShutterX_LtEnBind_val1_1->checkState() + + UPDATE(1); + UPDATE(2); + UPDATE(3); + UPDATE(4); + } } void MainWindow::constructUI() { @@ -317,7 +400,8 @@ void MainWindow::constructUI() { ui->serialBaudrateCB->addItem("38400"); ui->serialBaudrateCB->addItem("57600"); ui->serialBaudrateCB->addItem("115200"); - ui->serialBaudrateCB->setCurrentIndex(5); + ui->serialBaudrateCB->addItem("500000"); + ui->serialBaudrateCB->setCurrentIndex(6); /******************************************************************************* * 刷新串口 * @@ -529,6 +613,25 @@ void MainWindow::constructUI() { ui->LightSrcX_LightDriverFreq_2->setDisabled(true); ui->LightSrcX_LightDriverFreq_3->setDisabled(true); ui->LightSrcX_LightDriverFreq_4->setDisabled(true); + + /******************************************************************************* + * 快门时序配置页面 * + *******************************************************************************/ + + ui->ShutterX_OutputCtrlMode_1->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); + ui->ShutterX_OutputCtrlMode_2->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); + ui->ShutterX_OutputCtrlMode_3->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); + ui->ShutterX_OutputCtrlMode_4->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); + + ui->ShutterX_OutputCtrlMode_1->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); + ui->ShutterX_OutputCtrlMode_2->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); + ui->ShutterX_OutputCtrlMode_3->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); + ui->ShutterX_OutputCtrlMode_4->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); + + ui->ShutterX_InSigSelect_1->addItems(LightSrcX_TriSrc_QStringList); + ui->ShutterX_InSigSelect_2->addItems(LightSrcX_TriSrc_QStringList); + ui->ShutterX_InSigSelect_3->addItems(LightSrcX_TriSrc_QStringList); + ui->ShutterX_InSigSelect_4->addItems(LightSrcX_TriSrc_QStringList); } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { @@ -551,10 +654,22 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi constructUI(); // 创建定时器 - timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [this]() { refreshReadonlyPage(); }); - timer->setInterval(1000); // 每隔一秒触发一次 - timer->start(); + timer0 = new QTimer(this); + timer1 = new QTimer(this); + timer2 = new QTimer(this); + timer3 = new QTimer(this); + connect(timer0, &QTimer::timeout, this, [this]() { refreshReadonlyPage0(); }); + connect(timer1, &QTimer::timeout, this, [this]() { refreshReadonlyPage1(); }); + connect(timer2, &QTimer::timeout, this, [this]() { refreshReadonlyPage2(); }); + connect(timer3, &QTimer::timeout, this, [this]() { refreshReadonlyPage3(); }); + timer0->setInterval(1100); // 每隔一秒触发一次 + timer1->setInterval(1200); // 每隔一秒触发一次 + timer2->setInterval(900); // 每隔一秒触发一次 + timer3->setInterval(1000); // 每隔一秒触发一次 + timer0->start(); + timer1->start(); + timer2->start(); + timer3->start(); // m_clstc->regRawDataListener([this](uart_message_type_t type, uint8_t *data, size_t len) { // QString text; diff --git a/mainwindow.h b/mainwindow.h index 4b54db7..4b25a9a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -74,9 +74,14 @@ class MainWindow : public QMainWindow { MainWindow(QWidget *parent = nullptr); ~MainWindow(); void refreshPage(); - void refreshReadonlyPage(); void updatePage(); + void refreshReadonlyPage0(); + void refreshReadonlyPage1(); + void refreshReadonlyPage2(); + void refreshReadonlyPage3(); + + private slots: /** * @brief 一部修改UI方法 diff --git a/mainwindow.ui b/mainwindow.ui index b2680ca..bc394a7 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1244 - 790 + 1167 + 955 @@ -440,7 +440,7 @@ - + @@ -449,7 +449,7 @@ - 1 + 3 true @@ -817,7 +817,7 @@ - + Qt::Vertical @@ -830,8 +830,8 @@ - - + + 400 @@ -839,11 +839,11 @@ - 外部触发4 + 外部触发2 - + - + 0 @@ -868,7 +868,7 @@ - + 0 @@ -893,7 +893,7 @@ - + 0 @@ -903,7 +903,7 @@ - + 0 @@ -913,7 +913,7 @@ - + 0 @@ -938,7 +938,7 @@ - + 0 @@ -963,7 +963,7 @@ - + 0 @@ -973,7 +973,7 @@ - + 0 @@ -998,7 +998,7 @@ - + 0 @@ -1008,7 +1008,7 @@ - + 0 @@ -1033,7 +1033,7 @@ - + 0 @@ -1043,7 +1043,7 @@ - + 0 @@ -1059,9 +1059,9 @@ TRIGGER_MODE配置 - + - + 0 @@ -1071,7 +1071,7 @@ - + 0 @@ -1081,7 +1081,7 @@ - + 0 @@ -1106,7 +1106,7 @@ - + 0 @@ -1131,7 +1131,7 @@ - + 0 @@ -1141,7 +1141,7 @@ - + 0 @@ -1169,14 +1169,14 @@ - + Qt::Horizontal - + 0 @@ -1188,8 +1188,8 @@ - - + + 400 @@ -1197,11 +1197,11 @@ - 外部触发2 + 外部触发1 - + - + 0 @@ -1226,7 +1226,7 @@ - + 0 @@ -1251,7 +1251,7 @@ - + 0 @@ -1261,7 +1261,7 @@ - + 0 @@ -1271,7 +1271,7 @@ - + 0 @@ -1296,7 +1296,7 @@ - + 0 @@ -1321,7 +1321,7 @@ - + 0 @@ -1331,7 +1331,7 @@ - + 0 @@ -1356,7 +1356,7 @@ - + 0 @@ -1366,7 +1366,7 @@ - + 0 @@ -1391,7 +1391,7 @@ - + 0 @@ -1401,7 +1401,7 @@ - + 0 @@ -1417,9 +1417,9 @@ TRIGGER_MODE配置 - + - + 0 @@ -1429,7 +1429,7 @@ - + 0 @@ -1439,7 +1439,7 @@ - + 0 @@ -1464,7 +1464,7 @@ - + 0 @@ -1489,7 +1489,7 @@ - + 0 @@ -1499,7 +1499,7 @@ - + 0 @@ -1527,14 +1527,14 @@ - + Qt::Horizontal - + 0 @@ -1546,8 +1546,21 @@ - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + 400 @@ -1555,11 +1568,11 @@ - 外部触发1 + 外部触发4 - + - + 0 @@ -1584,7 +1597,7 @@ - + 0 @@ -1609,7 +1622,7 @@ - + 0 @@ -1619,7 +1632,7 @@ - + 0 @@ -1629,7 +1642,7 @@ - + 0 @@ -1654,7 +1667,7 @@ - + 0 @@ -1679,7 +1692,7 @@ - + 0 @@ -1689,7 +1702,7 @@ - + 0 @@ -1714,7 +1727,7 @@ - + 0 @@ -1724,7 +1737,7 @@ - + 0 @@ -1749,7 +1762,7 @@ - + 0 @@ -1759,7 +1772,7 @@ - + 0 @@ -1775,9 +1788,9 @@ TRIGGER_MODE配置 - + - + 0 @@ -1787,7 +1800,7 @@ - + 0 @@ -1797,7 +1810,7 @@ - + 0 @@ -1822,7 +1835,7 @@ - + 0 @@ -1847,7 +1860,7 @@ - + 0 @@ -1857,7 +1870,7 @@ - + 0 @@ -1885,14 +1898,14 @@ - + Qt::Horizontal - + 0 @@ -1904,19 +1917,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -2707,8 +2707,8 @@ - - + + 400 @@ -2716,11 +2716,11 @@ - 光源4 + 光源1 - + - + 0 @@ -2745,7 +2745,7 @@ - + 0 @@ -2770,14 +2770,14 @@ - + Qt::Horizontal - + 0 @@ -2802,7 +2802,7 @@ - + 0 @@ -2812,7 +2812,7 @@ - + 0 @@ -2837,7 +2837,7 @@ - + 0 @@ -2862,7 +2862,7 @@ - + 0 @@ -2872,7 +2872,7 @@ - + 0 @@ -2882,7 +2882,7 @@ - + 0 @@ -2892,7 +2892,7 @@ - + 0 @@ -2917,7 +2917,7 @@ - + 0 @@ -2942,7 +2942,7 @@ - + 0 @@ -2952,7 +2952,7 @@ - + 0 @@ -2977,7 +2977,7 @@ - + 0 @@ -2987,7 +2987,7 @@ - + 0 @@ -2997,7 +2997,7 @@ - + 0 @@ -3009,8 +3009,21 @@ - - + + + + Qt::Vertical + + + + 20 + 40 + + + + + + 400 @@ -3018,11 +3031,11 @@ - 光源1 + 光源4 - + - + 0 @@ -3047,7 +3060,7 @@ - + 0 @@ -3072,14 +3085,14 @@ - + Qt::Horizontal - + 0 @@ -3104,7 +3117,7 @@ - + 0 @@ -3114,7 +3127,7 @@ - + 0 @@ -3139,7 +3152,7 @@ - + 0 @@ -3164,7 +3177,7 @@ - + 0 @@ -3174,7 +3187,7 @@ - + 0 @@ -3184,7 +3197,7 @@ - + 0 @@ -3194,7 +3207,7 @@ - + 0 @@ -3219,7 +3232,7 @@ - + 0 @@ -3244,7 +3257,7 @@ - + 0 @@ -3254,7 +3267,7 @@ - + 0 @@ -3279,7 +3292,7 @@ - + 0 @@ -3289,7 +3302,7 @@ - + 0 @@ -3299,7 +3312,7 @@ - + 0 @@ -3311,25 +3324,908 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - 快门时序配置 + + + + + + 400 + 16777215 + + + + 快门输出1 + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + TRANSPARENT模式配置 + + + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 转发信号选择 + + + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发模式 + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + BIND模式配置 + + + + + + + 0 + 25 + + + + + + + + 光源1 + + + + + + + 光源2 + + + + + + + 光源3 + + + + + + + 光源4 + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发延迟(100ns) + + + + + + + + + + + 0 + 25 + + + + + + + + Qt::Vertical + + + + 20 + 60 + + + + + + + + + + + + 400 + 16777215 + + + + 快门输出1 + + + + + + Qt::Vertical + + + + 20 + 60 + + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + TRANSPARENT模式配置 + + + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 转发信号选择 + + + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发模式 + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + BIND模式配置 + + + + + + + 0 + 25 + + + + + + + + 光源2 + + + + + + + 光源3 + + + + + + + 光源4 + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发延迟(100ns) + + + + + + + 光源1 + + + + + + + + + + + 0 + 25 + + + + + + + + + + + + 400 + 16777215 + + + + 快门输出1 + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + TRANSPARENT模式配置 + + + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 转发信号选择 + + + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发模式 + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + BIND模式配置 + + + + + + + 0 + 25 + + + + + + + + 光源1 + + + + + + + 光源2 + + + + + + + 光源3 + + + + + + + 光源4 + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发延迟(100ns) + + + + + + + + + + + 0 + 25 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 400 + 16777215 + + + + 快门输出1 + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + TRANSPARENT模式配置 + + + + + + + 0 + 25 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 转发信号选择 + + + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发模式 + + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + BIND模式配置 + + + + + + + 0 + 25 + + + + + + + + 光源1 + + + + + + + 光源2 + + + + + + + 光源3 + + + + + + + 光源4 + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + 触发延迟(100ns) + + + + + + + + + + + 0 + 25 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -3364,7 +4260,7 @@ 0 0 - 1244 + 1167 23 diff --git a/src/camera_light_src_timing_controller/qt_serial_datachannel.cpp b/src/camera_light_src_timing_controller/qt_serial_datachannel.cpp index 294287f..d92c0fb 100644 --- a/src/camera_light_src_timing_controller/qt_serial_datachannel.cpp +++ b/src/camera_light_src_timing_controller/qt_serial_datachannel.cpp @@ -26,7 +26,7 @@ void QTDataChannel::init() { if (m_rxcb) m_rxcb(rx, rx_cnt); } } - this_thread::sleep_for(chrono::microseconds(100)); + // this_thread::sleep_for(chrono::microseconds(1000)); } })); }