parent
616af867e3
commit
2c6517030f
|
@ -82,34 +82,34 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
MainWindow::~MainWindow()
|
||||
{
|
||||
this->logInfo("-- 程序退出 --");
|
||||
this->recvLog.close();
|
||||
this->vecTrain.clear();
|
||||
this->needIdentify = false;
|
||||
this->rnameRfidLog();
|
||||
this->queue_.clear();
|
||||
this->initParam();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::logDebug(const QString& message) {
|
||||
LogDebug << message.toStdString();
|
||||
|
||||
ui->textBrowser->append(QString("[Debug] [") + this->currentTime_.toString("yyyy-MM-dd hh:mm:ss") + QString::fromStdString("] ") + message);
|
||||
ui->textBrowser->append(QString("[Debug] [") + this->getSystemTime() + QString::fromStdString("] ") + message);
|
||||
}
|
||||
void MainWindow::logInfo(const QString& message) {
|
||||
LogInfo << message.toStdString();
|
||||
ui->textBrowser->append(QString("[Info] [") + this->currentTime_.toString("yyyy-MM-dd hh:mm:ss") + QString::fromStdString("] ") + message);
|
||||
ui->textBrowser->append(QString("[Info] [") + this->getSystemTime() + QString::fromStdString("] ") + message);
|
||||
}
|
||||
void MainWindow::logWarn(const QString& message) {
|
||||
LogWarn << message.toStdString();
|
||||
ui->textBrowser->append(QString("[Warn] [") + this->currentTime_.toString("yyyy-MM-dd hh:mm:ss") + QString::fromStdString("] ") + message);
|
||||
ui->textBrowser->append(QString("[Warn] [") + this->getSystemTime() + QString::fromStdString("] ") + message);
|
||||
}
|
||||
void MainWindow::logError(const QString& message) {
|
||||
LogError << message.toStdString();
|
||||
ui->textBrowser->append(QString("[Error] [") + this->currentTime_.toString("yyyy-MM-dd hh:mm:ss") + QString::fromStdString("] ") + message);
|
||||
ui->textBrowser->append(QString("[Error] [") + this->getSystemTime() + QString::fromStdString("] ") + message);
|
||||
}
|
||||
|
||||
void MainWindow::initParam() {
|
||||
this->trainTime = "";
|
||||
this->recvLog.close();
|
||||
this->vecTrain.clear();
|
||||
this->needIdentify = false;
|
||||
this->rnameRfidLog();
|
||||
this->queue_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,7 +316,7 @@ bool MainWindow::upWeb(std::string &carriageType, std::string &carriageNumber, s
|
|||
|
||||
if (root["msg"].asString() == "请求未授权") {
|
||||
this->logWarn("因请求未授权,而上传识别结果失败!重新请求token。");
|
||||
this->getToken();
|
||||
if (!this->getToken()) return false;
|
||||
return this->upWeb(carriageType, carriageNumber, carriageOrder, time);
|
||||
}
|
||||
this->logError("识别结果上传失败,原因:" + QString::fromStdString(root.asString()));
|
||||
|
@ -382,7 +382,7 @@ bool MainWindow::getToken()
|
|||
|
||||
if (parsingSuccessful)
|
||||
{
|
||||
if (root["success"].asBool())
|
||||
if (!root.get("token_type", "").asString().empty())
|
||||
{
|
||||
this->webToken = root["token_type"].asString();
|
||||
this->webToken.append(" ");
|
||||
|
@ -448,11 +448,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
|
||||
// 验证账号和密码是否正确
|
||||
if (password == "matrix") {
|
||||
this->recvLog.close();
|
||||
this->vecTrain.clear();
|
||||
this->needIdentify = false;
|
||||
this->rnameRfidLog();
|
||||
this->queue_.clear();
|
||||
this->initParam();
|
||||
event->accept(); // 关闭窗口
|
||||
exit(0);
|
||||
} else {
|
||||
|
@ -567,11 +563,7 @@ void MainWindow::openComClicked()
|
|||
if (this->needIdentify == true) this->needIdentify = false;
|
||||
this->isOpenCom = false;
|
||||
this->logInfo("串口已关闭!");
|
||||
this->recvLog.close();
|
||||
this->vecTrain.clear();
|
||||
this->needIdentify = false;
|
||||
this->rnameRfidLog();
|
||||
this->queue_.clear();
|
||||
this->initParam();
|
||||
this->ui->openComButton->setText("打开串口");
|
||||
this->ui->LEDlabel->setStyleSheet("border-radius: 16px;\ "
|
||||
"background-color: red;\ "
|
||||
|
@ -645,6 +637,9 @@ void MainWindow::getQueueDataThread()
|
|||
QString strTrainInfo = i.left(14);
|
||||
if (vecTrain.empty() || !vecTrain.contains(strTrainInfo))
|
||||
{
|
||||
bool isCarriage = false;
|
||||
strTrainInfo.mid(3, 2).toInt(&isCarriage);
|
||||
if (isCarriage) continue;
|
||||
vecTrain.append(strTrainInfo);
|
||||
this->resultTableModel_->setItem(vecTrain.size()-1, 0, new QStandardItem(strTrainInfo));
|
||||
emit upRfid_signals();
|
||||
|
@ -661,10 +656,7 @@ void MainWindow::getQueueDataThread()
|
|||
{
|
||||
// 关功放信号
|
||||
// TODO: 需要结合 “来车状态”广播消息,确认是否真的车离开了 没有真离开,则向串口发送 @on& 避免关功放
|
||||
this->vecTrain.clear();
|
||||
this->needIdentify = false;
|
||||
this->rnameRfidLog();
|
||||
this->queue_.clear();
|
||||
this->initParam();
|
||||
this->logInfo("功放关闭");
|
||||
}
|
||||
else
|
||||
|
@ -677,6 +669,7 @@ void MainWindow::getQueueDataThread()
|
|||
this->logInfo("来车了");
|
||||
this->mkRfidLog();
|
||||
this->needIdentify = true;
|
||||
this->trainTime = this->getSystemTime();
|
||||
this->resultTableModel_->clear();
|
||||
this->resultTableModel_ = this->getStandardItemModel();
|
||||
}
|
||||
|
@ -705,12 +698,10 @@ void MainWindow::upRfid()
|
|||
int order = this->vecTrain.size();
|
||||
|
||||
info = info.mid(1,info.size() - 1);
|
||||
bool isCarriage = false;
|
||||
info.mid(2, 2).toInt(&isCarriage);
|
||||
if (isCarriage) return;
|
||||
|
||||
std::string carriageType = info.left(7).toStdString();
|
||||
std::string carriageNum = info.mid(7, info.size() - 7).toStdString();
|
||||
std::string nowTime = this->getSystemTime().toStdString();
|
||||
std::string nowTime = this->trainTime.toStdString();
|
||||
std::string strOrder = QString::number(order).toStdString();
|
||||
if (!this->upWeb(carriageType, carriageNum, strOrder, nowTime))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue