xsync上位机
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1132 lines
63 KiB

1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #include "mainwindow.h"
  2. #include <QDateTime>
  3. #include <QtConcurrent>
  4. #include "./ui_mainwindow.h"
  5. #include "xsync_regs.hpp"
  6. using namespace iflytop;
  7. using namespace xsync;
  8. using namespace std;
  9. static MainWindow *m_mainWindow;
  10. #define TAG "MainWindow"
  11. static const char *fmt(const char *fmt, ...) {
  12. va_list args;
  13. va_start(args, fmt);
  14. static char buf[1024] = {0};
  15. vsnprintf(buf, sizeof(buf), fmt, args);
  16. va_end(args);
  17. return buf;
  18. }
  19. static const uint32_t str2int(QString str) {
  20. // 如果0x开头,按16进制转换
  21. // 如果0b开头,按2进制转换
  22. // 否则按10进制转换
  23. // 去除掉str中_
  24. str.remove("_");
  25. if (str.startsWith("0x")) {
  26. return str.toUInt(nullptr, 16);
  27. } else if (str.startsWith("0b")) {
  28. // remove 0b
  29. str.remove(0, 2);
  30. return str.toUInt(nullptr, 2);
  31. } else {
  32. return str.toUInt(nullptr, 10);
  33. }
  34. }
  35. void MainWindow::log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
  36. QString text;
  37. text.append(msg);
  38. m_mainWindow->append_log_signal(text);
  39. }
  40. void MainWindow::append_log_slot(QString text) { ui->logbrowser->append(text); }
  41. void MainWindow::updateUI_timeCodeInfo_slot(QString text) { ui->TimecodeDisplayer->setText(text); }
  42. void MainWindow::updateUI_cameraSyncInfo_slot(QString text) { ui->CameraSyncIndex->setText(text); }
  43. void MainWindow::updateUI_reg_slot(int32_t regadd, uint32_t regval) {
  44. auto it = m_regdisplayer.find(regadd);
  45. if (it != m_regdisplayer.end()) {
  46. ZLOGI(TAG, "updateUI_reg_slot %x %d", regadd, regval);
  47. it->second->regBrowser->setText(QString::number(regval, 16));
  48. }
  49. }
  50. void MainWindow::doinui_slot(QFunction func) {
  51. if (func.get()) func.get()();
  52. }
  53. void MainWindow::push_reg(QWidget *parent, int off, const char *regname, int32_t regadd, int32_t rwflag, reg_val_type_t regvaltype) {
  54. DispalyRegIterm *regitem = new DispalyRegIterm();
  55. regitem->regvaltype = regvaltype;
  56. {
  57. auto *label = new QLabel(parent);
  58. label->setObjectName(QString::fromUtf8("label"));
  59. label->setText(QString(fmt("%s(0x%04x)", regname, regadd)));
  60. QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Expanding);
  61. sizePolicy1.setHorizontalStretch(0);
  62. sizePolicy1.setVerticalStretch(0);
  63. sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
  64. label->setSizePolicy(sizePolicy1);
  65. label->setMinimumSize(QSize(300, 0));
  66. label->setMaximumSize(QSize(16777215, 16777215));
  67. ui->reg_table->addWidget(label, off, 0, 1, 1);
  68. regitem->label = label;
  69. }
  70. {
  71. auto *textbrowser = new QTextBrowser(parent);
  72. textbrowser->setObjectName(QString::fromUtf8("textbrowser"));
  73. textbrowser->setEnabled(true);
  74. textbrowser->setText(QString("unset"));
  75. QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  76. sizePolicy.setHorizontalStretch(0);
  77. sizePolicy.setVerticalStretch(0);
  78. sizePolicy.setHeightForWidth(textbrowser->sizePolicy().hasHeightForWidth());
  79. textbrowser->setSizePolicy(sizePolicy);
  80. textbrowser->setMaximumSize(QSize(16777215, 16777215));
  81. ui->reg_table->addWidget(textbrowser, off, 1, 1, 1);
  82. regitem->regBrowser = textbrowser;
  83. }
  84. {
  85. auto *textEdit = new QTextEdit(parent);
  86. textEdit->setObjectName(QString::fromUtf8("textEdit"));
  87. textEdit->setEnabled(true);
  88. QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  89. sizePolicy.setHorizontalStretch(0);
  90. sizePolicy.setVerticalStretch(0);
  91. sizePolicy.setHeightForWidth(textEdit->sizePolicy().hasHeightForWidth());
  92. textEdit->setSizePolicy(sizePolicy);
  93. textEdit->setMaximumSize(QSize(16777215, 16777215));
  94. ui->reg_table->addWidget(textEdit, off, 2, 1, 1);
  95. regitem->regEditer = textEdit;
  96. }
  97. {
  98. // new button
  99. auto *button = new QPushButton(parent);
  100. button->setObjectName(QString::fromUtf8("button"));
  101. button->setText(QString("Write"));
  102. QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  103. sizePolicy.setHorizontalStretch(0);
  104. sizePolicy.setVerticalStretch(0);
  105. sizePolicy.setHeightForWidth(button->sizePolicy().hasHeightForWidth());
  106. button->setSizePolicy(sizePolicy);
  107. // connect(this,
  108. connect(button, &QPushButton::clicked, [this, regadd](bool) { //
  109. QString regval_str = m_regdisplayer[regadd]->regEditer->toPlainText();
  110. uint32_t regval = str2int(regval_str);
  111. ZLOGI(TAG, "write reg 0x%04x %d", regadd, regval);
  112. uint32_t readbackval = 0;
  113. auto ecode = XsyncIns()->reg_write(regadd, regval, readbackval);
  114. if (ecode == kxs_ec_success) {
  115. ZLOGI(TAG, "write reg 0x%04x %d success", regadd, regval);
  116. m_regdisplayer[regadd]->regvalcache = readbackval;
  117. updateUI_reg(regadd);
  118. } else {
  119. ZLOGE(TAG, "write reg 0x%04x %d fail,ecode:%s", regadd, regval, xs_error_code_2_str(ecode));
  120. }
  121. });
  122. regitem->writerButton = button;
  123. ui->reg_table->addWidget(button, off, 3, 1, 1);
  124. }
  125. m_regdisplayer[regadd] = regitem;
  126. }
  127. void MainWindow::updateUI_reg(uint32_t regoff) {
  128. // m_regdisplayer[regoff]->regBrowser->setText("0x" + QString::number(regValue, 16));
  129. uint32_t regval = m_regdisplayer[regoff]->regvalcache;
  130. auto *regBrowser = m_regdisplayer[regoff]->regBrowser;
  131. reg_val_type_t regvaltype = m_regdisplayer[regoff]->regvaltype;
  132. if (regvaltype == kreg_val_type_dotted_hex) {
  133. regBrowser->setText(QString(fmt("%02x.%02x.%02x.%02x", (regval >> 0) & 0xff, (regval >> 8) & 0xff, (regval >> 16) & 0xff, (regval >> 24) & 0xff)));
  134. } else if (regvaltype == kreg_val_type_dotted_decimal) {
  135. regBrowser->setText(QString(fmt("%d.%d.%d.%d", (regval >> 0) & 0xff, (regval >> 8) & 0xff, (regval >> 16) & 0xff, (regval >> 24) & 0xff)));
  136. } else if (regvaltype == kreg_val_type_str) {
  137. char text[5] = {0};
  138. memcpy(text, &regval, 4);
  139. regBrowser->setText(QString(text));
  140. } else if (regvaltype == kreg_val_type_hex) {
  141. regBrowser->setText(QString(fmt("0x%08x", regval)));
  142. } else if (regvaltype == kreg_val_type_decimal) {
  143. regBrowser->setText(QString::number(regval, 10));
  144. } else if (regvaltype == kreg_val_type_binary) {
  145. regBrowser->setText(QString::number(regval, 2));
  146. }
  147. }
  148. void MainWindow::construct_reg_table() { //
  149. int regoff = 1;
  150. push_reg(ui->gridLayoutWidget, regoff++, "software_version", reg::ksoftware_version, 0, kreg_val_type_dotted_decimal);
  151. push_reg(ui->gridLayoutWidget, regoff++, "manufacturer0", reg::kmanufacturer0, 0, kreg_val_type_str);
  152. push_reg(ui->gridLayoutWidget, regoff++, "manufacturer1", reg::kmanufacturer1, 0, kreg_val_type_str);
  153. push_reg(ui->gridLayoutWidget, regoff++, "product_type_id", reg::kproduct_type_id, 0, kreg_val_type_decimal);
  154. push_reg(ui->gridLayoutWidget, regoff++, "sn_id0", reg::ksn_id0, 0, kreg_val_type_dotted_hex);
  155. push_reg(ui->gridLayoutWidget, regoff++, "sn_id1", reg::ksn_id1, 0, kreg_val_type_dotted_hex);
  156. push_reg(ui->gridLayoutWidget, regoff++, "sn_id2", reg::ksn_id2, 0, kreg_val_type_dotted_hex);
  157. push_reg(ui->gridLayoutWidget, regoff++, "mac0", reg::kmac0, 0, kreg_val_type_dotted_hex);
  158. push_reg(ui->gridLayoutWidget, regoff++, "mac1", reg::kmac1, 0, kreg_val_type_dotted_hex);
  159. push_reg(ui->gridLayoutWidget, regoff++, "stm32_ip", reg::kstm32_ip, 0, kreg_val_type_dotted_decimal);
  160. push_reg(ui->gridLayoutWidget, regoff++, "stm32_gw", reg::kstm32_gw, 0, kreg_val_type_dotted_decimal);
  161. push_reg(ui->gridLayoutWidget, regoff++, "stm32_netmask", reg::kstm32_netmask, 0, kreg_val_type_dotted_decimal);
  162. push_reg(ui->gridLayoutWidget, regoff++, "stm32_camera_sync_signal_count", reg::kstm32_camera_sync_signal_count, 0, kreg_val_type_decimal);
  163. push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg0", reg::kfpga_info_reg0, 0, kreg_val_type_hex);
  164. push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg1", reg::kfpga_info_reg1, 0, kreg_val_type_hex);
  165. push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg2", reg::kfpga_info_reg2, 0, kreg_val_type_hex);
  166. push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg3", reg::kfpga_info_reg3, 0, kreg_val_type_hex);
  167. push_reg(ui->gridLayoutWidget, regoff++, "fpga_reg_test_reg4", reg::kfpga_info_reg4, 0, kreg_val_type_hex);
  168. push_reg(ui->gridLayoutWidget, regoff++, "ttlin_module", reg::k_ttlin_module, 0, kreg_val_type_hex);
  169. push_reg(ui->gridLayoutWidget, regoff++, "ttlin_en_reg", reg::k_ttlin_en_reg, 0, kreg_val_type_decimal);
  170. push_reg(ui->gridLayoutWidget, regoff++, "ttlin1_freq_detector_reg", reg::k_ttlin1_freq_detector_reg, 0, kreg_val_type_decimal);
  171. push_reg(ui->gridLayoutWidget, regoff++, "ttlin2_freq_detector_reg", reg::k_ttlin2_freq_detector_reg, 0, kreg_val_type_decimal);
  172. push_reg(ui->gridLayoutWidget, regoff++, "ttlin3_freq_detector_reg", reg::k_ttlin3_freq_detector_reg, 0, kreg_val_type_decimal);
  173. push_reg(ui->gridLayoutWidget, regoff++, "ttlin4_freq_detector_reg", reg::k_ttlin4_freq_detector_reg, 0, kreg_val_type_decimal);
  174. push_reg(ui->gridLayoutWidget, regoff++, "ttlin1_filter_factor_reg", reg::k_ttlin1_filter_factor_reg, 0, kreg_val_type_decimal);
  175. push_reg(ui->gridLayoutWidget, regoff++, "ttlin2_filter_factor_reg", reg::k_ttlin2_filter_factor_reg, 0, kreg_val_type_decimal);
  176. push_reg(ui->gridLayoutWidget, regoff++, "ttlin3_filter_factor_reg", reg::k_ttlin3_filter_factor_reg, 0, kreg_val_type_decimal);
  177. push_reg(ui->gridLayoutWidget, regoff++, "ttlin4_filter_factor_reg", reg::k_ttlin4_filter_factor_reg, 0, kreg_val_type_decimal);
  178. /*******************************************************************************
  179. * TIMECODE输入模块 *
  180. *******************************************************************************/
  181. push_reg(ui->gridLayoutWidget, regoff++, "internal_timecode_module", reg::internal_timecode_module, 0, kreg_val_type_hex);
  182. push_reg(ui->gridLayoutWidget, regoff++, "internal_timecode_en", reg::internal_timecode_en, 0, kreg_val_type_decimal);
  183. push_reg(ui->gridLayoutWidget, regoff++, "internal_timecode_format", reg::internal_timecode_format, 0, kreg_val_type_decimal);
  184. push_reg(ui->gridLayoutWidget, regoff++, "internal_timecode_data0", reg::internal_timecode_data0, 0, kreg_val_type_decimal);
  185. push_reg(ui->gridLayoutWidget, regoff++, "internal_timecode_data1", reg::internal_timecode_data1, 0, kreg_val_type_decimal);
  186. push_reg(ui->gridLayoutWidget, regoff++, "external_timecode_module", reg::external_timecode_module, 0, kreg_val_type_hex);
  187. push_reg(ui->gridLayoutWidget, regoff++, "sys_timecode_module", reg::sys_timecode_module, 0, kreg_val_type_hex);
  188. push_reg(ui->gridLayoutWidget, regoff++, "sys_timecode_select", reg::sys_timecode_select, 0, kreg_val_type_decimal);
  189. push_reg(ui->gridLayoutWidget, regoff++, "sys_timecode_format", reg::sys_timecode_format, 0, kreg_val_type_decimal);
  190. push_reg(ui->gridLayoutWidget, regoff++, "sys_timecode_data0", reg::sys_timecode_data0, 0, kreg_val_type_decimal);
  191. push_reg(ui->gridLayoutWidget, regoff++, "sys_timecode_data1", reg::sys_timecode_data1, 0, kreg_val_type_decimal);
  192. push_reg(ui->gridLayoutWidget, regoff++, "timecode_output_module", reg::timecode_output_module, 0, kreg_val_type_hex);
  193. push_reg(ui->gridLayoutWidget, regoff++, "timecode_output_timecode0", reg::timecode_output_timecode0, 0, kreg_val_type_decimal);
  194. push_reg(ui->gridLayoutWidget, regoff++, "timecode_output_timecode1", reg::timecode_output_timecode1, 0, kreg_val_type_decimal);
  195. push_reg(ui->gridLayoutWidget, regoff++, "timecode_output_timecode_format", reg::timecode_output_timecode_format, 0, kreg_val_type_decimal);
  196. push_reg(ui->gridLayoutWidget, regoff++, "timecode_output_bnc_outut_level_select", reg::timecode_output_bnc_outut_level_select, 0, kreg_val_type_decimal);
  197. /*******************************************************************************
  198. * TTL输出模块配置 *
  199. *******************************************************************************/
  200. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_module", reg::kreg_ttlout1_module, 0, kreg_val_type_hex);
  201. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_signal_process_mode", reg::kreg_ttlout1_signal_process_mode, 0, kreg_val_type_decimal);
  202. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_input_signal_select", reg::kreg_ttlout1_input_signal_select, 0, kreg_val_type_decimal);
  203. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pllout_freq_division_ctrl", reg::kreg_ttlout1_pllout_freq_division_ctrl, 0, kreg_val_type_decimal);
  204. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pllout_freq_multiplication_ctrl", reg::kreg_ttlout1_pllout_freq_multiplication_ctrl, 0, kreg_val_type_decimal);
  205. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pllout_polarity_ctrl", reg::kreg_ttlout1_pllout_polarity_ctrl, 0, kreg_val_type_decimal);
  206. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_pllout_trigger_edge_select", reg::kreg_ttlout1_pllout_trigger_edge_select, 0, kreg_val_type_decimal);
  207. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_forward_mode_polarity_ctrl", reg::kreg_ttlout1_forward_mode_polarity_ctrl, 0, kreg_val_type_decimal);
  208. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_freq_detect_bias", reg::kreg_ttlout1_freq_detect_bias, 0, kreg_val_type_decimal);
  209. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_placeholder0", reg::kreg_ttlout1_placeholder0, 0, kreg_val_type_decimal);
  210. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_sig_in_freq_detect", reg::kreg_ttlout1_sig_in_freq_detect, 0, kreg_val_type_decimal);
  211. push_reg(ui->gridLayoutWidget, regoff++, "ttlout1_sig_out_freq_detect", reg::kreg_ttlout1_sig_out_freq_detect, 0, kreg_val_type_decimal);
  212. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_module", reg::kreg_ttlout2_module, 0, kreg_val_type_hex);
  213. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_signal_process_mode", reg::kreg_ttlout2_signal_process_mode, 0, kreg_val_type_decimal);
  214. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_input_signal_select", reg::kreg_ttlout2_input_signal_select, 0, kreg_val_type_decimal);
  215. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pllout_freq_division_ctrl", reg::kreg_ttlout2_pllout_freq_division_ctrl, 0, kreg_val_type_decimal);
  216. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pllout_freq_multiplication_ctrl", reg::kreg_ttlout2_pllout_freq_multiplication_ctrl, 0, kreg_val_type_decimal);
  217. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pllout_polarity_ctrl", reg::kreg_ttlout2_pllout_polarity_ctrl, 0, kreg_val_type_decimal);
  218. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_pllout_trigger_edge_select", reg::kreg_ttlout2_pllout_trigger_edge_select, 0, kreg_val_type_decimal);
  219. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_forward_mode_polarity_ctrl", reg::kreg_ttlout2_forward_mode_polarity_ctrl, 0, kreg_val_type_decimal);
  220. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_freq_detect_bias", reg::kreg_ttlout2_freq_detect_bias, 0, kreg_val_type_decimal);
  221. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_placeholder0", reg::kreg_ttlout2_placeholder0, 0, kreg_val_type_decimal);
  222. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_sig_in_freq_detect", reg::kreg_ttlout2_sig_in_freq_detect, 0, kreg_val_type_decimal);
  223. push_reg(ui->gridLayoutWidget, regoff++, "ttlout2_sig_out_freq_detect", reg::kreg_ttlout2_sig_out_freq_detect, 0, kreg_val_type_decimal);
  224. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_module", reg::kreg_ttlout3_module, 0, kreg_val_type_hex);
  225. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_signal_process_mode", reg::kreg_ttlout3_signal_process_mode, 0, kreg_val_type_decimal);
  226. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_input_signal_select", reg::kreg_ttlout3_input_signal_select, 0, kreg_val_type_decimal);
  227. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pllout_freq_division_ctrl", reg::kreg_ttlout3_pllout_freq_division_ctrl, 0, kreg_val_type_decimal);
  228. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pllout_freq_multiplication_ctrl", reg::kreg_ttlout3_pllout_freq_multiplication_ctrl, 0, kreg_val_type_decimal);
  229. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pllout_polarity_ctrl", reg::kreg_ttlout3_pllout_polarity_ctrl, 0, kreg_val_type_decimal);
  230. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_pllout_trigger_edge_select", reg::kreg_ttlout3_pllout_trigger_edge_select, 0, kreg_val_type_decimal);
  231. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_forward_mode_polarity_ctrl", reg::kreg_ttlout3_forward_mode_polarity_ctrl, 0, kreg_val_type_decimal);
  232. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_freq_detect_bias", reg::kreg_ttlout3_freq_detect_bias, 0, kreg_val_type_decimal);
  233. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_placeholder0", reg::kreg_ttlout3_placeholder0, 0, kreg_val_type_decimal);
  234. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_sig_in_freq_detect", reg::kreg_ttlout3_sig_in_freq_detect, 0, kreg_val_type_decimal);
  235. push_reg(ui->gridLayoutWidget, regoff++, "ttlout3_sig_out_freq_detect", reg::kreg_ttlout3_sig_out_freq_detect, 0, kreg_val_type_decimal);
  236. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_module", reg::kreg_ttlout4_module, 0, kreg_val_type_hex);
  237. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_signal_process_mode", reg::kreg_ttlout4_signal_process_mode, 0, kreg_val_type_decimal);
  238. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_input_signal_select", reg::kreg_ttlout4_input_signal_select, 0, kreg_val_type_decimal);
  239. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_pllout_freq_division_ctrl", reg::kreg_ttlout4_pllout_freq_division_ctrl, 0, kreg_val_type_decimal);
  240. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_pllout_freq_multiplication_ctrl", reg::kreg_ttlout4_pllout_freq_multiplication_ctrl, 0, kreg_val_type_decimal);
  241. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_pllout_polarity_ctrl", reg::kreg_ttlout4_pllout_polarity_ctrl, 0, kreg_val_type_decimal);
  242. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_pllout_trigger_edge_select", reg::kreg_ttlout4_pllout_trigger_edge_select, 0, kreg_val_type_decimal);
  243. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_forward_mode_polarity_ctrl", reg::kreg_ttlout4_forward_mode_polarity_ctrl, 0, kreg_val_type_decimal);
  244. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_freq_detect_bias", reg::kreg_ttlout4_freq_detect_bias, 0, kreg_val_type_decimal);
  245. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_placeholder0", reg::kreg_ttlout4_placeholder0, 0, kreg_val_type_decimal);
  246. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_sig_in_freq_detect", reg::kreg_ttlout4_sig_in_freq_detect, 0, kreg_val_type_decimal);
  247. push_reg(ui->gridLayoutWidget, regoff++, "ttlout4_sig_out_freq_detect", reg::kreg_ttlout4_sig_out_freq_detect, 0, kreg_val_type_decimal);
  248. push_reg(ui->gridLayoutWidget, regoff++, "external_genlock_module", reg::external_genlock_module, 0, kreg_val_type_hex);
  249. push_reg(ui->gridLayoutWidget, regoff++, "external_genlock_freq_detect_bias", reg::external_genlock_freq_detect_bias, 0, kreg_val_type_decimal);
  250. push_reg(ui->gridLayoutWidget, regoff++, "external_genlock_freq", reg::external_genlock_freq, 0, kreg_val_type_decimal);
  251. push_reg(ui->gridLayoutWidget, regoff++, "internal_genlock_module", reg::internal_genlock_module, 0, kreg_val_type_hex);
  252. push_reg(ui->gridLayoutWidget, regoff++, "internal_genlock_ctrl_mode", reg::internal_genlock_ctrl_mode, 0, kreg_val_type_decimal);
  253. push_reg(ui->gridLayoutWidget, regoff++, "internal_genlock_en", reg::internal_genlock_en, 0, kreg_val_type_decimal);
  254. push_reg(ui->gridLayoutWidget, regoff++, "internal_genlock_format", reg::internal_genlock_format, 0, kreg_val_type_decimal);
  255. push_reg(ui->gridLayoutWidget, regoff++, "internal_genlock_freq", reg::internal_genlock_freq, 0, kreg_val_type_decimal);
  256. push_reg(ui->gridLayoutWidget, regoff++, "sys_genlock_module", reg::sys_genlock_module, 0, kreg_val_type_hex);
  257. push_reg(ui->gridLayoutWidget, regoff++, "sys_genlock_source", reg::sys_genlock_source, 0, kreg_val_type_decimal);
  258. push_reg(ui->gridLayoutWidget, regoff++, "sys_genlock_freq_detect_bias", reg::sys_genlock_freq_detect_bias, 0, kreg_val_type_decimal);
  259. push_reg(ui->gridLayoutWidget, regoff++, "sys_genlock_freq", reg::sys_genlock_freq, 0, kreg_val_type_decimal);
  260. push_reg(ui->gridLayoutWidget, regoff++, "internal_clock_module", reg::internal_clock_module, 0, kreg_val_type_hex);
  261. push_reg(ui->gridLayoutWidget, regoff++, "internal_clock_ctrl_mode", reg::internal_clock_ctrl_mode, 0, kreg_val_type_decimal);
  262. push_reg(ui->gridLayoutWidget, regoff++, "internal_clock_en", reg::internal_clock_en, 0, kreg_val_type_decimal);
  263. push_reg(ui->gridLayoutWidget, regoff++, "internal_clock_freq", reg::internal_clock_freq, 0, kreg_val_type_decimal);
  264. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_module", reg::sys_clock_module, 0, kreg_val_type_hex);
  265. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_source", reg::sys_clock_source, 0, kreg_val_type_decimal);
  266. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_freq_division_ctrl", reg::sys_clock_freq_division_ctrl, 0, kreg_val_type_decimal);
  267. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_freq_multiplication_ctrl", reg::sys_clock_freq_multiplication_ctrl, 0, kreg_val_type_decimal);
  268. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_freq_detect_bias", reg::sys_clock_freq_detect_bias, 0, kreg_val_type_decimal);
  269. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_trigger_edge_select", reg::sys_clock_trigger_edge_select, 0, kreg_val_type_decimal);
  270. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_infreq_detect", reg::sys_clock_infreq_detect, 0, kreg_val_type_decimal);
  271. push_reg(ui->gridLayoutWidget, regoff++, "sys_clock_outfreq_detect", reg::sys_clock_outfreq_detect, 0, kreg_val_type_decimal);
  272. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_module", reg::record_sig_gen_module, 0, kreg_val_type_hex);
  273. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_ctrl_control_mode", reg::record_sig_gen_ctrl_control_mode, 0, kreg_val_type_decimal);
  274. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_timecode_start0", reg::record_sig_gen_timecode_start0, 0, kreg_val_type_decimal);
  275. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_timecode_start1", reg::record_sig_gen_timecode_start1, 0, kreg_val_type_decimal);
  276. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_timecode_stop0", reg::record_sig_gen_timecode_stop0, 0, kreg_val_type_decimal);
  277. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_timecode_stop1", reg::record_sig_gen_timecode_stop1, 0, kreg_val_type_decimal);
  278. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_timecode_control_flag", reg::record_sig_gen_timecode_control_flag, 0, kreg_val_type_decimal);
  279. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_ttlin_trigger_sig_source", reg::record_sig_gen_ttlin_trigger_sig_source, 0, kreg_val_type_decimal);
  280. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_ttlin_trigger_level", reg::record_sig_gen_ttlin_trigger_level, 0, kreg_val_type_decimal);
  281. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_manual_ctrl", reg::record_sig_gen_manual_ctrl, 0, kreg_val_type_decimal);
  282. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_timecode_snapshot0", reg::record_sig_gen_timecode_snapshot0, 0, kreg_val_type_decimal);
  283. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_timecode_snapshot1", reg::record_sig_gen_timecode_snapshot1, 0, kreg_val_type_decimal);
  284. push_reg(ui->gridLayoutWidget, regoff++, "record_sig_gen_record_state", reg::record_sig_gen_record_state, 0, kreg_val_type_decimal);
  285. push_reg(ui->gridLayoutWidget, regoff++, "camera_sync_module", reg::camera_sync_module, 0, kreg_val_type_hex);
  286. push_reg(ui->gridLayoutWidget, regoff++, "camera_sync_pulse_mode_valid_len", reg::camera_sync_pulse_mode_valid_len, 0, kreg_val_type_decimal);
  287. push_reg(ui->gridLayoutWidget, regoff++, "delayer_module", reg::delayer_module, 0, kreg_val_type_hex);
  288. push_reg(ui->gridLayoutWidget, regoff++, "delayer_delay_sig_index", reg::delayer_delay_sig_index, 0, kreg_val_type_decimal);
  289. push_reg(ui->gridLayoutWidget, regoff++, "delayer_delay_us", reg::delayer_delay_us, 0, kreg_val_type_decimal);
  290. auto qrect = ui->gridLayoutWidget->geometry();
  291. qrect.setHeight(31 * regoff - 1);
  292. ui->scrollAreaWidgetContents->setMinimumHeight(31 * (regoff + 10) - 1);
  293. ui->gridLayoutWidget->setGeometry(qrect);
  294. }
  295. //
  296. void MainWindow::UI_TimecodePageConstruct() {
  297. ui->InternalTimecode_Format->clear();
  298. for (auto &str : TimecodeFormatStrSet()) {
  299. ui->InternalTimecode_Format->addItem(QString::fromStdString(str));
  300. }
  301. ui->ExternalTimecode_Format->clear();
  302. for (auto &str : TimecodeFormatStrSet()) {
  303. ui->ExternalTimecode_Format->addItem(QString::fromStdString(str));
  304. }
  305. ui->ExternalTimecode_Source->clear();
  306. ui->ExternalTimecode_Source->addItem(QString::fromStdString(InputInterface2Str(INPUT_IF_TIMECODE_BNC)));
  307. ui->ExternalTimecode_Source->addItem(QString::fromStdString(InputInterface2Str(INPUT_IF_TIMECODE_HEADPHONE)));
  308. ui->ExternalTimecode_Source->addItem(QString::fromStdString(InputInterface2Str(INPUT_IF_OFF)));
  309. ui->SysTimecode_Source->clear();
  310. ui->SysTimecode_Source->addItem(QString::fromStdString("0"));
  311. ui->SysTimecode_Source->addItem(QString::fromStdString("1"));
  312. }
  313. // void MainWindow::UI_CameraSyncPacketGeneratorModuleConstruct() {
  314. // ui->CameraSyncPacketGeneratorModule_TriggerSig->clear();
  315. // for (auto &str : camera_sync_packet_generator_module::TriggerSigTypeStrSet()) {
  316. // ui->CameraSyncPacketGeneratorModule_TriggerSig->addItem(QString::fromStdString(str));
  317. // }
  318. // }
  319. void MainWindow::UI_TTLPageConstruct() {
  320. QStringList list;
  321. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_LOGIC0)));
  322. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_LOGIC1)));
  323. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN1)));
  324. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN2)));
  325. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN3)));
  326. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN4)));
  327. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_SYS_CLK_OUTPUT)));
  328. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_SYS_GENLOCK_OUTPUT)));
  329. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_SYS_TIMECODE_FREQ_OUTPUT)));
  330. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_BUSINESS_RECORD_SIG)));
  331. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG)));
  332. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_BUSINESS_RECORD_EN_RSING_EDGE)));
  333. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_BUSINESS_RECORD_EN_FALLING_EDGE)));
  334. list.push_back(QString::fromStdString(SignalType2Str(SIGNAL_BUSINESS_RECORD_EN_EDGE)));
  335. ui->TTLOutputModule_SrcSigType_1->clear();
  336. ui->TTLOutputModule_SrcSigType_1->addItems(list);
  337. ui->TTLOutputModule_SrcSigType_2->clear();
  338. ui->TTLOutputModule_SrcSigType_2->addItems(list);
  339. ui->TTLOutputModule_SrcSigType_3->clear();
  340. ui->TTLOutputModule_SrcSigType_3->addItems(list);
  341. ui->TTLOutputModule_SrcSigType_4->clear();
  342. ui->TTLOutputModule_SrcSigType_4->addItems(list);
  343. ui->TTLOutputModule_TriggerEdge_1->clear();
  344. ui->TTLOutputModule_TriggerEdge_1->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_RISING)));
  345. ui->TTLOutputModule_TriggerEdge_1->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_FALLING)));
  346. ui->TTLOutputModule_TriggerEdge_1->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_BOTH)));
  347. ui->TTLOutputModule_TriggerEdge_2->clear();
  348. ui->TTLOutputModule_TriggerEdge_2->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_RISING)));
  349. ui->TTLOutputModule_TriggerEdge_2->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_FALLING)));
  350. ui->TTLOutputModule_TriggerEdge_2->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_BOTH)));
  351. ui->TTLOutputModule_TriggerEdge_3->clear();
  352. ui->TTLOutputModule_TriggerEdge_3->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_RISING)));
  353. ui->TTLOutputModule_TriggerEdge_3->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_FALLING)));
  354. ui->TTLOutputModule_TriggerEdge_3->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_BOTH)));
  355. ui->TTLOutputModule_TriggerEdge_4->clear();
  356. ui->TTLOutputModule_TriggerEdge_4->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_RISING)));
  357. ui->TTLOutputModule_TriggerEdge_4->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_FALLING)));
  358. ui->TTLOutputModule_TriggerEdge_4->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_BOTH)));
  359. }
  360. void MainWindow::UI_GenlockPageConstruct() {
  361. //
  362. // ui->ExternalGenlock_Source->clear();
  363. ui->InternalGenlock_Format->clear();
  364. for (auto &str : GenlockFormatStrSet()) {
  365. ui->InternalGenlock_Format->addItem(QString::fromStdString(str));
  366. }
  367. ui->SysGenlock_Src->clear();
  368. ui->SysGenlock_Src->addItem(QString::fromStdString("0"));
  369. ui->SysGenlock_Src->addItem(QString::fromStdString("1"));
  370. }
  371. void MainWindow::UI_SysClockPageConstruct() {
  372. ui->SysClock_Src->clear();
  373. ui->SysClock_Src->addItem(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN1)));
  374. ui->SysClock_Src->addItem(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN2)));
  375. ui->SysClock_Src->addItem(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN3)));
  376. ui->SysClock_Src->addItem(QString::fromStdString(SignalType2Str(SIGNAL_TTLIN4)));
  377. ui->SysClock_Src->addItem(QString::fromStdString(SignalType2Str(SIGNAL_INTERNAL_CLOCK_SIG)));
  378. ui->SysClock_Src->addItem(QString::fromStdString(SignalType2Str(SIGNAL_SYS_GENLOCK_OUTPUT)));
  379. ui->SysClock_Src->addItem(QString::fromStdString(SignalType2Str(SIGNAL_SYS_TIMECODE_FREQ_OUTPUT)));
  380. ui->SysClock_TriggerEdge->clear();
  381. ui->SysClock_TriggerEdge->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_RISING)));
  382. ui->SysClock_TriggerEdge->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_FALLING)));
  383. ui->SysClock_TriggerEdge->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_BOTH)));
  384. }
  385. void MainWindow::UI_RecordSigGenConstruct() {
  386. ui->RecordSigGenerator_ContrlMode->clear();
  387. ui->RecordSigGenerator_ContrlMode->addItem(QString::fromStdString(ControlMode2Str(CONTROLMODE_MANUAL_TRIGGER)));
  388. ui->RecordSigGenerator_ContrlMode->addItem(QString::fromStdString(ControlMode2Str(CONTROLMODE_TIMECODE_TRIGGER)));
  389. ui->RecordSigGenerator_ContrlMode->addItem(QString::fromStdString(ControlMode2Str(CONTROLMODE_EXTERNALTTL_TRIGGER)));
  390. ui->RecordSigGenerator_ContrlMode->addItem(QString::fromStdString(ControlMode2Str(CONTROLMODE_EXTERNALTTL_EDGE_TRIGGER)));
  391. ui->RecordSigGenerator_ExternalTTLTriggerSrc->clear();
  392. ui->RecordSigGenerator_ExternalTTLTriggerSrc->addItem(QString::fromStdString(InputInterface2Str(INPUT_IF_TTL1)));
  393. ui->RecordSigGenerator_ExternalTTLTriggerSrc->addItem(QString::fromStdString(InputInterface2Str(INPUT_IF_TTL2)));
  394. ui->RecordSigGenerator_ExternalTTLTriggerSrc->addItem(QString::fromStdString(InputInterface2Str(INPUT_IF_TTL3)));
  395. ui->RecordSigGenerator_ExternalTTLTriggerSrc->addItem(QString::fromStdString(InputInterface2Str(INPUT_IF_TTL4)));
  396. ui->RecordSigGenerator_TriggerEdge->clear();
  397. ui->RecordSigGenerator_TriggerEdge->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_RISING)));
  398. ui->RecordSigGenerator_TriggerEdge->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_FALLING)));
  399. ui->RecordSigGenerator_TriggerEdge->addItem(QString::fromStdString(TriggerEdge2Str(TRIGGER_EDGE_BOTH)));
  400. }
  401. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
  402. ui->setupUi(this);
  403. m_mainWindow = this;
  404. /**
  405. * @brief UI
  406. */
  407. construct_reg_table();
  408. qInstallMessageHandler(log_output);
  409. UI_TimecodePageConstruct();
  410. // UI_CameraSyncPacketGeneratorModuleConstruct();
  411. UI_TTLPageConstruct();
  412. UI_GenlockPageConstruct();
  413. UI_SysClockPageConstruct();
  414. UI_RecordSigGenConstruct();
  415. /*******************************************************************************
  416. * *
  417. *******************************************************************************/
  418. qRegisterMetaType<int32_t>("int32_t");
  419. qRegisterMetaType<uint32_t>("uint32_t");
  420. qRegisterMetaType<function<void()>>("function<void()>");
  421. qRegisterMetaType<QFunction>("QFunction");
  422. XSyncUdpFactoryImpl::Ins()->initialize();
  423. connect(this, SIGNAL(append_log_signal(QString)), this, SLOT(append_log_slot(QString)));
  424. connect(this, SIGNAL(updateUI_timeCodeInfo_signal(QString)), this, SLOT(updateUI_timeCodeInfo_slot(QString)));
  425. connect(this, SIGNAL(updateUI_cameraSyncInfo_signal(QString)), this, SLOT(updateUI_cameraSyncInfo_slot(QString)));
  426. connect(this, SIGNAL(updateUI_reg_signal(int32_t, uint32_t)), this, SLOT(updateUI_reg_slot(int32_t, uint32_t)));
  427. connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction)));
  428. m_thread.reset(new ZQThread("test", [this]() { mainWindowsRun(); }));
  429. m_thread->start();
  430. // m_xsync.reset(new Xsync());
  431. // XsyncIns()->initialize(XSyncUdpFactoryImpl::Ins());
  432. XsyncInit(XSyncUdpFactoryImpl::Ins());
  433. xsync_config_t config = {0};
  434. config.listenCameraSyncPacket = true;
  435. XsyncIns()->initialize(&config);
  436. XsyncIns()->registerOnConnectStateChangeCallback([this](bool state, string targetIp) {
  437. ZLOGI(TAG, "targetIp:%s,state:%d", targetIp.c_str(), state);
  438. if (state) {
  439. string sn;
  440. XsyncIns()->readSn(sn);
  441. version_t sdkverion;
  442. version_t armverion;
  443. version_t fpgaverion;
  444. XsyncIns()->readSDKVersion(sdkverion);
  445. XsyncIns()->readARMSoftwareVersion(armverion);
  446. XsyncIns()->readFPGASoftwareVersion(fpgaverion);
  447. ZLOGI(TAG, "sdkverion:%d.%d.%d", sdkverion.main, sdkverion.sub, sdkverion.fix);
  448. ZLOGI(TAG, "armverion:%d.%d.%d", armverion.main, armverion.sub, armverion.fix);
  449. ZLOGI(TAG, "fpgaverion:%d.%d.%d", fpgaverion.main, fpgaverion.sub, fpgaverion.fix);
  450. emit doinui_signal(QFunction([this, targetIp, sn]() {
  451. ui->IpInput->setText(QString::fromStdString(targetIp));
  452. ui->snDisplay->setText(QString::fromStdString(sn));
  453. }));
  454. } else {
  455. emit doinui_signal(QFunction([this, targetIp]() { ui->IpInput->setText(QString::fromStdString("disconnect")); }));
  456. }
  457. });
  458. XsyncIns()->registerOnTimecodeMsgCallback([this](XsyncTimecode_t *timecode_msg) { //
  459. XsyncTimecode_t timecode = *timecode_msg;
  460. QString text = QString(fmt("%02d:%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame, timecode.subframe));
  461. ZLOGI(TAG, "%s", text.toStdString().c_str());
  462. updateUI_timeCodeInfo_signal(text);
  463. });
  464. XsyncIns()->registerOnCameraSyncMsgCallback([this](xysnc_camera_sync_data_t *camera_sync_msg) { //
  465. xysnc_camera_sync_data_t camera_sync_data = *camera_sync_msg;
  466. ZLOGI(TAG, "SYNC:%d",camera_sync_msg->frameIndex );
  467. updateUI_cameraSyncInfo_signal(QString(fmt("%d", camera_sync_data.frameIndex)));
  468. });
  469. XsyncIns()->registerOnRecordSigChangeMsgCallback([this](uint32_t recordSig, XsyncTimecode_t *timecode_msg) { //
  470. XsyncTimecode_t timecodecpy = *timecode_msg;
  471. QString timecodeStr = QString(fmt("%02d:%02d:%02d:%02d", timecodecpy.hour, timecodecpy.minute, timecodecpy.second, timecodecpy.frame));
  472. emit doinui_signal(QFunction([this, recordSig, timecodeStr]() {
  473. ui->WorkState->setText(QString::number(recordSig));
  474. ui->WorkState_Timecode->setText(timecodeStr);
  475. }));
  476. });
  477. }
  478. MainWindow::~MainWindow() { delete ui; }
  479. #define XS_ASSERT(exptr) \
  480. { \
  481. auto ecode = exptr; \
  482. while (!(ecode == kxs_ec_success)) { \
  483. ZLOGE(TAG, "do: %s fail,ecode:%d", #exptr, ecode); \
  484. ZQThread::sleep(1); \
  485. } \
  486. }
  487. void MainWindow::on_RefreshRegsButton_clicked() { //
  488. ZLOGI(TAG, "on_refreshRegsButton_clicked");
  489. // int32_t _t1, uint32_t _t2
  490. QtConcurrent::run([this]() {
  491. bool suc = true;
  492. for (auto &reg : m_regdisplayer) {
  493. uint32_t regValue = 0;
  494. auto ecode = XsyncIns()->reg_read(reg.first, regValue);
  495. int regoff = reg.first;
  496. if (ecode == kxs_ec_success) {
  497. ZLOGI(TAG, "reg_read %x success", reg.first);
  498. m_regdisplayer[regoff]->regvalcache = regValue;
  499. emit doinui_signal(QFunction([this, regoff, regValue]() { updateUI_reg(regoff); }));
  500. } else {
  501. emit doinui_signal(QFunction([this, regoff, regValue]() {
  502. m_regdisplayer[regoff]->regvalcache = 0;
  503. m_regdisplayer[regoff]->regBrowser->setText("error");
  504. }));
  505. }
  506. }
  507. });
  508. }
  509. void MainWindow::on_ClearLogButton_clicked() { //
  510. ui->logbrowser->clear();
  511. }
  512. void MainWindow::on_Connect2XsyncButton_clicked() { //
  513. // XsyncIns()->changeXsyncIp(ui->IpInput->text().toStdString());
  514. }
  515. void MainWindow::mainWindowsRun() { //
  516. }
  517. #define DO_XSYNC_FUNC(exptr) \
  518. { \
  519. auto ecode = exptr; \
  520. if (!(ecode == kxs_ec_success)) { \
  521. ZLOGE(TAG, "do: %s fail,ecode:[%d](%s)", #exptr, ecode, xs_error_code_2_str(ecode)); \
  522. return; \
  523. } else { \
  524. } \
  525. }
  526. void MainWindow::on_TimecodePage_Read_clicked() {
  527. TimecodeFormat_t InternalTimecode_Format;
  528. XsyncTimecode_t InternalTimecode_Code;
  529. float InternalTimecode_Freq;
  530. TimecodeFormat_t ExternalTimecode_Format;
  531. InputInterface_t ExternalTimecode_Source;
  532. XsyncTimecode_t ExternalTimecode_Code;
  533. float ExternalTimecode_Freq;
  534. uint32_t SysTimecode_Source;
  535. TimecodeFormat_t SysTimecode_Format;
  536. XsyncTimecode_t SysTimecode_Code;
  537. float SysTimecode_Freq;
  538. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_getFormat(InternalTimecode_Format));
  539. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_getCode(InternalTimecode_Code));
  540. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_readFreq(InternalTimecode_Freq));
  541. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readFormat(ExternalTimecode_Format));
  542. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readSrc(ExternalTimecode_Source));
  543. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readCode(ExternalTimecode_Code));
  544. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readFreq(ExternalTimecode_Freq));
  545. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_getSource(SysTimecode_Source));
  546. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_readFormat(SysTimecode_Format));
  547. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_readCode(SysTimecode_Code));
  548. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_readFreq(SysTimecode_Freq));
  549. ui->InternalTimecode_Format->setCurrentText(QString::fromStdString(TimecodeFormatToStr(InternalTimecode_Format)));
  550. ui->InternalTimecode_Code->setText(QString(XsyncTimecodeToStr(InternalTimecode_Code).c_str()));
  551. ui->InternalTimecode_Freq->setText(QString::number(InternalTimecode_Freq, 'f', 2));
  552. ui->ExternalTimecode_Format->setCurrentText(QString::fromStdString(TimecodeFormatToStr(ExternalTimecode_Format)));
  553. ui->ExternalTimecode_Source->setCurrentText(QString::fromStdString(InputInterface2Str(ExternalTimecode_Source)));
  554. ui->ExternalTimecode_Code->setText(QString(XsyncTimecodeToStr(ExternalTimecode_Code).c_str()));
  555. ui->ExternalTimecode_Freq->setText(QString::number(ExternalTimecode_Freq, 'f', 2));
  556. ui->SysTimecode_Source->setCurrentText(QString::number(SysTimecode_Source));
  557. ui->SysTimecode_Format->setText(QString::fromStdString(TimecodeFormatToStr(SysTimecode_Format)));
  558. ui->SysTimecode_Code->setText(QString(XsyncTimecodeToStr(SysTimecode_Code).c_str()));
  559. ui->SysTimecode_Freq->setText(QString::number(SysTimecode_Freq, 'f', 2));
  560. }
  561. void MainWindow::on_TimecodePage_Update_clicked() {
  562. TimecodeFormat_t InternalTimecode_Format = Str2TimecodeFormat(ui->InternalTimecode_Format->currentText().toStdString());
  563. XsyncTimecode_t InternalTimecode_Code = Str2XsyncTimecode(ui->InternalTimecode_Code->text().toStdString());
  564. TimecodeFormat_t ExternalTimecode_Format = Str2TimecodeFormat(ui->ExternalTimecode_Format->currentText().toStdString());
  565. InputInterface_t ExternalTimecode_Source = Str2InputInterface(ui->ExternalTimecode_Source->currentText().toStdString());
  566. uint32_t SysTimecode_Source = ui->SysTimecode_Source->currentText().toInt();
  567. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_setFormat(InternalTimecode_Format));
  568. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_setCode(InternalTimecode_Code));
  569. // DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_setFormat(ExternalTimecode_Format));
  570. // DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_setSource(ExternalTimecode_Source));
  571. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_setSource(SysTimecode_Source));
  572. }
  573. // void MainWindow::on_CameraSyncPacketGeneratorModule_ClearPacketIndex_clicked() {
  574. // DO_XSYNC_FUNC(XsyncIns()->CameraSyncPacketGeneratorModule_clearPacketIndex());
  575. // on_CameraSyncPacketGeneratorModule_Read_clicked();
  576. // }
  577. void MainWindow::on_tabWidget_currentChanged(int index) {
  578. on_RefreshRegsButton_clicked();
  579. on_TimecodePage_Read_clicked();
  580. on_TTLPage_Read_clicked();
  581. on_GenlockPage_Read_clicked();
  582. on_SysClockPage_Read_clicked();
  583. on_RecordSigGen_Read_clicked();
  584. }
  585. void MainWindow::on_TTLPage_Read_clicked() {
  586. /*******************************************************************************
  587. * TTL输入页面 *
  588. *******************************************************************************/
  589. {
  590. float freq1 = 0;
  591. float freq2 = 0;
  592. float freq3 = 0;
  593. float freq4 = 0;
  594. bool En;
  595. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule1_detectFreq(freq1));
  596. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule2_detectFreq(freq2));
  597. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule3_detectFreq(freq3));
  598. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule4_detectFreq(freq4));
  599. ui->TTLinModule_ttl_freq_1->setText(QString::number(freq1, 'f', 2));
  600. ui->TTLinModule_ttl_freq_2->setText(QString::number(freq2, 'f', 2));
  601. ui->TTLinModule_ttl_freq_3->setText(QString::number(freq3, 'f', 2));
  602. ui->TTLinModule_ttl_freq_4->setText(QString::number(freq4, 'f', 2));
  603. }
  604. /*******************************************************************************
  605. * TTL输出组件 *
  606. *******************************************************************************/
  607. SignalType_t source;
  608. TriggerEdge_t edge;
  609. uint32_t div;
  610. uint32_t multi;
  611. uint32_t PluseWidth;
  612. uint32_t OffsetTime;
  613. uint32_t outPolarity;
  614. float infreq;
  615. float outfreq;
  616. {
  617. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(1, source));
  618. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(1, edge));
  619. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(1, div));
  620. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(1, multi));
  621. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(1, PluseWidth));
  622. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(1, OffsetTime));
  623. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(1, outPolarity));
  624. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(1, infreq));
  625. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(1, outfreq));
  626. ui->TTLOutputModule_SrcSigType_1->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  627. ui->TTLOutputModule_TriggerEdge_1->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  628. ui->TTLOutputModule_FreqDivision_1->setText(QString::number(div));
  629. ui->TTLOutputModule_FreqMultiplication_1->setText(QString::number(multi));
  630. ui->TTLOutputModule_PluseWidth_1->setText(QString::number(PluseWidth));
  631. ui->TTLOutputModule_OffsetTime_1->setText(QString::number(OffsetTime));
  632. ui->TTLOutputModule_Polarity_1->setText(QString::number(outPolarity));
  633. ui->TTLOutputModule_InFreq_1->setText(QString::number(infreq, 'f', 2));
  634. ui->TTLOutputModule_OutFreq_1->setText(QString::number(outfreq, 'f', 2));
  635. }
  636. {
  637. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(2, source));
  638. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(2, edge));
  639. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(2, div));
  640. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(2, multi));
  641. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(2, PluseWidth));
  642. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(2, OffsetTime));
  643. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(2, outPolarity));
  644. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(2, infreq));
  645. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(2, outfreq));
  646. ui->TTLOutputModule_SrcSigType_2->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  647. ui->TTLOutputModule_TriggerEdge_2->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  648. ui->TTLOutputModule_FreqDivision_2->setText(QString::number(div));
  649. ui->TTLOutputModule_FreqMultiplication_2->setText(QString::number(multi));
  650. ui->TTLOutputModule_PluseWidth_2->setText(QString::number(PluseWidth));
  651. ui->TTLOutputModule_OffsetTime_2->setText(QString::number(OffsetTime));
  652. ui->TTLOutputModule_Polarity_2->setText(QString::number(outPolarity));
  653. ui->TTLOutputModule_InFreq_2->setText(QString::number(infreq, 'f', 2));
  654. ui->TTLOutputModule_OutFreq_2->setText(QString::number(outfreq, 'f', 2));
  655. }
  656. {
  657. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(3, source));
  658. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(3, edge));
  659. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(3, div));
  660. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(3, multi));
  661. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(3, PluseWidth));
  662. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(3, OffsetTime));
  663. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(3, outPolarity));
  664. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(3, infreq));
  665. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(3, outfreq));
  666. ui->TTLOutputModule_SrcSigType_3->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  667. ui->TTLOutputModule_TriggerEdge_3->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  668. ui->TTLOutputModule_FreqDivision_3->setText(QString::number(div));
  669. ui->TTLOutputModule_FreqMultiplication_3->setText(QString::number(multi));
  670. ui->TTLOutputModule_PluseWidth_3->setText(QString::number(PluseWidth));
  671. ui->TTLOutputModule_OffsetTime_3->setText(QString::number(OffsetTime));
  672. ui->TTLOutputModule_Polarity_3->setText(QString::number(outPolarity));
  673. ui->TTLOutputModule_InFreq_3->setText(QString::number(infreq, 'f', 2));
  674. ui->TTLOutputModule_OutFreq_3->setText(QString::number(outfreq, 'f', 2));
  675. }
  676. {
  677. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(4, source));
  678. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(4, edge));
  679. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(4, div));
  680. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(4, multi));
  681. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(4, PluseWidth));
  682. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(4, OffsetTime));
  683. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(4, outPolarity));
  684. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(4, infreq));
  685. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(4, outfreq));
  686. ui->TTLOutputModule_SrcSigType_4->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  687. ui->TTLOutputModule_TriggerEdge_4->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  688. ui->TTLOutputModule_FreqDivision_4->setText(QString::number(div));
  689. ui->TTLOutputModule_FreqMultiplication_4->setText(QString::number(multi));
  690. ui->TTLOutputModule_PluseWidth_4->setText(QString::number(PluseWidth));
  691. ui->TTLOutputModule_OffsetTime_4->setText(QString::number(OffsetTime));
  692. ui->TTLOutputModule_Polarity_4->setText(QString::number(outPolarity));
  693. ui->TTLOutputModule_InFreq_4->setText(QString::number(infreq, 'f', 2));
  694. ui->TTLOutputModule_OutFreq_4->setText(QString::number(outfreq, 'f', 2));
  695. }
  696. }
  697. void MainWindow::on_TTLPage_Write_clicked() {
  698. {
  699. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_1->currentText().toStdString());
  700. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_1->currentText().toStdString());
  701. auto div = ui->TTLOutputModule_FreqDivision_1->text().toUInt();
  702. auto multi = ui->TTLOutputModule_FreqMultiplication_1->text().toUInt();
  703. auto PluseWidth = ui->TTLOutputModule_PluseWidth_1->text().toUInt();
  704. auto OffsetTime = ui->TTLOutputModule_OffsetTime_1->text().toUInt();
  705. auto outPolarity = ui->TTLOutputModule_Polarity_1->text().toUInt();
  706. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(1, source));
  707. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(1, edge));
  708. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(1, div));
  709. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(1, multi));
  710. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(1, PluseWidth));
  711. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(1, OffsetTime));
  712. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(1, outPolarity));
  713. }
  714. {
  715. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_2->currentText().toStdString());
  716. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_2->currentText().toStdString());
  717. auto div = ui->TTLOutputModule_FreqDivision_2->text().toUInt();
  718. auto multi = ui->TTLOutputModule_FreqMultiplication_2->text().toUInt();
  719. auto PluseWidth = ui->TTLOutputModule_PluseWidth_2->text().toUInt();
  720. auto OffsetTime = ui->TTLOutputModule_OffsetTime_2->text().toUInt();
  721. auto outPolarity = ui->TTLOutputModule_Polarity_2->text().toUInt();
  722. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(2, source));
  723. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(2, edge));
  724. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(2, div));
  725. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(2, multi));
  726. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(2, PluseWidth));
  727. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(2, OffsetTime));
  728. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(2, outPolarity));
  729. }
  730. {
  731. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_3->currentText().toStdString());
  732. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_3->currentText().toStdString());
  733. auto div = ui->TTLOutputModule_FreqDivision_3->text().toUInt();
  734. auto multi = ui->TTLOutputModule_FreqMultiplication_3->text().toUInt();
  735. auto PluseWidth = ui->TTLOutputModule_PluseWidth_3->text().toUInt();
  736. auto OffsetTime = ui->TTLOutputModule_OffsetTime_3->text().toUInt();
  737. auto outPolarity = ui->TTLOutputModule_Polarity_3->text().toUInt();
  738. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(3, source));
  739. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(3, edge));
  740. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(3, div));
  741. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(3, multi));
  742. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(3, PluseWidth));
  743. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(3, OffsetTime));
  744. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(3, outPolarity));
  745. }
  746. {
  747. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_4->currentText().toStdString());
  748. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_4->currentText().toStdString());
  749. auto div = ui->TTLOutputModule_FreqDivision_4->text().toUInt();
  750. auto multi = ui->TTLOutputModule_FreqMultiplication_4->text().toUInt();
  751. auto PluseWidth = ui->TTLOutputModule_PluseWidth_4->text().toUInt();
  752. auto OffsetTime = ui->TTLOutputModule_OffsetTime_4->text().toUInt();
  753. auto outPolarity = ui->TTLOutputModule_Polarity_4->text().toUInt();
  754. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(4, source));
  755. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(4, edge));
  756. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(4, div));
  757. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(4, multi));
  758. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(4, PluseWidth));
  759. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(4, OffsetTime));
  760. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(4, outPolarity));
  761. }
  762. }
  763. void MainWindow::on_GenlockPage_Read_clicked() {
  764. {
  765. GenlockFormat_t format;
  766. DO_XSYNC_FUNC(XsyncIns()->InternalGenlock_getFormat(format));
  767. ui->InternalGenlock_Format->setCurrentText(QString::fromStdString(GenlockFormatToStr(format)));
  768. }
  769. {
  770. float freq;
  771. DO_XSYNC_FUNC(XsyncIns()->InternalGenlock_readFreq(freq));
  772. ui->InternalGenlock_Freq->setText(QString::number(freq, 'f', 2));
  773. }
  774. {
  775. float freq;
  776. DO_XSYNC_FUNC(XsyncIns()->ExternalGenlock_detectFreq(freq));
  777. ui->ExternalGenlock_Freq->setText(QString::number(freq, 'f', 2));
  778. }
  779. {
  780. uint32_t src;
  781. DO_XSYNC_FUNC(XsyncIns()->SysGenlock_getSrc(src));
  782. ui->SysGenlock_Src->setCurrentText(QString::number(src));
  783. }
  784. {
  785. float freq;
  786. DO_XSYNC_FUNC(XsyncIns()->SysGenlock_readFreq(freq));
  787. ui->SysGenlock_Freq->setText(QString::number(freq, 'f', 2));
  788. }
  789. }
  790. void MainWindow::on_GenlockPage_Write_clicked() {
  791. {
  792. auto format = Str2GenlockFormat(ui->InternalGenlock_Format->currentText().toStdString());
  793. DO_XSYNC_FUNC(XsyncIns()->InternalGenlock_setFormat(format));
  794. }
  795. {
  796. auto src = ui->SysGenlock_Src->currentText().toUInt();
  797. DO_XSYNC_FUNC(XsyncIns()->SysGenlock_setSrc(src));
  798. }
  799. }
  800. void MainWindow::on_SysClockPage_Read_clicked() {
  801. {
  802. float freq;
  803. DO_XSYNC_FUNC(XsyncIns()->InternalClock_getFreq(freq));
  804. ui->InternalClock_Freq->setText(QString::number(freq, 'f', 2));
  805. }
  806. {
  807. float freq;
  808. DO_XSYNC_FUNC(XsyncIns()->InternalClock_readOutFreq(freq));
  809. ui->InternalClock_OutFreq->setText(QString::number(freq, 'f', 2));
  810. }
  811. {
  812. SignalType_t src;
  813. DO_XSYNC_FUNC(XsyncIns()->SysClock_getSrc(src));
  814. ui->SysClock_Src->setCurrentText(QString::fromStdString(SignalType2Str(src)));
  815. }
  816. {
  817. uint32_t div;
  818. DO_XSYNC_FUNC(XsyncIns()->SysClock_geFreqtDivision(div));
  819. ui->SysClock_FreqtDivision->setText(QString::number(div));
  820. }
  821. {
  822. uint32_t multi;
  823. DO_XSYNC_FUNC(XsyncIns()->SysClock_getFreqMultiplication(multi));
  824. ui->SysClock_FreqMultiplication->setText(QString::number(multi));
  825. }
  826. {
  827. float freq;
  828. DO_XSYNC_FUNC(XsyncIns()->SysClock_readInSigFreq(freq));
  829. ui->SysClock_InSigFreq->setText(QString::number(freq, 'f', 2));
  830. }
  831. {
  832. float freq;
  833. DO_XSYNC_FUNC(XsyncIns()->SysClock_readOutSigFreq(freq));
  834. ui->SysClock_OutSigFreq->setText(QString::number(freq, 'f', 2));
  835. }
  836. {
  837. TriggerEdge_t edge;
  838. DO_XSYNC_FUNC(XsyncIns()->SysClock_getTriggerEdge(edge));
  839. ui->SysClock_TriggerEdge->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  840. }
  841. }
  842. void MainWindow::on_SysClockPage_Wirte_clicked() {
  843. {
  844. auto freq = ui->InternalClock_Freq->text().toFloat();
  845. DO_XSYNC_FUNC(XsyncIns()->InternalClock_setFreq(freq));
  846. }
  847. {
  848. auto src = Str2SignalType(ui->SysClock_Src->currentText().toStdString());
  849. DO_XSYNC_FUNC(XsyncIns()->SysClock_setSrc(src));
  850. }
  851. {
  852. auto div = ui->SysClock_FreqtDivision->text().toUInt();
  853. DO_XSYNC_FUNC(XsyncIns()->SysClock_setFreqDivision(div));
  854. }
  855. {
  856. auto multi = ui->SysClock_FreqMultiplication->text().toUInt();
  857. DO_XSYNC_FUNC(XsyncIns()->SysClock_setFreqMultiplication(multi));
  858. }
  859. {
  860. TriggerEdge_t edge = Str2TriggerEdge(ui->SysClock_TriggerEdge->currentText().toStdString());
  861. DO_XSYNC_FUNC(XsyncIns()->SysClock_setTriggerEdge(edge));
  862. }
  863. }
  864. void MainWindow::on_RecordSigGen_Read_clicked() {
  865. ControlMode_t mode;
  866. XsyncTimecode_t autoStartTimecode;
  867. XsyncTimecode_t autoStopTimecode;
  868. uint32_t autoStart;
  869. uint32_t autoStop;
  870. InputInterface_t ttlPortNum;
  871. uint32_t polarity;
  872. uint32_t exposureTime;
  873. uint32_t exposureOffsetTime;
  874. uint32_t state;
  875. XsyncTimecode_t timecode_snapshot;
  876. TriggerEdge_t edge;
  877. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getContrlMode(mode));
  878. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getAutoStartTimecode(autoStartTimecode));
  879. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getAutoStopTimecode(autoStopTimecode));
  880. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getTimecodeCtrlFlag(autoStart, autoStop));
  881. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getExternalTTLTriggerSrc(ttlPortNum));
  882. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getExternalTTLTriggerPolarity(polarity));
  883. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getRecordState(state));
  884. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_readTimecodeSnapshot(timecode_snapshot));
  885. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getTriggerEdge(edge));
  886. ui->RecordSigGenerator_ContrlMode->setCurrentText(QString::fromStdString(ControlMode2Str(mode)));
  887. ui->RecordSigGenerator_AutoStartTimecode->setText(QString(XsyncTimecodeToStr(autoStartTimecode).c_str()));
  888. ui->RecordSigGenerator_AutoStopTimecode->setText(QString(XsyncTimecodeToStr(autoStopTimecode).c_str()));
  889. ui->RecordSigGenerator_TimecodeCtrlFlag0->setChecked(autoStart);
  890. ui->RecordSigGenerator_TimecodeCtrlFlag1->setChecked(autoStop);
  891. ui->RecordSigGenerator_ExternalTTLTriggerSrc->setCurrentText(QString::fromStdString(InputInterface2Str(ttlPortNum)));
  892. ui->RecordSigGenerator_ExternalTTLTriggerPolarity->setText(QString::number(polarity));
  893. ui->RecordSigGenerator_TriggerEdge->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  894. // ui->RecordSigGenerator_RecordExposureTime->setText(QString::number(exposureTime));
  895. // ui->RecordSigGenerator_RecordExposureOffsetTime->setText(QString::number(exposureOffsetTime));
  896. ui->RecordSigGenerator_RecordState->setText(QString::number(state));
  897. ui->RecordSigGenerator_TimecodeSnapshot->setText(QString(XsyncTimecodeToStr(timecode_snapshot).c_str()));
  898. }
  899. void MainWindow::on_RecordSigGen_Write_clicked() {
  900. ControlMode_t mode = Str2ControlMode(ui->RecordSigGenerator_ContrlMode->currentText().toStdString());
  901. uint32_t autoStart = ui->RecordSigGenerator_TimecodeCtrlFlag0->isChecked();
  902. uint32_t autoStop = ui->RecordSigGenerator_TimecodeCtrlFlag1->isChecked();
  903. InputInterface_t ttlPortNum = Str2InputInterface(ui->RecordSigGenerator_ExternalTTLTriggerSrc->currentText().toStdString());
  904. uint32_t polarity = ui->RecordSigGenerator_ExternalTTLTriggerPolarity->text().toUInt();
  905. TriggerEdge_t edge = Str2TriggerEdge(ui->RecordSigGenerator_TriggerEdge->currentText().toStdString());
  906. static XsyncTimecode_t autoStopTimecode;
  907. Str2XsyncTimecode(ui->RecordSigGenerator_AutoStopTimecode->text().toStdString(), autoStopTimecode);
  908. static XsyncTimecode_t autoStartTimecode;
  909. Str2XsyncTimecode(ui->RecordSigGenerator_AutoStartTimecode->text().toStdString(), autoStartTimecode);
  910. ZLOGI(TAG, "............. %s", ui->RecordSigGenerator_AutoStartTimecode->text().toStdString().c_str());
  911. ZLOGI(TAG, "............. %s", ui->RecordSigGenerator_AutoStopTimecode->text().toStdString().c_str());
  912. ZLOGI(TAG, "1 %d %d %d %d %d ", autoStartTimecode.hour, autoStartTimecode.minute, autoStartTimecode.second, autoStartTimecode.frame, autoStartTimecode.subframe);
  913. ZLOGI(TAG, "2 %d %d %d %d %d ", autoStopTimecode.hour, autoStopTimecode.minute, autoStopTimecode.second, autoStopTimecode.frame, autoStopTimecode.subframe);
  914. // uint32_t exposureTime = ui->RecordSigGenerator_RecordExposureTime->text().toUInt();
  915. // uint32_t exposureOffsetTime = ui->RecordSigGenerator_RecordExposureOffsetTime->text().toUInt();
  916. // RecordSigGenerator_readTimecodeSnapshot
  917. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setContrlMode(mode));
  918. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setAutoStartTimecode(autoStartTimecode));
  919. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setAutoStopTimecode(autoStopTimecode));
  920. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setTimecodeCtrlFlag(autoStart, autoStop));
  921. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setExternalTTLTriggerSrc(ttlPortNum));
  922. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setExternalTTLTriggerPolarity(polarity));
  923. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setTriggerEdge(edge));
  924. // DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setRecordExposureTime(exposureTime));
  925. // DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setRecordExposureOffsetTime(exposureOffsetTime));
  926. }
  927. void MainWindow::on_RecordSigGenerator_manualStart_clicked() { DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_manualStart()); }
  928. void MainWindow::on_RecordSigGenerator_manualStop_clicked() { DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_manualStop()); }
  929. void MainWindow::on_NetworkConfig_read_clicked() {
  930. // DO_XSYNC_FUNC(XsyncIns()->changeNetworkConfig(ui->ChangeNetCfg_ip->text().toStdString(), ui->ChangeNetCfg_mask->text().toStdString(), ui->ChangeNetCfg_gateway->text().toStdString()));
  931. string ip;
  932. string mask;
  933. string gateway;
  934. NetworkMode_t mode;
  935. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_getIp(ip));
  936. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_getMask(mask));
  937. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_getGateway(gateway));
  938. DO_XSYNC_FUNC(XsyncIns()->NetworkConfig_getMode(mode));
  939. ui->NetworkConfigStaticIpMode_Ip->setText(QString::fromStdString(ip));
  940. ui->NetworkConfigStaticIpMode_Mask->setText(QString::fromStdString(mask));
  941. ui->NetworkConfigStaticIpMode_Gateway->setText(QString::fromStdString(gateway));
  942. ui->NetworkConfig_Mode->setText(QString::fromStdString(QString::number(mode).toStdString()));
  943. }
  944. void MainWindow::on_NetworkConfig_storage_clicked() {
  945. string ip = ui->NetworkConfigStaticIpMode_Ip->text().toStdString();
  946. string mask = ui->NetworkConfigStaticIpMode_Mask->text().toStdString();
  947. string gateway = ui->NetworkConfigStaticIpMode_Gateway->text().toStdString();
  948. NetworkMode_t mode = (NetworkMode_t)ui->NetworkConfig_Mode->text().toUInt();
  949. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_setIp(ip));
  950. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_setMask(mask));
  951. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_setGateway(gateway));
  952. DO_XSYNC_FUNC(XsyncIns()->NetworkConfig_setMode(mode));
  953. DO_XSYNC_FUNC(XsyncIns()->storageConfig());
  954. }
  955. void MainWindow::on_GenNewMac_clicked() { DO_XSYNC_FUNC(XsyncIns()->generatorNewMac()); }
  956. void MainWindow::on_FactoryReset_clicked() { DO_XSYNC_FUNC(XsyncIns()->factoryReset()); }
  957. void MainWindow::on_Reboot_clicked() { DO_XSYNC_FUNC(XsyncIns()->reboot()); }
  958. void MainWindow::on_InternalSigSrouce_start_clicked() { DO_XSYNC_FUNC(XsyncIns()->InternalSigSrouce_start()); }
  959. void MainWindow::on_InternalSigSrouce_stop_clicked() { DO_XSYNC_FUNC(XsyncIns()->InternalSigSrouce_stop()); }
  960. void MainWindow::on_DelayContrl_Read_clicked() {
  961. uint32_t DelayContrl_InputDelay;
  962. uint32_t DelayContrl_OutputDelay;
  963. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_getInputDelay(DelayContrl_InputDelay));
  964. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_getOutputDelay(DelayContrl_OutputDelay));
  965. ui->DelayContrl_InputDelay->setText(QString::number(DelayContrl_InputDelay));
  966. ui->DelayContrl_OutputDelay->setText(QString::number(DelayContrl_OutputDelay));
  967. }
  968. void MainWindow::on_DelayContrl_Update_clicked() {
  969. uint32_t DelayContrl_InputDelay = ui->DelayContrl_InputDelay->text().toUInt();
  970. uint32_t DelayContrl_OutputDelay = ui->DelayContrl_OutputDelay->text().toUInt();
  971. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_setInputDelay(DelayContrl_InputDelay));
  972. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_setOutputDelay(DelayContrl_OutputDelay));
  973. }