1、优化部分 北铁高科 BT210 和 BT220的磁条信号支持,以及粘包数据不完整时的处理
This commit is contained in:
parent
4e7614f93d
commit
c83ec8cf6b
|
|
@ -91,7 +91,7 @@ void TcpClient::connectToServer(QString ip, int port) {
|
||||||
come_time = jsonObject["cometime"].toString();
|
come_time = jsonObject["cometime"].toString();
|
||||||
carType = jsonObject["type"].toString();
|
carType = jsonObject["type"].toString();
|
||||||
}
|
}
|
||||||
else if (jsonObject["type"].toString() != carType && carType == "1")
|
else if (jsonObject["type"].toString() != carType)
|
||||||
{
|
{
|
||||||
// 火车无
|
// 火车无
|
||||||
emit this->comeTrainSignals(false);
|
emit this->comeTrainSignals(false);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ int main(int argc, char *argv[]) {
|
||||||
QApplication::setWindowIcon(QIcon("./logo.ico"));
|
QApplication::setWindowIcon(QIcon("./logo.ico"));
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
qInfo() << "111";
|
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
}
|
}
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
//
|
||||||
|
// Created by Mr.V on 2024/3/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "DeleteOldLog.h"
|
||||||
|
|
||||||
|
void DeleteOldLog::deleteFile() {
|
||||||
|
QDir dir("./Logs");
|
||||||
|
QStringList fileList;
|
||||||
|
QFileInfoList fileInfoList = dir.entryInfoList(fileList, QDir::Files);
|
||||||
|
|
||||||
|
for (int i = 0; i < fileInfoList.size(); i++) {
|
||||||
|
QFileInfo info = fileInfoList.at(i);
|
||||||
|
if (info.birthTime() < QDateTime::currentDateTime().addDays(-10))
|
||||||
|
{
|
||||||
|
QFile::remove(info.absoluteFilePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
//
|
||||||
|
// Created by Mr.V on 2024/3/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef TRAIN_RFID_DELETEOLDLOG_H
|
||||||
|
#define TRAIN_RFID_DELETEOLDLOG_H
|
||||||
|
#include <QDir>
|
||||||
|
#include <Qobject>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
class DeleteOldLog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
bool readDeleteConfig();
|
||||||
|
public slots:
|
||||||
|
void deleteFile();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //TRAIN_RFID_DELETEOLDLOG_H
|
||||||
|
|
@ -15,12 +15,12 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
this->statusBar = new QStatusBar();
|
this->statusBar = new QStatusBar();
|
||||||
this->statusInfo = new QLabel("初始化完成",this);
|
this->statusInfo = new QLabel("初始化完成",this);
|
||||||
this->statusBar->addPermanentWidget(this->statusInfo);//显示正常信息
|
this->statusBar->addPermanentWidget(this->statusInfo);//显示正常信息
|
||||||
QLabel* statusVersion = new QLabel("编译版本:" + QDateTime::currentDateTime().toString("yy.MM.dd.hh.mm"),this);
|
QLabel* statusVersion = new QLabel("开启时间:" + QDateTime::currentDateTime().toString("yy.MM.dd.hh.mm"),this);
|
||||||
this->statusBar->addWidget(statusVersion);
|
this->statusBar->addWidget(statusVersion);
|
||||||
|
|
||||||
layout()->addWidget(this->statusBar);
|
layout()->addWidget(this->statusBar);
|
||||||
|
|
||||||
this->setWindowTitle("Matrix_RFID");
|
this->setWindowTitle("Matrix_RFID 车号识别程序(勿关!!)");
|
||||||
this->configPath_ = "./config/config.ini";
|
this->configPath_ = "./config/config.ini";
|
||||||
|
|
||||||
if (!this->mkLogDir())
|
if (!this->mkLogDir())
|
||||||
|
|
@ -137,6 +137,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
{
|
{
|
||||||
this->logInfo("视频车号识别-火车离开了");
|
this->logInfo("视频车号识别-火车离开了");
|
||||||
this->videoHasTrain = false;
|
this->videoHasTrain = false;
|
||||||
|
if (this->needIdentify)
|
||||||
emit IdentifyType();
|
emit IdentifyType();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -342,6 +343,7 @@ bool MainWindow::upWeb(std::string &carriageType, std::string &carriageNumber, s
|
||||||
try {
|
try {
|
||||||
httplib::Client cli(this->interfaceConfig_.httpIp.toStdString(), this->interfaceConfig_.httpPort);
|
httplib::Client cli(this->interfaceConfig_.httpIp.toStdString(), this->interfaceConfig_.httpPort);
|
||||||
cli.set_connection_timeout(0, 300 * 1000);
|
cli.set_connection_timeout(0, 300 * 1000);
|
||||||
|
cli.set_read_timeout(1,0);
|
||||||
httplib::Headers header;
|
httplib::Headers header;
|
||||||
httplib::Params params;
|
httplib::Params params;
|
||||||
Json::Value arrayObj; //构建对象
|
Json::Value arrayObj; //构建对象
|
||||||
|
|
@ -350,6 +352,7 @@ bool MainWindow::upWeb(std::string &carriageType, std::string &carriageNumber, s
|
||||||
//header.emplace("Content-Type", "application/json");
|
//header.emplace("Content-Type", "application/json");
|
||||||
|
|
||||||
arrayObj["comeTime"] = time;
|
arrayObj["comeTime"] = time;
|
||||||
|
arrayObj["collectTime"] = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz").toStdString();
|
||||||
arrayObj["carriageNumber"] = carriageNumber;
|
arrayObj["carriageNumber"] = carriageNumber;
|
||||||
arrayObj["carriageType"] = carriageType;
|
arrayObj["carriageType"] = carriageType;
|
||||||
arrayObj["carriageOrder"] = carriageOrder;
|
arrayObj["carriageOrder"] = carriageOrder;
|
||||||
|
|
@ -428,6 +431,8 @@ bool MainWindow::getToken()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
httplib::Client cli(this->interfaceConfig_.httpIp.toStdString(), this->interfaceConfig_.httpPort);
|
httplib::Client cli(this->interfaceConfig_.httpIp.toStdString(), this->interfaceConfig_.httpPort);
|
||||||
|
cli.set_connection_timeout(0, 300 * 1000);
|
||||||
|
cli.set_read_timeout(1,0);
|
||||||
httplib::Headers header;
|
httplib::Headers header;
|
||||||
httplib::Params params;
|
httplib::Params params;
|
||||||
|
|
||||||
|
|
@ -530,8 +535,8 @@ void MainWindow::creat_action()
|
||||||
{
|
{
|
||||||
m_pActionShow = new QAction("主界面", this);
|
m_pActionShow = new QAction("主界面", this);
|
||||||
connect(m_pActionShow, &QAction::triggered, this,&MainWindow::on_ShowMainAction);
|
connect(m_pActionShow, &QAction::triggered, this,&MainWindow::on_ShowMainAction);
|
||||||
m_pActionQuit = new QAction("退出", this);
|
// m_pActionQuit = new QAction("退出", this);
|
||||||
connect(m_pActionQuit, &QAction::triggered, this, &MainWindow::on_ExitAppAction);
|
// connect(m_pActionQuit, &QAction::triggered, this, &MainWindow::on_ExitAppAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::creat_menu()
|
void MainWindow::creat_menu()
|
||||||
|
|
@ -540,9 +545,9 @@ void MainWindow::creat_menu()
|
||||||
//新增菜单项---显示主界面
|
//新增菜单项---显示主界面
|
||||||
m_pTrayMennu->addAction(m_pActionShow);
|
m_pTrayMennu->addAction(m_pActionShow);
|
||||||
//增加分隔符
|
//增加分隔符
|
||||||
m_pTrayMennu->addSeparator();
|
// m_pTrayMennu->addSeparator();
|
||||||
//新增菜单项---退出程序
|
// //新增菜单项---退出程序
|
||||||
m_pTrayMennu->addAction(m_pActionQuit);
|
// m_pTrayMennu->addAction(m_pActionQuit);
|
||||||
//把QMenu赋给QSystemTrayIcon对象
|
//把QMenu赋给QSystemTrayIcon对象
|
||||||
m_pSystemTray->setContextMenu(m_pTrayMennu);
|
m_pSystemTray->setContextMenu(m_pTrayMennu);
|
||||||
}
|
}
|
||||||
|
|
@ -576,6 +581,7 @@ void MainWindow::on_ExitAppAction()
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, "验证失败", "密码不正确!");
|
QMessageBox::warning(this, "验证失败", "密码不正确!");
|
||||||
|
//event->ignore(); // 阻止关闭窗口
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -701,8 +707,8 @@ void MainWindow::getQueueDataThread()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// this->logDebug("--" + this->tmpRfid);
|
// this->logDebug("--" + this->tmpRfid);
|
||||||
this->tmpRfid = this->tmpRfid.replace("@", "");
|
this->tmpRfid = this->tmpRfid.replace("&", "");
|
||||||
QStringList rfidSubList = this->tmpRfid.split("&");
|
QStringList rfidSubList = this->tmpRfid.split("@");
|
||||||
this->tmpRfid = "";
|
this->tmpRfid = "";
|
||||||
|
|
||||||
auto split_lambda = [=](QString strFirst, QString strOther){
|
auto split_lambda = [=](QString strFirst, QString strOther){
|
||||||
|
|
@ -730,7 +736,7 @@ void MainWindow::getQueueDataThread()
|
||||||
|
|
||||||
for (const auto & i : rfidSubList)
|
for (const auto & i : rfidSubList)
|
||||||
{
|
{
|
||||||
if (i.size() == 26)
|
if (i.size() == 26 || i.size() == 24)
|
||||||
{
|
{
|
||||||
// 车厢信息
|
// 车厢信息
|
||||||
QString strTrainInfo = i.left(14);
|
QString strTrainInfo = i.left(14);
|
||||||
|
|
@ -757,10 +763,14 @@ void MainWindow::getQueueDataThread()
|
||||||
}
|
}
|
||||||
else if (i.size() == 14) // 特殊情况,来车信号少了&符
|
else if (i.size() == 14) // 特殊情况,来车信号少了&符
|
||||||
{
|
{
|
||||||
QString strFirst = i.left(1);
|
for (int j = 0; j < i.size(); j+=7) {
|
||||||
QString strOther = i.mid(1, 6);
|
QString rfid_cg = i.mid(j, 7);
|
||||||
|
QString strFirst = rfid_cg.left(1);
|
||||||
|
QString strOther = rfid_cg.mid(1, 6);
|
||||||
split_lambda(strFirst, strOther);
|
split_lambda(strFirst, strOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue