信号发送代码补全

This commit is contained in:
Mr.V 2024-05-20 14:43:51 +08:00
parent b8880f4da7
commit 5c73baced8
1 changed files with 37 additions and 37 deletions

View File

@ -12,11 +12,11 @@ ReadComThread::ReadComThread(MQueue<TrainInfo> *queueTrainInfo,
QString errorMessage = "";
if (!ConfigUtil::readBaseConfig(g_config_path, errorMessage, this->baseConfig_))
{
this->ErrorSignals(errorMessage);
emit this->ErrorSignals(errorMessage);
}
if (!ConfigUtil::readSocketServerConfig(g_config_path, errorMessage, this->socketServerConfig_))
{
this->ErrorSignals(errorMessage);
emit this->ErrorSignals(errorMessage);
}
this->queueTrainInfo_ = queueTrainInfo;
@ -49,8 +49,8 @@ ReadComThread::ReadComThread(MQueue<TrainInfo> *queueTrainInfo,
// 接收子线程的消息提示
connect(this->tcpClient, &TcpClient::sendTcpInfoSignals, this, [=](const QString& info){
this->InfoSignals(info);
this->statusInfoUpdate(info);
emit this->InfoSignals(info);
emit this->statusInfoUpdate(info);
if (info == "链接服务端超时"
|| info == "未连接Socket服务器"
|| info == "链接服务端失败"
@ -62,7 +62,7 @@ ReadComThread::ReadComThread(MQueue<TrainInfo> *queueTrainInfo,
});
// 接收子线程的TCP消息内容展示
connect(this->tcpClient, &TcpClient::getTcpInfoSignals, this, [=](const QString& info){
this->InfoSignals(info);
emit this->InfoSignals(info);
});
emit connect_socket(this->socketServerConfig_.server_ip, this->socketServerConfig_.server_port);
@ -70,22 +70,22 @@ ReadComThread::ReadComThread(MQueue<TrainInfo> *queueTrainInfo,
connect(this->tcpClient, &TcpClient::comeTrainSignals, this, [=](bool type) {
if (type)
{
this->InfoSignals("视频车号识别-来车了");
emit this->InfoSignals("视频车号识别-来车了");
this->videoHasTrain = true;
emit IdentifyType();
emit this->IdentifyType();
}
else
{
this->InfoSignals("视频车号识别-火车离开了");
emit this->InfoSignals("视频车号识别-火车离开了");
this->videoHasTrain = false;
if (this->needIdentify)
emit IdentifyType();
emit this->IdentifyType();
}
});
connect(this->tcpClient, &TcpClient::getDirectionSignals, this, [=](int direction) {
if (this->iDirection == 0)
{
this->InfoSignals("获得方向判定:" + QString(direction > -1 ? (direction > 0 ? "需识别" : "待定") : "无需上传"));
emit this->InfoSignals("获得方向判定:" + QString(direction > -1 ? (direction > 0 ? "需识别" : "待定") : "无需上传"));
this->iDirection = direction;
}
});
@ -127,7 +127,7 @@ void ReadComThread::openCom(const bool &type, const int &msec)
if (this->baseConfig_.havaMagnetSteel)
logs.append("磁钢顺序:" + this->baseConfig_.magnetSteelOrder);
this->isOpenCom = true;
this->InfoSignals(logs);
emit this->InfoSignals(logs);
connect(this->serial_,&QSerialPort::readyRead,this,&ReadComThread::readCom); //
connect(this->serial_, &QSerialPort::errorOccurred, this, &ReadComThread::serialPort_error);
@ -140,7 +140,7 @@ void ReadComThread::openCom(const bool &type, const int &msec)
{
this->comDetect_->closeCom(this->serial_);
this->isOpenCom = false;
this->ErrorSignals("串口打开失败!");
emit this->ErrorSignals("串口打开失败!");
emit this->openComSuccess(false);
this->timer_.start(10*1000);
}
@ -152,8 +152,8 @@ void ReadComThread::openCom(const bool &type, const int &msec)
if (this->comDetect_->closeCom(this->serial_))
{
this->initParam();
this->InfoSignals("串口已关闭!");
this->closeComSuccess(true);
emit this->InfoSignals("串口已关闭!");
emit this->closeComSuccess(true);
}
else
{
@ -177,16 +177,16 @@ void ReadComThread::readCom()
if(!data.isEmpty())
{
this->queue_.push(QString(data));
emit getRfid_signals();
emit this->getRfid_signals();
}
data.clear();
}
else
{
this->ErrorSignals("等待读取超时");
emit this->ErrorSignals("等待读取超时");
}
} catch(...) {
this->ErrorSignals("读取串口数据异常!");
emit this->ErrorSignals("读取串口数据异常!");
}
}
@ -194,20 +194,20 @@ void ReadComThread::readTestInfo(const QString &filePath) {
// 创建一个QFile对象并打开要读取的文本文件
QFile file(filePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
this->ErrorSignals("无法打开测试文件:" + filePath);
emit this->ErrorSignals("无法打开测试文件:" + filePath);
return;
}
this->InfoSignals("开始读取测试数据...");
emit this->InfoSignals("开始读取测试数据...");
// 将文件内容读入到QStringList中
QTextStream in(&file);
while(!in.atEnd()) {
QString line = in.readLine();
this->queue_.push(line);
emit getRfid_signals();
emit this->getRfid_signals();
}
// 关闭文件
file.close();
this->InfoSignals("---读取测试数据完毕---");
emit this->InfoSignals("---读取测试数据完毕---");
}
/**
@ -236,10 +236,10 @@ void ReadComThread::getQueueDataThread()
if (strFirst == "0")
{
this->rfidHasTrain = false;
this->InfoSignals("RFID-火车离开了");
emit this->InfoSignals("RFID-火车离开了");
// 关功放信号
// 需要结合 “来车状态”广播消息,确认是否真的车离开了; TODO:没有真离开,则向串口发送 @on& 避免关功放
emit IdentifyType();
emit this->IdentifyType();
}
else
{
@ -249,8 +249,8 @@ void ReadComThread::getQueueDataThread()
|| strFirst == this->baseConfig_.magnetSteelOrder.mid(1, 1)))
{
this->rfidHasTrain = true;
this->InfoSignals("RFID-来车了");
emit IdentifyType();
emit this->InfoSignals("RFID-来车了");
emit this->IdentifyType();
}
}
};
@ -275,13 +275,13 @@ void ReadComThread::getQueueDataThread()
vecTrain.append(strTrainInfo);
int train_order = vecTrain.size();
// this->resultTableModel_->setItem(train_order - 1, 0, new QStandardItem(strTrainInfo));
this->addResultSignals(strTrainInfo);
this->InfoSignals(QString("第%1节 %2").arg(train_order).arg(strTrainInfo));
emit this->addResultSignals(strTrainInfo);
emit this->InfoSignals(QString("第%1节 %2").arg(train_order).arg(strTrainInfo));
// 将接收到的RFID使用@符拼接起来以待后续上传web
this->rfidSourceInfo.append("@" + i);
QString rfidinfo = this->rfidSourceInfo;
this->rfidSourceInfo = "";
emit upRfid_signals(rfidinfo);
emit this->upRfid_signals(rfidinfo);
}
}
@ -317,19 +317,19 @@ void ReadComThread::IdentifyTypeUpdate() {
{
if (!this->needIdentify)
{
this->InfoSignals("来车了");
emit this->InfoSignals("来车了");
this->mkRfidLog();
this->vecTrain.clear();
this->needIdentify = true;
this->trainTime = this->getSystemTime();
emit this->comeTrain(false);
}
}
else if (!this->rfidHasTrain && !this->videoHasTrain)
{
this->rfidSourceInfo
this->initParam();
this->InfoSignals("火车离开了");
emit this->InfoSignals("火车离开了");
}
}
@ -392,8 +392,8 @@ bool ReadComThread::mkRfidLog()
}
return true;
} catch (const std::exception &e) {
this->ErrorSignals("创建、打开RFID原始数据日志文件失败,详细:");
this->ErrorSignals(e.what());
emit this->ErrorSignals("创建、打开RFID原始数据日志文件失败,详细:");
emit this->ErrorSignals(e.what());
}
return false;
}
@ -409,7 +409,7 @@ void ReadComThread::saveRfidLog(const QString &value)
this->recvLog.write(logValue.toUtf8());
this->recvLog.flush();
} catch (const std::exception &e) {
this->ErrorSignals("保存RFID原数据失败");
emit this->ErrorSignals("保存RFID原数据失败");
}
}
@ -427,13 +427,13 @@ bool ReadComThread::rnameRfidLog()
if (!logFile.rename(newLogFileName))
{
this->ErrorSignals("读取RFID原始数据存储重命名失败");
emit this->ErrorSignals("读取RFID原始数据存储重命名失败");
return false;
}
this->deleteOldFiles(fileInfo.path(), 3);
} catch (const std::exception &e) {
this->ErrorSignals("读取RFID原始数据存储重命名失败");
emit this->ErrorSignals("读取RFID原始数据存储重命名失败");
return false;
}
return true;
@ -461,7 +461,7 @@ void ReadComThread::serialPort_error(QSerialPort::SerialPortError error)
{
//关闭串口
this->serial_->close();
this->ErrorSignals("串口异常退出,疑似接口松动;10秒后自动尝试重连...");
emit this->ErrorSignals("串口异常退出,疑似接口松动;10秒后自动尝试重连...");
emit this->openComSuccess(false);
this->timer_.start(10*1000);
}