|
|
@ -16,14 +16,7 @@ using namespace std; |
|
|
|
|
|
|
|
static MainWindow *m_mainWindow; |
|
|
|
static CLSTControler *m_clstc; |
|
|
|
QTimer *timer0; |
|
|
|
QTimer *timer1; |
|
|
|
QTimer *timer2; |
|
|
|
QTimer *timer3; |
|
|
|
QTimer *checkConnectTimer0; |
|
|
|
static bool m_connected = false; |
|
|
|
|
|
|
|
ZQThread *m_zqthread; |
|
|
|
ZQThread *m_zqthread; |
|
|
|
#define TAG "MainWindow"
|
|
|
|
|
|
|
|
static const char *fmt(const char *fmt, ...) { |
|
|
@ -35,800 +28,11 @@ static const char *fmt(const char *fmt, ...) { |
|
|
|
return buf; |
|
|
|
} |
|
|
|
|
|
|
|
static const uint32_t str2int(QString str) { |
|
|
|
// 如果0x开头,??16进制转换
|
|
|
|
// 如果0b开头,??2进制转换
|
|
|
|
// 否则??10进制转换
|
|
|
|
// 去除掉str中_
|
|
|
|
str.remove("_"); |
|
|
|
|
|
|
|
if (str.startsWith("0x")) { |
|
|
|
return str.toUInt(nullptr, 16); |
|
|
|
} else if (str.startsWith("0b")) { |
|
|
|
// remove 0b
|
|
|
|
str.remove(0, 2); |
|
|
|
return str.toUInt(nullptr, 2); |
|
|
|
} else { |
|
|
|
return str.toUInt(nullptr, 10); |
|
|
|
} |
|
|
|
} |
|
|
|
// static QSerialPort G_SerialPort;
|
|
|
|
// static QThread G_SerialPortThread;
|
|
|
|
static QTDataChannel G_QTDataChannel; |
|
|
|
|
|
|
|
static const QString zaferror_to_str(zaf_error_code_t value) { |
|
|
|
if (value == kaf_ec_overtime) { |
|
|
|
return "通信超时"; |
|
|
|
} else if (value == kaf_ec_device_notopen) { |
|
|
|
return "设备未打开"; |
|
|
|
} else { |
|
|
|
return "未知错误"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#define DO_NO_RET(action) \
|
|
|
|
{ \ |
|
|
|
zaf_error_code_t ecode = action; \ |
|
|
|
if (ecode != kaf_ec_success) { \ |
|
|
|
dumpLog("do %s fail,%s", #action, zaferror_to_str(ecode).toStdString().c_str()); \ |
|
|
|
displayInfo(false, zaferror_to_str(ecode)); \ |
|
|
|
return; \ |
|
|
|
} \ |
|
|
|
} |
|
|
|
|
|
|
|
#define DO(action) \
|
|
|
|
{ \ |
|
|
|
zaf_error_code_t ecode = action; \ |
|
|
|
if (ecode != kaf_ec_success) { \ |
|
|
|
dumpLog("do %s fail,%s", #action, zaferror_to_str(ecode).toStdString().c_str()); \ |
|
|
|
displayInfo(false, zaferror_to_str(ecode)); \ |
|
|
|
return ecode; \ |
|
|
|
} \ |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg) { |
|
|
|
// QString text;
|
|
|
|
// text.append(msg);
|
|
|
|
} |
|
|
|
// void MainWindow::append_log_slot(QString text) { ui->logbrowser->append(text); }
|
|
|
|
void MainWindow::log_output(QtMsgType type, const QMessageLogContext &context, const QString &msg) {} |
|
|
|
void MainWindow::doinui_slot(QFunction func) { |
|
|
|
if (func.get()) func.get()(); |
|
|
|
} |
|
|
|
|
|
|
|
zaf_error_code_t MainWindow::updatePage() { |
|
|
|
{ |
|
|
|
float Freq; |
|
|
|
uint32_t PluseCnt; |
|
|
|
uint32_t SeqCtrlPluseCntMax; |
|
|
|
|
|
|
|
Freq = ui->InterClk_Freq_Text->text().toFloat(); |
|
|
|
PluseCnt = ui->InterClk_PluseCnt_Text->text().toUInt(); |
|
|
|
SeqCtrlPluseCntMax = ui->InterClk_SeqCtrlPluseCntMax_Text->text().toUInt(); |
|
|
|
|
|
|
|
DO(m_clstc->InterClk_setFreq(Freq)); |
|
|
|
DO(m_clstc->InterClk_setPluseCnt(PluseCnt)); |
|
|
|
DO(m_clstc->InterClk_setSeqCtrlPluseCntMax(SeqCtrlPluseCntMax)); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
ExtTriggerSrcType src; |
|
|
|
SigProcessMode mode; |
|
|
|
TriggerEdge edge; |
|
|
|
uint32_t coefficient; |
|
|
|
uint32_t bias; |
|
|
|
uint32_t division; |
|
|
|
uint32_t multiplication; |
|
|
|
uint32_t cnt; |
|
|
|
// TriInX_setSequentialControlPluseCntMax
|
|
|
|
|
|
|
|
#define UPDATE(index) \
|
|
|
|
src = ExtTriggerSrcType(ui->TriInX_SrcSelect_Val_##index->currentText().toStdString()); \ |
|
|
|
coefficient = ui->TriInX_FileterCoefficient_Val_##index->text().toUInt(); \ |
|
|
|
bias = ui->TriInX_FreqDetectBias_Val_##index->text().toUInt(); \ |
|
|
|
mode = SigProcessMode(ui->TriInX_Mode_Val_##index->currentText().toStdString()); \ |
|
|
|
edge = TriggerEdge(ui->TriInX_TriggerModeTriggerEdge_Val_##index->currentText().toStdString()); \ |
|
|
|
division = ui->TriInX_TriggerModeFreqDivision_Val_##index->text().toUInt(); \ |
|
|
|
multiplication = ui->TriInX_TriggerModeFreqMultiplication_Val_##index->text().toUInt(); \ |
|
|
|
cnt = ui->TriInX_SequentialControlPluseCntMax_Val_##index->text().toUInt(); \ |
|
|
|
DO(m_clstc->TriInX_setSrcSelect(index, src)); \ |
|
|
|
DO(m_clstc->TriInX_setFileterCoefficient(index, coefficient)); \ |
|
|
|
DO(m_clstc->TriInX_setFreqDetectBias(index, bias)); \ |
|
|
|
DO(m_clstc->TriInX_setMode(index, mode)); \ |
|
|
|
DO(m_clstc->TriInX_setTriggerModeTriggerEdge(index, edge)); \ |
|
|
|
DO(m_clstc->TriInX_setTriggerModeFreqDivision(index, division)); \ |
|
|
|
DO(m_clstc->TriInX_setTriggerModeFreqMultiplication(index, multiplication)); \ |
|
|
|
DO(m_clstc->TriInX_setSequentialControlPluseCntMax(index, cnt)); |
|
|
|
|
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
InternalSig src; |
|
|
|
uint32_t width; |
|
|
|
uint32_t offset; |
|
|
|
float duty; |
|
|
|
float freq; |
|
|
|
|
|
|
|
#define UPDATE(index) \
|
|
|
|
src = InternalSig(ui->LightSrcX_TriSrc_##index->currentText().toStdString()); \ |
|
|
|
width = ui->LightSrcX_TriggerModePluseWidth_##index->text().toUInt(); \ |
|
|
|
offset = ui->LightSrcX_TriggerModeFirstPluseOffset_##index->text().toUInt(); \ |
|
|
|
duty = ui->LightSrcX_LightIntensityDuty_##index->text().toFloat(); \ |
|
|
|
freq = ui->LightSrcX_LightDriverFreq_##index->text().toFloat(); \ |
|
|
|
DO(m_clstc->LightSrcX_setTriSrc(index, src)); \ |
|
|
|
DO(m_clstc->LightSrcX_setTriggerModePluseWidth(index, width)); \ |
|
|
|
DO(m_clstc->LightSrcX_setTriggerModeFirstPluseOffset(index, offset)); \ |
|
|
|
DO(m_clstc->LightSrcX_setLightIntensityDuty(index, duty)); \ |
|
|
|
DO(m_clstc->LightSrcX_setLightDriverFreq(index, freq)); |
|
|
|
|
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
SigProcessMode mode; |
|
|
|
uint32_t offset; |
|
|
|
uint32_t bindstate1; |
|
|
|
uint32_t bindstate2; |
|
|
|
uint32_t bindstate3; |
|
|
|
uint32_t bindstate4; |
|
|
|
InternalSig sig; |
|
|
|
uint32_t reversal; |
|
|
|
|
|
|
|
#define UPDATE(index) \
|
|
|
|
mode = SigProcessMode(ui->ShutterX_OutputCtrlMode_##index->currentText().toStdString()); \ |
|
|
|
offset = ui->ShutterX_LtEnOffset_##index->text().toUInt(); \ |
|
|
|
bindstate1 = ui->ShutterX_LtEnBind_val1_##index->checkState() == Qt::CheckState::Checked; \ |
|
|
|
bindstate2 = ui->ShutterX_LtEnBind_val2_##index->checkState() == Qt::CheckState::Checked; \ |
|
|
|
bindstate3 = ui->ShutterX_LtEnBind_val3_##index->checkState() == Qt::CheckState::Checked; \ |
|
|
|
bindstate4 = ui->ShutterX_LtEnBind_val4_##index->checkState() == Qt::CheckState::Checked; \ |
|
|
|
sig = InternalSig(ui->ShutterX_InSigSelect_##index->currentText().toStdString()); \ |
|
|
|
reversal = ui->ShutterX_OutPolarityReversal_##index->checkState() == Qt::CheckState::Checked; \ |
|
|
|
DO(m_clstc->ShutterX_setOutputCtrlMode(index, mode)); \ |
|
|
|
DO(m_clstc->ShutterX_setLtEnOffset(index, offset)); \ |
|
|
|
DO(m_clstc->ShutterX_setLtEnBind(index, 1, bindstate1)); \ |
|
|
|
DO(m_clstc->ShutterX_setLtEnBind(index, 2, bindstate2)); \ |
|
|
|
DO(m_clstc->ShutterX_setLtEnBind(index, 3, bindstate3)); \ |
|
|
|
DO(m_clstc->ShutterX_setLtEnBind(index, 4, bindstate4)); \ |
|
|
|
DO(m_clstc->ShutterX_setInSigSelect(index, sig)); \ |
|
|
|
DO(m_clstc->ShutterX_setOutPolarityReversal(index, reversal)); |
|
|
|
|
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
return kaf_ec_success; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::refreshReadonlyPage0() { |
|
|
|
zaf_error_code_t ecode; |
|
|
|
|
|
|
|
if (!G_QTDataChannel.isOpen()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
float TriOutSignalFreq; |
|
|
|
DO_NO_RET(m_clstc->InterClk_readTriOutSignalFreq(TriOutSignalFreq)); |
|
|
|
emit doinui_signal(QFunction([this, TriOutSignalFreq]() { //
|
|
|
|
ui->InterClk_TriOutSignalFreq_Text->setText(QString::number(TriOutSignalFreq, 'f', 2)); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::refreshReadonlyPage1() { |
|
|
|
if (!G_QTDataChannel.isOpen()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
float infreq; |
|
|
|
float outfreq; |
|
|
|
|
|
|
|
#define UPDATE(index) \
|
|
|
|
DO_NO_RET(m_clstc->TriInX_readInSignalFreq(index, infreq)); \ |
|
|
|
DO_NO_RET(m_clstc->TriInX_readOutSignalFreq(index, outfreq)); \ |
|
|
|
{ \ |
|
|
|
emit doinui_signal(QFunction([this, infreq, outfreq]() { \ |
|
|
|
ui->TriInX_OutSignalFreq_Val_##index->setText(QString::number(outfreq, 'f', 2)); \ |
|
|
|
ui->TriInX_InSignalFreq_Val_##index->setText(QString::number(infreq, 'f', 2)); \ |
|
|
|
})); \ |
|
|
|
} |
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
|
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::refreshReadonlyPage2() { |
|
|
|
if (!G_QTDataChannel.isOpen()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 刷新光源时序控制页面
|
|
|
|
{ |
|
|
|
float infreq; |
|
|
|
float outfreq; |
|
|
|
uint32_t state; |
|
|
|
|
|
|
|
#define UPDATE(index) \
|
|
|
|
DO_NO_RET(m_clstc->LightSrcX_readInSigFreqDetect(index, infreq)); \ |
|
|
|
DO_NO_RET(m_clstc->LightSrcX_readOutSigFreqDetect(index, outfreq)); \ |
|
|
|
DO_NO_RET(m_clstc->LightSrcX_readLightSrcErrorState(index, state)); \ |
|
|
|
{ \ |
|
|
|
emit doinui_signal(QFunction([this, infreq, outfreq, state]() { \ |
|
|
|
ui->LightSrcX_InSigFreqDetect_##index->setText(QString::number(infreq, 'f', 2)); \ |
|
|
|
ui->LightSrcX_OutSigFreqDetect_##index->setText(QString::number(outfreq, 'f', 2)); \ |
|
|
|
ui->LightSrcX_LightSrcErrorState_##index->setText(QString::number(state)); \ |
|
|
|
})); \ |
|
|
|
} |
|
|
|
|
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::refreshReadonlyPage3() { |
|
|
|
if (!G_QTDataChannel.isOpen()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
bool MainWindow::checkConnected() { |
|
|
|
if (!G_QTDataChannel.isOpen()) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
uint32_t val; |
|
|
|
zaf_error_code_t ecode = m_clstc->reg_read(kreg_software_version, val); |
|
|
|
if (ecode != kaf_ec_success) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
zaf_error_code_t MainWindow::refreshPage() { |
|
|
|
/*******************************************************************************
|
|
|
|
* 刷新内部触发源页面 * |
|
|
|
*******************************************************************************/ |
|
|
|
{ |
|
|
|
float Freq; |
|
|
|
uint32_t PluseCnt; |
|
|
|
uint32_t SeqCtrlPluseCntMax; |
|
|
|
float TriOutSignalFreq; |
|
|
|
|
|
|
|
DO(m_clstc->InterClk_getFreq(Freq)); |
|
|
|
DO(m_clstc->InterClk_getPluseCnt(PluseCnt)); |
|
|
|
DO(m_clstc->InterClk_getSeqCtrlPluseCntMax(SeqCtrlPluseCntMax)); |
|
|
|
DO(m_clstc->InterClk_readTriOutSignalFreq(TriOutSignalFreq)); |
|
|
|
|
|
|
|
ui->InterClk_Freq_Text->setText(QString::number(Freq, 'f', 2)); |
|
|
|
ui->InterClk_PluseCnt_Text->setText(QString::number(PluseCnt)); |
|
|
|
ui->InterClk_SeqCtrlPluseCntMax_Text->setText(QString::number(SeqCtrlPluseCntMax)); |
|
|
|
ui->InterClk_TriOutSignalFreq_Text->setText(QString::number(TriOutSignalFreq, 'f', 2)); |
|
|
|
} |
|
|
|
/*******************************************************************************
|
|
|
|
* 刷新外部触发源页面 * |
|
|
|
*******************************************************************************/ |
|
|
|
{ |
|
|
|
ExtTriggerSrcType src; |
|
|
|
SigProcessMode mode; |
|
|
|
TriggerEdge edge; |
|
|
|
uint32_t coefficient; |
|
|
|
uint32_t bias; |
|
|
|
uint32_t division; |
|
|
|
uint32_t multiplication; |
|
|
|
float infreq; |
|
|
|
float outfreq; |
|
|
|
uint32_t cnt; |
|
|
|
// TriInX_setSequentialControlPluseCntMax
|
|
|
|
#define UPDATE(index) \
|
|
|
|
DO(m_clstc->TriInX_getSrcSelect(index, src)); \ |
|
|
|
DO(m_clstc->TriInX_getFileterCoefficient(index, coefficient)); \ |
|
|
|
DO(m_clstc->TriInX_getFreqDetectBias(index, bias)); \ |
|
|
|
DO(m_clstc->TriInX_getMode(index, mode)); \ |
|
|
|
DO(m_clstc->TriInX_getTriggerModeTriggerEdge(index, edge)); \ |
|
|
|
DO(m_clstc->TriInX_getTriggerModeFreqDivision(index, division)); \ |
|
|
|
DO(m_clstc->TriInX_getTriggerModeFreqMultiplication(index, multiplication)); \ |
|
|
|
DO(m_clstc->TriInX_readInSignalFreq(index, infreq)); \ |
|
|
|
DO(m_clstc->TriInX_readOutSignalFreq(index, outfreq)); \ |
|
|
|
DO(m_clstc->TriInX_getSequentialControlPluseCntMax(index, cnt)); \ |
|
|
|
ui->TriInX_SrcSelect_Val_##index->setCurrentText(QString::fromStdString(src.toString())); \ |
|
|
|
ui->TriInX_FileterCoefficient_Val_##index->setText(QString::number(coefficient)); \ |
|
|
|
ui->TriInX_FreqDetectBias_Val_##index->setText(QString::number(bias)); \ |
|
|
|
ui->TriInX_Mode_Val_##index->setCurrentText(QString::fromStdString(mode.toString())); \ |
|
|
|
ui->TriInX_OutSignalFreq_Val_##index->setText(QString::number(outfreq, 'f', 2)); \ |
|
|
|
ui->TriInX_InSignalFreq_Val_##index->setText(QString::number(infreq, 'f', 2)); \ |
|
|
|
ui->TriInX_TriggerModeFreqDivision_Val_##index->setText(QString::number(division)); \ |
|
|
|
ui->TriInX_TriggerModeFreqMultiplication_Val_##index->setText(QString::number(multiplication)); \ |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_##index->setCurrentText(QString::fromStdString(edge.toString())); \ |
|
|
|
ui->TriInX_SequentialControlPluseCntMax_Val_##index->setText(QString::number(cnt)); |
|
|
|
|
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
|
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
|
|
|
|
// 刷新光源时序控制页面
|
|
|
|
{ |
|
|
|
InternalSig src; |
|
|
|
uint32_t width; |
|
|
|
uint32_t offset; |
|
|
|
float duty; |
|
|
|
float freq; |
|
|
|
uint32_t state; |
|
|
|
float infreq; |
|
|
|
float outfreq; |
|
|
|
|
|
|
|
#define UPDATE(index) \
|
|
|
|
DO(m_clstc->LightSrcX_getTriSrc(index, src)); \ |
|
|
|
DO(m_clstc->LightSrcX_getTriggerModePluseWidth(index, width)); \ |
|
|
|
DO(m_clstc->LightSrcX_getTriggerModeFirstPluseOffset(index, offset)); \ |
|
|
|
DO(m_clstc->LightSrcX_getLightIntensityDuty(index, duty)); \ |
|
|
|
DO(m_clstc->LightSrcX_getLightDriverFreq(index, freq)); \ |
|
|
|
DO(m_clstc->LightSrcX_readLightSrcErrorState(index, state)); \ |
|
|
|
DO(m_clstc->LightSrcX_readInSigFreqDetect(index, infreq)); \ |
|
|
|
DO(m_clstc->LightSrcX_readOutSigFreqDetect(index, outfreq)); \ |
|
|
|
ui->LightSrcX_TriSrc_##index->setCurrentText(QString::fromStdString(src.toString())); \ |
|
|
|
ui->LightSrcX_TriggerModePluseWidth_##index->setText(QString::number(width)); \ |
|
|
|
ui->LightSrcX_TriggerModeFirstPluseOffset_##index->setText(QString::number(offset)); \ |
|
|
|
ui->LightSrcX_LightIntensityDuty_##index->setText(QString::number(duty, 'f', 2)); \ |
|
|
|
ui->LightSrcX_LightDriverFreq_##index->setText(QString::number(freq, 'f', 2)); \ |
|
|
|
ui->LightSrcX_LightSrcErrorState_##index->setText(QString::number(state)); \ |
|
|
|
ui->LightSrcX_InSigFreqDetect_##index->setText(QString::number(infreq, 'f', 2)); \ |
|
|
|
ui->LightSrcX_OutSigFreqDetect_##index->setText(QString::number(outfreq, 'f', 2)); |
|
|
|
|
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
SigProcessMode mode; |
|
|
|
uint32_t offset; |
|
|
|
uint32_t bindstate1; |
|
|
|
uint32_t bindstate2; |
|
|
|
uint32_t bindstate3; |
|
|
|
uint32_t bindstate4; |
|
|
|
InternalSig sig; |
|
|
|
uint32_t reversal; |
|
|
|
|
|
|
|
// zaf_error_code_t ShutterX_setOutPolarityReversal(int32_t index, uint32_t reversal);
|
|
|
|
|
|
|
|
#define UPDATE(index) \
|
|
|
|
DO(m_clstc->ShutterX_getOutputCtrlMode(index, mode)); \ |
|
|
|
DO(m_clstc->ShutterX_getLtEnOffset(index, offset)); \ |
|
|
|
DO(m_clstc->ShutterX_getLtEnBind(index, 1, bindstate1)); \ |
|
|
|
DO(m_clstc->ShutterX_getLtEnBind(index, 2, bindstate2)); \ |
|
|
|
DO(m_clstc->ShutterX_getLtEnBind(index, 3, bindstate3)); \ |
|
|
|
DO(m_clstc->ShutterX_getLtEnBind(index, 4, bindstate4)); \ |
|
|
|
DO(m_clstc->ShutterX_getInSigSelect(index, sig)); \ |
|
|
|
DO(m_clstc->ShutterX_getOutPolarityReversal(index, reversal)); \ |
|
|
|
ui->ShutterX_OutputCtrlMode_##index->setCurrentText(QString::fromStdString(mode.toString())); \ |
|
|
|
ui->ShutterX_LtEnOffset_##index->setText(QString::number(offset)); \ |
|
|
|
ui->ShutterX_LtEnBind_val1_##index->setChecked(bindstate1 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ |
|
|
|
ui->ShutterX_LtEnBind_val2_##index->setChecked(bindstate2 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ |
|
|
|
ui->ShutterX_LtEnBind_val3_##index->setChecked(bindstate3 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ |
|
|
|
ui->ShutterX_LtEnBind_val4_##index->setChecked(bindstate4 != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); \ |
|
|
|
ui->ShutterX_InSigSelect_##index->setCurrentText(QString::fromStdString(sig.toString())); \ |
|
|
|
ui->ShutterX_OutPolarityReversal_##index->setChecked(reversal != 0 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); |
|
|
|
|
|
|
|
// ui->ShutterX_LtEnBind_val1_1->checkState()
|
|
|
|
|
|
|
|
UPDATE(1); |
|
|
|
UPDATE(2); |
|
|
|
UPDATE(3); |
|
|
|
UPDATE(4); |
|
|
|
#undef UPDATE
|
|
|
|
} |
|
|
|
|
|
|
|
return kaf_ec_success; |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::constructUI() { |
|
|
|
/*******************************************************************************
|
|
|
|
* serialPortCB * |
|
|
|
*******************************************************************************/ |
|
|
|
const auto infos = QSerialPortInfo::availablePorts(); |
|
|
|
for (const QSerialPortInfo &info : infos) { |
|
|
|
ui->serialPortCB->addItem(info.portName()); |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 波特率填?? * |
|
|
|
*******************************************************************************/ |
|
|
|
ui->serialBaudrateCB->addItem("9600"); |
|
|
|
ui->serialBaudrateCB->addItem("14400"); |
|
|
|
ui->serialBaudrateCB->addItem("19200"); |
|
|
|
ui->serialBaudrateCB->addItem("38400"); |
|
|
|
ui->serialBaudrateCB->addItem("57600"); |
|
|
|
ui->serialBaudrateCB->addItem("115200"); |
|
|
|
ui->serialBaudrateCB->addItem("500000"); |
|
|
|
ui->serialBaudrateCB->setCurrentIndex(6); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 刷新串口 * |
|
|
|
*******************************************************************************/ |
|
|
|
connect(ui->serialPortRefreshKey, &QPushButton::clicked, this, [this](bool check) { |
|
|
|
ui->serialPortCB->clear(); |
|
|
|
const auto infos = QSerialPortInfo::availablePorts(); |
|
|
|
for (const QSerialPortInfo &info : infos) { |
|
|
|
ui->serialPortCB->addItem(info.portName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 打开串口 * |
|
|
|
*******************************************************************************/ |
|
|
|
connect(ui->serialOpenKey, &QPushButton::clicked, this, [=](bool check) { |
|
|
|
// 打开串口
|
|
|
|
if (ui->serialOpenKey->text() == "打开") { |
|
|
|
G_QTDataChannel.setPortName(ui->serialPortCB->currentText().toStdString()); |
|
|
|
G_QTDataChannel.setBaudRate(ui->serialBaudrateCB->currentText().toInt()); |
|
|
|
G_QTDataChannel.setDataBits(QSerialPort::Data8); |
|
|
|
G_QTDataChannel.setParity(QSerialPort::NoParity); |
|
|
|
G_QTDataChannel.setFlowControl(QSerialPort::NoFlowControl); |
|
|
|
G_QTDataChannel.setStopBits(QSerialPort::OneStop); |
|
|
|
|
|
|
|
if (!G_QTDataChannel.open()) { |
|
|
|
QMessageBox::about(NULL, "提示", "串口无法打开,串口不存在或已被占??"); |
|
|
|
return; |
|
|
|
} |
|
|
|
ui->serialOpenKey->setText("关闭"); |
|
|
|
// 下拉菜单控件使能
|
|
|
|
ui->serialBaudrateCB->setEnabled(false); |
|
|
|
ui->serialPortCB->setEnabled(false); |
|
|
|
ui->serialPortRefreshKey->setEnabled(false); |
|
|
|
} else { |
|
|
|
G_QTDataChannel.close(); |
|
|
|
ui->serialOpenKey->setText("打开"); |
|
|
|
ui->serialBaudrateCB->setEnabled(true); |
|
|
|
ui->serialPortCB->setEnabled(true); |
|
|
|
ui->serialPortRefreshKey->setEnabled(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 刷新页面 * |
|
|
|
*******************************************************************************/ |
|
|
|
connect(ui->refreshPageKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
zaf_error_code_t ecode = refreshPage(); |
|
|
|
if (ecode != kaf_ec_success) return; |
|
|
|
|
|
|
|
dumpLog("刷新成功"); |
|
|
|
displayInfo(true, "刷新成功"); |
|
|
|
QMessageBox::about(NULL, "消息", "刷新成功"); |
|
|
|
}); |
|
|
|
|
|
|
|
connect(ui->UpdateCfg_Key, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
zaf_error_code_t ecode = updatePage(); |
|
|
|
if (ecode != kaf_ec_success) return; |
|
|
|
ecode = refreshPage(); |
|
|
|
if (ecode != kaf_ec_success) return; |
|
|
|
|
|
|
|
dumpLog("提交成功"); |
|
|
|
displayInfo(true, "提交成功"); |
|
|
|
QMessageBox::about(NULL, "消息", "提交成功"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 保存配置 * |
|
|
|
*******************************************************************************/ |
|
|
|
connect(ui->storageConfigKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO(m_clstc->storageConfigs()); |
|
|
|
dumpLog("保存配置成功"); |
|
|
|
displayInfo(true, "保存配置成功"); |
|
|
|
QMessageBox::about(NULL, "消息", "保存配置成功"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 重启设备 * |
|
|
|
*******************************************************************************/ |
|
|
|
connect(ui->rebootDeviceKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO_NO_RET(m_clstc->reboot()); |
|
|
|
dumpLog("重启设备成功"); |
|
|
|
displayInfo(true, "重启设备成功"); |
|
|
|
QMessageBox::about(NULL, "消息", "重启设备成功"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 恢复出厂设置 * |
|
|
|
*******************************************************************************/ |
|
|
|
connect(ui->factoryResetKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO_NO_RET(m_clstc->factoryReset()); |
|
|
|
dumpLog("恢复出厂设置成功"); |
|
|
|
displayInfo(true, "恢复出厂设置成功"); |
|
|
|
QMessageBox::about(NULL, "消息", "恢复出厂设置成功"); |
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 寄存器操?? * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
ui->RegAdd->setText("0x00000000"); |
|
|
|
connect(ui->regReadKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
uint32_t addr = str2int(ui->RegAdd->text()); |
|
|
|
uint32_t value = 0; |
|
|
|
DO_NO_RET(m_clstc->reg_read(addr, value, 100)); |
|
|
|
ui->regReadbakVal->setText(fmt("0x%08X", value)); |
|
|
|
dumpLog(fmt("读取0x%04x成功", addr)); |
|
|
|
}); |
|
|
|
|
|
|
|
connect(ui->regWriteKey, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
uint32_t addr = str2int(ui->RegAdd->text()); |
|
|
|
uint32_t value = str2int(ui->regWriteVal->text()); |
|
|
|
uint32_t readkbak = 0; |
|
|
|
DO_NO_RET(m_clstc->reg_write(addr, value, readkbak, 100)); |
|
|
|
ui->regReadbakVal->setText(fmt("0x%04x", readkbak)); |
|
|
|
dumpLog(fmt("写入0x%08x成功", addr)); |
|
|
|
}); |
|
|
|
|
|
|
|
connect(ui->InterClk_trigger_Key, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO_NO_RET(m_clstc->InterClk_trigger()); |
|
|
|
dumpLog(fmt("触发成功")); |
|
|
|
}); |
|
|
|
connect(ui->InterClk_stop_Key, &QPushButton::clicked, this, [=](bool check) { //
|
|
|
|
DO_NO_RET(m_clstc->InterClk_stop()); |
|
|
|
dumpLog(fmt("停止触发成功")); |
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 外部触发页面初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
ui->TriInX_SrcSelect_Val_1->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::DIFF_INPUT).toString())); |
|
|
|
ui->TriInX_SrcSelect_Val_1->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::OPTOCOUPLER_INPUT).toString())); |
|
|
|
ui->TriInX_Mode_Val_1->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRIGGER_MODE).toString())); |
|
|
|
ui->TriInX_Mode_Val_1->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_1->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::RISING).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_1->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::FALLING).toString())); |
|
|
|
|
|
|
|
ui->TriInX_SrcSelect_Val_2->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::DIFF_INPUT).toString())); |
|
|
|
ui->TriInX_SrcSelect_Val_2->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::OPTOCOUPLER_INPUT).toString())); |
|
|
|
ui->TriInX_Mode_Val_2->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRIGGER_MODE).toString())); |
|
|
|
ui->TriInX_Mode_Val_2->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_2->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::RISING).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_2->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::FALLING).toString())); |
|
|
|
|
|
|
|
ui->TriInX_SrcSelect_Val_3->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::DIFF_INPUT).toString())); |
|
|
|
ui->TriInX_SrcSelect_Val_3->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::OPTOCOUPLER_INPUT).toString())); |
|
|
|
ui->TriInX_Mode_Val_3->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRIGGER_MODE).toString())); |
|
|
|
ui->TriInX_Mode_Val_3->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_3->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::RISING).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_3->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::FALLING).toString())); |
|
|
|
|
|
|
|
ui->TriInX_SrcSelect_Val_4->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::DIFF_INPUT).toString())); |
|
|
|
ui->TriInX_SrcSelect_Val_4->addItem(QString::fromStdString(ExtTriggerSrcType(ExtTriggerSrcType::OPTOCOUPLER_INPUT).toString())); |
|
|
|
ui->TriInX_Mode_Val_4->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRIGGER_MODE).toString())); |
|
|
|
ui->TriInX_Mode_Val_4->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_4->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::RISING).toString())); |
|
|
|
ui->TriInX_TriggerModeTriggerEdge_Val_4->addItem(QString::fromStdString(TriggerEdge(TriggerEdge::FALLING).toString())); |
|
|
|
|
|
|
|
ui->TriInX_InSignalFreq_Val_1->setDisabled(true); |
|
|
|
ui->TriInX_InSignalFreq_Val_2->setDisabled(true); |
|
|
|
ui->TriInX_InSignalFreq_Val_3->setDisabled(true); |
|
|
|
ui->TriInX_InSignalFreq_Val_4->setDisabled(true); |
|
|
|
|
|
|
|
ui->TriInX_OutSignalFreq_Val_1->setDisabled(true); |
|
|
|
ui->TriInX_OutSignalFreq_Val_2->setDisabled(true); |
|
|
|
ui->TriInX_OutSignalFreq_Val_3->setDisabled(true); |
|
|
|
ui->TriInX_OutSignalFreq_Val_4->setDisabled(true); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 光源时序配置 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
QStringList LightSrcX_TriSrc_QStringList; |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::LOGIC0).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::LOGIC1).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::INTERNAL_TRIGGER).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::INTERNAL_TRIGGER_I1).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::INTERNAL_TRIGGER_I2).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::INTERNAL_TRIGGER_I3).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::INTERNAL_TRIGGER_I4).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_1).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_1_I1).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_1_I2).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_1_I3).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_1_I4).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_2).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_2_I1).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_2_I2).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_2_I3).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_2_I4).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_3).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_3_I1).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_3_I2).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_3_I3).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_3_I4).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_4).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_4_I1).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_4_I2).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_4_I3).toString())); |
|
|
|
LightSrcX_TriSrc_QStringList.append(QString::fromStdString(InternalSig(InternalSig::EXT_TRIGGER_4_I4).toString())); |
|
|
|
|
|
|
|
ui->LightSrcX_TriSrc_1->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
ui->LightSrcX_TriSrc_2->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
ui->LightSrcX_TriSrc_3->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
ui->LightSrcX_TriSrc_4->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
|
|
|
|
ui->LightSrcX_InSigFreqDetect_1->setDisabled(true); |
|
|
|
ui->LightSrcX_InSigFreqDetect_2->setDisabled(true); |
|
|
|
ui->LightSrcX_InSigFreqDetect_3->setDisabled(true); |
|
|
|
ui->LightSrcX_InSigFreqDetect_4->setDisabled(true); |
|
|
|
|
|
|
|
ui->LightSrcX_OutSigFreqDetect_1->setDisabled(true); |
|
|
|
ui->LightSrcX_OutSigFreqDetect_2->setDisabled(true); |
|
|
|
ui->LightSrcX_OutSigFreqDetect_3->setDisabled(true); |
|
|
|
ui->LightSrcX_OutSigFreqDetect_4->setDisabled(true); |
|
|
|
|
|
|
|
ui->LightSrcX_LightSrcErrorState_1->setDisabled(true); |
|
|
|
ui->LightSrcX_LightSrcErrorState_2->setDisabled(true); |
|
|
|
ui->LightSrcX_LightSrcErrorState_3->setDisabled(true); |
|
|
|
ui->LightSrcX_LightSrcErrorState_4->setDisabled(true); |
|
|
|
|
|
|
|
ui->LightSrcX_LightDriverFreq_1->setDisabled(false); |
|
|
|
ui->LightSrcX_LightDriverFreq_2->setDisabled(false); |
|
|
|
ui->LightSrcX_LightDriverFreq_3->setDisabled(false); |
|
|
|
ui->LightSrcX_LightDriverFreq_4->setDisabled(false); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 快门时序配置页面 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
ui->ShutterX_OutputCtrlMode_1->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
ui->ShutterX_OutputCtrlMode_2->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
ui->ShutterX_OutputCtrlMode_3->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
ui->ShutterX_OutputCtrlMode_4->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::TRANSPARENT_MODE).toString())); |
|
|
|
|
|
|
|
ui->ShutterX_OutputCtrlMode_1->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); |
|
|
|
ui->ShutterX_OutputCtrlMode_2->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); |
|
|
|
ui->ShutterX_OutputCtrlMode_3->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); |
|
|
|
ui->ShutterX_OutputCtrlMode_4->addItem(QString::fromStdString(SigProcessMode(SigProcessMode::BIND_MODE).toString())); |
|
|
|
|
|
|
|
ui->ShutterX_InSigSelect_1->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
ui->ShutterX_InSigSelect_2->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
ui->ShutterX_InSigSelect_3->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
ui->ShutterX_InSigSelect_4->addItems(LightSrcX_TriSrc_QStringList); |
|
|
|
|
|
|
|
ui->InterClk_TriOutSignalFreq_Text->setDisabled(true); |
|
|
|
} |
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { |
|
|
|
// G_SerialPort.moveToThread();
|
|
|
|
// QObject::connect(&G_SerialPortThread, &QThread::started, &G_SerialPort, &QSerialPort::open);
|
|
|
|
|
|
|
|
G_QTDataChannel.init(); |
|
|
|
CLSTControler::ins()->initialize(&G_QTDataChannel); |
|
|
|
m_clstc = CLSTControler::ins(); |
|
|
|
|
|
|
|
ui->setupUi(this); |
|
|
|
m_mainWindow = this; |
|
|
|
|
|
|
|
qRegisterMetaType<int32_t>("int32_t"); |
|
|
|
qRegisterMetaType<uint32_t>("uint32_t"); |
|
|
|
qRegisterMetaType<float>("float"); |
|
|
|
qRegisterMetaType<function<void()>>("function<void()>"); |
|
|
|
qRegisterMetaType<QFunction>("QFunction"); |
|
|
|
// qInstallMessageHandler(log_output);
|
|
|
|
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); |
|
|
|
constructUI(); |
|
|
|
|
|
|
|
// 创建定时器
|
|
|
|
timer0 = new QTimer(this); |
|
|
|
timer1 = new QTimer(this); |
|
|
|
timer2 = new QTimer(this); |
|
|
|
timer3 = new QTimer(this); |
|
|
|
checkConnectTimer0 = new QTimer(this); |
|
|
|
|
|
|
|
m_zqthread = new ZQThread("", [this]() { |
|
|
|
while (true) { |
|
|
|
static bool first = true; |
|
|
|
bool connect = checkConnected(); |
|
|
|
if (m_connected != connect || first) { |
|
|
|
first = false; |
|
|
|
m_connected = connect; |
|
|
|
emit doinui_signal(QFunction([this, connect]() { |
|
|
|
if (connect) { |
|
|
|
ui->DeviceConnectStateTB->setText("已连接"); |
|
|
|
ui->DeviceConnectStateTB->setStyleSheet("color: green"); |
|
|
|
displayInfo(true, "连接成功"); |
|
|
|
} else { |
|
|
|
ui->DeviceConnectStateTB->setText("未连接"); |
|
|
|
ui->DeviceConnectStateTB->setStyleSheet("color: red"); |
|
|
|
} |
|
|
|
if (m_connected) { |
|
|
|
refreshPage(); |
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
refreshReadonlyPage0(); |
|
|
|
refreshReadonlyPage1(); |
|
|
|
refreshReadonlyPage2(); |
|
|
|
refreshReadonlyPage3(); |
|
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); |
|
|
|
} |
|
|
|
}); |
|
|
|
m_zqthread->start(); |
|
|
|
|
|
|
|
// connect(timer0, &QTimer::timeout, this, [this]() { refreshReadonlyPage0(); });
|
|
|
|
// connect(timer1, &QTimer::timeout, this, [this]() { refreshReadonlyPage1(); });
|
|
|
|
// connect(timer2, &QTimer::timeout, this, [this]() { refreshReadonlyPage2(); });
|
|
|
|
// connect(timer3, &QTimer::timeout, this, [this]() { refreshReadonlyPage3(); });
|
|
|
|
|
|
|
|
// connect(checkConnectTimer0, &QTimer::timeout, this, [this]() { //
|
|
|
|
// static bool connected = false;
|
|
|
|
// bool connect = checkConnected();
|
|
|
|
// if (connect) {
|
|
|
|
// ui->DeviceConnectStateTB->setText("已连接");
|
|
|
|
// ui->DeviceConnectStateTB->setStyleSheet("color: green");
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
// ui->DeviceConnectStateTB->setText("未连接");
|
|
|
|
// ui->DeviceConnectStateTB->setStyleSheet("color: red");
|
|
|
|
// }
|
|
|
|
// if (connected != connect) {
|
|
|
|
// connected = connect;
|
|
|
|
// if (connected) {
|
|
|
|
// refreshPage();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
// timer0->setInterval(1100); // 每隔一秒触发一次
|
|
|
|
// timer1->setInterval(1200); // 每隔一秒触发一次
|
|
|
|
// timer2->setInterval(900); // 每隔一秒触发一次
|
|
|
|
// timer3->setInterval(1000); // 每隔一秒触发一次
|
|
|
|
// checkConnectTimer0->setInterval(100);
|
|
|
|
// timer0->start();
|
|
|
|
// timer1->start();
|
|
|
|
// timer2->start();
|
|
|
|
// timer3->start();
|
|
|
|
// checkConnectTimer0->start();
|
|
|
|
|
|
|
|
// m_clstc->regRawDataListener([this](uart_message_type_t type, uint8_t *data, size_t len) {
|
|
|
|
// QString text;
|
|
|
|
// if (type == kuart_raw_tx) {
|
|
|
|
// text.append("TX: ");
|
|
|
|
// for (size_t i = 0; i < len; i++) {
|
|
|
|
// text.append(fmt("%02X ", data[i]));
|
|
|
|
// }
|
|
|
|
// } else if (type == kuart_raw_rx) {
|
|
|
|
// text.append("RX: ");
|
|
|
|
// for (size_t i = 0; i < len; i++) {
|
|
|
|
// text.append(fmt("%02X ", data[i]));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// emit doinui_signal(QFunction([this, text]() {
|
|
|
|
// if (ui->instructionPreview->document()->lineCount() > 100) {
|
|
|
|
// ui->instructionPreview->document()->clear();
|
|
|
|
// }
|
|
|
|
// ui->instructionPreview->append(text);
|
|
|
|
// }));
|
|
|
|
// });
|
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::dumpLog(const char *fmt, ...) { |
|
|
|
va_list args; |
|
|
|
va_start(args, fmt); |
|
|
@ -878,4 +82,28 @@ void MainWindow::displayInfo(bool suc, QString info) { |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { |
|
|
|
/*******************************************************************************
|
|
|
|
* QT初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
ui->setupUi(this); |
|
|
|
m_mainWindow = this; |
|
|
|
qRegisterMetaType<int32_t>("int32_t"); |
|
|
|
qRegisterMetaType<uint32_t>("uint32_t"); |
|
|
|
qRegisterMetaType<float>("float"); |
|
|
|
qRegisterMetaType<function<void()>>("function<void()>"); |
|
|
|
qRegisterMetaType<QFunction>("QFunction"); |
|
|
|
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 页面逻辑初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
constructUI(); |
|
|
|
} |
|
|
|
MainWindow::~MainWindow() { delete ui; } |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* UI相关构造 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
void MainWindow::constructUI() {} |