#include "MainWindow.h" #include "ui_MainWindow.h" MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); connect(&_honaAPI, &HonaAPI::honaDataResult, this, &MainWindow::honaDataResultUi); // ApiResult _resultInit = _honaAPI.init(); // ApiResult _hsruStartResult = _honaAPI.hsruStart(); } MainWindow::~MainWindow() { delete ui; } /*************************************************************************************************/ void MainWindow::honaDataResultUi(QList honaPacketList, quint32 hsruLoss, quint32 Doa) { QString _str; _str = QDateTime::currentDateTime().toString("hh:mm:ss.z") + "\nhonaPacketList size " + QString::number(honaPacketList.size()); for(auto i = 0; i < qMin(10, honaPacketList.length()); i++) { _str += "\n[PacketType] :" + QString::number(honaPacketList[i].getPacketType()); _str += "\n[PacketNumber] :" + QString::number(honaPacketList[i].getPacketNumber()); _str += "\n[Toa] :" + QString::number(honaPacketList[i].getToa()); _str += "\n[Doa] :" + QString::number(honaPacketList[i].getDoa()); _str += "\n[Pa1] :" + QString::number(honaPacketList[i].getPa1()); _str += "\n[Pa2] :" + QString::number(honaPacketList[i].getPa2()); _str += "\n[Pa3] :" + QString::number(honaPacketList[i].getPa3()); _str += "\n[Pa4] :" + QString::number(honaPacketList[i].getPa4()); _str += "\n[Code] :" + QString::number(honaPacketList[i].getCode(), 16); _str += "\n[CodeL] :" + QString::number(honaPacketList[i].getCodeL(), 16); _str += "\n[CodeM] :" + QString::number(honaPacketList[i].getCodeM(), 16); _str += "\n[hsruLoss] :" + QString::number(hsruLoss); _str += "\n[doa] :" + QString::number(Doa); } ui->dataFromMemory->setText(_str); qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss.z") << " honaPacketList size "<< honaPacketList.size(); } QString resultString(ApiResult res){ switch (res) { case ApiResult::success: return "success"; case ApiResult::alreadyStarted: return "alreadyStarted"; case ApiResult::busy: return "busy"; case ApiResult::error: return "error"; } return ""; }; void MainWindow::on_startHsru_clicked() { //******************************************************** ApiResult _resultInit = _honaAPI.init(); ui->errorMonitoring->setText("_resultInit: " + resultString(_resultInit)); //******************************************************** ApiResult _hsruStartResult = _honaAPI.hsruStart(); QString temp = ui->errorMonitoring->text(); ui->errorMonitoring->setText(temp + "\n _hsruStartResult: " + resultString(_hsruStartResult)); } void MainWindow::on_resetDevice_clicked() { ApiResult _hsruStop = _honaAPI.deviceReset(); ui->errorMonitoring->setText("deviceReset: " + resultString(_hsruStop)); } void MainWindow::on_stopHsru_clicked() { ApiResult _hsruStop = _honaAPI.hsruStop(); ui->errorMonitoring->setText("hsruStop: " + resultString(_hsruStop)); }