|
|
@ -47,6 +47,19 @@ void MainWindow::log_output(QtMsgType type, const QMessageLogContext &context, c |
|
|
|
|
|
|
|
void MainWindow::append_log_slot(QString text) { ui->logbrowser->append(text); } |
|
|
|
|
|
|
|
void MainWindow::updateUI_timeCodeInfo_slot(QString text) { ui->TimecodeDisplayer->setText(text); } |
|
|
|
void MainWindow::updateUI_cameraSyncInfo_slot(QString text) { ui->CameraSyncIndex->setText(text); } |
|
|
|
void MainWindow::updateUI_reg_slot(int32_t regadd, uint32_t regval) { |
|
|
|
auto it = m_regdisplayer.find(regadd); |
|
|
|
if (it != m_regdisplayer.end()) { |
|
|
|
ZLOGI(TAG, "updateUI_reg_slot %x %d", regadd, regval); |
|
|
|
it->second->regBrowser->setText(QString::number(regval, 16)); |
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::doinui_slot(QFunction func) { |
|
|
|
if (func.get()) func.get()(); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::push_reg(QWidget *parent, int off, const char *regname, int32_t regadd, int32_t rwflag) { |
|
|
|
DispalyRegIterm *regitem = new DispalyRegIterm(); |
|
|
|
{ |
|
|
@ -58,7 +71,7 @@ void MainWindow::push_reg(QWidget *parent, int off, const char *regname, int32_t |
|
|
|
sizePolicy1.setVerticalStretch(0); |
|
|
|
sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); |
|
|
|
label->setSizePolicy(sizePolicy1); |
|
|
|
label->setMinimumSize(QSize(100, 0)); |
|
|
|
label->setMinimumSize(QSize(200, 0)); |
|
|
|
label->setMaximumSize(QSize(16777215, 16777215)); |
|
|
|
ui->reg_table->addWidget(label, off, 0, 1, 1); |
|
|
|
regitem->label = label; |
|
|
@ -132,11 +145,16 @@ void MainWindow::push_reg(QWidget *parent, int off, const char *regname, int32_t |
|
|
|
|
|
|
|
void MainWindow::construct_reg_table() { //
|
|
|
|
int regoff = 1; |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "reg1", 0x1000, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "reg1", 0x1001, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "reg1", 0x1002, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "reg1", 0x1003, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "reg1", 0x1004, 0); |
|
|
|
|
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "software_version", kxsync_reg_software_version, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "manufacturer0", kxsync_reg_manufacturer0, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "manufacturer1", kxsync_reg_manufacturer1, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "product_type_id", kxsync_reg_product_type_id, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "sn_id0", kxsync_reg_sn_id0, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "sn_id1", kxsync_reg_sn_id1, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "sn_id2", kxsync_reg_sn_id2, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "mac0", kxsync_reg_mac0, 0); |
|
|
|
push_reg(ui->gridLayoutWidget, regoff++, "mac1", kxsync_reg_mac1, 0); |
|
|
|
|
|
|
|
// 设置table的高度
|
|
|
|
auto qrect = ui->gridLayoutWidget->geometry(); |
|
|
@ -148,14 +166,36 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi |
|
|
|
ui->setupUi(this); |
|
|
|
m_mainWindow = this; |
|
|
|
construct_reg_table(); |
|
|
|
connect(this, SIGNAL(append_log_signal(QString)), this, SLOT(append_log_slot(QString))); |
|
|
|
qInstallMessageHandler(log_output); |
|
|
|
|
|
|
|
qRegisterMetaType<int32_t>("int32_t"); |
|
|
|
qRegisterMetaType<uint32_t>("uint32_t"); |
|
|
|
qRegisterMetaType<function<void()>>("function<void()>"); |
|
|
|
qRegisterMetaType<QFunction>("QFunction"); |
|
|
|
|
|
|
|
XSyncUdpFactoryImpl::Ins()->initialize(); |
|
|
|
connect(this, SIGNAL(append_log_signal(QString)), this, SLOT(append_log_slot(QString))); |
|
|
|
connect(this, SIGNAL(updateUI_timeCodeInfo_signal(QString)), this, SLOT(updateUI_timeCodeInfo_slot(QString))); |
|
|
|
connect(this, SIGNAL(updateUI_cameraSyncInfo_signal(QString)), this, SLOT(updateUI_cameraSyncInfo_slot(QString))); |
|
|
|
connect(this, SIGNAL(updateUI_reg_signal(int32_t, uint32_t)), this, SLOT(updateUI_reg_slot(int32_t, uint32_t))); |
|
|
|
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); |
|
|
|
|
|
|
|
m_thread.reset(new ZQThread("test", [this]() { mainWindowsRun(); })); |
|
|
|
m_thread->start(); |
|
|
|
|
|
|
|
// m_xsync.reset(new Xsync());
|
|
|
|
|
|
|
|
Xsync::Ins().initialize(XSyncUdpFactoryImpl::Ins()); |
|
|
|
Xsync::Ins().regOnTimecodeMsg([this](xysnc_timecode_t *timecode_msg) { //
|
|
|
|
xysnc_timecode_t timecode = *timecode_msg; |
|
|
|
QString text = QString(fmt("%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame)); |
|
|
|
updateUI_timeCodeInfo_signal(text); |
|
|
|
}); |
|
|
|
|
|
|
|
Xsync::Ins().regOnCameraSyncMsg([this](xysnc_camera_sync_data_t *camera_sync_msg) { //
|
|
|
|
xysnc_camera_sync_data_t camera_sync_data = *camera_sync_msg; |
|
|
|
updateUI_cameraSyncInfo_signal(QString(fmt("%d", camera_sync_data.frameIndex))); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
MainWindow::~MainWindow() { delete ui; } |
|
|
@ -171,16 +211,21 @@ MainWindow::~MainWindow() { delete ui; } |
|
|
|
|
|
|
|
void MainWindow::on_RefreshRegsButton_clicked() { //
|
|
|
|
ZLOGI(TAG, "on_refreshRegsButton_clicked"); |
|
|
|
// int32_t _t1, uint32_t _t2
|
|
|
|
|
|
|
|
QtConcurrent::run([this]() { |
|
|
|
bool suc = true; |
|
|
|
for (auto ® : m_regdisplayer) { |
|
|
|
uint32_t regValue = 0; |
|
|
|
auto ecode = Xsync::Ins().reg_read(reg.first, regValue); |
|
|
|
int regoff = reg.first; |
|
|
|
|
|
|
|
if (ecode == kxs_ec_success) { |
|
|
|
ZLOGI(TAG, "reg_read %x success", reg.first); |
|
|
|
reg.second->regvalcache = regValue; |
|
|
|
reg.second->regBrowser->setText(QString::number(regValue, 16)); |
|
|
|
emit doinui_signal(QFunction([this, regoff, regValue]() { |
|
|
|
m_regdisplayer[regoff]->regvalcache = regValue; |
|
|
|
m_regdisplayer[regoff]->regBrowser->setText("0x" + QString::number(regValue, 16)); |
|
|
|
})); |
|
|
|
} else { |
|
|
|
ZLOGE(TAG, "reg_read %x fail,ecode:%s", reg.first, xs_error_code_2_str(ecode)); |
|
|
|
suc = false; |
|
|
@ -207,7 +252,7 @@ void MainWindow::on_Connect2XsyncButton_clicked() { // |
|
|
|
ZLOGI(TAG, "connect %s ecode:%s", ui->IpInput->text().toStdString().c_str(), xs_error_code_2_str(ecode)); |
|
|
|
} |
|
|
|
void MainWindow::mainWindowsRun() { //
|
|
|
|
XSyncUdpFactoryImpl::Ins()->initialize(); |
|
|
|
|
|
|
|
// auto xsudp = XSyncUdpFactoryImpl::Ins()->createXSUDP();
|
|
|
|
// XS_ASSERT(xsudp->initialize("0.0.0.0", 9999));
|
|
|
|
// xsudp->startReceive([this, xsudp](XsyncNetAdd &from, uint8_t *data, size_t length) {
|
|
|
|