zhaohe 1 year ago
parent
commit
0cd2624896
  1. 129
      mainwindow.cpp
  2. 7
      mainwindow.h
  3. 1194
      mainwindow.ui
  4. 2
      src/camera_light_src_timing_controller/qt_serial_datachannel.cpp

129
mainwindow.cpp

@ -16,7 +16,10 @@ using namespace std;
static MainWindow *m_mainWindow; static MainWindow *m_mainWindow;
static CLSTControler *m_clstc; static CLSTControler *m_clstc;
QTimer *timer;
QTimer *timer0;
QTimer *timer1;
QTimer *timer2;
QTimer *timer3;
#define TAG "MainWindow" #define TAG "MainWindow"
static const char *fmt(const char *fmt, ...) { static const char *fmt(const char *fmt, ...) {
@ -148,8 +151,40 @@ void MainWindow::updatePage() {
UPDATE(3); UPDATE(3);
UPDATE(4); 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; zaf_error_code_t ecode;
if (!G_QTDataChannel.isOpen()) { if (!G_QTDataChannel.isOpen()) {
@ -161,6 +196,11 @@ void MainWindow::refreshReadonlyPage() {
DO(m_clstc->InterClk_readTriOutSignalFreq(TriOutSignalFreq)); DO(m_clstc->InterClk_readTriOutSignalFreq(TriOutSignalFreq));
ui->InterClk_TriOutSignalFreq_Text->setText(QString::number(TriOutSignalFreq, 'f', 2)); ui->InterClk_TriOutSignalFreq_Text->setText(QString::number(TriOutSignalFreq, 'f', 2));
} }
}
void MainWindow::refreshReadonlyPage1() {
if (!G_QTDataChannel.isOpen()) {
return;
}
{ {
float infreq; float infreq;
@ -179,6 +219,11 @@ void MainWindow::refreshReadonlyPage() {
#undef UPDATE #undef UPDATE
} }
}
void MainWindow::refreshReadonlyPage2() {
if (!G_QTDataChannel.isOpen()) {
return;
}
// 刷新光源时序控制页面 // 刷新光源时序控制页面
{ {
@ -200,6 +245,11 @@ void MainWindow::refreshReadonlyPage() {
UPDATE(4); UPDATE(4);
} }
} }
void MainWindow::refreshReadonlyPage3() {
if (!G_QTDataChannel.isOpen()) {
return;
}
}
void MainWindow::refreshPage() { void MainWindow::refreshPage() {
/******************************************************************************* /*******************************************************************************
@ -297,6 +347,39 @@ void MainWindow::refreshPage() {
UPDATE(3); UPDATE(3);
UPDATE(4); 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() { void MainWindow::constructUI() {
@ -317,7 +400,8 @@ void MainWindow::constructUI() {
ui->serialBaudrateCB->addItem("38400"); ui->serialBaudrateCB->addItem("38400");
ui->serialBaudrateCB->addItem("57600"); ui->serialBaudrateCB->addItem("57600");
ui->serialBaudrateCB->addItem("115200"); 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_2->setDisabled(true);
ui->LightSrcX_LightDriverFreq_3->setDisabled(true); ui->LightSrcX_LightDriverFreq_3->setDisabled(true);
ui->LightSrcX_LightDriverFreq_4->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) { 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(); 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) { // m_clstc->regRawDataListener([this](uart_message_type_t type, uint8_t *data, size_t len) {
// QString text; // QString text;

7
mainwindow.h

@ -74,9 +74,14 @@ class MainWindow : public QMainWindow {
MainWindow(QWidget *parent = nullptr); MainWindow(QWidget *parent = nullptr);
~MainWindow(); ~MainWindow();
void refreshPage(); void refreshPage();
void refreshReadonlyPage();
void updatePage(); void updatePage();
void refreshReadonlyPage0();
void refreshReadonlyPage1();
void refreshReadonlyPage2();
void refreshReadonlyPage3();
private slots: private slots:
/** /**
* @brief UI方法 * @brief UI方法

1194
mainwindow.ui
File diff suppressed because it is too large
View File

2
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); if (m_rxcb) m_rxcb(rx, rx_cnt);
} }
} }
this_thread::sleep_for(chrono::microseconds(100));
// this_thread::sleep_for(chrono::microseconds(1000));
} }
})); }));
} }

Loading…
Cancel
Save