diff --git a/CounterAcq/CounterDevice.cpp b/CounterAcq/CounterDevice.cpp index a794ab6..502cffe 100644 --- a/CounterAcq/CounterDevice.cpp +++ b/CounterAcq/CounterDevice.cpp @@ -118,10 +118,10 @@ // 2. 各个通道的clock diff数据 for (int i = 1; i <= counterData->channelActiveArray.size(); i++) { -// if (counterData->channelRefId == i) -// { -// continue; -// } + if (counterData->channelRefId == i) + { + continue; + } if (counterData->channelActiveArray.at(i-1).toUInt() == 1) { QString chFilename("%1_CH_%2.log"); diff --git a/CounterAcq/CounterDevice.cpp b/CounterAcq/CounterDevice.cpp index a794ab6..502cffe 100644 --- a/CounterAcq/CounterDevice.cpp +++ b/CounterAcq/CounterDevice.cpp @@ -118,10 +118,10 @@ // 2. 各个通道的clock diff数据 for (int i = 1; i <= counterData->channelActiveArray.size(); i++) { -// if (counterData->channelRefId == i) -// { -// continue; -// } + if (counterData->channelRefId == i) + { + continue; + } if (counterData->channelActiveArray.at(i-1).toUInt() == 1) { QString chFilename("%1_CH_%2.log"); diff --git a/CounterRealTime/CounterDevice.cpp b/CounterRealTime/CounterDevice.cpp index bf3fa8c..46370d5 100644 --- a/CounterRealTime/CounterDevice.cpp +++ b/CounterRealTime/CounterDevice.cpp @@ -2,7 +2,6 @@ #include #include -#include CounterDevice::CounterDevice(QObject *parent) : QObject(parent) { @@ -95,6 +94,11 @@ void CounterDevice::dataReceivedHandler(QByteArray data) { this->dataBuff.append(data); + +// QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd"); +// QString filename = "serial_" + devCode + ".log"; +// QString content = QString::fromLocal8Bit(data.data()); +// QLogUtil::writeRawDataLogByDate(date, filename, content); // qDebug() << this->dataBuff; CounterDataDto * counterData = new CounterDataDto(this); @@ -119,7 +123,6 @@ { qDebug() << QString("%1").arg(this->dataBuff.size()); this->dataBuff.clear(); - std::cout << "clear buffer" << std::endl; } // 在此处释放内存,不影响后续显示 @@ -142,6 +145,12 @@ QJsonArray messageArray; QString msgLogFilename = "msg_" + devCode + ".log"; + CounterChannel * refChanPtr = ConstCache::getInstance().channelMap.value(QString("%1-%2").arg(deviceId).arg(counterData->channelRefId)); + double refDelay = 0.0; + if (refChanPtr != nullptr && refChanPtr->getDelays().isEmpty() == false) { + refDelay = refChanPtr->getDelays().toDouble(); + } + // 2. 各个通道的clock diff数据 for (int i = 1; i <= counterData->channelActiveArray.size(); i++) { @@ -170,7 +179,7 @@ { // 通道时延值 并计算 减去时延值的测量值 double delay = channelPtr->getDelays().isEmpty() == false ? channelPtr->getDelays().toDouble() : 0.0; - double valueMinusDelay = counterData->channelDataArray.at(i-1).toDouble() - delay * 1E-9; + double valueMinusDelay = counterData->channelDataArray.at(i-1).toDouble() - (delay * 1E-9) + (refDelay * 1E-9); channelPtr->appendHisData(QString::number(counterData->milisecond), QString::number(valueMinusDelay, 'f', 12)); QJsonObject jsonObj = counterData->toJSON(i - 1); @@ -193,7 +202,6 @@ kafkaUtil.produceMessage(QString(QJsonDocument(messageArray).toJson(QJsonDocument::Compact))); kafkaUtil.produceMessage(SettingConfig::getInstance().KAFKA_STATUS_TOPIC, QString(QJsonDocument(statusObj).toJson(QJsonDocument::Compact))); - qDebug() << messageArray; QLogUtil::writeChannelDataLogByDate(date, msgLogFilename, QString(QJsonDocument(messageArray).toJson(QJsonDocument::Compact))); } diff --git a/CounterAcq/CounterDevice.cpp b/CounterAcq/CounterDevice.cpp index a794ab6..502cffe 100644 --- a/CounterAcq/CounterDevice.cpp +++ b/CounterAcq/CounterDevice.cpp @@ -118,10 +118,10 @@ // 2. 各个通道的clock diff数据 for (int i = 1; i <= counterData->channelActiveArray.size(); i++) { -// if (counterData->channelRefId == i) -// { -// continue; -// } + if (counterData->channelRefId == i) + { + continue; + } if (counterData->channelActiveArray.at(i-1).toUInt() == 1) { QString chFilename("%1_CH_%2.log"); diff --git a/CounterRealTime/CounterDevice.cpp b/CounterRealTime/CounterDevice.cpp index bf3fa8c..46370d5 100644 --- a/CounterRealTime/CounterDevice.cpp +++ b/CounterRealTime/CounterDevice.cpp @@ -2,7 +2,6 @@ #include #include -#include CounterDevice::CounterDevice(QObject *parent) : QObject(parent) { @@ -95,6 +94,11 @@ void CounterDevice::dataReceivedHandler(QByteArray data) { this->dataBuff.append(data); + +// QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd"); +// QString filename = "serial_" + devCode + ".log"; +// QString content = QString::fromLocal8Bit(data.data()); +// QLogUtil::writeRawDataLogByDate(date, filename, content); // qDebug() << this->dataBuff; CounterDataDto * counterData = new CounterDataDto(this); @@ -119,7 +123,6 @@ { qDebug() << QString("%1").arg(this->dataBuff.size()); this->dataBuff.clear(); - std::cout << "clear buffer" << std::endl; } // 在此处释放内存,不影响后续显示 @@ -142,6 +145,12 @@ QJsonArray messageArray; QString msgLogFilename = "msg_" + devCode + ".log"; + CounterChannel * refChanPtr = ConstCache::getInstance().channelMap.value(QString("%1-%2").arg(deviceId).arg(counterData->channelRefId)); + double refDelay = 0.0; + if (refChanPtr != nullptr && refChanPtr->getDelays().isEmpty() == false) { + refDelay = refChanPtr->getDelays().toDouble(); + } + // 2. 各个通道的clock diff数据 for (int i = 1; i <= counterData->channelActiveArray.size(); i++) { @@ -170,7 +179,7 @@ { // 通道时延值 并计算 减去时延值的测量值 double delay = channelPtr->getDelays().isEmpty() == false ? channelPtr->getDelays().toDouble() : 0.0; - double valueMinusDelay = counterData->channelDataArray.at(i-1).toDouble() - delay * 1E-9; + double valueMinusDelay = counterData->channelDataArray.at(i-1).toDouble() - (delay * 1E-9) + (refDelay * 1E-9); channelPtr->appendHisData(QString::number(counterData->milisecond), QString::number(valueMinusDelay, 'f', 12)); QJsonObject jsonObj = counterData->toJSON(i - 1); @@ -193,7 +202,6 @@ kafkaUtil.produceMessage(QString(QJsonDocument(messageArray).toJson(QJsonDocument::Compact))); kafkaUtil.produceMessage(SettingConfig::getInstance().KAFKA_STATUS_TOPIC, QString(QJsonDocument(statusObj).toJson(QJsonDocument::Compact))); - qDebug() << messageArray; QLogUtil::writeChannelDataLogByDate(date, msgLogFilename, QString(QJsonDocument(messageArray).toJson(QJsonDocument::Compact))); } diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 37b6cb6..04eb5eb 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -81,7 +81,7 @@ { switch (event->key()) { case Qt::Key_Escape: - QTimer::singleShot(100, qApp, SLOT(quit())); +// QTimer::singleShot(100, qApp, SLOT(quit())); default: QWidget::keyPressEvent(event); @@ -309,6 +309,12 @@ channelDataJsonMap.insert(channelNo, channelDataItem); } + CounterChannel * refChanPtr = ConstCache::getInstance().channelMap.value(QString("%1-%2").arg(deviceId).arg(refChNo)); + double refDelay = 0.0; + if (refChanPtr != nullptr && refChanPtr->getDelays().isEmpty() == false) { + refDelay = refChanPtr->getDelays().toDouble(); + } + // 逐个通道显示 for (int i = 0; i < 16; i++) { @@ -332,7 +338,7 @@ { // 通道时延值 并计算 减去时延值的测量值 double delay = channel->getDelays().isEmpty() == false ? channel->getDelays().toDouble() : 0.0; - double valueMinusDelay = channelDataItem.value("data").toObject().value("dataValue").toString().toDouble() - delay * 1E-9; + double valueMinusDelay = channelDataItem.value("data").toObject().value("dataValue").toString().toDouble() - delay * 1E-9 + refDelay * 1E-9; // 设置通道名和测量值的QLabel channelNameList.at(chanelIdx)->setText(QString("CH%1:%2").arg(channelNoStr).arg(channel->getChannelCode())); @@ -453,13 +459,13 @@ // 如果不是当前显示的计数器 则直接返回 CounterDevice * devicePtr = ConstCache::getInstance().deviceMap.value(deviceId); - if (SettingConfig::getInstance().MASTER != devicePtr->getIsUse()) + if (devicePtr == nullptr || SettingConfig::getInstance().MASTER != devicePtr->getIsUse()) { return; } // 根据设备id 从map中取出列索引的值 - int devIdx = ConstCache::getInstance().deviceMap.value(deviceId)->getFormColIndex(); + int devIdx = devicePtr->getFormColIndex(); if (devIdx > SettingConfig::getInstance().DISPLAY_COUNT) { return; diff --git a/CounterAcq/CounterDevice.cpp b/CounterAcq/CounterDevice.cpp index a794ab6..502cffe 100644 --- a/CounterAcq/CounterDevice.cpp +++ b/CounterAcq/CounterDevice.cpp @@ -118,10 +118,10 @@ // 2. 各个通道的clock diff数据 for (int i = 1; i <= counterData->channelActiveArray.size(); i++) { -// if (counterData->channelRefId == i) -// { -// continue; -// } + if (counterData->channelRefId == i) + { + continue; + } if (counterData->channelActiveArray.at(i-1).toUInt() == 1) { QString chFilename("%1_CH_%2.log"); diff --git a/CounterRealTime/CounterDevice.cpp b/CounterRealTime/CounterDevice.cpp index bf3fa8c..46370d5 100644 --- a/CounterRealTime/CounterDevice.cpp +++ b/CounterRealTime/CounterDevice.cpp @@ -2,7 +2,6 @@ #include #include -#include CounterDevice::CounterDevice(QObject *parent) : QObject(parent) { @@ -95,6 +94,11 @@ void CounterDevice::dataReceivedHandler(QByteArray data) { this->dataBuff.append(data); + +// QString date = QDateTime::currentDateTime().toString("yyyy-MM-dd"); +// QString filename = "serial_" + devCode + ".log"; +// QString content = QString::fromLocal8Bit(data.data()); +// QLogUtil::writeRawDataLogByDate(date, filename, content); // qDebug() << this->dataBuff; CounterDataDto * counterData = new CounterDataDto(this); @@ -119,7 +123,6 @@ { qDebug() << QString("%1").arg(this->dataBuff.size()); this->dataBuff.clear(); - std::cout << "clear buffer" << std::endl; } // 在此处释放内存,不影响后续显示 @@ -142,6 +145,12 @@ QJsonArray messageArray; QString msgLogFilename = "msg_" + devCode + ".log"; + CounterChannel * refChanPtr = ConstCache::getInstance().channelMap.value(QString("%1-%2").arg(deviceId).arg(counterData->channelRefId)); + double refDelay = 0.0; + if (refChanPtr != nullptr && refChanPtr->getDelays().isEmpty() == false) { + refDelay = refChanPtr->getDelays().toDouble(); + } + // 2. 各个通道的clock diff数据 for (int i = 1; i <= counterData->channelActiveArray.size(); i++) { @@ -170,7 +179,7 @@ { // 通道时延值 并计算 减去时延值的测量值 double delay = channelPtr->getDelays().isEmpty() == false ? channelPtr->getDelays().toDouble() : 0.0; - double valueMinusDelay = counterData->channelDataArray.at(i-1).toDouble() - delay * 1E-9; + double valueMinusDelay = counterData->channelDataArray.at(i-1).toDouble() - (delay * 1E-9) + (refDelay * 1E-9); channelPtr->appendHisData(QString::number(counterData->milisecond), QString::number(valueMinusDelay, 'f', 12)); QJsonObject jsonObj = counterData->toJSON(i - 1); @@ -193,7 +202,6 @@ kafkaUtil.produceMessage(QString(QJsonDocument(messageArray).toJson(QJsonDocument::Compact))); kafkaUtil.produceMessage(SettingConfig::getInstance().KAFKA_STATUS_TOPIC, QString(QJsonDocument(statusObj).toJson(QJsonDocument::Compact))); - qDebug() << messageArray; QLogUtil::writeChannelDataLogByDate(date, msgLogFilename, QString(QJsonDocument(messageArray).toJson(QJsonDocument::Compact))); } diff --git a/CounterRealTime/CounterWindowRT.cpp b/CounterRealTime/CounterWindowRT.cpp index 37b6cb6..04eb5eb 100644 --- a/CounterRealTime/CounterWindowRT.cpp +++ b/CounterRealTime/CounterWindowRT.cpp @@ -81,7 +81,7 @@ { switch (event->key()) { case Qt::Key_Escape: - QTimer::singleShot(100, qApp, SLOT(quit())); +// QTimer::singleShot(100, qApp, SLOT(quit())); default: QWidget::keyPressEvent(event); @@ -309,6 +309,12 @@ channelDataJsonMap.insert(channelNo, channelDataItem); } + CounterChannel * refChanPtr = ConstCache::getInstance().channelMap.value(QString("%1-%2").arg(deviceId).arg(refChNo)); + double refDelay = 0.0; + if (refChanPtr != nullptr && refChanPtr->getDelays().isEmpty() == false) { + refDelay = refChanPtr->getDelays().toDouble(); + } + // 逐个通道显示 for (int i = 0; i < 16; i++) { @@ -332,7 +338,7 @@ { // 通道时延值 并计算 减去时延值的测量值 double delay = channel->getDelays().isEmpty() == false ? channel->getDelays().toDouble() : 0.0; - double valueMinusDelay = channelDataItem.value("data").toObject().value("dataValue").toString().toDouble() - delay * 1E-9; + double valueMinusDelay = channelDataItem.value("data").toObject().value("dataValue").toString().toDouble() - delay * 1E-9 + refDelay * 1E-9; // 设置通道名和测量值的QLabel channelNameList.at(chanelIdx)->setText(QString("CH%1:%2").arg(channelNoStr).arg(channel->getChannelCode())); @@ -453,13 +459,13 @@ // 如果不是当前显示的计数器 则直接返回 CounterDevice * devicePtr = ConstCache::getInstance().deviceMap.value(deviceId); - if (SettingConfig::getInstance().MASTER != devicePtr->getIsUse()) + if (devicePtr == nullptr || SettingConfig::getInstance().MASTER != devicePtr->getIsUse()) { return; } // 根据设备id 从map中取出列索引的值 - int devIdx = ConstCache::getInstance().deviceMap.value(deviceId)->getFormColIndex(); + int devIdx = devicePtr->getFormColIndex(); if (devIdx > SettingConfig::getInstance().DISPLAY_COUNT) { return; diff --git a/CounterRealTime/CounterWindowRT.h b/CounterRealTime/CounterWindowRT.h index c64e07f..9ed7190 100644 --- a/CounterRealTime/CounterWindowRT.h +++ b/CounterRealTime/CounterWindowRT.h @@ -71,10 +71,5 @@ void drawCounterDataOnPage(QJsonArray messageArray); void onKafkaMessageReceived(QJsonObject message); - - - - - }; #endif // COUNTERWINDOWRT_H