diff --git a/DeviceHub/FreqReplicatorForm.cpp b/DeviceHub/FreqReplicatorForm.cpp index bda0658..b9d739a 100644 --- a/DeviceHub/FreqReplicatorForm.cpp +++ b/DeviceHub/FreqReplicatorForm.cpp @@ -39,7 +39,7 @@ if (frameData->frameType == "1001") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - ui->frABCDStatus->setText(statusFrameDto->abOrCd); + ui->frABStatus->setText(statusFrameDto->abOrCd); ui->label_ts->setText(statusFrameDto->timestamp); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); @@ -53,7 +53,7 @@ } else if (frameData->frameType == "1002") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - + ui->frCDStatus->setText(statusFrameDto->abOrCd); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); QJsonDocument doc; diff --git a/DeviceHub/FreqReplicatorForm.cpp b/DeviceHub/FreqReplicatorForm.cpp index bda0658..b9d739a 100644 --- a/DeviceHub/FreqReplicatorForm.cpp +++ b/DeviceHub/FreqReplicatorForm.cpp @@ -39,7 +39,7 @@ if (frameData->frameType == "1001") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - ui->frABCDStatus->setText(statusFrameDto->abOrCd); + ui->frABStatus->setText(statusFrameDto->abOrCd); ui->label_ts->setText(statusFrameDto->timestamp); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); @@ -53,7 +53,7 @@ } else if (frameData->frameType == "1002") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - + ui->frCDStatus->setText(statusFrameDto->abOrCd); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); QJsonDocument doc; diff --git a/DeviceHub/FreqReplicatorForm.h b/DeviceHub/FreqReplicatorForm.h index fb6dffc..5e6abeb 100644 --- a/DeviceHub/FreqReplicatorForm.h +++ b/DeviceHub/FreqReplicatorForm.h @@ -18,7 +18,6 @@ public slots: void drawDeviceFrameOnForm(DeviceFrameBaseDto * frameData); -// void displayDeviceCommandOnForm(QJsonObject command); private slots: void on_freqRepButt_clicked(); diff --git a/DeviceHub/FreqReplicatorForm.cpp b/DeviceHub/FreqReplicatorForm.cpp index bda0658..b9d739a 100644 --- a/DeviceHub/FreqReplicatorForm.cpp +++ b/DeviceHub/FreqReplicatorForm.cpp @@ -39,7 +39,7 @@ if (frameData->frameType == "1001") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - ui->frABCDStatus->setText(statusFrameDto->abOrCd); + ui->frABStatus->setText(statusFrameDto->abOrCd); ui->label_ts->setText(statusFrameDto->timestamp); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); @@ -53,7 +53,7 @@ } else if (frameData->frameType == "1002") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - + ui->frCDStatus->setText(statusFrameDto->abOrCd); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); QJsonDocument doc; diff --git a/DeviceHub/FreqReplicatorForm.h b/DeviceHub/FreqReplicatorForm.h index fb6dffc..5e6abeb 100644 --- a/DeviceHub/FreqReplicatorForm.h +++ b/DeviceHub/FreqReplicatorForm.h @@ -18,7 +18,6 @@ public slots: void drawDeviceFrameOnForm(DeviceFrameBaseDto * frameData); -// void displayDeviceCommandOnForm(QJsonObject command); private slots: void on_freqRepButt_clicked(); diff --git a/DeviceHub/FreqReplicatorForm.ui b/DeviceHub/FreqReplicatorForm.ui index 2f6c15d..96c1343 100644 --- a/DeviceHub/FreqReplicatorForm.ui +++ b/DeviceHub/FreqReplicatorForm.ui @@ -74,7 +74,7 @@ - + 100 @@ -87,7 +87,7 @@ - 310 + 480 130 200 30 @@ -110,7 +110,7 @@ - ABCD输入 + AB输入 @@ -135,7 +135,7 @@ - 230 + 400 130 80 30 @@ -173,7 +173,7 @@ - 540 + 710 130 80 30 @@ -192,7 +192,7 @@ - 620 + 790 130 200 30 @@ -228,6 +228,35 @@ 输出监测CD + + + + 219 + 130 + 51 + 30 + + + + + 微软雅黑 + 10 + + + + CD输入 + + + + + + 270 + 130 + 100 + 30 + + + diff --git a/DeviceHub/FreqReplicatorForm.cpp b/DeviceHub/FreqReplicatorForm.cpp index bda0658..b9d739a 100644 --- a/DeviceHub/FreqReplicatorForm.cpp +++ b/DeviceHub/FreqReplicatorForm.cpp @@ -39,7 +39,7 @@ if (frameData->frameType == "1001") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - ui->frABCDStatus->setText(statusFrameDto->abOrCd); + ui->frABStatus->setText(statusFrameDto->abOrCd); ui->label_ts->setText(statusFrameDto->timestamp); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); @@ -53,7 +53,7 @@ } else if (frameData->frameType == "1002") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - + ui->frCDStatus->setText(statusFrameDto->abOrCd); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); QJsonDocument doc; diff --git a/DeviceHub/FreqReplicatorForm.h b/DeviceHub/FreqReplicatorForm.h index fb6dffc..5e6abeb 100644 --- a/DeviceHub/FreqReplicatorForm.h +++ b/DeviceHub/FreqReplicatorForm.h @@ -18,7 +18,6 @@ public slots: void drawDeviceFrameOnForm(DeviceFrameBaseDto * frameData); -// void displayDeviceCommandOnForm(QJsonObject command); private slots: void on_freqRepButt_clicked(); diff --git a/DeviceHub/FreqReplicatorForm.ui b/DeviceHub/FreqReplicatorForm.ui index 2f6c15d..96c1343 100644 --- a/DeviceHub/FreqReplicatorForm.ui +++ b/DeviceHub/FreqReplicatorForm.ui @@ -74,7 +74,7 @@ - + 100 @@ -87,7 +87,7 @@ - 310 + 480 130 200 30 @@ -110,7 +110,7 @@ - ABCD输入 + AB输入 @@ -135,7 +135,7 @@ - 230 + 400 130 80 30 @@ -173,7 +173,7 @@ - 540 + 710 130 80 30 @@ -192,7 +192,7 @@ - 620 + 790 130 200 30 @@ -228,6 +228,35 @@ 输出监测CD + + + + 219 + 130 + 51 + 30 + + + + + 微软雅黑 + 10 + + + + CD输入 + + + + + + 270 + 130 + 100 + 30 + + + diff --git a/DeviceHub/device/FreqReplicator.cpp b/DeviceHub/device/FreqReplicator.cpp index 363f640..72f8340 100644 --- a/DeviceHub/device/FreqReplicator.cpp +++ b/DeviceHub/device/FreqReplicator.cpp @@ -34,6 +34,7 @@ // 频率信号放大器 buffer.append(QByteUtil::hexStringToBytes("AA550015010001000101010101010101010101010101010101EB")); buffer.append(QByteUtil::hexStringToBytes("AA550015020001000101010101010101010101010101010101E8")); +// buffer.append(QByteUtil::hexStringToBytes("AA55000B0100010101010101010101F4AA55000B0200010101010101010101F7")); this->dataReceivedHandler(buffer); } @@ -95,7 +96,7 @@ } void FreqReplicator::afterFrameParse(DeviceFrameBaseDto * frameDto) { - std::cout << QByteUtil::binToHexString(frameDto->rawFrame).toStdString() << std::endl; +// std::cout << QByteUtil::binToHexString(frameDto->rawFrame).toStdString() << std::endl; // 0. 输出到日志文件中 QString date = frameDto->timestamp.mid(0, 10); diff --git a/DeviceHub/FreqReplicatorForm.cpp b/DeviceHub/FreqReplicatorForm.cpp index bda0658..b9d739a 100644 --- a/DeviceHub/FreqReplicatorForm.cpp +++ b/DeviceHub/FreqReplicatorForm.cpp @@ -39,7 +39,7 @@ if (frameData->frameType == "1001") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - ui->frABCDStatus->setText(statusFrameDto->abOrCd); + ui->frABStatus->setText(statusFrameDto->abOrCd); ui->label_ts->setText(statusFrameDto->timestamp); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); @@ -53,7 +53,7 @@ } else if (frameData->frameType == "1002") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - + ui->frCDStatus->setText(statusFrameDto->abOrCd); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); QJsonDocument doc; diff --git a/DeviceHub/FreqReplicatorForm.h b/DeviceHub/FreqReplicatorForm.h index fb6dffc..5e6abeb 100644 --- a/DeviceHub/FreqReplicatorForm.h +++ b/DeviceHub/FreqReplicatorForm.h @@ -18,7 +18,6 @@ public slots: void drawDeviceFrameOnForm(DeviceFrameBaseDto * frameData); -// void displayDeviceCommandOnForm(QJsonObject command); private slots: void on_freqRepButt_clicked(); diff --git a/DeviceHub/FreqReplicatorForm.ui b/DeviceHub/FreqReplicatorForm.ui index 2f6c15d..96c1343 100644 --- a/DeviceHub/FreqReplicatorForm.ui +++ b/DeviceHub/FreqReplicatorForm.ui @@ -74,7 +74,7 @@ - + 100 @@ -87,7 +87,7 @@ - 310 + 480 130 200 30 @@ -110,7 +110,7 @@ - ABCD输入 + AB输入 @@ -135,7 +135,7 @@ - 230 + 400 130 80 30 @@ -173,7 +173,7 @@ - 540 + 710 130 80 30 @@ -192,7 +192,7 @@ - 620 + 790 130 200 30 @@ -228,6 +228,35 @@ 输出监测CD + + + + 219 + 130 + 51 + 30 + + + + + 微软雅黑 + 10 + + + + CD输入 + + + + + + 270 + 130 + 100 + 30 + + + diff --git a/DeviceHub/device/FreqReplicator.cpp b/DeviceHub/device/FreqReplicator.cpp index 363f640..72f8340 100644 --- a/DeviceHub/device/FreqReplicator.cpp +++ b/DeviceHub/device/FreqReplicator.cpp @@ -34,6 +34,7 @@ // 频率信号放大器 buffer.append(QByteUtil::hexStringToBytes("AA550015010001000101010101010101010101010101010101EB")); buffer.append(QByteUtil::hexStringToBytes("AA550015020001000101010101010101010101010101010101E8")); +// buffer.append(QByteUtil::hexStringToBytes("AA55000B0100010101010101010101F4AA55000B0200010101010101010101F7")); this->dataReceivedHandler(buffer); } @@ -95,7 +96,7 @@ } void FreqReplicator::afterFrameParse(DeviceFrameBaseDto * frameDto) { - std::cout << QByteUtil::binToHexString(frameDto->rawFrame).toStdString() << std::endl; +// std::cout << QByteUtil::binToHexString(frameDto->rawFrame).toStdString() << std::endl; // 0. 输出到日志文件中 QString date = frameDto->timestamp.mid(0, 10); diff --git a/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp b/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp index b99d5ed..44227be 100644 --- a/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp +++ b/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp @@ -89,22 +89,49 @@ QList FreqReplicatorProtocolTX::extractFrameList(QByteArray rawData) { QList resultList; - while (QByteUtil::binToHexString(rawData.mid(0, 3)) == "AA5500") + if (rawData.indexOf(0x15) >= 0) { - QByteArray ba; - - qint8 length = rawData.mid(3, 1).toHex().toInt(0, 16); - if (rawData.length() >= length + 5) + while (QByteUtil::binToHexString(rawData.mid(0, 3)) == "AA5500") { - ba.append(rawData.mid(0, length + 5)); + QByteArray ba; - resultList.append(ba); - ba.clear(); + qint8 length = rawData.mid(3, 1).toHex().toInt(0, 16); + if (rawData.length() >= length + 5) // 0x15 + { + ba.append(rawData.mid(0, length + 5)); - rawData = rawData.mid(length + 5, rawData.length() - length - 5); - } else + resultList.append(ba); + ba.clear(); + + rawData = rawData.mid(length + 5, rawData.length() - length - 5); + } else + { + break; + } + } + } else if (rawData.indexOf(0x0B) >= 0) + { + while (QByteUtil::binToHexString(rawData.mid(0, 5)) == "AA55000B01") { - break; + QByteArray ba; + + if (rawData.length() >= 32) // 0x0B + { + ba.append(QByteUtil::hexStringToBytes("AA55001501")); + ba.append(rawData.mid(5, 2)); + ba.append(rawData.mid(21, 2)); + ba.append(rawData.mid(7, 8)); + ba.append(rawData.mid(23, 8)); + ba.append(QByteUtil::hexStringToBytes("FF")); + + resultList.append(ba); + ba.clear(); + + rawData = rawData.right(rawData.length() - 32); + } else + { + break; + } } } diff --git a/DeviceHub/FreqReplicatorForm.cpp b/DeviceHub/FreqReplicatorForm.cpp index bda0658..b9d739a 100644 --- a/DeviceHub/FreqReplicatorForm.cpp +++ b/DeviceHub/FreqReplicatorForm.cpp @@ -39,7 +39,7 @@ if (frameData->frameType == "1001") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - ui->frABCDStatus->setText(statusFrameDto->abOrCd); + ui->frABStatus->setText(statusFrameDto->abOrCd); ui->label_ts->setText(statusFrameDto->timestamp); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); @@ -53,7 +53,7 @@ } else if (frameData->frameType == "1002") { FreqReplicatorStatusDto * statusFrameDto = (FreqReplicatorStatusDto *) frameData; - + ui->frCDStatus->setText(statusFrameDto->abOrCd); QJsonObject dataObj = statusFrameDto->toJSON().find("data")->toObject(); QJsonDocument doc; diff --git a/DeviceHub/FreqReplicatorForm.h b/DeviceHub/FreqReplicatorForm.h index fb6dffc..5e6abeb 100644 --- a/DeviceHub/FreqReplicatorForm.h +++ b/DeviceHub/FreqReplicatorForm.h @@ -18,7 +18,6 @@ public slots: void drawDeviceFrameOnForm(DeviceFrameBaseDto * frameData); -// void displayDeviceCommandOnForm(QJsonObject command); private slots: void on_freqRepButt_clicked(); diff --git a/DeviceHub/FreqReplicatorForm.ui b/DeviceHub/FreqReplicatorForm.ui index 2f6c15d..96c1343 100644 --- a/DeviceHub/FreqReplicatorForm.ui +++ b/DeviceHub/FreqReplicatorForm.ui @@ -74,7 +74,7 @@ - + 100 @@ -87,7 +87,7 @@ - 310 + 480 130 200 30 @@ -110,7 +110,7 @@ - ABCD输入 + AB输入 @@ -135,7 +135,7 @@ - 230 + 400 130 80 30 @@ -173,7 +173,7 @@ - 540 + 710 130 80 30 @@ -192,7 +192,7 @@ - 620 + 790 130 200 30 @@ -228,6 +228,35 @@ 输出监测CD + + + + 219 + 130 + 51 + 30 + + + + + 微软雅黑 + 10 + + + + CD输入 + + + + + + 270 + 130 + 100 + 30 + + + diff --git a/DeviceHub/device/FreqReplicator.cpp b/DeviceHub/device/FreqReplicator.cpp index 363f640..72f8340 100644 --- a/DeviceHub/device/FreqReplicator.cpp +++ b/DeviceHub/device/FreqReplicator.cpp @@ -34,6 +34,7 @@ // 频率信号放大器 buffer.append(QByteUtil::hexStringToBytes("AA550015010001000101010101010101010101010101010101EB")); buffer.append(QByteUtil::hexStringToBytes("AA550015020001000101010101010101010101010101010101E8")); +// buffer.append(QByteUtil::hexStringToBytes("AA55000B0100010101010101010101F4AA55000B0200010101010101010101F7")); this->dataReceivedHandler(buffer); } @@ -95,7 +96,7 @@ } void FreqReplicator::afterFrameParse(DeviceFrameBaseDto * frameDto) { - std::cout << QByteUtil::binToHexString(frameDto->rawFrame).toStdString() << std::endl; +// std::cout << QByteUtil::binToHexString(frameDto->rawFrame).toStdString() << std::endl; // 0. 输出到日志文件中 QString date = frameDto->timestamp.mid(0, 10); diff --git a/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp b/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp index b99d5ed..44227be 100644 --- a/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp +++ b/DeviceHub/protocol/FreqReplicatorProtocolTX.cpp @@ -89,22 +89,49 @@ QList FreqReplicatorProtocolTX::extractFrameList(QByteArray rawData) { QList resultList; - while (QByteUtil::binToHexString(rawData.mid(0, 3)) == "AA5500") + if (rawData.indexOf(0x15) >= 0) { - QByteArray ba; - - qint8 length = rawData.mid(3, 1).toHex().toInt(0, 16); - if (rawData.length() >= length + 5) + while (QByteUtil::binToHexString(rawData.mid(0, 3)) == "AA5500") { - ba.append(rawData.mid(0, length + 5)); + QByteArray ba; - resultList.append(ba); - ba.clear(); + qint8 length = rawData.mid(3, 1).toHex().toInt(0, 16); + if (rawData.length() >= length + 5) // 0x15 + { + ba.append(rawData.mid(0, length + 5)); - rawData = rawData.mid(length + 5, rawData.length() - length - 5); - } else + resultList.append(ba); + ba.clear(); + + rawData = rawData.mid(length + 5, rawData.length() - length - 5); + } else + { + break; + } + } + } else if (rawData.indexOf(0x0B) >= 0) + { + while (QByteUtil::binToHexString(rawData.mid(0, 5)) == "AA55000B01") { - break; + QByteArray ba; + + if (rawData.length() >= 32) // 0x0B + { + ba.append(QByteUtil::hexStringToBytes("AA55001501")); + ba.append(rawData.mid(5, 2)); + ba.append(rawData.mid(21, 2)); + ba.append(rawData.mid(7, 8)); + ba.append(rawData.mid(23, 8)); + ba.append(QByteUtil::hexStringToBytes("FF")); + + resultList.append(ba); + ba.clear(); + + rawData = rawData.right(rawData.length() - 32); + } else + { + break; + } } } diff --git a/DeviceHub/protocol/SignalGeneratorProtocolBM.cpp b/DeviceHub/protocol/SignalGeneratorProtocolBM.cpp index 2356821..fc87aa4 100644 --- a/DeviceHub/protocol/SignalGeneratorProtocolBM.cpp +++ b/DeviceHub/protocol/SignalGeneratorProtocolBM.cpp @@ -101,22 +101,22 @@ QList SignalGeneratorProtocolBM::extractFrameList(QByteArray rawData) { QList resultList; - int start = rawData.indexOf("$GL"); - if (start < 0) - { - return resultList; - } - rawData = rawData.right(rawData.size() - start); - - int end = rawData.lastIndexOf("\r\n"); - if (end < 0) - { - return resultList; - } - rawData = rawData.left(end); - -// if (rawData.endsWith(QByteArray("\r\n")) == true && rawData.startsWith("$") == true) +// int start = rawData.indexOf("$GL"); +// if (start < 0) // { +// return resultList; +// } +// rawData = rawData.right(rawData.size() - start); + +// int end = rawData.lastIndexOf("\r\n"); +// if (end < 0) +// { +// return resultList; +// } +// rawData = rawData.left(end); + + if (rawData.endsWith(QByteArray("\r\n")) == true && rawData.startsWith("$") == true) + { QByteArray ba; for (int i = 0; i < rawData.size() - 1; i++) { @@ -137,7 +137,7 @@ } } } -// } + } return resultList; }