115 lines
2.4 KiB
C++
115 lines
2.4 KiB
C++
#include "LoggerWidget.h"
|
|
#include "msg.h"
|
|
#include "spdlog/sinks/qt_sinks.h"
|
|
#include "spdlog/sinks/basic_file_sink.h"
|
|
#include "ui_LoggerWidget.h"
|
|
|
|
#include <QMessageBox>
|
|
|
|
LoggerWidget::LoggerWidget(QWidget *parent)
|
|
: QWidget(parent)
|
|
, ui(new Ui::LoggerWidget)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
m_logger = spdlog::qt_color_logger_mt("logger", ui->txtLogger, 500,true);
|
|
m_logger->set_level(spdlog::level::info);
|
|
|
|
}
|
|
|
|
LoggerWidget::~LoggerWidget()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void LoggerWidget::on_btnClear_clicked()
|
|
{
|
|
ui->txtLogger->clear();
|
|
}
|
|
|
|
void LoggerWidget::updateRespStatus(const QString &text)
|
|
{
|
|
ui->cmdResp->setText(text);
|
|
}
|
|
|
|
void LoggerWidget::clearRespStatus()
|
|
{
|
|
ui->cmdResp->clear();
|
|
}
|
|
|
|
void LoggerWidget::on_btnUCarrierType_clicked()
|
|
{
|
|
clearRespStatus();
|
|
emit sendUdpRequest(pack_debug_cmd_UCattierType(ui->uCarrierType->currentIndex())); // 发射信号
|
|
}
|
|
|
|
|
|
void LoggerWidget::on_btnURate_clicked()
|
|
{
|
|
clearRespStatus();
|
|
emit sendUdpRequest(pack_debug_cmd_URate(ui->uRate->currentIndex()));
|
|
}
|
|
|
|
int LoggerWidget::checkFreq(const QString& freq){
|
|
bool result;
|
|
if (freq.isEmpty()) {
|
|
QMessageBox::information(this, "错误", "请输入正确信道号");
|
|
return 0;
|
|
}
|
|
|
|
int freqValue = freq.toInt(&result);
|
|
|
|
if(result && freqValue >= 1 && freqValue <= 1388)
|
|
{
|
|
return freqValue;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void LoggerWidget::on_btnSFreq_clicked()
|
|
{
|
|
uint16_t freq = 0;
|
|
freq = checkFreq(ui->sFreq->text());
|
|
if(freq != 0)
|
|
{
|
|
clearRespStatus();
|
|
emit sendUdpRequest(pack_debug_cmd_SFreq(freq));
|
|
}
|
|
}
|
|
|
|
|
|
void LoggerWidget::on_btnSRate_clicked()
|
|
{
|
|
clearRespStatus();
|
|
emit sendUdpRequest(pack_debug_cmd_SRate(ui->sRate->currentIndex()));
|
|
}
|
|
|
|
|
|
void LoggerWidget::on_btnPa_clicked()
|
|
{
|
|
clearRespStatus();
|
|
emit sendUdpRequest(pack_debug_cmd_PASwitch(ui->sPa->isChecked(), ui->uPa->isChecked(), ui->bdPa->isChecked()));
|
|
}
|
|
|
|
|
|
void LoggerWidget::on_btnZTCtrl_clicked()
|
|
{
|
|
clearRespStatus();
|
|
emit sendUdpRequest(pack_debug_cmd_ZTCtrl(ui->ztCtrlType->currentIndex()));
|
|
}
|
|
|
|
void LoggerWidget::on_btnCmdSend_clicked()
|
|
{
|
|
if(ui->cmdContent->text().isEmpty())
|
|
{
|
|
QMessageBox::information(this, "错误", "请输入指令内容");
|
|
return;
|
|
}
|
|
clearRespStatus();
|
|
emit sendUdpRequest(pack_debug_cmd_CmdCtrl(ui->cmdType->currentIndex(), ui->cmdContent->text().toStdString()));
|
|
int a = 1;
|
|
}
|
|
|
|
|