diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 489627c..5debd5a 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -5,15 +5,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include +#include "common/utils/SettingConfig.h" +#include "common/utils/QLogUtil.h" + PhaseWindow::PhaseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PhaseWindow) @@ -35,19 +36,18 @@ ui->endButt->move(screenRect.width() - 260, 10); ui->startButt->move(screenRect.width() - 320, 10); ui->line->setGeometry(0, 89, screenRect.width(), 1); - ui->pointsList->setGeometry(200,30,screenRect.width()-600,40); - ui->labelsList->setGeometry(200,60,screenRect.width()-600,30); + ui->pointsList->setGeometry(250,30,screenRect.width()-600,40); + ui->labelsList->setGeometry(250,60,screenRect.width()-600,30); // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 90, screenRect.width(), screenRect.height() - 90); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")); + ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")); this->generateWidgetForDevice(); device = new PhaseDevice(this); - device->startWork(); connect(device, &PhaseDevice::sendDataToDraw, this, &PhaseWindow::drawPhaseDataOnPage); } @@ -60,27 +60,36 @@ void PhaseWindow::drawPhaseDataOnPage(PhaseDataDto * phaseData) { ui->tim3->setText(phaseData->timestamp); + updateChannelActive(phaseData->channelActive); // 更新所有通道BOX的值 -// for (int i = 0; i < phaseData->channelActive.size(); i++) -// { -// // 获取对应的通道BOX -// QGroupBox * channelBox = (QGroupBox *)ui->scrollContents->children().at(i + 1); + for (int i = 0; i < phaseData->channelActive.size(); i++) + { + // 获取对应的通道BOX + if (phaseData->channelActive.at(i) == "1") + { + ChannelItem * channel = channelItemList.at(i); + double phaseValue = channel->updatePhaseMeasureData(phaseData->channelData.at(i)); -// // 赋值,对应的lineEdit/label -// ((QLineEdit *)channelBox->children().at(2))->setText(phaseData->timestamp); -// ((QLineEdit *)channelBox->children().at(4))->setText(QString("%1 s").arg(phaseData->channelDataStr.at(i))); -// ((QLineEdit *)channelBox->children().at(6))->setText(phaseData->frameId); -// ((QLabel *)channelBox->children().at(7))->setText(phaseData->channelActive.at(i) == "1" ? "有效" : "无效"); -// } + QString chFilename = QString("CH_%1.log").arg(i + 1, 2, 10, QLatin1Char('0')); + QString channelDataStr = QString("%1 [%2] %3 %4 %5") + .arg(phaseData->timestamp) + .arg(phaseData->frameId) + .arg(phaseData->channelDataStr.at(i)) + .arg(QString::number(channel->getChannelDelay())) + .arg(QString::number(phaseValue, 'f', 15)); + std::cout << channelDataStr.toStdString() << std::endl; + + QLogUtil::writeChannelDataLogByDate(phaseData->timestamp.mid(0, 10), chFilename, channelDataStr); + } + } } void PhaseWindow::generateWidgetForDevice() { // 获取设备数据 - int channelNum = 16; - //测试通道 - bool arr[16] = {true,false,true,false,true,false,true,false,true,false,true,false,true,false,true,false}; + int channelNum = SettingConfig::getInstance().CHANNEL_COUNT; + QRect screenRect = QApplication::desktop()->screenGeometry(); ui->scrollContents->setGeometry(0, 90, screenRect.width(), channelNum * 170); @@ -90,25 +99,49 @@ for (int i = 0; i < channelNum; i++) { + // 通道状态图标默认显示为离线/无效状态 QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 - if(arr[i]) label->setPixmap(QPixmap(":/points/images/green.png")); - else label->setPixmap(QPixmap(":/points/images/white.png")); - if(!arr[i]) continue; + label->setPixmap(QPixmap(":/points/images/white.png")); + QGroupBox * group = new QGroupBox(ui->scrollContents); group->setTitle(QString("通道 - %1").arg(i + 1)); group->setFont(QFont("微软雅黑", 12)); group->setGeometry(20, i * 160 + 10, screenRect.width() - 40, 160); + this->channelGroupList.append(group); QHBoxLayout * vbox = new QHBoxLayout(group); - ChannelItem *widget=new ChannelItem(); - widget->setGeometry(10, 0, screenRect.width() - 60, 160); + ChannelItem * channelItem = new ChannelItem(); + channelItem->setGeometry(10, 0, screenRect.width() - 60, 160); + this->channelItemList.append(channelItem); - vbox->addWidget(widget); + vbox->addWidget(channelItem); group->setLayout(vbox); layout->addWidget(group); } } +void PhaseWindow::updateChannelActive(QList channelActive) +{ + for (int i = 0; i < channelActive.size(); i++) + { + if (channelActive.at(i) == "1") + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/green.png")); + + // 显示有效的通道 + this->channelGroupList.at(i)->show(); + } else + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/white.png")); + + // 隐藏无效的通道 + this->channelGroupList.at(i)->hide(); + } + } +} + void PhaseWindow::on_minButt_clicked() { @@ -123,11 +156,13 @@ void PhaseWindow::on_startButt_clicked() { //发送开始指令 + device->startWork(); } void PhaseWindow::on_endButt_clicked() { //发送结束指令 + device->stopWork(); } void PhaseWindow::on_settingButt_clicked() diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 489627c..5debd5a 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -5,15 +5,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include +#include "common/utils/SettingConfig.h" +#include "common/utils/QLogUtil.h" + PhaseWindow::PhaseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PhaseWindow) @@ -35,19 +36,18 @@ ui->endButt->move(screenRect.width() - 260, 10); ui->startButt->move(screenRect.width() - 320, 10); ui->line->setGeometry(0, 89, screenRect.width(), 1); - ui->pointsList->setGeometry(200,30,screenRect.width()-600,40); - ui->labelsList->setGeometry(200,60,screenRect.width()-600,30); + ui->pointsList->setGeometry(250,30,screenRect.width()-600,40); + ui->labelsList->setGeometry(250,60,screenRect.width()-600,30); // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 90, screenRect.width(), screenRect.height() - 90); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")); + ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")); this->generateWidgetForDevice(); device = new PhaseDevice(this); - device->startWork(); connect(device, &PhaseDevice::sendDataToDraw, this, &PhaseWindow::drawPhaseDataOnPage); } @@ -60,27 +60,36 @@ void PhaseWindow::drawPhaseDataOnPage(PhaseDataDto * phaseData) { ui->tim3->setText(phaseData->timestamp); + updateChannelActive(phaseData->channelActive); // 更新所有通道BOX的值 -// for (int i = 0; i < phaseData->channelActive.size(); i++) -// { -// // 获取对应的通道BOX -// QGroupBox * channelBox = (QGroupBox *)ui->scrollContents->children().at(i + 1); + for (int i = 0; i < phaseData->channelActive.size(); i++) + { + // 获取对应的通道BOX + if (phaseData->channelActive.at(i) == "1") + { + ChannelItem * channel = channelItemList.at(i); + double phaseValue = channel->updatePhaseMeasureData(phaseData->channelData.at(i)); -// // 赋值,对应的lineEdit/label -// ((QLineEdit *)channelBox->children().at(2))->setText(phaseData->timestamp); -// ((QLineEdit *)channelBox->children().at(4))->setText(QString("%1 s").arg(phaseData->channelDataStr.at(i))); -// ((QLineEdit *)channelBox->children().at(6))->setText(phaseData->frameId); -// ((QLabel *)channelBox->children().at(7))->setText(phaseData->channelActive.at(i) == "1" ? "有效" : "无效"); -// } + QString chFilename = QString("CH_%1.log").arg(i + 1, 2, 10, QLatin1Char('0')); + QString channelDataStr = QString("%1 [%2] %3 %4 %5") + .arg(phaseData->timestamp) + .arg(phaseData->frameId) + .arg(phaseData->channelDataStr.at(i)) + .arg(QString::number(channel->getChannelDelay())) + .arg(QString::number(phaseValue, 'f', 15)); + std::cout << channelDataStr.toStdString() << std::endl; + + QLogUtil::writeChannelDataLogByDate(phaseData->timestamp.mid(0, 10), chFilename, channelDataStr); + } + } } void PhaseWindow::generateWidgetForDevice() { // 获取设备数据 - int channelNum = 16; - //测试通道 - bool arr[16] = {true,false,true,false,true,false,true,false,true,false,true,false,true,false,true,false}; + int channelNum = SettingConfig::getInstance().CHANNEL_COUNT; + QRect screenRect = QApplication::desktop()->screenGeometry(); ui->scrollContents->setGeometry(0, 90, screenRect.width(), channelNum * 170); @@ -90,25 +99,49 @@ for (int i = 0; i < channelNum; i++) { + // 通道状态图标默认显示为离线/无效状态 QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 - if(arr[i]) label->setPixmap(QPixmap(":/points/images/green.png")); - else label->setPixmap(QPixmap(":/points/images/white.png")); - if(!arr[i]) continue; + label->setPixmap(QPixmap(":/points/images/white.png")); + QGroupBox * group = new QGroupBox(ui->scrollContents); group->setTitle(QString("通道 - %1").arg(i + 1)); group->setFont(QFont("微软雅黑", 12)); group->setGeometry(20, i * 160 + 10, screenRect.width() - 40, 160); + this->channelGroupList.append(group); QHBoxLayout * vbox = new QHBoxLayout(group); - ChannelItem *widget=new ChannelItem(); - widget->setGeometry(10, 0, screenRect.width() - 60, 160); + ChannelItem * channelItem = new ChannelItem(); + channelItem->setGeometry(10, 0, screenRect.width() - 60, 160); + this->channelItemList.append(channelItem); - vbox->addWidget(widget); + vbox->addWidget(channelItem); group->setLayout(vbox); layout->addWidget(group); } } +void PhaseWindow::updateChannelActive(QList channelActive) +{ + for (int i = 0; i < channelActive.size(); i++) + { + if (channelActive.at(i) == "1") + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/green.png")); + + // 显示有效的通道 + this->channelGroupList.at(i)->show(); + } else + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/white.png")); + + // 隐藏无效的通道 + this->channelGroupList.at(i)->hide(); + } + } +} + void PhaseWindow::on_minButt_clicked() { @@ -123,11 +156,13 @@ void PhaseWindow::on_startButt_clicked() { //发送开始指令 + device->startWork(); } void PhaseWindow::on_endButt_clicked() { //发送结束指令 + device->stopWork(); } void PhaseWindow::on_settingButt_clicked() diff --git a/PhaseWindow.h b/PhaseWindow.h index 1ad6281..3321d15 100644 --- a/PhaseWindow.h +++ b/PhaseWindow.h @@ -2,12 +2,10 @@ #define PHASEWINDOW_H #include -#include -#include -#include +#include #include "PhaseDevice.h" -#include "common/utils/SettingConfig.h" +#include "ChannelItem.h" namespace Ui { class PhaseWindow; @@ -29,17 +27,18 @@ void on_exitButt_clicked(); void on_startButt_clicked(); - void on_endButt_clicked(); - void on_settingButt_clicked(); private: Ui::PhaseWindow *ui; + QList channelGroupList; + QList channelItemList; PhaseDevice * device; void generateWidgetForDevice(); + void updateChannelActive(QList channelActive); }; #endif // PHASEWINDOW_H diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 489627c..5debd5a 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -5,15 +5,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include +#include "common/utils/SettingConfig.h" +#include "common/utils/QLogUtil.h" + PhaseWindow::PhaseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PhaseWindow) @@ -35,19 +36,18 @@ ui->endButt->move(screenRect.width() - 260, 10); ui->startButt->move(screenRect.width() - 320, 10); ui->line->setGeometry(0, 89, screenRect.width(), 1); - ui->pointsList->setGeometry(200,30,screenRect.width()-600,40); - ui->labelsList->setGeometry(200,60,screenRect.width()-600,30); + ui->pointsList->setGeometry(250,30,screenRect.width()-600,40); + ui->labelsList->setGeometry(250,60,screenRect.width()-600,30); // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 90, screenRect.width(), screenRect.height() - 90); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")); + ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")); this->generateWidgetForDevice(); device = new PhaseDevice(this); - device->startWork(); connect(device, &PhaseDevice::sendDataToDraw, this, &PhaseWindow::drawPhaseDataOnPage); } @@ -60,27 +60,36 @@ void PhaseWindow::drawPhaseDataOnPage(PhaseDataDto * phaseData) { ui->tim3->setText(phaseData->timestamp); + updateChannelActive(phaseData->channelActive); // 更新所有通道BOX的值 -// for (int i = 0; i < phaseData->channelActive.size(); i++) -// { -// // 获取对应的通道BOX -// QGroupBox * channelBox = (QGroupBox *)ui->scrollContents->children().at(i + 1); + for (int i = 0; i < phaseData->channelActive.size(); i++) + { + // 获取对应的通道BOX + if (phaseData->channelActive.at(i) == "1") + { + ChannelItem * channel = channelItemList.at(i); + double phaseValue = channel->updatePhaseMeasureData(phaseData->channelData.at(i)); -// // 赋值,对应的lineEdit/label -// ((QLineEdit *)channelBox->children().at(2))->setText(phaseData->timestamp); -// ((QLineEdit *)channelBox->children().at(4))->setText(QString("%1 s").arg(phaseData->channelDataStr.at(i))); -// ((QLineEdit *)channelBox->children().at(6))->setText(phaseData->frameId); -// ((QLabel *)channelBox->children().at(7))->setText(phaseData->channelActive.at(i) == "1" ? "有效" : "无效"); -// } + QString chFilename = QString("CH_%1.log").arg(i + 1, 2, 10, QLatin1Char('0')); + QString channelDataStr = QString("%1 [%2] %3 %4 %5") + .arg(phaseData->timestamp) + .arg(phaseData->frameId) + .arg(phaseData->channelDataStr.at(i)) + .arg(QString::number(channel->getChannelDelay())) + .arg(QString::number(phaseValue, 'f', 15)); + std::cout << channelDataStr.toStdString() << std::endl; + + QLogUtil::writeChannelDataLogByDate(phaseData->timestamp.mid(0, 10), chFilename, channelDataStr); + } + } } void PhaseWindow::generateWidgetForDevice() { // 获取设备数据 - int channelNum = 16; - //测试通道 - bool arr[16] = {true,false,true,false,true,false,true,false,true,false,true,false,true,false,true,false}; + int channelNum = SettingConfig::getInstance().CHANNEL_COUNT; + QRect screenRect = QApplication::desktop()->screenGeometry(); ui->scrollContents->setGeometry(0, 90, screenRect.width(), channelNum * 170); @@ -90,25 +99,49 @@ for (int i = 0; i < channelNum; i++) { + // 通道状态图标默认显示为离线/无效状态 QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 - if(arr[i]) label->setPixmap(QPixmap(":/points/images/green.png")); - else label->setPixmap(QPixmap(":/points/images/white.png")); - if(!arr[i]) continue; + label->setPixmap(QPixmap(":/points/images/white.png")); + QGroupBox * group = new QGroupBox(ui->scrollContents); group->setTitle(QString("通道 - %1").arg(i + 1)); group->setFont(QFont("微软雅黑", 12)); group->setGeometry(20, i * 160 + 10, screenRect.width() - 40, 160); + this->channelGroupList.append(group); QHBoxLayout * vbox = new QHBoxLayout(group); - ChannelItem *widget=new ChannelItem(); - widget->setGeometry(10, 0, screenRect.width() - 60, 160); + ChannelItem * channelItem = new ChannelItem(); + channelItem->setGeometry(10, 0, screenRect.width() - 60, 160); + this->channelItemList.append(channelItem); - vbox->addWidget(widget); + vbox->addWidget(channelItem); group->setLayout(vbox); layout->addWidget(group); } } +void PhaseWindow::updateChannelActive(QList channelActive) +{ + for (int i = 0; i < channelActive.size(); i++) + { + if (channelActive.at(i) == "1") + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/green.png")); + + // 显示有效的通道 + this->channelGroupList.at(i)->show(); + } else + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/white.png")); + + // 隐藏无效的通道 + this->channelGroupList.at(i)->hide(); + } + } +} + void PhaseWindow::on_minButt_clicked() { @@ -123,11 +156,13 @@ void PhaseWindow::on_startButt_clicked() { //发送开始指令 + device->startWork(); } void PhaseWindow::on_endButt_clicked() { //发送结束指令 + device->stopWork(); } void PhaseWindow::on_settingButt_clicked() diff --git a/PhaseWindow.h b/PhaseWindow.h index 1ad6281..3321d15 100644 --- a/PhaseWindow.h +++ b/PhaseWindow.h @@ -2,12 +2,10 @@ #define PHASEWINDOW_H #include -#include -#include -#include +#include #include "PhaseDevice.h" -#include "common/utils/SettingConfig.h" +#include "ChannelItem.h" namespace Ui { class PhaseWindow; @@ -29,17 +27,18 @@ void on_exitButt_clicked(); void on_startButt_clicked(); - void on_endButt_clicked(); - void on_settingButt_clicked(); private: Ui::PhaseWindow *ui; + QList channelGroupList; + QList channelItemList; PhaseDevice * device; void generateWidgetForDevice(); + void updateChannelActive(QList channelActive); }; #endif // PHASEWINDOW_H diff --git a/common/utils/SettingConfig.cpp b/common/utils/SettingConfig.cpp index 1af9d22..e4e4533 100644 --- a/common/utils/SettingConfig.cpp +++ b/common/utils/SettingConfig.cpp @@ -24,5 +24,7 @@ DEVICE_PORT = getProperty("net", "devicePort").toUInt(); LISTEN_PORT = getProperty("net", "listenPort").toUInt(); + CHANNEL_COUNT = getProperty("dev", "channelCount").toUInt(); + BASE_LOG_PATH = getProperty("log", "basePath").toString(); } diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 489627c..5debd5a 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -5,15 +5,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include +#include "common/utils/SettingConfig.h" +#include "common/utils/QLogUtil.h" + PhaseWindow::PhaseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PhaseWindow) @@ -35,19 +36,18 @@ ui->endButt->move(screenRect.width() - 260, 10); ui->startButt->move(screenRect.width() - 320, 10); ui->line->setGeometry(0, 89, screenRect.width(), 1); - ui->pointsList->setGeometry(200,30,screenRect.width()-600,40); - ui->labelsList->setGeometry(200,60,screenRect.width()-600,30); + ui->pointsList->setGeometry(250,30,screenRect.width()-600,40); + ui->labelsList->setGeometry(250,60,screenRect.width()-600,30); // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 90, screenRect.width(), screenRect.height() - 90); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")); + ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")); this->generateWidgetForDevice(); device = new PhaseDevice(this); - device->startWork(); connect(device, &PhaseDevice::sendDataToDraw, this, &PhaseWindow::drawPhaseDataOnPage); } @@ -60,27 +60,36 @@ void PhaseWindow::drawPhaseDataOnPage(PhaseDataDto * phaseData) { ui->tim3->setText(phaseData->timestamp); + updateChannelActive(phaseData->channelActive); // 更新所有通道BOX的值 -// for (int i = 0; i < phaseData->channelActive.size(); i++) -// { -// // 获取对应的通道BOX -// QGroupBox * channelBox = (QGroupBox *)ui->scrollContents->children().at(i + 1); + for (int i = 0; i < phaseData->channelActive.size(); i++) + { + // 获取对应的通道BOX + if (phaseData->channelActive.at(i) == "1") + { + ChannelItem * channel = channelItemList.at(i); + double phaseValue = channel->updatePhaseMeasureData(phaseData->channelData.at(i)); -// // 赋值,对应的lineEdit/label -// ((QLineEdit *)channelBox->children().at(2))->setText(phaseData->timestamp); -// ((QLineEdit *)channelBox->children().at(4))->setText(QString("%1 s").arg(phaseData->channelDataStr.at(i))); -// ((QLineEdit *)channelBox->children().at(6))->setText(phaseData->frameId); -// ((QLabel *)channelBox->children().at(7))->setText(phaseData->channelActive.at(i) == "1" ? "有效" : "无效"); -// } + QString chFilename = QString("CH_%1.log").arg(i + 1, 2, 10, QLatin1Char('0')); + QString channelDataStr = QString("%1 [%2] %3 %4 %5") + .arg(phaseData->timestamp) + .arg(phaseData->frameId) + .arg(phaseData->channelDataStr.at(i)) + .arg(QString::number(channel->getChannelDelay())) + .arg(QString::number(phaseValue, 'f', 15)); + std::cout << channelDataStr.toStdString() << std::endl; + + QLogUtil::writeChannelDataLogByDate(phaseData->timestamp.mid(0, 10), chFilename, channelDataStr); + } + } } void PhaseWindow::generateWidgetForDevice() { // 获取设备数据 - int channelNum = 16; - //测试通道 - bool arr[16] = {true,false,true,false,true,false,true,false,true,false,true,false,true,false,true,false}; + int channelNum = SettingConfig::getInstance().CHANNEL_COUNT; + QRect screenRect = QApplication::desktop()->screenGeometry(); ui->scrollContents->setGeometry(0, 90, screenRect.width(), channelNum * 170); @@ -90,25 +99,49 @@ for (int i = 0; i < channelNum; i++) { + // 通道状态图标默认显示为离线/无效状态 QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 - if(arr[i]) label->setPixmap(QPixmap(":/points/images/green.png")); - else label->setPixmap(QPixmap(":/points/images/white.png")); - if(!arr[i]) continue; + label->setPixmap(QPixmap(":/points/images/white.png")); + QGroupBox * group = new QGroupBox(ui->scrollContents); group->setTitle(QString("通道 - %1").arg(i + 1)); group->setFont(QFont("微软雅黑", 12)); group->setGeometry(20, i * 160 + 10, screenRect.width() - 40, 160); + this->channelGroupList.append(group); QHBoxLayout * vbox = new QHBoxLayout(group); - ChannelItem *widget=new ChannelItem(); - widget->setGeometry(10, 0, screenRect.width() - 60, 160); + ChannelItem * channelItem = new ChannelItem(); + channelItem->setGeometry(10, 0, screenRect.width() - 60, 160); + this->channelItemList.append(channelItem); - vbox->addWidget(widget); + vbox->addWidget(channelItem); group->setLayout(vbox); layout->addWidget(group); } } +void PhaseWindow::updateChannelActive(QList channelActive) +{ + for (int i = 0; i < channelActive.size(); i++) + { + if (channelActive.at(i) == "1") + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/green.png")); + + // 显示有效的通道 + this->channelGroupList.at(i)->show(); + } else + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/white.png")); + + // 隐藏无效的通道 + this->channelGroupList.at(i)->hide(); + } + } +} + void PhaseWindow::on_minButt_clicked() { @@ -123,11 +156,13 @@ void PhaseWindow::on_startButt_clicked() { //发送开始指令 + device->startWork(); } void PhaseWindow::on_endButt_clicked() { //发送结束指令 + device->stopWork(); } void PhaseWindow::on_settingButt_clicked() diff --git a/PhaseWindow.h b/PhaseWindow.h index 1ad6281..3321d15 100644 --- a/PhaseWindow.h +++ b/PhaseWindow.h @@ -2,12 +2,10 @@ #define PHASEWINDOW_H #include -#include -#include -#include +#include #include "PhaseDevice.h" -#include "common/utils/SettingConfig.h" +#include "ChannelItem.h" namespace Ui { class PhaseWindow; @@ -29,17 +27,18 @@ void on_exitButt_clicked(); void on_startButt_clicked(); - void on_endButt_clicked(); - void on_settingButt_clicked(); private: Ui::PhaseWindow *ui; + QList channelGroupList; + QList channelItemList; PhaseDevice * device; void generateWidgetForDevice(); + void updateChannelActive(QList channelActive); }; #endif // PHASEWINDOW_H diff --git a/common/utils/SettingConfig.cpp b/common/utils/SettingConfig.cpp index 1af9d22..e4e4533 100644 --- a/common/utils/SettingConfig.cpp +++ b/common/utils/SettingConfig.cpp @@ -24,5 +24,7 @@ DEVICE_PORT = getProperty("net", "devicePort").toUInt(); LISTEN_PORT = getProperty("net", "listenPort").toUInt(); + CHANNEL_COUNT = getProperty("dev", "channelCount").toUInt(); + BASE_LOG_PATH = getProperty("log", "basePath").toString(); } diff --git a/common/utils/SettingConfig.h b/common/utils/SettingConfig.h index 1e16b63..6401f07 100644 --- a/common/utils/SettingConfig.h +++ b/common/utils/SettingConfig.h @@ -33,6 +33,8 @@ quint16 DEVICE_PORT; quint16 LISTEN_PORT; + quint8 CHANNEL_COUNT; + QString BASE_LOG_PATH; private: diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 489627c..5debd5a 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -5,15 +5,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include +#include "common/utils/SettingConfig.h" +#include "common/utils/QLogUtil.h" + PhaseWindow::PhaseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PhaseWindow) @@ -35,19 +36,18 @@ ui->endButt->move(screenRect.width() - 260, 10); ui->startButt->move(screenRect.width() - 320, 10); ui->line->setGeometry(0, 89, screenRect.width(), 1); - ui->pointsList->setGeometry(200,30,screenRect.width()-600,40); - ui->labelsList->setGeometry(200,60,screenRect.width()-600,30); + ui->pointsList->setGeometry(250,30,screenRect.width()-600,40); + ui->labelsList->setGeometry(250,60,screenRect.width()-600,30); // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 90, screenRect.width(), screenRect.height() - 90); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")); + ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")); this->generateWidgetForDevice(); device = new PhaseDevice(this); - device->startWork(); connect(device, &PhaseDevice::sendDataToDraw, this, &PhaseWindow::drawPhaseDataOnPage); } @@ -60,27 +60,36 @@ void PhaseWindow::drawPhaseDataOnPage(PhaseDataDto * phaseData) { ui->tim3->setText(phaseData->timestamp); + updateChannelActive(phaseData->channelActive); // 更新所有通道BOX的值 -// for (int i = 0; i < phaseData->channelActive.size(); i++) -// { -// // 获取对应的通道BOX -// QGroupBox * channelBox = (QGroupBox *)ui->scrollContents->children().at(i + 1); + for (int i = 0; i < phaseData->channelActive.size(); i++) + { + // 获取对应的通道BOX + if (phaseData->channelActive.at(i) == "1") + { + ChannelItem * channel = channelItemList.at(i); + double phaseValue = channel->updatePhaseMeasureData(phaseData->channelData.at(i)); -// // 赋值,对应的lineEdit/label -// ((QLineEdit *)channelBox->children().at(2))->setText(phaseData->timestamp); -// ((QLineEdit *)channelBox->children().at(4))->setText(QString("%1 s").arg(phaseData->channelDataStr.at(i))); -// ((QLineEdit *)channelBox->children().at(6))->setText(phaseData->frameId); -// ((QLabel *)channelBox->children().at(7))->setText(phaseData->channelActive.at(i) == "1" ? "有效" : "无效"); -// } + QString chFilename = QString("CH_%1.log").arg(i + 1, 2, 10, QLatin1Char('0')); + QString channelDataStr = QString("%1 [%2] %3 %4 %5") + .arg(phaseData->timestamp) + .arg(phaseData->frameId) + .arg(phaseData->channelDataStr.at(i)) + .arg(QString::number(channel->getChannelDelay())) + .arg(QString::number(phaseValue, 'f', 15)); + std::cout << channelDataStr.toStdString() << std::endl; + + QLogUtil::writeChannelDataLogByDate(phaseData->timestamp.mid(0, 10), chFilename, channelDataStr); + } + } } void PhaseWindow::generateWidgetForDevice() { // 获取设备数据 - int channelNum = 16; - //测试通道 - bool arr[16] = {true,false,true,false,true,false,true,false,true,false,true,false,true,false,true,false}; + int channelNum = SettingConfig::getInstance().CHANNEL_COUNT; + QRect screenRect = QApplication::desktop()->screenGeometry(); ui->scrollContents->setGeometry(0, 90, screenRect.width(), channelNum * 170); @@ -90,25 +99,49 @@ for (int i = 0; i < channelNum; i++) { + // 通道状态图标默认显示为离线/无效状态 QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 - if(arr[i]) label->setPixmap(QPixmap(":/points/images/green.png")); - else label->setPixmap(QPixmap(":/points/images/white.png")); - if(!arr[i]) continue; + label->setPixmap(QPixmap(":/points/images/white.png")); + QGroupBox * group = new QGroupBox(ui->scrollContents); group->setTitle(QString("通道 - %1").arg(i + 1)); group->setFont(QFont("微软雅黑", 12)); group->setGeometry(20, i * 160 + 10, screenRect.width() - 40, 160); + this->channelGroupList.append(group); QHBoxLayout * vbox = new QHBoxLayout(group); - ChannelItem *widget=new ChannelItem(); - widget->setGeometry(10, 0, screenRect.width() - 60, 160); + ChannelItem * channelItem = new ChannelItem(); + channelItem->setGeometry(10, 0, screenRect.width() - 60, 160); + this->channelItemList.append(channelItem); - vbox->addWidget(widget); + vbox->addWidget(channelItem); group->setLayout(vbox); layout->addWidget(group); } } +void PhaseWindow::updateChannelActive(QList channelActive) +{ + for (int i = 0; i < channelActive.size(); i++) + { + if (channelActive.at(i) == "1") + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/green.png")); + + // 显示有效的通道 + this->channelGroupList.at(i)->show(); + } else + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/white.png")); + + // 隐藏无效的通道 + this->channelGroupList.at(i)->hide(); + } + } +} + void PhaseWindow::on_minButt_clicked() { @@ -123,11 +156,13 @@ void PhaseWindow::on_startButt_clicked() { //发送开始指令 + device->startWork(); } void PhaseWindow::on_endButt_clicked() { //发送结束指令 + device->stopWork(); } void PhaseWindow::on_settingButt_clicked() diff --git a/PhaseWindow.h b/PhaseWindow.h index 1ad6281..3321d15 100644 --- a/PhaseWindow.h +++ b/PhaseWindow.h @@ -2,12 +2,10 @@ #define PHASEWINDOW_H #include -#include -#include -#include +#include #include "PhaseDevice.h" -#include "common/utils/SettingConfig.h" +#include "ChannelItem.h" namespace Ui { class PhaseWindow; @@ -29,17 +27,18 @@ void on_exitButt_clicked(); void on_startButt_clicked(); - void on_endButt_clicked(); - void on_settingButt_clicked(); private: Ui::PhaseWindow *ui; + QList channelGroupList; + QList channelItemList; PhaseDevice * device; void generateWidgetForDevice(); + void updateChannelActive(QList channelActive); }; #endif // PHASEWINDOW_H diff --git a/common/utils/SettingConfig.cpp b/common/utils/SettingConfig.cpp index 1af9d22..e4e4533 100644 --- a/common/utils/SettingConfig.cpp +++ b/common/utils/SettingConfig.cpp @@ -24,5 +24,7 @@ DEVICE_PORT = getProperty("net", "devicePort").toUInt(); LISTEN_PORT = getProperty("net", "listenPort").toUInt(); + CHANNEL_COUNT = getProperty("dev", "channelCount").toUInt(); + BASE_LOG_PATH = getProperty("log", "basePath").toString(); } diff --git a/common/utils/SettingConfig.h b/common/utils/SettingConfig.h index 1e16b63..6401f07 100644 --- a/common/utils/SettingConfig.h +++ b/common/utils/SettingConfig.h @@ -33,6 +33,8 @@ quint16 DEVICE_PORT; quint16 LISTEN_PORT; + quint8 CHANNEL_COUNT; + QString BASE_LOG_PATH; private: diff --git a/conf/config.ini b/conf/config.ini index 73d6400..60bf865 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -3,5 +3,8 @@ devicePort=233 listenPort=243 +[dev] +channelCount=16 + [log] basePath="/home/admin/Qt/ZXSSCJ-Release/PhaseCompAcq/logs/" diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 489627c..5debd5a 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -5,15 +5,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include +#include "common/utils/SettingConfig.h" +#include "common/utils/QLogUtil.h" + PhaseWindow::PhaseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PhaseWindow) @@ -35,19 +36,18 @@ ui->endButt->move(screenRect.width() - 260, 10); ui->startButt->move(screenRect.width() - 320, 10); ui->line->setGeometry(0, 89, screenRect.width(), 1); - ui->pointsList->setGeometry(200,30,screenRect.width()-600,40); - ui->labelsList->setGeometry(200,60,screenRect.width()-600,30); + ui->pointsList->setGeometry(250,30,screenRect.width()-600,40); + ui->labelsList->setGeometry(250,60,screenRect.width()-600,30); // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 90, screenRect.width(), screenRect.height() - 90); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")); + ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")); this->generateWidgetForDevice(); device = new PhaseDevice(this); - device->startWork(); connect(device, &PhaseDevice::sendDataToDraw, this, &PhaseWindow::drawPhaseDataOnPage); } @@ -60,27 +60,36 @@ void PhaseWindow::drawPhaseDataOnPage(PhaseDataDto * phaseData) { ui->tim3->setText(phaseData->timestamp); + updateChannelActive(phaseData->channelActive); // 更新所有通道BOX的值 -// for (int i = 0; i < phaseData->channelActive.size(); i++) -// { -// // 获取对应的通道BOX -// QGroupBox * channelBox = (QGroupBox *)ui->scrollContents->children().at(i + 1); + for (int i = 0; i < phaseData->channelActive.size(); i++) + { + // 获取对应的通道BOX + if (phaseData->channelActive.at(i) == "1") + { + ChannelItem * channel = channelItemList.at(i); + double phaseValue = channel->updatePhaseMeasureData(phaseData->channelData.at(i)); -// // 赋值,对应的lineEdit/label -// ((QLineEdit *)channelBox->children().at(2))->setText(phaseData->timestamp); -// ((QLineEdit *)channelBox->children().at(4))->setText(QString("%1 s").arg(phaseData->channelDataStr.at(i))); -// ((QLineEdit *)channelBox->children().at(6))->setText(phaseData->frameId); -// ((QLabel *)channelBox->children().at(7))->setText(phaseData->channelActive.at(i) == "1" ? "有效" : "无效"); -// } + QString chFilename = QString("CH_%1.log").arg(i + 1, 2, 10, QLatin1Char('0')); + QString channelDataStr = QString("%1 [%2] %3 %4 %5") + .arg(phaseData->timestamp) + .arg(phaseData->frameId) + .arg(phaseData->channelDataStr.at(i)) + .arg(QString::number(channel->getChannelDelay())) + .arg(QString::number(phaseValue, 'f', 15)); + std::cout << channelDataStr.toStdString() << std::endl; + + QLogUtil::writeChannelDataLogByDate(phaseData->timestamp.mid(0, 10), chFilename, channelDataStr); + } + } } void PhaseWindow::generateWidgetForDevice() { // 获取设备数据 - int channelNum = 16; - //测试通道 - bool arr[16] = {true,false,true,false,true,false,true,false,true,false,true,false,true,false,true,false}; + int channelNum = SettingConfig::getInstance().CHANNEL_COUNT; + QRect screenRect = QApplication::desktop()->screenGeometry(); ui->scrollContents->setGeometry(0, 90, screenRect.width(), channelNum * 170); @@ -90,25 +99,49 @@ for (int i = 0; i < channelNum; i++) { + // 通道状态图标默认显示为离线/无效状态 QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 - if(arr[i]) label->setPixmap(QPixmap(":/points/images/green.png")); - else label->setPixmap(QPixmap(":/points/images/white.png")); - if(!arr[i]) continue; + label->setPixmap(QPixmap(":/points/images/white.png")); + QGroupBox * group = new QGroupBox(ui->scrollContents); group->setTitle(QString("通道 - %1").arg(i + 1)); group->setFont(QFont("微软雅黑", 12)); group->setGeometry(20, i * 160 + 10, screenRect.width() - 40, 160); + this->channelGroupList.append(group); QHBoxLayout * vbox = new QHBoxLayout(group); - ChannelItem *widget=new ChannelItem(); - widget->setGeometry(10, 0, screenRect.width() - 60, 160); + ChannelItem * channelItem = new ChannelItem(); + channelItem->setGeometry(10, 0, screenRect.width() - 60, 160); + this->channelItemList.append(channelItem); - vbox->addWidget(widget); + vbox->addWidget(channelItem); group->setLayout(vbox); layout->addWidget(group); } } +void PhaseWindow::updateChannelActive(QList channelActive) +{ + for (int i = 0; i < channelActive.size(); i++) + { + if (channelActive.at(i) == "1") + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/green.png")); + + // 显示有效的通道 + this->channelGroupList.at(i)->show(); + } else + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/white.png")); + + // 隐藏无效的通道 + this->channelGroupList.at(i)->hide(); + } + } +} + void PhaseWindow::on_minButt_clicked() { @@ -123,11 +156,13 @@ void PhaseWindow::on_startButt_clicked() { //发送开始指令 + device->startWork(); } void PhaseWindow::on_endButt_clicked() { //发送结束指令 + device->stopWork(); } void PhaseWindow::on_settingButt_clicked() diff --git a/PhaseWindow.h b/PhaseWindow.h index 1ad6281..3321d15 100644 --- a/PhaseWindow.h +++ b/PhaseWindow.h @@ -2,12 +2,10 @@ #define PHASEWINDOW_H #include -#include -#include -#include +#include #include "PhaseDevice.h" -#include "common/utils/SettingConfig.h" +#include "ChannelItem.h" namespace Ui { class PhaseWindow; @@ -29,17 +27,18 @@ void on_exitButt_clicked(); void on_startButt_clicked(); - void on_endButt_clicked(); - void on_settingButt_clicked(); private: Ui::PhaseWindow *ui; + QList channelGroupList; + QList channelItemList; PhaseDevice * device; void generateWidgetForDevice(); + void updateChannelActive(QList channelActive); }; #endif // PHASEWINDOW_H diff --git a/common/utils/SettingConfig.cpp b/common/utils/SettingConfig.cpp index 1af9d22..e4e4533 100644 --- a/common/utils/SettingConfig.cpp +++ b/common/utils/SettingConfig.cpp @@ -24,5 +24,7 @@ DEVICE_PORT = getProperty("net", "devicePort").toUInt(); LISTEN_PORT = getProperty("net", "listenPort").toUInt(); + CHANNEL_COUNT = getProperty("dev", "channelCount").toUInt(); + BASE_LOG_PATH = getProperty("log", "basePath").toString(); } diff --git a/common/utils/SettingConfig.h b/common/utils/SettingConfig.h index 1e16b63..6401f07 100644 --- a/common/utils/SettingConfig.h +++ b/common/utils/SettingConfig.h @@ -33,6 +33,8 @@ quint16 DEVICE_PORT; quint16 LISTEN_PORT; + quint8 CHANNEL_COUNT; + QString BASE_LOG_PATH; private: diff --git a/conf/config.ini b/conf/config.ini index 73d6400..60bf865 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -3,5 +3,8 @@ devicePort=233 listenPort=243 +[dev] +channelCount=16 + [log] basePath="/home/admin/Qt/ZXSSCJ-Release/PhaseCompAcq/logs/" diff --git a/protocol/PhaseProtocolBM.cpp b/protocol/PhaseProtocolBM.cpp index aa4f086..6b5ca73 100644 --- a/protocol/PhaseProtocolBM.cpp +++ b/protocol/PhaseProtocolBM.cpp @@ -44,7 +44,7 @@ double phase = (channelRawData - CALCULATE_OFFSET) * CALCULATE_FACTOR; dataObj->channelActive.append("1"); dataObj->channelData.append(phase); - dataObj->channelDataStr.append(QString::number(phase, 'f', 12)); + dataObj->channelDataStr.append(QString::number(phase, 'f', 15)); } } @@ -60,6 +60,33 @@ return "$$STOP*"; } +QList PhaseProtocolBM::extractFrameList(QByteArray rawData) +{ + QList resultList; + if (rawData.size() < PHASE_FRAM_LENGTH) + { + // 长度小于帧长度则直接返回空 + return resultList; + } + + int tail = rawData.indexOf(PHASE_FRAME_TAIL); + if (tail < PHASE_FRAM_LENGTH - PHASE_FRAME_TAIL.size()) + { + // 没有检测到帧尾EEEEEEEE或者帧尾前的长度不够则直接返回空 + return resultList; + } + + while (rawData.size() > 0) + { + QByteArray ba; + ba.append(rawData.mid(tail - PHASE_FRAM_LENGTH + PHASE_FRAME_TAIL.size(), PHASE_FRAM_LENGTH)); + resultList.append(ba); + rawData = rawData.right(tail + PHASE_FRAME_TAIL.size()); + } + + return resultList; +} + bool PhaseProtocolBM::checkFrame(QByteArray rawData) { // 帧长度小于最小的长度 diff --git a/ChannelItem.cpp b/ChannelItem.cpp index 8e66b15..93ef844 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -1,4 +1,4 @@ -#include "ChannelItem.h" +#include "ChannelItem.h" #include "ui_ChannelItem.h" ChannelItem::ChannelItem(QWidget *parent) : @@ -6,9 +6,29 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); + ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); + ui->delay->setFont(QFont("微软雅黑", 10)); } ChannelItem::~ChannelItem() { delete ui; } + +double ChannelItem::getChannelDelay() +{ + return channelDelay; +} + +double ChannelItem::updatePhaseMeasureData(double raw) +{ + ui->rawValue->setText(QString::number(raw, 'f', 15)); + ui->channelValue->setText(QString::number(raw + channelDelay * 1e-9, 'f', 15)); + + return raw + channelDelay * 1e-9; +} + +void ChannelItem::on_delay_valueChanged(double value) +{ + channelDelay = value; +} diff --git a/ChannelItem.h b/ChannelItem.h index 3ccd5e3..74ff48b 100644 --- a/ChannelItem.h +++ b/ChannelItem.h @@ -1,4 +1,4 @@ -#ifndef CHANNELITEM_H +#ifndef CHANNELITEM_H #define CHANNELITEM_H #include @@ -15,8 +15,16 @@ explicit ChannelItem(QWidget *parent = nullptr); ~ChannelItem(); + double getChannelDelay(); + double updatePhaseMeasureData(double channelValue); + +private slots: + void on_delay_valueChanged(double value); + private: Ui::ChannelItem *ui; + + double channelDelay; }; #endif // CHANNELITEM_H diff --git a/ChannelItem.ui b/ChannelItem.ui index 1b750a3..173f4a5 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -89,7 +89,7 @@ - 4.78e-13 + 0.00 Qt::AlignCenter @@ -105,7 +105,7 @@ - 52262 + 0 Qt::AlignCenter @@ -150,7 +150,7 @@ - 1.47e-14 + 0.00 Qt::AlignCenter @@ -166,7 +166,7 @@ - 52 + 0 Qt::AlignCenter @@ -207,7 +207,7 @@ - 6.38e-14 + 0.00 Qt::AlignCenter @@ -223,7 +223,7 @@ - 5226 + 0 Qt::AlignCenter @@ -268,7 +268,7 @@ - 4.45e-15 + 0.00 Qt::AlignCenter @@ -284,7 +284,7 @@ - 5 + 0 Qt::AlignCenter @@ -325,7 +325,7 @@ - 1.65e-14 + 0.00 Qt::AlignCenter @@ -341,7 +341,7 @@ - 522 + 0 Qt::AlignCenter @@ -477,13 +477,13 @@ 190 10 - 171 + 200 160 - + 微软雅黑 @@ -491,25 +491,28 @@ - 3.61751e-12s + 0.00 s - - - - 微软雅黑 - 12 - + + + ns - - 1.00e-12 + + 3 + + + -99.000000000000000 + + + 0.001000000000000 - + 微软雅黑 @@ -517,7 +520,7 @@ - 4.61751e-12s + 0.00 s @@ -530,7 +533,7 @@ - 1.02e-15 + 0.00 diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 58674c7..cbf7709 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -12,24 +12,10 @@ PhaseDevice::~PhaseDevice() { - + disconnect(clientUtil, &UDPClientUtil::dataRecieved, + this, &PhaseDevice::dataReceivedHandler); } - -QString PhaseDevice::getDevCode() -{ - return this->devCode; -} -void PhaseDevice::setDevCode(QString devCode) -{ - this->devCode = devCode; -} -void PhaseDevice::setDeviceId(QString deviceId) -{ - this->deviceId = deviceId; -} - - void PhaseDevice::startWork() { QString startCmd = PhaseProtocolBM::startMessure(); @@ -46,8 +32,6 @@ { this->dataBuff.append(data); - std::cout << QByteUtil::binToHexString(this->dataBuff).toStdString() << std::endl; - PhaseDataDto * phaseData = new PhaseDataDto(this); if (PhaseProtocolBM::checkFrame(this->dataBuff) == true) { @@ -60,7 +44,6 @@ if (parse == true) { QDateTime now = QDateTime::currentDateTime(); - phaseData->devCode = this->devCode; phaseData->timestamp = now.toString("yyyy-MM-dd HH:mm:ss.zzz"); phaseData->milisecond = now.toMSecsSinceEpoch(); this->afterFramePhase(phaseData); @@ -86,30 +69,10 @@ QString date = phaseData->timestamp.mid(0, 10); // 2.1 原始字节数组数据 - QString filename = "raw_" + devCode + ".log"; + QString filename = "rawBytes.log"; QString content = phaseData->timestamp + " " + QByteUtil::binToHexString(phaseData->rawFrame); QLogUtil::writeRawDataLogByDate(date, filename, content); - // 2.2 各个通道的相差数据 - for (int i = 1; i <= phaseData->channelActive.size(); i++) - { - if (phaseData->channelActive.at(i-1).toUInt() == 1) - { - QString chFilename("%1_CH_%2.log"); - chFilename = chFilename.arg(devCode); - if (i < 10) - { - chFilename = chFilename.arg(QString("0%1").arg(i)); - } else - { - chFilename = chFilename.arg(i); - } - QString channelDataStr = QString("%1 [%2] %3").arg(phaseData->timestamp).arg(phaseData->frameId).arg(phaseData->channelDataStr.at(i-1)); - - QLogUtil::writeChannelDataLogByDate(date, chFilename, channelDataStr); - } - } - // 4. 在界面上简单显示相差数据结果 emit this->sendDataToDraw(phaseData); } diff --git a/PhaseDevice.h b/PhaseDevice.h index f69839c..963d983 100644 --- a/PhaseDevice.h +++ b/PhaseDevice.h @@ -17,16 +17,7 @@ void stopWork(); void afterFramePhase(PhaseDataDto * phaseData); - - QString getDevCode(); - void setDevCode(QString devCode); - void setDeviceId(QString deviceId); - - bool isSerialOpen(); private: - QString deviceId; - QString devCode; - UDPClientUtil * clientUtil; QByteArray dataBuff; diff --git a/PhaseMeasure.pro.user b/PhaseMeasure.pro.user index 2e56ba6..d1824d6 100644 --- a/PhaseMeasure.pro.user +++ b/PhaseMeasure.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {58895c32-e1e9-4248-b30e-d2ac0dfba9c9} + {b3715025-e290-4df4-afaa-42a38b3e40c1} ProjectExplorer.Project.ActiveTarget @@ -64,14 +64,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.14.2 MinGW 32-bit - Desktop Qt 5.14.2 MinGW 32-bit - qt.qt5.5142.win32_mingw73_kit + Desktop Qt 5.12.8 MinGW 64-bit + Desktop Qt 5.12.8 MinGW 64-bit + qt.qt5.5128.win64_mingw73_kit 0 0 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug true @@ -119,7 +119,7 @@ 2 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Release + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Release true @@ -167,7 +167,7 @@ 0 - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_32_bit-Profile + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Profile true @@ -287,8 +287,8 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro - E:/workspace/ZXSSCJ/PhaseMeasure/PhaseMeasure.pro + Qt4ProjectManager.Qt4RunConfiguration:D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro + D:/Workspace Qt/PhaseMeasure/PhaseMeasure.pro false @@ -299,257 +299,14 @@ false true - E:/workspace/ZXSSCJ/build-PhaseMeasure_Qt_5_14_2_MinGW_32_bit-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop Qt 5.14.2 MinGW 64-bit - Desktop Qt 5.14.2 MinGW 64-bit - qt.qt5.5142.win64_mingw73_kit - 0 - 0 - 0 - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - E:/workspace/ZXSSCJ/build-PhaseMeasure-Desktop_Qt_5_14_2_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - ProjectExplorer.CustomExecutableRunConfiguration - - - false - - false - true - false - false - true - - + D:/Workspace Qt/build-PhaseMeasure-Desktop_Qt_5_12_8_MinGW_64_bit-Debug 1 ProjectExplorer.Project.TargetCount - 2 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index 489627c..5debd5a 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -5,15 +5,16 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include +#include "common/utils/SettingConfig.h" +#include "common/utils/QLogUtil.h" + PhaseWindow::PhaseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PhaseWindow) @@ -35,19 +36,18 @@ ui->endButt->move(screenRect.width() - 260, 10); ui->startButt->move(screenRect.width() - 320, 10); ui->line->setGeometry(0, 89, screenRect.width(), 1); - ui->pointsList->setGeometry(200,30,screenRect.width()-600,40); - ui->labelsList->setGeometry(200,60,screenRect.width()-600,30); + ui->pointsList->setGeometry(250,30,screenRect.width()-600,40); + ui->labelsList->setGeometry(250,60,screenRect.width()-600,30); // 设置主体区域的大小和位置 ui->scrollArea->setGeometry(0, 90, screenRect.width(), screenRect.height() - 90); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")); + ui->tim3->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")); this->generateWidgetForDevice(); device = new PhaseDevice(this); - device->startWork(); connect(device, &PhaseDevice::sendDataToDraw, this, &PhaseWindow::drawPhaseDataOnPage); } @@ -60,27 +60,36 @@ void PhaseWindow::drawPhaseDataOnPage(PhaseDataDto * phaseData) { ui->tim3->setText(phaseData->timestamp); + updateChannelActive(phaseData->channelActive); // 更新所有通道BOX的值 -// for (int i = 0; i < phaseData->channelActive.size(); i++) -// { -// // 获取对应的通道BOX -// QGroupBox * channelBox = (QGroupBox *)ui->scrollContents->children().at(i + 1); + for (int i = 0; i < phaseData->channelActive.size(); i++) + { + // 获取对应的通道BOX + if (phaseData->channelActive.at(i) == "1") + { + ChannelItem * channel = channelItemList.at(i); + double phaseValue = channel->updatePhaseMeasureData(phaseData->channelData.at(i)); -// // 赋值,对应的lineEdit/label -// ((QLineEdit *)channelBox->children().at(2))->setText(phaseData->timestamp); -// ((QLineEdit *)channelBox->children().at(4))->setText(QString("%1 s").arg(phaseData->channelDataStr.at(i))); -// ((QLineEdit *)channelBox->children().at(6))->setText(phaseData->frameId); -// ((QLabel *)channelBox->children().at(7))->setText(phaseData->channelActive.at(i) == "1" ? "有效" : "无效"); -// } + QString chFilename = QString("CH_%1.log").arg(i + 1, 2, 10, QLatin1Char('0')); + QString channelDataStr = QString("%1 [%2] %3 %4 %5") + .arg(phaseData->timestamp) + .arg(phaseData->frameId) + .arg(phaseData->channelDataStr.at(i)) + .arg(QString::number(channel->getChannelDelay())) + .arg(QString::number(phaseValue, 'f', 15)); + std::cout << channelDataStr.toStdString() << std::endl; + + QLogUtil::writeChannelDataLogByDate(phaseData->timestamp.mid(0, 10), chFilename, channelDataStr); + } + } } void PhaseWindow::generateWidgetForDevice() { // 获取设备数据 - int channelNum = 16; - //测试通道 - bool arr[16] = {true,false,true,false,true,false,true,false,true,false,true,false,true,false,true,false}; + int channelNum = SettingConfig::getInstance().CHANNEL_COUNT; + QRect screenRect = QApplication::desktop()->screenGeometry(); ui->scrollContents->setGeometry(0, 90, screenRect.width(), channelNum * 170); @@ -90,25 +99,49 @@ for (int i = 0; i < channelNum; i++) { + // 通道状态图标默认显示为离线/无效状态 QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 - if(arr[i]) label->setPixmap(QPixmap(":/points/images/green.png")); - else label->setPixmap(QPixmap(":/points/images/white.png")); - if(!arr[i]) continue; + label->setPixmap(QPixmap(":/points/images/white.png")); + QGroupBox * group = new QGroupBox(ui->scrollContents); group->setTitle(QString("通道 - %1").arg(i + 1)); group->setFont(QFont("微软雅黑", 12)); group->setGeometry(20, i * 160 + 10, screenRect.width() - 40, 160); + this->channelGroupList.append(group); QHBoxLayout * vbox = new QHBoxLayout(group); - ChannelItem *widget=new ChannelItem(); - widget->setGeometry(10, 0, screenRect.width() - 60, 160); + ChannelItem * channelItem = new ChannelItem(); + channelItem->setGeometry(10, 0, screenRect.width() - 60, 160); + this->channelItemList.append(channelItem); - vbox->addWidget(widget); + vbox->addWidget(channelItem); group->setLayout(vbox); layout->addWidget(group); } } +void PhaseWindow::updateChannelActive(QList channelActive) +{ + for (int i = 0; i < channelActive.size(); i++) + { + if (channelActive.at(i) == "1") + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/green.png")); + + // 显示有效的通道 + this->channelGroupList.at(i)->show(); + } else + { + QLabel* label = ui->pointsList->findChild(QString("p%1").arg(i+1)); //根据子控件的名称查找子控件 + label->setPixmap(QPixmap(":/points/images/white.png")); + + // 隐藏无效的通道 + this->channelGroupList.at(i)->hide(); + } + } +} + void PhaseWindow::on_minButt_clicked() { @@ -123,11 +156,13 @@ void PhaseWindow::on_startButt_clicked() { //发送开始指令 + device->startWork(); } void PhaseWindow::on_endButt_clicked() { //发送结束指令 + device->stopWork(); } void PhaseWindow::on_settingButt_clicked() diff --git a/PhaseWindow.h b/PhaseWindow.h index 1ad6281..3321d15 100644 --- a/PhaseWindow.h +++ b/PhaseWindow.h @@ -2,12 +2,10 @@ #define PHASEWINDOW_H #include -#include -#include -#include +#include #include "PhaseDevice.h" -#include "common/utils/SettingConfig.h" +#include "ChannelItem.h" namespace Ui { class PhaseWindow; @@ -29,17 +27,18 @@ void on_exitButt_clicked(); void on_startButt_clicked(); - void on_endButt_clicked(); - void on_settingButt_clicked(); private: Ui::PhaseWindow *ui; + QList channelGroupList; + QList channelItemList; PhaseDevice * device; void generateWidgetForDevice(); + void updateChannelActive(QList channelActive); }; #endif // PHASEWINDOW_H diff --git a/common/utils/SettingConfig.cpp b/common/utils/SettingConfig.cpp index 1af9d22..e4e4533 100644 --- a/common/utils/SettingConfig.cpp +++ b/common/utils/SettingConfig.cpp @@ -24,5 +24,7 @@ DEVICE_PORT = getProperty("net", "devicePort").toUInt(); LISTEN_PORT = getProperty("net", "listenPort").toUInt(); + CHANNEL_COUNT = getProperty("dev", "channelCount").toUInt(); + BASE_LOG_PATH = getProperty("log", "basePath").toString(); } diff --git a/common/utils/SettingConfig.h b/common/utils/SettingConfig.h index 1e16b63..6401f07 100644 --- a/common/utils/SettingConfig.h +++ b/common/utils/SettingConfig.h @@ -33,6 +33,8 @@ quint16 DEVICE_PORT; quint16 LISTEN_PORT; + quint8 CHANNEL_COUNT; + QString BASE_LOG_PATH; private: diff --git a/conf/config.ini b/conf/config.ini index 73d6400..60bf865 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -3,5 +3,8 @@ devicePort=233 listenPort=243 +[dev] +channelCount=16 + [log] basePath="/home/admin/Qt/ZXSSCJ-Release/PhaseCompAcq/logs/" diff --git a/protocol/PhaseProtocolBM.cpp b/protocol/PhaseProtocolBM.cpp index aa4f086..6b5ca73 100644 --- a/protocol/PhaseProtocolBM.cpp +++ b/protocol/PhaseProtocolBM.cpp @@ -44,7 +44,7 @@ double phase = (channelRawData - CALCULATE_OFFSET) * CALCULATE_FACTOR; dataObj->channelActive.append("1"); dataObj->channelData.append(phase); - dataObj->channelDataStr.append(QString::number(phase, 'f', 12)); + dataObj->channelDataStr.append(QString::number(phase, 'f', 15)); } } @@ -60,6 +60,33 @@ return "$$STOP*"; } +QList PhaseProtocolBM::extractFrameList(QByteArray rawData) +{ + QList resultList; + if (rawData.size() < PHASE_FRAM_LENGTH) + { + // 长度小于帧长度则直接返回空 + return resultList; + } + + int tail = rawData.indexOf(PHASE_FRAME_TAIL); + if (tail < PHASE_FRAM_LENGTH - PHASE_FRAME_TAIL.size()) + { + // 没有检测到帧尾EEEEEEEE或者帧尾前的长度不够则直接返回空 + return resultList; + } + + while (rawData.size() > 0) + { + QByteArray ba; + ba.append(rawData.mid(tail - PHASE_FRAM_LENGTH + PHASE_FRAME_TAIL.size(), PHASE_FRAM_LENGTH)); + resultList.append(ba); + rawData = rawData.right(tail + PHASE_FRAME_TAIL.size()); + } + + return resultList; +} + bool PhaseProtocolBM::checkFrame(QByteArray rawData) { // 帧长度小于最小的长度 diff --git a/protocol/PhaseProtocolBM.h b/protocol/PhaseProtocolBM.h index 048a9c2..eaac7bb 100644 --- a/protocol/PhaseProtocolBM.h +++ b/protocol/PhaseProtocolBM.h @@ -31,6 +31,9 @@ // 检测帧格式,帧头帧尾 static bool checkFrame(QByteArray rawData); + + // 截取帧列表 + static QList extractFrameList(QByteArray rawData); }; #endif // PHASEROTOCOLBM_H