From 304db928d7d54e1ef07fbccd853682e52c674c2f Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 11 Jan 2024 16:26:39 +0800 Subject: [PATCH] update --- libxsync | 2 +- mainwindow.cpp | 182 +++++++++++++++++++++++---------- mainwindow.h | 6 ++ mainwindow.ui | 312 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 447 insertions(+), 55 deletions(-) diff --git a/libxsync b/libxsync index 5d0eb6f..76e2707 160000 --- a/libxsync +++ b/libxsync @@ -1 +1 @@ -Subproject commit 5d0eb6fcc626df90938927b50280699f90604bfb +Subproject commit 76e2707f5c6bd1297e135f41e55ade20f456678c diff --git a/mainwindow.cpp b/mainwindow.cpp index b292642..f15cdba 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -172,54 +172,74 @@ void MainWindow::updateUI_timeCodeInfo(uint32_t regoff) { void MainWindow::construct_reg_table() { // int regoff = 1; - push_reg(ui->gridLayoutWidget, regoff++, "software_version", kxsync_reg_software_version, 0, kreg_val_type_dotted_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "manufacturer0", kxsync_reg_manufacturer0, 0, kreg_val_type_str); - push_reg(ui->gridLayoutWidget, regoff++, "manufacturer1", kxsync_reg_manufacturer1, 0, kreg_val_type_str); - push_reg(ui->gridLayoutWidget, regoff++, "product_type_id", kxsync_reg_product_type_id, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "sn_id0", kxsync_reg_sn_id0, 0, kreg_val_type_dotted_hex); - push_reg(ui->gridLayoutWidget, regoff++, "sn_id1", kxsync_reg_sn_id1, 0, kreg_val_type_dotted_hex); - push_reg(ui->gridLayoutWidget, regoff++, "sn_id2", kxsync_reg_sn_id2, 0, kreg_val_type_dotted_hex); - push_reg(ui->gridLayoutWidget, regoff++, "mac0", kxsync_reg_mac0, 0, kreg_val_type_dotted_hex); - push_reg(ui->gridLayoutWidget, regoff++, "mac1", kxsync_reg_mac1, 0, kreg_val_type_dotted_hex); - - // kxsync_reg_stm32_ip - // kxsync_reg_stm32_gw - // kxsync_reg_stm32_netmask - // kxsync_reg_stm32_camera_sync_signal_count - - push_reg(ui->gridLayoutWidget, regoff++, "stm32_ip", kxsync_reg_stm32_ip, 0, kreg_val_type_dotted_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "stm32_gw", kxsync_reg_stm32_gw, 0, kreg_val_type_dotted_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "stm32_netmask", kxsync_reg_stm32_netmask, 0, kreg_val_type_dotted_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "stm32_camera_sync_signal_count", kxsync_reg_stm32_camera_sync_signal_count, 0, kreg_val_type_decimal); - - push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg0", kxsync_fpga_reg_test_reg0, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg1", kxsync_fpga_reg_test_reg1, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg2", kxsync_fpga_reg_test_reg2, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg3", kxsync_fpga_reg_test_reg3, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg4", kxsync_fpga_reg_test_reg4, 0, kreg_val_type_hex); - - push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_input_sig_slt", kxsync_reg_ttlout1_input_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_output_sig_slt", kxsync_reg_ttlout1_output_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_config", kxsync_reg_ttlout1_config, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pulse_mode_duration", kxsync_reg_ttlout1_pulse_mode_duration, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pulse_mode_delay", kxsync_reg_ttlout1_pulse_mode_delay, 0, kreg_val_type_decimal); - - push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_input_sig_slt", kxsync_reg_ttlout2_input_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_output_sig_slt", kxsync_reg_ttlout2_output_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_config", kxsync_reg_ttlout2_config, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pulse_mode_duration", kxsync_reg_ttlout2_pulse_mode_duration, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pulse_mode_delay", kxsync_reg_ttlout2_pulse_mode_delay, 0, kreg_val_type_decimal); - - push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_input_sig_slt", kxsync_reg_ttlout3_input_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_output_sig_slt", kxsync_reg_ttlout3_output_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_config", kxsync_reg_ttlout3_config, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pulse_mode_duration", kxsync_reg_ttlout3_pulse_mode_duration, 0, kreg_val_type_decimal); - - push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pulse_mode_delay", kxsync_reg_ttlout3_pulse_mode_delay, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_input_sig_slt", kxsync_reg_ttlout4_input_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_output_sig_slt", kxsync_reg_ttlout4_output_sig_slt, 0, kreg_val_type_decimal); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_config", kxsync_reg_ttlout4_config, 0, kreg_val_type_hex); - push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_pulse_mode_duration", kxsync_reg_ttlout4_pulse_mode_duration, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "software_version", reg::ksoftware_version, 0, kreg_val_type_dotted_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "manufacturer0", reg::kmanufacturer0, 0, kreg_val_type_str); + push_reg(ui->gridLayoutWidget, regoff++, "manufacturer1", reg::kmanufacturer1, 0, kreg_val_type_str); + push_reg(ui->gridLayoutWidget, regoff++, "product_type_id", reg::kproduct_type_id, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "sn_id0", reg::ksn_id0, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "sn_id1", reg::ksn_id1, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "sn_id2", reg::ksn_id2, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "mac0", reg::kmac0, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "mac1", reg::kmac1, 0, kreg_val_type_dotted_hex); + + // reg::kstm32_ip + // reg::kstm32_gw + // reg::kstm32_netmask + // reg::kstm32_camera_sync_signal_count + + push_reg(ui->gridLayoutWidget, regoff++, "stm32_ip", reg::kstm32_ip, 0, kreg_val_type_dotted_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "stm32_gw", reg::kstm32_gw, 0, kreg_val_type_dotted_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "stm32_netmask", reg::kstm32_netmask, 0, kreg_val_type_dotted_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "stm32_camera_sync_signal_count", reg::kstm32_camera_sync_signal_count, 0, kreg_val_type_decimal); + + push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg0", reg::kfpga_test_reg0, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg1", reg::kfpga_test_reg1, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg2", reg::kfpga_test_reg2, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg3", reg::kfpga_test_reg3, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg4", reg::kfpga_test_reg4, 0, kreg_val_type_hex); + + push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_input_sig_slt", reg::kttlout1_input_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_output_sig_slt", reg::kttlout1_output_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_config", reg::kttlout1_config, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pulse_mode_duration", reg::kttlout1_pulse_mode_duration, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pulse_mode_delay", reg::kttlout1_pulse_mode_delay, 0, kreg_val_type_decimal); + + push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_input_sig_slt", reg::kttlout2_input_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_output_sig_slt", reg::kttlout2_output_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_config", reg::kttlout2_config, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pulse_mode_duration", reg::kttlout2_pulse_mode_duration, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pulse_mode_delay", reg::kttlout2_pulse_mode_delay, 0, kreg_val_type_decimal); + + push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_input_sig_slt", reg::kttlout3_input_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_output_sig_slt", reg::kttlout3_output_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_config", reg::kttlout3_config, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pulse_mode_duration", reg::kttlout3_pulse_mode_duration, 0, kreg_val_type_decimal); + + push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pulse_mode_delay", reg::kttlout3_pulse_mode_delay, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_input_sig_slt", reg::kttlout4_input_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_output_sig_slt", reg::kttlout4_output_sig_slt, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_config", reg::kttlout4_config, 0, kreg_val_type_hex); + push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_pulse_mode_duration", reg::kttlout4_pulse_mode_duration, 0, kreg_val_type_decimal); + + // kSigGenerator_ctl + // kSigGenerator_genlock_format + // kSigGenerator_timecode_format + // kSigGenerator_control_trigger_reg + // kSigGenerator_timecode0 + // kSigGenerator_timecode1 + // kSigGenerator_timecode_start0 + // kSigGenerator_timecode_start1 + // kSigGenerator_work_state + + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_ctl", reg::kSigGenerator_ctl, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_genlock_format", reg::kSigGenerator_genlock_format, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_timecode_format", reg::kSigGenerator_timecode_format, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_control_trigger_reg", reg::kSigGenerator_control_trigger_reg, 0, kreg_val_type_decimal); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_timecode0", reg::kSigGenerator_timecode0, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_timecode1", reg::kSigGenerator_timecode1, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_timecode_start0", reg::kSigGenerator_timecode_start0, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_timecode_start1", reg::kSigGenerator_timecode_start1, 0, kreg_val_type_dotted_hex); + push_reg(ui->gridLayoutWidget, regoff++, "SigGenerator_work_state", reg::kSigGenerator_work_state, 0, kreg_val_type_decimal); // 设置table的高度 auto qrect = ui->gridLayoutWidget->geometry(); @@ -244,6 +264,23 @@ void MainWindow::UI_TTLOutputMoudleConstruct() { } } +void MainWindow::UI_SigGeneratorConstruct() { + ui->SigGenerator_ControlMode->clear(); + for (auto &str : sig_generator_module::ControlModeStrSet()) { + ui->SigGenerator_ControlMode->addItem(QString::fromStdString(str)); + } + + ui->SigGenerator_GenlockFormat->clear(); + for (auto &str : GenlockFormatStrSet()) { + ui->SigGenerator_GenlockFormat->addItem(QString::fromStdString(str)); + } + + ui->SigGenerator_TimecodeFormat->clear(); + for (auto &str : TimecodeFormatStrSet()) { + ui->SigGenerator_TimecodeFormat->addItem(QString::fromStdString(str)); + } +} + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); m_mainWindow = this; @@ -254,6 +291,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi construct_reg_table(); qInstallMessageHandler(log_output); UI_TTLOutputMoudleConstruct(); + UI_SigGeneratorConstruct(); /******************************************************************************* * 连接信号与槽 * @@ -276,9 +314,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi // m_xsync.reset(new Xsync()); Xsync::Ins().initialize(XSyncUdpFactoryImpl::Ins()); - Xsync::Ins().Basic_registerOnTimecodeMsgCallback([this](xysnc_timecode_t *timecode_msg) { // - xysnc_timecode_t timecode = *timecode_msg; - QString text = QString(fmt("%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame)); + Xsync::Ins().Basic_registerOnTimecodeMsgCallback([this](XsyncTimecode_t *timecode_msg) { // + XsyncTimecode_t timecode = *timecode_msg; + QString text = QString(fmt("%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame)); updateUI_timeCodeInfo_signal(text); }); @@ -417,4 +455,46 @@ void MainWindow::on_TTLOutputMoudle_Read_clicked() { ui->TTLOutputMoudle_OutputSigType->setCurrentText(QString::fromStdString(ttlout_module::OutputSigType2Str(OutputSigType))); ui->TTLOutputMoudle_TriggerModePulseWidth->setText(QString::number(TriggerModePulseWidth)); ui->TTLOutputMoudle_TriggerModePulseDelay->setText(QString::number(TriggerModePulseDelay)); +} + +void MainWindow::on_SigGenerator_Read_clicked() { + sig_generator_module::ControlMode_t ControlMode; + GenlockFormat_t GenlockFormat; + TimecodeFormat_t TimecodeFormat; + XsyncTimecode_t Timecode; + XsyncTimecode_t AutoStartTimecode; + uint32_t WorkState; + + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_getControlMode(ControlMode)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_getGenlockFormat(GenlockFormat)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_getTimecodeFormat(TimecodeFormat)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_getTimecode(Timecode)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_getAutoStartTimecode(AutoStartTimecode)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_getWorkState(WorkState)); + + ui->SigGenerator_ControlMode->setCurrentText(QString::fromStdString(sig_generator_module::ControlMode2Str(ControlMode))); + ui->SigGenerator_GenlockFormat->setCurrentText(QString::fromStdString(GenlockFormatToStr(GenlockFormat))); + ui->SigGenerator_TimecodeFormat->setCurrentText(QString::fromStdString(TimecodeFormatToStr(TimecodeFormat))); + ui->SigGenerator_Timecode->setText(QString(XsyncTimecodeToStr(Timecode).c_str())); + ui->SigGenerator_AutoStartTimecode->setText(QString(XsyncTimecodeToStr(AutoStartTimecode).c_str())); + ui->SigGenerator_WorkState->setText(QString::number(WorkState)); +} +void MainWindow::on_SigGenerator_Update_clicked() { + auto ControlMode = sig_generator_module::Str2ControlMode(ui->SigGenerator_ControlMode->currentText().toStdString()); + auto GenlockFormat = Str2GenlockFormat(ui->SigGenerator_GenlockFormat->currentText().toStdString()); + auto TimecodeFormat = Str2TimecodeFormat(ui->SigGenerator_TimecodeFormat->currentText().toStdString()); + XsyncTimecode_t timecode = Str2XsyncTimecode(ui->SigGenerator_Timecode->text().toStdString()); + XsyncTimecode_t autoStartTimecode = Str2XsyncTimecode(ui->SigGenerator_AutoStartTimecode->text().toStdString()); + + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_setControlMode(ControlMode)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_setGenlockFormat(GenlockFormat)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_setTimecodeFormat(TimecodeFormat)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_setTimecode(timecode)); + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_setAutoStartTimecode(autoStartTimecode)); +} +void MainWindow::on_SigGenerator_Start_clicked() { + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_manualStart()); +} +void MainWindow::on_SigGenerator_Stop_clicked() { + DO_XSYNC_FUNC(Xsync::Ins().SigGenerator_manualStop()); } \ No newline at end of file diff --git a/mainwindow.h b/mainwindow.h index e5346d5..f2fb316 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -102,6 +102,11 @@ class MainWindow : public QMainWindow { void on_TTLOutputMoudle_Read_clicked(); void on_TTLOutputMoudle_Update_clicked(); + void on_SigGenerator_Read_clicked(); + void on_SigGenerator_Update_clicked(); + void on_SigGenerator_Start_clicked(); + void on_SigGenerator_Stop_clicked(); + signals: void append_log_signal(QString str); void updateUI_timeCodeInfo_signal(QString); @@ -114,5 +119,6 @@ class MainWindow : public QMainWindow { void updateUI_timeCodeInfo(uint32_t regoff); void UI_TTLOutputMoudleConstruct(); + void UI_SigGeneratorConstruct(); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index d2d5f21..da008a1 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -102,7 +102,7 @@ - 2 + 3 @@ -385,6 +385,84 @@ false + + + + 490 + 20 + 131 + 31 + + + + SetGenlockFormat + + + + + + 490 + 60 + 131 + 31 + + + + GetGenlockFormat + + + + + + 490 + 100 + 131 + 31 + + + + SetTimecodeFormat + + + + + + 490 + 140 + 131 + 31 + + + + GetTimecodeFormat + + + + + + 630 + 40 + 241 + 31 + + + + -1 + + + + + + 630 + 110 + 241 + 31 + + + + -1 + + @@ -442,7 +520,7 @@ - 10 + false @@ -464,7 +542,7 @@ - 5 + false @@ -549,6 +627,234 @@ + + + 信号生成器 + + + + + 20 + 30 + 101 + 31 + + + + ControlMode + + + + + + 20 + 70 + 141 + 31 + + + + Timecode(hh:mm:ss:ff) + + + + + + 20 + 110 + 191 + 31 + + + + AutoStartTimecode(hh:mm:ss:ff) + + + + + + 20 + 150 + 101 + 31 + + + + GenlockFormat + + + + + + 20 + 190 + 101 + 31 + + + + TimecodeFormat + + + + + + 240 + 30 + 241 + 31 + + + + -1 + + + + + + 240 + 150 + 241 + 31 + + + + -1 + + + + + + 240 + 190 + 241 + 31 + + + + -1 + + + + + + 240 + 70 + 241 + 31 + + + + + 75 + true + + + + + + + false + + + + + + 240 + 110 + 241 + 31 + + + + + 75 + true + + + + + + + false + + + + + + 530 + 30 + 151 + 41 + + + + Read + + + + + + 530 + 80 + 151 + 41 + + + + Update + + + + + + 530 + 130 + 151 + 41 + + + + 启动 + + + + + + 530 + 180 + 151 + 41 + + + + 停止 + + + + + + 240 + 230 + 141 + 31 + + + + + + + 20 + 230 + 101 + 31 + + + + WorkState + + +