diff --git a/CMakeLists.txt b/CMakeLists.txt index 51a2c47..4e326e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,11 +50,6 @@ add_executable(CameraLightingController target_link_options(CameraLightingController PRIVATE -static -static-libgcc -static-libstdc++) target_link_libraries(CameraLightingController PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::SerialPort Qt${QT_VERSION_MAJOR}::Charts Qt${QT_VERSION_MAJOR}::Concurrent wsock32) -target_link_libraries(CameraLightingController PRIVATE Qt${QT_VERSION_MAJOR}::Widgets # - Qt${QT_VERSION_MAJOR}::SerialPort # - Qt${QT_VERSION_MAJOR}::Charts # - Qt${QT_VERSION_MAJOR}::Concurrent # -wsock32) set_target_properties(CameraLightingController PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com diff --git a/mainwindow.cpp b/mainwindow.cpp index 5d5c470..0c3a687 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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; } diff --git a/mainwindow.h b/mainwindow.h index ca97eac..c4e96a3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -95,5 +95,6 @@ class MainWindow : public QMainWindow { static void log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg); void constructUI(); void dumpLog(const char *fmt, ...); + void displayInfo(bool suc,QString info); }; #endif // MAINWINDOW_H diff --git a/src/camera_light_src_timing_controller/clst_controler.cpp b/src/camera_light_src_timing_controller/clst_controler.cpp index a4fbcb8..83c8704 100644 --- a/src/camera_light_src_timing_controller/clst_controler.cpp +++ b/src/camera_light_src_timing_controller/clst_controler.cpp @@ -601,9 +601,9 @@ zaf_error_code_t CLSTControler::ShutterX_setLtEnBind(int32_t index, uint32_t lt_ uint32_t readbak_state = 0; DO_CMD(reg_read(kreg_ttl_output_module1_lt_en_bind + (index - 1) * 32, readbak_state)); if (state == 1) { - readbak_state |= (1 << lt_en_sig_index); + readbak_state |= (1 << (lt_en_sig_index - 1)); } else { - readbak_state &= ~(1 << lt_en_sig_index); + readbak_state &= ~(1 << (lt_en_sig_index - 1)); } DO_CMD(reg_write(kreg_ttl_output_module1_lt_en_bind + (index - 1) * 32, readbak_state)); return kaf_ec_success; @@ -624,7 +624,7 @@ zaf_error_code_t CLSTControler::ShutterX_getOutputCtrlMode(int32_t index, SigPro zaf_error_code_t CLSTControler::ShutterX_getLtEnBind(int32_t index, uint32_t lt_en_sig_index, uint32_t &state) { // uint32_t readbak_state = 0; DO_CMD(reg_read(kreg_ttl_output_module1_lt_en_bind + (index - 1) * 32, readbak_state)); - state = (readbak_state >> lt_en_sig_index) & 0x01; + state = (readbak_state >> (lt_en_sig_index - 1)) & 0x01; return kaf_ec_success; } zaf_error_code_t CLSTControler::ShutterX_getLtEnOffset(int32_t index, uint32_t &offset) { //