You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.4 KiB

#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);
3 years ago
// ApiResult _resultInit = _honaAPI.init();
// ApiResult _hsruStartResult = _honaAPI.hsruStart();
}
MainWindow::~MainWindow()
{
delete ui;
}
/*************************************************************************************************/
void MainWindow::honaDataResultUi(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa)
{
QString _str;
3 years ago
_str = QDateTime::currentDateTime().toString("hh:mm:ss.z") + "\nhonaPacketList size " + QString::number(honaPacketList.size());
for(auto i = 0; i < qMin(10, honaPacketList.length()); i++)
{
3 years ago
_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);
3 years ago
qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss.z") << " honaPacketList size "<< honaPacketList.size();
}
3 years ago
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()
{
3 years ago
//********************************************************
ApiResult _resultInit = _honaAPI.init();
3 years ago
ui->errorMonitoring->setText("_resultInit: " + resultString(_resultInit));
//********************************************************
3 years ago
ApiResult _hsruStartResult = _honaAPI.hsruStart();
QString temp = ui->errorMonitoring->text();
3 years ago
ui->errorMonitoring->setText(temp + "\n _hsruStartResult: " + resultString(_hsruStartResult));
3 years ago
}
void MainWindow::on_resetDevice_clicked()
{
ApiResult _hsruStop = _honaAPI.hsruStop();
ui->errorMonitoring->setText("hsruStop: " + resultString(_hsruStop));
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_stopHsru_clicked()
{
3 years ago
ApiResult _hsruStop = _honaAPI.hsruStop();
3 years ago
ui->errorMonitoring->setText("hsruStop: " + resultString(_hsruStop));
}