|
|
@ -80,18 +80,6 @@ void MainWindow::ishow(QString text) { |
|
|
|
info.append(text); |
|
|
|
emit doinui_signal(QFunction([this, info]() { ui->instructionPreview->append(info); })); |
|
|
|
} |
|
|
|
void MainWindow::reportPreviewShow(QString text) { |
|
|
|
QString info; |
|
|
|
|
|
|
|
info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz ")); |
|
|
|
info.append(text); |
|
|
|
emit doinui_signal(QFunction([this, info]() { |
|
|
|
if (ui->reportPreview->document()->lineCount() > 1000) { |
|
|
|
ui->reportPreview->document()->clear(); |
|
|
|
} |
|
|
|
ui->reportPreview->append(info); |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::rawshow(QString text) { |
|
|
|
QString info; |
|
|
@ -110,40 +98,6 @@ void MainWindow::instructionPreviewClear() { |
|
|
|
doinui_signal(QFunction([this]() { ui->instructionPreview->clear(); })); |
|
|
|
} |
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
typedef struct { |
|
|
|
uint16_t header; |
|
|
|
int16_t wave1; |
|
|
|
int16_t wave2; |
|
|
|
int16_t wave3; |
|
|
|
int16_t wave4; |
|
|
|
int16_t wave5; |
|
|
|
uint8_t check; |
|
|
|
uint16_t tail; |
|
|
|
} Wave_t; |
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
void MainWindow::displayWave(int16_t wave1, int16_t wave2, int16_t wave3) { |
|
|
|
// 1. 生成波形数据
|
|
|
|
Wave_t wave; |
|
|
|
wave.header = 0xAAAA; |
|
|
|
wave.wave1 = wave1; |
|
|
|
wave.wave2 = wave2; |
|
|
|
wave.wave3 = wave3; |
|
|
|
wave.wave4 = 0; |
|
|
|
wave.wave5 = 0; |
|
|
|
wave.tail = 0x5555; |
|
|
|
wave.check = 0; |
|
|
|
|
|
|
|
uint8_t check = 0; |
|
|
|
for (size_t i = 2; i < sizeof(wave) - 2; i++) { |
|
|
|
check += ((uint8_t *)&wave)[i]; |
|
|
|
} |
|
|
|
wave.check = check; |
|
|
|
// 2. 发送波形数据
|
|
|
|
G_WaveDataChannel.send((uint8_t *)&wave, sizeof(wave)); |
|
|
|
} |
|
|
|
|
|
|
|
/***********************************************************************************************************************
|
|
|
|
* UI相关构造 * |
|
|
|
***********************************************************************************************************************/ |
|
|
@ -236,7 +190,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi |
|
|
|
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); |
|
|
|
ZQUI::ins()->initialize(); |
|
|
|
ZQUI::ins()->setishow([this](QString text) { ishow(text); }); |
|
|
|
ZQUI::ins()->setReportPreviewShow([this](QString text) { reportPreviewShow(text); }); |
|
|
|
ZQUI::ins()->setrawshow([this](QString text) { rawshow(text); }); |
|
|
|
ZQUI::ins()->setInstructionPreviewClear([this]() { instructionPreviewClear(); }); |
|
|
|
|
|
|
@ -263,20 +216,28 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi |
|
|
|
int32_t packetType = frame->packetType; |
|
|
|
|
|
|
|
if (type == kcmd_cmd) { |
|
|
|
ZQUI::ins()->rawshow("[CMD ] %s", zhex2str(hex, hexlen).c_str()); |
|
|
|
if (cmdId == kmodule_set_reg) { |
|
|
|
ZQUI::ins()->rawshow(" [-->] module_set_reg %d(mid) %d(reg) %d(val)", mid, param[0], param[1]); |
|
|
|
// ZQUI::ins()->rawshow("[CMD ] %s", zhex2str(hex, hexlen).c_str());
|
|
|
|
ZQUI::ins()->rawshow(" [-->] module_set_reg %d(mid) %s(%d) %d(val)", mid, regindex2str(param[0]), param[0], param[1]); |
|
|
|
} else if (cmdId == kmodule_get_reg) { |
|
|
|
ZQUI::ins()->rawshow(" [-->] module_get_reg %d(mid) %d(reg)", mid, param[0]); |
|
|
|
// ZQUI::ins()->rawshow("[CMD ] %s", zhex2str(hex, hexlen).c_str());
|
|
|
|
ZQUI::ins()->rawshow(" [-->] module_get_reg %d(mid) %s(%d)", mid, regindex2str(param[0]), param[0]); |
|
|
|
} else { |
|
|
|
ZQUI::ins()->rawshow(" [-->] index:%d cmdid:0x%04x mid:%d param:%s", frame->packetindex, cmdId, mid, zhex2str(frame->data, hexlen - sizeof(zcr_cmd_header_t)).c_str()); |
|
|
|
if (cmdId != kmodule_get_status) { |
|
|
|
ZQUI::ins()->rawshow("[CMD ] %d cmdid:(%s)0x%04x mid:%d param:%s", frame->packetindex, cmdid2str(cmdId), cmdId, mid, zhex2str(frame->data, hexlen - sizeof(zcr_cmd_header_t)).c_str()); |
|
|
|
} else { |
|
|
|
// ZQUI::ins()->rawshow("[CMD ] %s", zhex2str(hex, hexlen).c_str());
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if (type == kcmd_receipt) { |
|
|
|
if (kptv2_error_ack == packetType) { |
|
|
|
ZQUI::ins()->rawshow("[E-RECEI] %s(%d)", err::error2str(param[0]), param[0]); |
|
|
|
} else { |
|
|
|
ZQUI::ins()->rawshow("[ RECEI] %s", zhex2str(hex, hexlen).c_str()); |
|
|
|
if (cmdId != kmodule_get_status) { |
|
|
|
ZQUI::ins()->rawshow("[ RECEI] %s", zhex2str(hex, hexlen).c_str()); |
|
|
|
} else { |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type == kcmd_report) { |
|
|
|
ZQUI::ins()->rawshow("[REPORT ] %s", zhex2str(hex, hexlen).c_str()); |
|
|
@ -314,7 +275,6 @@ void MainWindow::on_PublicState_DeviceID_textChanged() { PublicState_DeviceIDVal |
|
|
|
|
|
|
|
void MainWindow::on_clearPreview_clicked() { |
|
|
|
doinui_signal(QFunction([this]() { ui->instructionPreview->clear(); })); |
|
|
|
doinui_signal(QFunction([this]() { ui->reportPreview->clear(); })); |
|
|
|
doinui_signal(QFunction([this]() { ui->rawDataPreview->clear(); })); |
|
|
|
} |
|
|
|
|
|
|
|