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.

1136 lines
64 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
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 = false;
  435. xs_error_code_t ecode = XsyncIns()->initialize(&config);
  436. if(ecode != kxs_ec_success){
  437. ZLOGE(TAG, "XsyncIns()->initialize fail,ecode:%d", ecode);
  438. exit(-1);
  439. }
  440. XsyncIns()->registerOnConnectStateChangeCallback([this](bool state, string targetIp) {
  441. ZLOGI(TAG, "targetIp:%s,state:%d", targetIp.c_str(), state);
  442. if (state) {
  443. string sn;
  444. XsyncIns()->readSn(sn);
  445. version_t sdkverion;
  446. version_t armverion;
  447. version_t fpgaverion;
  448. XsyncIns()->readSDKVersion(sdkverion);
  449. XsyncIns()->readARMSoftwareVersion(armverion);
  450. XsyncIns()->readFPGASoftwareVersion(fpgaverion);
  451. ZLOGI(TAG, "sdkverion:%d.%d.%d", sdkverion.main, sdkverion.sub, sdkverion.fix);
  452. ZLOGI(TAG, "armverion:%d.%d.%d", armverion.main, armverion.sub, armverion.fix);
  453. ZLOGI(TAG, "fpgaverion:%d.%d.%d", fpgaverion.main, fpgaverion.sub, fpgaverion.fix);
  454. emit doinui_signal(QFunction([this, targetIp, sn]() {
  455. ui->IpInput->setText(QString::fromStdString(targetIp));
  456. ui->snDisplay->setText(QString::fromStdString(sn));
  457. }));
  458. } else {
  459. emit doinui_signal(QFunction([this, targetIp]() { ui->IpInput->setText(QString::fromStdString("disconnect")); }));
  460. }
  461. });
  462. XsyncIns()->registerOnTimecodeMsgCallback([this](XsyncTimecode_t *timecode_msg) { //
  463. XsyncTimecode_t timecode = *timecode_msg;
  464. QString text = QString(fmt("%02d:%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame, timecode.subframe));
  465. ZLOGI(TAG, "%s", text.toStdString().c_str());
  466. updateUI_timeCodeInfo_signal(text);
  467. });
  468. XsyncIns()->registerOnCameraSyncMsgCallback([this](xysnc_camera_sync_data_t *camera_sync_msg) { //
  469. xysnc_camera_sync_data_t camera_sync_data = *camera_sync_msg;
  470. ZLOGI(TAG, "SYNC:%d",camera_sync_msg->frameIndex );
  471. updateUI_cameraSyncInfo_signal(QString(fmt("%d", camera_sync_data.frameIndex)));
  472. });
  473. XsyncIns()->registerOnRecordSigChangeMsgCallback([this](uint32_t recordSig, XsyncTimecode_t *timecode_msg) { //
  474. XsyncTimecode_t timecodecpy = *timecode_msg;
  475. QString timecodeStr = QString(fmt("%02d:%02d:%02d:%02d", timecodecpy.hour, timecodecpy.minute, timecodecpy.second, timecodecpy.frame));
  476. emit doinui_signal(QFunction([this, recordSig, timecodeStr]() {
  477. ui->WorkState->setText(QString::number(recordSig));
  478. ui->WorkState_Timecode->setText(timecodeStr);
  479. }));
  480. });
  481. }
  482. MainWindow::~MainWindow() { delete ui; }
  483. #define XS_ASSERT(exptr) \
  484. { \
  485. auto ecode = exptr; \
  486. while (!(ecode == kxs_ec_success)) { \
  487. ZLOGE(TAG, "do: %s fail,ecode:%d", #exptr, ecode); \
  488. ZQThread::sleep(1); \
  489. } \
  490. }
  491. void MainWindow::on_RefreshRegsButton_clicked() { //
  492. ZLOGI(TAG, "on_refreshRegsButton_clicked");
  493. // int32_t _t1, uint32_t _t2
  494. QtConcurrent::run([this]() {
  495. bool suc = true;
  496. for (auto &reg : m_regdisplayer) {
  497. uint32_t regValue = 0;
  498. auto ecode = XsyncIns()->reg_read(reg.first, regValue);
  499. int regoff = reg.first;
  500. if (ecode == kxs_ec_success) {
  501. ZLOGI(TAG, "reg_read %x success", reg.first);
  502. m_regdisplayer[regoff]->regvalcache = regValue;
  503. emit doinui_signal(QFunction([this, regoff, regValue]() { updateUI_reg(regoff); }));
  504. } else {
  505. emit doinui_signal(QFunction([this, regoff, regValue]() {
  506. m_regdisplayer[regoff]->regvalcache = 0;
  507. m_regdisplayer[regoff]->regBrowser->setText("error");
  508. }));
  509. }
  510. }
  511. });
  512. }
  513. void MainWindow::on_ClearLogButton_clicked() { //
  514. ui->logbrowser->clear();
  515. }
  516. void MainWindow::on_Connect2XsyncButton_clicked() { //
  517. // XsyncIns()->changeXsyncIp(ui->IpInput->text().toStdString());
  518. }
  519. void MainWindow::mainWindowsRun() { //
  520. }
  521. #define DO_XSYNC_FUNC(exptr) \
  522. { \
  523. auto ecode = exptr; \
  524. if (!(ecode == kxs_ec_success)) { \
  525. ZLOGE(TAG, "do: %s fail,ecode:[%d](%s)", #exptr, ecode, xs_error_code_2_str(ecode)); \
  526. return; \
  527. } else { \
  528. } \
  529. }
  530. void MainWindow::on_TimecodePage_Read_clicked() {
  531. TimecodeFormat_t InternalTimecode_Format;
  532. XsyncTimecode_t InternalTimecode_Code;
  533. float InternalTimecode_Freq;
  534. TimecodeFormat_t ExternalTimecode_Format;
  535. InputInterface_t ExternalTimecode_Source;
  536. XsyncTimecode_t ExternalTimecode_Code;
  537. float ExternalTimecode_Freq;
  538. uint32_t SysTimecode_Source;
  539. TimecodeFormat_t SysTimecode_Format;
  540. XsyncTimecode_t SysTimecode_Code;
  541. float SysTimecode_Freq;
  542. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_getFormat(InternalTimecode_Format));
  543. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_getCode(InternalTimecode_Code));
  544. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_readFreq(InternalTimecode_Freq));
  545. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readFormat(ExternalTimecode_Format));
  546. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readSrc(ExternalTimecode_Source));
  547. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readCode(ExternalTimecode_Code));
  548. DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_readFreq(ExternalTimecode_Freq));
  549. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_getSource(SysTimecode_Source));
  550. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_readFormat(SysTimecode_Format));
  551. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_readCode(SysTimecode_Code));
  552. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_readFreq(SysTimecode_Freq));
  553. ui->InternalTimecode_Format->setCurrentText(QString::fromStdString(TimecodeFormatToStr(InternalTimecode_Format)));
  554. ui->InternalTimecode_Code->setText(QString(XsyncTimecodeToStr(InternalTimecode_Code).c_str()));
  555. ui->InternalTimecode_Freq->setText(QString::number(InternalTimecode_Freq, 'f', 2));
  556. ui->ExternalTimecode_Format->setCurrentText(QString::fromStdString(TimecodeFormatToStr(ExternalTimecode_Format)));
  557. ui->ExternalTimecode_Source->setCurrentText(QString::fromStdString(InputInterface2Str(ExternalTimecode_Source)));
  558. ui->ExternalTimecode_Code->setText(QString(XsyncTimecodeToStr(ExternalTimecode_Code).c_str()));
  559. ui->ExternalTimecode_Freq->setText(QString::number(ExternalTimecode_Freq, 'f', 2));
  560. ui->SysTimecode_Source->setCurrentText(QString::number(SysTimecode_Source));
  561. ui->SysTimecode_Format->setText(QString::fromStdString(TimecodeFormatToStr(SysTimecode_Format)));
  562. ui->SysTimecode_Code->setText(QString(XsyncTimecodeToStr(SysTimecode_Code).c_str()));
  563. ui->SysTimecode_Freq->setText(QString::number(SysTimecode_Freq, 'f', 2));
  564. }
  565. void MainWindow::on_TimecodePage_Update_clicked() {
  566. TimecodeFormat_t InternalTimecode_Format = Str2TimecodeFormat(ui->InternalTimecode_Format->currentText().toStdString());
  567. XsyncTimecode_t InternalTimecode_Code = Str2XsyncTimecode(ui->InternalTimecode_Code->text().toStdString());
  568. TimecodeFormat_t ExternalTimecode_Format = Str2TimecodeFormat(ui->ExternalTimecode_Format->currentText().toStdString());
  569. InputInterface_t ExternalTimecode_Source = Str2InputInterface(ui->ExternalTimecode_Source->currentText().toStdString());
  570. uint32_t SysTimecode_Source = ui->SysTimecode_Source->currentText().toInt();
  571. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_setFormat(InternalTimecode_Format));
  572. DO_XSYNC_FUNC(XsyncIns()->InternalTimecode_setCode(InternalTimecode_Code));
  573. // DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_setFormat(ExternalTimecode_Format));
  574. // DO_XSYNC_FUNC(XsyncIns()->ExternalTimecode_setSource(ExternalTimecode_Source));
  575. DO_XSYNC_FUNC(XsyncIns()->SysTimecode_setSource(SysTimecode_Source));
  576. }
  577. // void MainWindow::on_CameraSyncPacketGeneratorModule_ClearPacketIndex_clicked() {
  578. // DO_XSYNC_FUNC(XsyncIns()->CameraSyncPacketGeneratorModule_clearPacketIndex());
  579. // on_CameraSyncPacketGeneratorModule_Read_clicked();
  580. // }
  581. void MainWindow::on_tabWidget_currentChanged(int index) {
  582. on_RefreshRegsButton_clicked();
  583. on_TimecodePage_Read_clicked();
  584. on_TTLPage_Read_clicked();
  585. on_GenlockPage_Read_clicked();
  586. on_SysClockPage_Read_clicked();
  587. on_RecordSigGen_Read_clicked();
  588. }
  589. void MainWindow::on_TTLPage_Read_clicked() {
  590. /*******************************************************************************
  591. * TTL输入页面 *
  592. *******************************************************************************/
  593. {
  594. float freq1 = 0;
  595. float freq2 = 0;
  596. float freq3 = 0;
  597. float freq4 = 0;
  598. bool En;
  599. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule1_detectFreq(freq1));
  600. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule2_detectFreq(freq2));
  601. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule3_detectFreq(freq3));
  602. DO_XSYNC_FUNC(XsyncIns()->TTLInputModule4_detectFreq(freq4));
  603. ui->TTLinModule_ttl_freq_1->setText(QString::number(freq1, 'f', 2));
  604. ui->TTLinModule_ttl_freq_2->setText(QString::number(freq2, 'f', 2));
  605. ui->TTLinModule_ttl_freq_3->setText(QString::number(freq3, 'f', 2));
  606. ui->TTLinModule_ttl_freq_4->setText(QString::number(freq4, 'f', 2));
  607. }
  608. /*******************************************************************************
  609. * TTL输出组件 *
  610. *******************************************************************************/
  611. SignalType_t source;
  612. TriggerEdge_t edge;
  613. uint32_t div;
  614. uint32_t multi;
  615. uint32_t PluseWidth;
  616. uint32_t OffsetTime;
  617. uint32_t outPolarity;
  618. float infreq;
  619. float outfreq;
  620. {
  621. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(1, source));
  622. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(1, edge));
  623. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(1, div));
  624. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(1, multi));
  625. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(1, PluseWidth));
  626. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(1, OffsetTime));
  627. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(1, outPolarity));
  628. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(1, infreq));
  629. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(1, outfreq));
  630. ui->TTLOutputModule_SrcSigType_1->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  631. ui->TTLOutputModule_TriggerEdge_1->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  632. ui->TTLOutputModule_FreqDivision_1->setText(QString::number(div));
  633. ui->TTLOutputModule_FreqMultiplication_1->setText(QString::number(multi));
  634. ui->TTLOutputModule_PluseWidth_1->setText(QString::number(PluseWidth));
  635. ui->TTLOutputModule_OffsetTime_1->setText(QString::number(OffsetTime));
  636. ui->TTLOutputModule_Polarity_1->setText(QString::number(outPolarity));
  637. ui->TTLOutputModule_InFreq_1->setText(QString::number(infreq, 'f', 2));
  638. ui->TTLOutputModule_OutFreq_1->setText(QString::number(outfreq, 'f', 2));
  639. }
  640. {
  641. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(2, source));
  642. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(2, edge));
  643. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(2, div));
  644. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(2, multi));
  645. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(2, PluseWidth));
  646. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(2, OffsetTime));
  647. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(2, outPolarity));
  648. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(2, infreq));
  649. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(2, outfreq));
  650. ui->TTLOutputModule_SrcSigType_2->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  651. ui->TTLOutputModule_TriggerEdge_2->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  652. ui->TTLOutputModule_FreqDivision_2->setText(QString::number(div));
  653. ui->TTLOutputModule_FreqMultiplication_2->setText(QString::number(multi));
  654. ui->TTLOutputModule_PluseWidth_2->setText(QString::number(PluseWidth));
  655. ui->TTLOutputModule_OffsetTime_2->setText(QString::number(OffsetTime));
  656. ui->TTLOutputModule_Polarity_2->setText(QString::number(outPolarity));
  657. ui->TTLOutputModule_InFreq_2->setText(QString::number(infreq, 'f', 2));
  658. ui->TTLOutputModule_OutFreq_2->setText(QString::number(outfreq, 'f', 2));
  659. }
  660. {
  661. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(3, source));
  662. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(3, edge));
  663. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(3, div));
  664. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(3, multi));
  665. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(3, PluseWidth));
  666. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(3, OffsetTime));
  667. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(3, outPolarity));
  668. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(3, infreq));
  669. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(3, outfreq));
  670. ui->TTLOutputModule_SrcSigType_3->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  671. ui->TTLOutputModule_TriggerEdge_3->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  672. ui->TTLOutputModule_FreqDivision_3->setText(QString::number(div));
  673. ui->TTLOutputModule_FreqMultiplication_3->setText(QString::number(multi));
  674. ui->TTLOutputModule_PluseWidth_3->setText(QString::number(PluseWidth));
  675. ui->TTLOutputModule_OffsetTime_3->setText(QString::number(OffsetTime));
  676. ui->TTLOutputModule_Polarity_3->setText(QString::number(outPolarity));
  677. ui->TTLOutputModule_InFreq_3->setText(QString::number(infreq, 'f', 2));
  678. ui->TTLOutputModule_OutFreq_3->setText(QString::number(outfreq, 'f', 2));
  679. }
  680. {
  681. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getSrcSigType(4, source));
  682. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getTriggerEdge(4, edge));
  683. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqDivision(4, div));
  684. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getFreqMultiplication(4, multi));
  685. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPluseWidth(4, PluseWidth));
  686. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getOffsetTime(4, OffsetTime));
  687. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_getPolarity(4, outPolarity));
  688. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readInFreq(4, infreq));
  689. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_readOutFreq(4, outfreq));
  690. ui->TTLOutputModule_SrcSigType_4->setCurrentText(QString::fromStdString(SignalType2Str(source)));
  691. ui->TTLOutputModule_TriggerEdge_4->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  692. ui->TTLOutputModule_FreqDivision_4->setText(QString::number(div));
  693. ui->TTLOutputModule_FreqMultiplication_4->setText(QString::number(multi));
  694. ui->TTLOutputModule_PluseWidth_4->setText(QString::number(PluseWidth));
  695. ui->TTLOutputModule_OffsetTime_4->setText(QString::number(OffsetTime));
  696. ui->TTLOutputModule_Polarity_4->setText(QString::number(outPolarity));
  697. ui->TTLOutputModule_InFreq_4->setText(QString::number(infreq, 'f', 2));
  698. ui->TTLOutputModule_OutFreq_4->setText(QString::number(outfreq, 'f', 2));
  699. }
  700. }
  701. void MainWindow::on_TTLPage_Write_clicked() {
  702. {
  703. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_1->currentText().toStdString());
  704. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_1->currentText().toStdString());
  705. auto div = ui->TTLOutputModule_FreqDivision_1->text().toUInt();
  706. auto multi = ui->TTLOutputModule_FreqMultiplication_1->text().toUInt();
  707. auto PluseWidth = ui->TTLOutputModule_PluseWidth_1->text().toUInt();
  708. auto OffsetTime = ui->TTLOutputModule_OffsetTime_1->text().toUInt();
  709. auto outPolarity = ui->TTLOutputModule_Polarity_1->text().toUInt();
  710. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(1, source));
  711. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(1, edge));
  712. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(1, div));
  713. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(1, multi));
  714. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(1, PluseWidth));
  715. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(1, OffsetTime));
  716. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(1, outPolarity));
  717. }
  718. {
  719. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_2->currentText().toStdString());
  720. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_2->currentText().toStdString());
  721. auto div = ui->TTLOutputModule_FreqDivision_2->text().toUInt();
  722. auto multi = ui->TTLOutputModule_FreqMultiplication_2->text().toUInt();
  723. auto PluseWidth = ui->TTLOutputModule_PluseWidth_2->text().toUInt();
  724. auto OffsetTime = ui->TTLOutputModule_OffsetTime_2->text().toUInt();
  725. auto outPolarity = ui->TTLOutputModule_Polarity_2->text().toUInt();
  726. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(2, source));
  727. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(2, edge));
  728. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(2, div));
  729. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(2, multi));
  730. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(2, PluseWidth));
  731. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(2, OffsetTime));
  732. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(2, outPolarity));
  733. }
  734. {
  735. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_3->currentText().toStdString());
  736. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_3->currentText().toStdString());
  737. auto div = ui->TTLOutputModule_FreqDivision_3->text().toUInt();
  738. auto multi = ui->TTLOutputModule_FreqMultiplication_3->text().toUInt();
  739. auto PluseWidth = ui->TTLOutputModule_PluseWidth_3->text().toUInt();
  740. auto OffsetTime = ui->TTLOutputModule_OffsetTime_3->text().toUInt();
  741. auto outPolarity = ui->TTLOutputModule_Polarity_3->text().toUInt();
  742. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(3, source));
  743. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(3, edge));
  744. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(3, div));
  745. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(3, multi));
  746. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(3, PluseWidth));
  747. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(3, OffsetTime));
  748. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(3, outPolarity));
  749. }
  750. {
  751. auto source = Str2SignalType(ui->TTLOutputModule_SrcSigType_4->currentText().toStdString());
  752. auto edge = Str2TriggerEdge(ui->TTLOutputModule_TriggerEdge_4->currentText().toStdString());
  753. auto div = ui->TTLOutputModule_FreqDivision_4->text().toUInt();
  754. auto multi = ui->TTLOutputModule_FreqMultiplication_4->text().toUInt();
  755. auto PluseWidth = ui->TTLOutputModule_PluseWidth_4->text().toUInt();
  756. auto OffsetTime = ui->TTLOutputModule_OffsetTime_4->text().toUInt();
  757. auto outPolarity = ui->TTLOutputModule_Polarity_4->text().toUInt();
  758. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setSrcSigType(4, source));
  759. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setTriggerEdge(4, edge));
  760. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqDivision(4, div));
  761. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setFreqMultiplication(4, multi));
  762. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPluseWidth(4, PluseWidth));
  763. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setOffsetTime(4, OffsetTime));
  764. DO_XSYNC_FUNC(XsyncIns()->TTLOutputModule_setPolarity(4, outPolarity));
  765. }
  766. }
  767. void MainWindow::on_GenlockPage_Read_clicked() {
  768. {
  769. GenlockFormat_t format;
  770. DO_XSYNC_FUNC(XsyncIns()->InternalGenlock_getFormat(format));
  771. ui->InternalGenlock_Format->setCurrentText(QString::fromStdString(GenlockFormatToStr(format)));
  772. }
  773. {
  774. float freq;
  775. DO_XSYNC_FUNC(XsyncIns()->InternalGenlock_readFreq(freq));
  776. ui->InternalGenlock_Freq->setText(QString::number(freq, 'f', 2));
  777. }
  778. {
  779. float freq;
  780. DO_XSYNC_FUNC(XsyncIns()->ExternalGenlock_detectFreq(freq));
  781. ui->ExternalGenlock_Freq->setText(QString::number(freq, 'f', 2));
  782. }
  783. {
  784. uint32_t src;
  785. DO_XSYNC_FUNC(XsyncIns()->SysGenlock_getSrc(src));
  786. ui->SysGenlock_Src->setCurrentText(QString::number(src));
  787. }
  788. {
  789. float freq;
  790. DO_XSYNC_FUNC(XsyncIns()->SysGenlock_readFreq(freq));
  791. ui->SysGenlock_Freq->setText(QString::number(freq, 'f', 2));
  792. }
  793. }
  794. void MainWindow::on_GenlockPage_Write_clicked() {
  795. {
  796. auto format = Str2GenlockFormat(ui->InternalGenlock_Format->currentText().toStdString());
  797. DO_XSYNC_FUNC(XsyncIns()->InternalGenlock_setFormat(format));
  798. }
  799. {
  800. auto src = ui->SysGenlock_Src->currentText().toUInt();
  801. DO_XSYNC_FUNC(XsyncIns()->SysGenlock_setSrc(src));
  802. }
  803. }
  804. void MainWindow::on_SysClockPage_Read_clicked() {
  805. {
  806. float freq;
  807. DO_XSYNC_FUNC(XsyncIns()->InternalClock_getFreq(freq));
  808. ui->InternalClock_Freq->setText(QString::number(freq, 'f', 2));
  809. }
  810. {
  811. float freq;
  812. DO_XSYNC_FUNC(XsyncIns()->InternalClock_readOutFreq(freq));
  813. ui->InternalClock_OutFreq->setText(QString::number(freq, 'f', 2));
  814. }
  815. {
  816. SignalType_t src;
  817. DO_XSYNC_FUNC(XsyncIns()->SysClock_getSrc(src));
  818. ui->SysClock_Src->setCurrentText(QString::fromStdString(SignalType2Str(src)));
  819. }
  820. {
  821. uint32_t div;
  822. DO_XSYNC_FUNC(XsyncIns()->SysClock_geFreqtDivision(div));
  823. ui->SysClock_FreqtDivision->setText(QString::number(div));
  824. }
  825. {
  826. uint32_t multi;
  827. DO_XSYNC_FUNC(XsyncIns()->SysClock_getFreqMultiplication(multi));
  828. ui->SysClock_FreqMultiplication->setText(QString::number(multi));
  829. }
  830. {
  831. float freq;
  832. DO_XSYNC_FUNC(XsyncIns()->SysClock_readInSigFreq(freq));
  833. ui->SysClock_InSigFreq->setText(QString::number(freq, 'f', 2));
  834. }
  835. {
  836. float freq;
  837. DO_XSYNC_FUNC(XsyncIns()->SysClock_readOutSigFreq(freq));
  838. ui->SysClock_OutSigFreq->setText(QString::number(freq, 'f', 2));
  839. }
  840. {
  841. TriggerEdge_t edge;
  842. DO_XSYNC_FUNC(XsyncIns()->SysClock_getTriggerEdge(edge));
  843. ui->SysClock_TriggerEdge->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  844. }
  845. }
  846. void MainWindow::on_SysClockPage_Wirte_clicked() {
  847. {
  848. auto freq = ui->InternalClock_Freq->text().toFloat();
  849. DO_XSYNC_FUNC(XsyncIns()->InternalClock_setFreq(freq));
  850. }
  851. {
  852. auto src = Str2SignalType(ui->SysClock_Src->currentText().toStdString());
  853. DO_XSYNC_FUNC(XsyncIns()->SysClock_setSrc(src));
  854. }
  855. {
  856. auto div = ui->SysClock_FreqtDivision->text().toUInt();
  857. DO_XSYNC_FUNC(XsyncIns()->SysClock_setFreqDivision(div));
  858. }
  859. {
  860. auto multi = ui->SysClock_FreqMultiplication->text().toUInt();
  861. DO_XSYNC_FUNC(XsyncIns()->SysClock_setFreqMultiplication(multi));
  862. }
  863. {
  864. TriggerEdge_t edge = Str2TriggerEdge(ui->SysClock_TriggerEdge->currentText().toStdString());
  865. DO_XSYNC_FUNC(XsyncIns()->SysClock_setTriggerEdge(edge));
  866. }
  867. }
  868. void MainWindow::on_RecordSigGen_Read_clicked() {
  869. ControlMode_t mode;
  870. XsyncTimecode_t autoStartTimecode;
  871. XsyncTimecode_t autoStopTimecode;
  872. uint32_t autoStart;
  873. uint32_t autoStop;
  874. InputInterface_t ttlPortNum;
  875. uint32_t polarity;
  876. uint32_t exposureTime;
  877. uint32_t exposureOffsetTime;
  878. uint32_t state;
  879. XsyncTimecode_t timecode_snapshot;
  880. TriggerEdge_t edge;
  881. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getContrlMode(mode));
  882. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getAutoStartTimecode(autoStartTimecode));
  883. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getAutoStopTimecode(autoStopTimecode));
  884. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getTimecodeCtrlFlag(autoStart, autoStop));
  885. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getExternalTTLTriggerSrc(ttlPortNum));
  886. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getExternalTTLTriggerPolarity(polarity));
  887. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getRecordState(state));
  888. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_readTimecodeSnapshot(timecode_snapshot));
  889. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_getTriggerEdge(edge));
  890. ui->RecordSigGenerator_ContrlMode->setCurrentText(QString::fromStdString(ControlMode2Str(mode)));
  891. ui->RecordSigGenerator_AutoStartTimecode->setText(QString(XsyncTimecodeToStr(autoStartTimecode).c_str()));
  892. ui->RecordSigGenerator_AutoStopTimecode->setText(QString(XsyncTimecodeToStr(autoStopTimecode).c_str()));
  893. ui->RecordSigGenerator_TimecodeCtrlFlag0->setChecked(autoStart);
  894. ui->RecordSigGenerator_TimecodeCtrlFlag1->setChecked(autoStop);
  895. ui->RecordSigGenerator_ExternalTTLTriggerSrc->setCurrentText(QString::fromStdString(InputInterface2Str(ttlPortNum)));
  896. ui->RecordSigGenerator_ExternalTTLTriggerPolarity->setText(QString::number(polarity));
  897. ui->RecordSigGenerator_TriggerEdge->setCurrentText(QString::fromStdString(TriggerEdge2Str(edge)));
  898. // ui->RecordSigGenerator_RecordExposureTime->setText(QString::number(exposureTime));
  899. // ui->RecordSigGenerator_RecordExposureOffsetTime->setText(QString::number(exposureOffsetTime));
  900. ui->RecordSigGenerator_RecordState->setText(QString::number(state));
  901. ui->RecordSigGenerator_TimecodeSnapshot->setText(QString(XsyncTimecodeToStr(timecode_snapshot).c_str()));
  902. }
  903. void MainWindow::on_RecordSigGen_Write_clicked() {
  904. ControlMode_t mode = Str2ControlMode(ui->RecordSigGenerator_ContrlMode->currentText().toStdString());
  905. uint32_t autoStart = ui->RecordSigGenerator_TimecodeCtrlFlag0->isChecked();
  906. uint32_t autoStop = ui->RecordSigGenerator_TimecodeCtrlFlag1->isChecked();
  907. InputInterface_t ttlPortNum = Str2InputInterface(ui->RecordSigGenerator_ExternalTTLTriggerSrc->currentText().toStdString());
  908. uint32_t polarity = ui->RecordSigGenerator_ExternalTTLTriggerPolarity->text().toUInt();
  909. TriggerEdge_t edge = Str2TriggerEdge(ui->RecordSigGenerator_TriggerEdge->currentText().toStdString());
  910. static XsyncTimecode_t autoStopTimecode;
  911. Str2XsyncTimecode(ui->RecordSigGenerator_AutoStopTimecode->text().toStdString(), autoStopTimecode);
  912. static XsyncTimecode_t autoStartTimecode;
  913. Str2XsyncTimecode(ui->RecordSigGenerator_AutoStartTimecode->text().toStdString(), autoStartTimecode);
  914. ZLOGI(TAG, "............. %s", ui->RecordSigGenerator_AutoStartTimecode->text().toStdString().c_str());
  915. ZLOGI(TAG, "............. %s", ui->RecordSigGenerator_AutoStopTimecode->text().toStdString().c_str());
  916. ZLOGI(TAG, "1 %d %d %d %d %d ", autoStartTimecode.hour, autoStartTimecode.minute, autoStartTimecode.second, autoStartTimecode.frame, autoStartTimecode.subframe);
  917. ZLOGI(TAG, "2 %d %d %d %d %d ", autoStopTimecode.hour, autoStopTimecode.minute, autoStopTimecode.second, autoStopTimecode.frame, autoStopTimecode.subframe);
  918. // uint32_t exposureTime = ui->RecordSigGenerator_RecordExposureTime->text().toUInt();
  919. // uint32_t exposureOffsetTime = ui->RecordSigGenerator_RecordExposureOffsetTime->text().toUInt();
  920. // RecordSigGenerator_readTimecodeSnapshot
  921. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setContrlMode(mode));
  922. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setAutoStartTimecode(autoStartTimecode));
  923. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setAutoStopTimecode(autoStopTimecode));
  924. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setTimecodeCtrlFlag(autoStart, autoStop));
  925. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setExternalTTLTriggerSrc(ttlPortNum));
  926. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setExternalTTLTriggerPolarity(polarity));
  927. DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setTriggerEdge(edge));
  928. // DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setRecordExposureTime(exposureTime));
  929. // DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_setRecordExposureOffsetTime(exposureOffsetTime));
  930. }
  931. void MainWindow::on_RecordSigGenerator_manualStart_clicked() { DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_manualStart()); }
  932. void MainWindow::on_RecordSigGenerator_manualStop_clicked() { DO_XSYNC_FUNC(XsyncIns()->RecordSigGenerator_manualStop()); }
  933. void MainWindow::on_NetworkConfig_read_clicked() {
  934. // DO_XSYNC_FUNC(XsyncIns()->changeNetworkConfig(ui->ChangeNetCfg_ip->text().toStdString(), ui->ChangeNetCfg_mask->text().toStdString(), ui->ChangeNetCfg_gateway->text().toStdString()));
  935. string ip;
  936. string mask;
  937. string gateway;
  938. NetworkMode_t mode;
  939. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_getIp(ip));
  940. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_getMask(mask));
  941. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_getGateway(gateway));
  942. DO_XSYNC_FUNC(XsyncIns()->NetworkConfig_getMode(mode));
  943. ui->NetworkConfigStaticIpMode_Ip->setText(QString::fromStdString(ip));
  944. ui->NetworkConfigStaticIpMode_Mask->setText(QString::fromStdString(mask));
  945. ui->NetworkConfigStaticIpMode_Gateway->setText(QString::fromStdString(gateway));
  946. ui->NetworkConfig_Mode->setText(QString::fromStdString(QString::number(mode).toStdString()));
  947. }
  948. void MainWindow::on_NetworkConfig_storage_clicked() {
  949. string ip = ui->NetworkConfigStaticIpMode_Ip->text().toStdString();
  950. string mask = ui->NetworkConfigStaticIpMode_Mask->text().toStdString();
  951. string gateway = ui->NetworkConfigStaticIpMode_Gateway->text().toStdString();
  952. NetworkMode_t mode = (NetworkMode_t)ui->NetworkConfig_Mode->text().toUInt();
  953. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_setIp(ip));
  954. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_setMask(mask));
  955. DO_XSYNC_FUNC(XsyncIns()->NetworkConfigStaticIpMode_setGateway(gateway));
  956. DO_XSYNC_FUNC(XsyncIns()->NetworkConfig_setMode(mode));
  957. DO_XSYNC_FUNC(XsyncIns()->storageConfig());
  958. }
  959. void MainWindow::on_GenNewMac_clicked() { DO_XSYNC_FUNC(XsyncIns()->generatorNewMac()); }
  960. void MainWindow::on_FactoryReset_clicked() { DO_XSYNC_FUNC(XsyncIns()->factoryReset()); }
  961. void MainWindow::on_Reboot_clicked() { DO_XSYNC_FUNC(XsyncIns()->reboot()); }
  962. void MainWindow::on_InternalSigSrouce_start_clicked() { DO_XSYNC_FUNC(XsyncIns()->InternalSigSrouce_start()); }
  963. void MainWindow::on_InternalSigSrouce_stop_clicked() { DO_XSYNC_FUNC(XsyncIns()->InternalSigSrouce_stop()); }
  964. void MainWindow::on_DelayContrl_Read_clicked() {
  965. uint32_t DelayContrl_InputDelay;
  966. uint32_t DelayContrl_OutputDelay;
  967. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_getInputDelay(DelayContrl_InputDelay));
  968. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_getOutputDelay(DelayContrl_OutputDelay));
  969. ui->DelayContrl_InputDelay->setText(QString::number(DelayContrl_InputDelay));
  970. ui->DelayContrl_OutputDelay->setText(QString::number(DelayContrl_OutputDelay));
  971. }
  972. void MainWindow::on_DelayContrl_Update_clicked() {
  973. uint32_t DelayContrl_InputDelay = ui->DelayContrl_InputDelay->text().toUInt();
  974. uint32_t DelayContrl_OutputDelay = ui->DelayContrl_OutputDelay->text().toUInt();
  975. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_setInputDelay(DelayContrl_InputDelay));
  976. DO_XSYNC_FUNC(XsyncIns()->DelayContrl_setOutputDelay(DelayContrl_OutputDelay));
  977. }