diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp index 0a86047..2c35e96 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp @@ -43,6 +43,21 @@ return nullptr; } +QByteArray DeviceStatusProtocolBase::generateSettingCommand(QString commandType, QString valueSet) +{ + QByteArray commandBytes; + commandBytes.append(commandType).append(","); + commandBytes.append(valueSet); + + QString xorValue = this->calculateXOR(commandBytes); + + commandBytes.prepend("$"); + commandBytes.append("*"); + commandBytes.append(xorValue); + + return commandBytes; +} + QString DeviceStatusProtocolBase::calculateXOR(QByteArray byteArray) { quint8 xorValue = 0; diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp index 0a86047..2c35e96 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp @@ -43,6 +43,21 @@ return nullptr; } +QByteArray DeviceStatusProtocolBase::generateSettingCommand(QString commandType, QString valueSet) +{ + QByteArray commandBytes; + commandBytes.append(commandType).append(","); + commandBytes.append(valueSet); + + QString xorValue = this->calculateXOR(commandBytes); + + commandBytes.prepend("$"); + commandBytes.append("*"); + commandBytes.append(xorValue); + + return commandBytes; +} + QString DeviceStatusProtocolBase::calculateXOR(QByteArray byteArray) { quint8 xorValue = 0; diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h index 667c30c..ae3d4cb 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h @@ -115,6 +115,7 @@ virtual int checkFrame(QByteArray rawData) = 0; virtual QList extractFrameList(QByteArray rawData) = 0; virtual bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) = 0; + virtual QByteArray generateSettingCommand(QString commandType, QString valueSet); signals: diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp index 0a86047..2c35e96 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp @@ -43,6 +43,21 @@ return nullptr; } +QByteArray DeviceStatusProtocolBase::generateSettingCommand(QString commandType, QString valueSet) +{ + QByteArray commandBytes; + commandBytes.append(commandType).append(","); + commandBytes.append(valueSet); + + QString xorValue = this->calculateXOR(commandBytes); + + commandBytes.prepend("$"); + commandBytes.append("*"); + commandBytes.append(xorValue); + + return commandBytes; +} + QString DeviceStatusProtocolBase::calculateXOR(QByteArray byteArray) { quint8 xorValue = 0; diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h index 667c30c..ae3d4cb 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h @@ -115,6 +115,7 @@ virtual int checkFrame(QByteArray rawData) = 0; virtual QList extractFrameList(QByteArray rawData) = 0; virtual bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) = 0; + virtual QByteArray generateSettingCommand(QString commandType, QString valueSet); signals: diff --git a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp index 3277e17..36fbbd7 100644 --- a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp +++ b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp @@ -28,8 +28,8 @@ QByteArray outputACByte = content.mid(5, 8); QByteArray outputBDByte = content.mid(13, 8); - QString inputAC = QString("%1,%2"); - QString inputBD = QString("%1,%2"); + QString inputAC = ""; + QString inputBD = ""; QString outputAC = ""; QString outputBD = ""; @@ -37,8 +37,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "AB"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputAC); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputBD); @@ -59,8 +59,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "CD"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp index 0a86047..2c35e96 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp @@ -43,6 +43,21 @@ return nullptr; } +QByteArray DeviceStatusProtocolBase::generateSettingCommand(QString commandType, QString valueSet) +{ + QByteArray commandBytes; + commandBytes.append(commandType).append(","); + commandBytes.append(valueSet); + + QString xorValue = this->calculateXOR(commandBytes); + + commandBytes.prepend("$"); + commandBytes.append("*"); + commandBytes.append(xorValue); + + return commandBytes; +} + QString DeviceStatusProtocolBase::calculateXOR(QByteArray byteArray) { quint8 xorValue = 0; diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h index 667c30c..ae3d4cb 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h @@ -115,6 +115,7 @@ virtual int checkFrame(QByteArray rawData) = 0; virtual QList extractFrameList(QByteArray rawData) = 0; virtual bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) = 0; + virtual QByteArray generateSettingCommand(QString commandType, QString valueSet); signals: diff --git a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp index 3277e17..36fbbd7 100644 --- a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp +++ b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp @@ -28,8 +28,8 @@ QByteArray outputACByte = content.mid(5, 8); QByteArray outputBDByte = content.mid(13, 8); - QString inputAC = QString("%1,%2"); - QString inputBD = QString("%1,%2"); + QString inputAC = ""; + QString inputBD = ""; QString outputAC = ""; QString outputBD = ""; @@ -37,8 +37,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "AB"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputAC); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputBD); @@ -59,8 +59,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "CD"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); diff --git a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp index 9d8f261..51b6542 100644 --- a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp +++ b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp @@ -30,86 +30,6 @@ return frameData; } -// 生成频率微调设置指令 -QByteArray FrequencyTuningProtocolBM::generateFreqTunSetCommand(qlonglong freqTunSet) -{ - QByteArray command; - command.append("GLF,20,"); - command.append(QString("%1").arg(freqTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成相位微调设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseTunSetCommand(qlonglong phaseTunSet) -{ - QByteArray command; - command.append("GLF,21,"); - command.append(QString("%1").arg(phaseTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成移相设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseShiftSetCommand(qlonglong phaseShiftSet) -{ - QByteArray command; - command.append("GLP,01,"); - command.append(QString("%1").arg(phaseShiftSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成单次同步设置指令 -QByteArray FrequencyTuningProtocolBM::generateSingleSynchSetCommand(qint8 singleSynchSet) -{ - QByteArray command; - command.append("GLP,02,"); - command.append(QString("%1").arg(singleSynchSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成秒脉宽设置指令 -QByteArray FrequencyTuningProtocolBM::generateSecondWidthSetCommand(qlonglong secondWidthSet) -{ - QByteArray command; - command.append("GLP,03,"); - command.append(QString("%1").arg(secondWidthSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - bool FrequencyTuningProtocolBM::parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) { // get the raw data between ',' and '*' diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp index 0a86047..2c35e96 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp @@ -43,6 +43,21 @@ return nullptr; } +QByteArray DeviceStatusProtocolBase::generateSettingCommand(QString commandType, QString valueSet) +{ + QByteArray commandBytes; + commandBytes.append(commandType).append(","); + commandBytes.append(valueSet); + + QString xorValue = this->calculateXOR(commandBytes); + + commandBytes.prepend("$"); + commandBytes.append("*"); + commandBytes.append(xorValue); + + return commandBytes; +} + QString DeviceStatusProtocolBase::calculateXOR(QByteArray byteArray) { quint8 xorValue = 0; diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h index 667c30c..ae3d4cb 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h @@ -115,6 +115,7 @@ virtual int checkFrame(QByteArray rawData) = 0; virtual QList extractFrameList(QByteArray rawData) = 0; virtual bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) = 0; + virtual QByteArray generateSettingCommand(QString commandType, QString valueSet); signals: diff --git a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp index 3277e17..36fbbd7 100644 --- a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp +++ b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp @@ -28,8 +28,8 @@ QByteArray outputACByte = content.mid(5, 8); QByteArray outputBDByte = content.mid(13, 8); - QString inputAC = QString("%1,%2"); - QString inputBD = QString("%1,%2"); + QString inputAC = ""; + QString inputBD = ""; QString outputAC = ""; QString outputBD = ""; @@ -37,8 +37,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "AB"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputAC); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputBD); @@ -59,8 +59,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "CD"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); diff --git a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp index 9d8f261..51b6542 100644 --- a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp +++ b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp @@ -30,86 +30,6 @@ return frameData; } -// 生成频率微调设置指令 -QByteArray FrequencyTuningProtocolBM::generateFreqTunSetCommand(qlonglong freqTunSet) -{ - QByteArray command; - command.append("GLF,20,"); - command.append(QString("%1").arg(freqTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成相位微调设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseTunSetCommand(qlonglong phaseTunSet) -{ - QByteArray command; - command.append("GLF,21,"); - command.append(QString("%1").arg(phaseTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成移相设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseShiftSetCommand(qlonglong phaseShiftSet) -{ - QByteArray command; - command.append("GLP,01,"); - command.append(QString("%1").arg(phaseShiftSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成单次同步设置指令 -QByteArray FrequencyTuningProtocolBM::generateSingleSynchSetCommand(qint8 singleSynchSet) -{ - QByteArray command; - command.append("GLP,02,"); - command.append(QString("%1").arg(singleSynchSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成秒脉宽设置指令 -QByteArray FrequencyTuningProtocolBM::generateSecondWidthSetCommand(qlonglong secondWidthSet) -{ - QByteArray command; - command.append("GLP,03,"); - command.append(QString("%1").arg(secondWidthSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - bool FrequencyTuningProtocolBM::parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) { // get the raw data between ',' and '*' diff --git a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h index 9fd65aa..1937f92 100644 --- a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h +++ b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h @@ -19,21 +19,6 @@ bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType); DeviceFrameBaseDto * frameFactory(int frameType); - // 生成频率微调设置指令 - QByteArray generateFreqTunSetCommand(qlonglong freqTunSet); - - // 生成相位微调设置指令 - QByteArray generatePhaseTunSetCommand(qlonglong phaseTunSet); - - // 生成移相设置指令 - QByteArray generatePhaseShiftSetCommand(qlonglong phaseShiftSet); - - // 生成单次同步设置指令 - QByteArray generateSingleSynchSetCommand(qint8 singleSynchSet); - - // 生成秒脉宽设置指令 - QByteArray generateSecondWidthSetCommand(qlonglong secondWidthSet); - // QList extractFrameList(QByteArray rawData); diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp index 0a86047..2c35e96 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp @@ -43,6 +43,21 @@ return nullptr; } +QByteArray DeviceStatusProtocolBase::generateSettingCommand(QString commandType, QString valueSet) +{ + QByteArray commandBytes; + commandBytes.append(commandType).append(","); + commandBytes.append(valueSet); + + QString xorValue = this->calculateXOR(commandBytes); + + commandBytes.prepend("$"); + commandBytes.append("*"); + commandBytes.append(xorValue); + + return commandBytes; +} + QString DeviceStatusProtocolBase::calculateXOR(QByteArray byteArray) { quint8 xorValue = 0; diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h index 667c30c..ae3d4cb 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h @@ -115,6 +115,7 @@ virtual int checkFrame(QByteArray rawData) = 0; virtual QList extractFrameList(QByteArray rawData) = 0; virtual bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) = 0; + virtual QByteArray generateSettingCommand(QString commandType, QString valueSet); signals: diff --git a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp index 3277e17..36fbbd7 100644 --- a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp +++ b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp @@ -28,8 +28,8 @@ QByteArray outputACByte = content.mid(5, 8); QByteArray outputBDByte = content.mid(13, 8); - QString inputAC = QString("%1,%2"); - QString inputBD = QString("%1,%2"); + QString inputAC = ""; + QString inputBD = ""; QString outputAC = ""; QString outputBD = ""; @@ -37,8 +37,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "AB"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputAC); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputBD); @@ -59,8 +59,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "CD"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); diff --git a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp index 9d8f261..51b6542 100644 --- a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp +++ b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp @@ -30,86 +30,6 @@ return frameData; } -// 生成频率微调设置指令 -QByteArray FrequencyTuningProtocolBM::generateFreqTunSetCommand(qlonglong freqTunSet) -{ - QByteArray command; - command.append("GLF,20,"); - command.append(QString("%1").arg(freqTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成相位微调设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseTunSetCommand(qlonglong phaseTunSet) -{ - QByteArray command; - command.append("GLF,21,"); - command.append(QString("%1").arg(phaseTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成移相设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseShiftSetCommand(qlonglong phaseShiftSet) -{ - QByteArray command; - command.append("GLP,01,"); - command.append(QString("%1").arg(phaseShiftSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成单次同步设置指令 -QByteArray FrequencyTuningProtocolBM::generateSingleSynchSetCommand(qint8 singleSynchSet) -{ - QByteArray command; - command.append("GLP,02,"); - command.append(QString("%1").arg(singleSynchSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成秒脉宽设置指令 -QByteArray FrequencyTuningProtocolBM::generateSecondWidthSetCommand(qlonglong secondWidthSet) -{ - QByteArray command; - command.append("GLP,03,"); - command.append(QString("%1").arg(secondWidthSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - bool FrequencyTuningProtocolBM::parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) { // get the raw data between ',' and '*' diff --git a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h index 9fd65aa..1937f92 100644 --- a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h +++ b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h @@ -19,21 +19,6 @@ bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType); DeviceFrameBaseDto * frameFactory(int frameType); - // 生成频率微调设置指令 - QByteArray generateFreqTunSetCommand(qlonglong freqTunSet); - - // 生成相位微调设置指令 - QByteArray generatePhaseTunSetCommand(qlonglong phaseTunSet); - - // 生成移相设置指令 - QByteArray generatePhaseShiftSetCommand(qlonglong phaseShiftSet); - - // 生成单次同步设置指令 - QByteArray generateSingleSynchSetCommand(qint8 singleSynchSet); - - // 生成秒脉宽设置指令 - QByteArray generateSecondWidthSetCommand(qlonglong secondWidthSet); - // QList extractFrameList(QByteArray rawData); diff --git a/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp b/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp index db30632..6fc9ed8 100644 --- a/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp +++ b/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp @@ -98,70 +98,6 @@ return true; } -// 生成闰秒设置指令 -QByteArray SignalGeneratorProtocolBM::generateLeapSecondSetCommand(qint8 leapSecondSet) -{ - QByteArray command; - command.append("GLF,01,"); - command.append(QString("%1").arg(leapSecondSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成单次同步设置指令 -QByteArray SignalGeneratorProtocolBM::generateSingleSynchSetCommand(qint8 singleSynchSet) -{ - QByteArray command; - command.append("GLF,02,"); - command.append(QString("%1").arg(singleSynchSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成年月日设置指令 -QByteArray SignalGeneratorProtocolBM::generateDateSetCommand(QString dateSet) -{ - QByteArray command; - command.append("GLF,03,"); - command.append(dateSet); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成秒脉宽设置指令 -QByteArray SignalGeneratorProtocolBM::generateSecondWidthSetCommand(qlonglong secondWidthSet) -{ - QByteArray command; - command.append("GLF,04,"); - command.append(QString("%1").arg(secondWidthSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - QList SignalGeneratorProtocolBM::extractFrameList(QByteArray rawData) { QList resultList; diff --git a/DevStatusAcq/DevStatusAcq.pro b/DevStatusAcq/DevStatusAcq.pro index ee80867..f74d7b0 100644 --- a/DevStatusAcq/DevStatusAcq.pro +++ b/DevStatusAcq/DevStatusAcq.pro @@ -34,9 +34,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -#INCLUDEPATH += $$PWD/include/librdkafka -#DEPENDPATH += $$PWD/include/librdkafka +INCLUDEPATH += $$PWD/include/librdkafka +DEPENDPATH += $$PWD/include/librdkafka -#unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ +unix:!macx: LIBS += -L$$PWD/lib/librdkafka/ -lrdkafka -lrdkafka++ DISTFILES += conf/config.ini diff --git a/DevStatusAcq/DevStatusWindow.cpp b/DevStatusAcq/DevStatusWindow.cpp index 43b1c8b..5e11c14 100644 --- a/DevStatusAcq/DevStatusWindow.cpp +++ b/DevStatusAcq/DevStatusWindow.cpp @@ -135,8 +135,13 @@ void DevStatusWindow::on_sigGenButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + sigGenDevice->setComName("SignalGenerator"); - sigGenDevice->setDevCode("300001"); + sigGenDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + sigGenDevice->setDevCode(devItem.find("deviceNo")->toString()); + sigGenDevice->setDeviceId(devItem.find("deviceId")->toString()); sigGenDevice->initSerialPort(); } @@ -147,49 +152,74 @@ QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); freqTunDevice->setComName("FrequencyTuning"); - freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqTunDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); freqTunDevice->setDevCode(devItem.find("deviceNo")->toString()); - freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); + freqTunDevice->setDeviceId(devItem.find("deviceId")->toString()); freqTunDevice->initSerialPort(); } void DevStatusWindow::on_tmSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeSwitDevice->setComName("TimeSwitcher"); - timeSwitDevice->setDevCode("500001"); + timeSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); timeSwitDevice->initSerialPort(); } void DevStatusWindow::on_freqSwiButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqSwitDevice->setComName("FreqSwitcher"); - freqSwitDevice->setDevCode("600001"); + freqSwitDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqSwitDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqSwitDevice->setDeviceId(devItem.find("deviceId")->toString()); freqSwitDevice->initSerialPort(); } void DevStatusWindow::on_tmRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + timeRepDevice->setComName("TimeReplicator"); - timeRepDevice->setDevCode("090001"); + timeRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + timeRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + timeRepDevice->setDeviceId(devItem.find("deviceId")->toString()); timeRepDevice->initSerialPort(); } void DevStatusWindow::on_freqRepButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + freqRepDevice->setComName("FreqReplicator"); - freqRepDevice->setDevCode("100001"); + freqRepDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + freqRepDevice->setDevCode(devItem.find("deviceNo")->toString()); + freqRepDevice->setDeviceId(devItem.find("deviceId")->toString()); freqRepDevice->initSerialPort(); } void DevStatusWindow::on_bctButt_clicked() { + // 获取设备对象 + QJsonObject devItem = ui->devSelect->currentData().toJsonObject(); + bCodeTermDevice->setComName("BCodeTerminal"); - bCodeTermDevice->setDevCode("07001"); + bCodeTermDevice->setBaudRate(devItem.find("baudRate")->toString().toInt()); + bCodeTermDevice->setDevCode(devItem.find("deviceNo")->toString()); + bCodeTermDevice->setDeviceId(devItem.find("deviceId")->toString()); bCodeTermDevice->initSerialPort(); } @@ -220,7 +250,7 @@ QMessageBox::information(this, "数据错误", "调整范围-2E-7 ~ 2E-7,(单位:1E-19)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateFreqTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,20", ui->ftSetFreqTurn->text()); ui->ftSetFreqTurnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -235,7 +265,7 @@ QMessageBox::information(this, "数据错误", "调整范围-1us~+1us,(单位:0.1fs)"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseTunSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLF,21", ui->ftSetPhaseTunn->text()); ui->ftSetPhaseTunnRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -250,7 +280,7 @@ QMessageBox::information(this, "数据错误", "取值范围-500ms - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generatePhaseShiftSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,01", ui->ftSetPhaseShift->text()); ui->ftSetPhaseShiftRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -265,7 +295,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,02", ui->ftSetSynch->text()); ui->ftSetSynchRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -280,7 +310,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((FrequencyTuningProtocolBM) freqTunDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = freqTunDevice->protocol->generateSettingCommand("GLP,03", ui->ftSetPulseWidth->text()); ui->ftSetPulseWidthRaw->setText(setBytes); freqTunDevice->sendDataToSerial(setBytes); } @@ -290,12 +320,12 @@ { sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); qint8 value = ui->sgLeapSecondSet->text().toInt(); - if (value != 1 || value != 2 || value != 3) + if (value != 1 && value != 2 && value != 3) { QMessageBox::information(this, "数据错误", "取值范围0 / 1 / 2"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateLeapSecondSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,01", ui->sgLeapSecondSet->text()); ui->sgLeapSecondSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -310,7 +340,7 @@ QMessageBox::information(this, "数据错误", "1:有效;其他无效"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSingleSynchSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,02", ui->sgSingleSynchSet->text()); ui->sgSingleSynchSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -325,7 +355,7 @@ QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateDateSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,03", ui->sgDateSet->text()); ui->sgDateSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -340,7 +370,7 @@ QMessageBox::information(this, "数据错误", "取值范围10us - 500ms"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,04", ui->sgSecondWidthSet->text()); ui->sgSecondWidthSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } @@ -355,8 +385,113 @@ QMessageBox::information(this, "数据错误", "取值范围2 - 6"); } else { - QByteArray setBytes = ((SignalGeneratorProtocolBM) sigGenDevice->protocol).generateSecondWidthSetCommand(value); + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,05", ui->sgBacRatioSet->text()); ui->sgBacRatioSetRaw->setText(setBytes); sigGenDevice->sendDataToSerial(setBytes); } } + +void DevStatusWindow::on_sgBacRangeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + float value = ui->sgBacRangeSet->text().toFloat(); + if (value < 5 || value > 100) + { + QMessageBox::information(this, "数据错误", "取值范围5 - 100"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,06", ui->sgBacRangeSet->text()); + ui->sgBacRangeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgOppsPhaseShiftSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + qlonglong value = ui->sgOppsPhaseShiftSet->text().toLongLong(); + if (value < -1E12 || value > 1E12) + { + QMessageBox::information(this, "数据错误", "取值范围-1s - 1s"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,07", ui->sgOppsPhaseShiftSet->text()); + ui->sgOppsPhaseShiftSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgLeapTimestampSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgLeapTimestampSet->text(); + if (value.length() != 8) + { + QMessageBox::information(this, "数据错误", "年月日格式:YYYYMMDD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,08", ui->sgLeapTimestampSet->text()); + ui->sgLeapTimestampSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgMJDDateSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgMJDDateSet->text(); + if (value.length() != 5) + { + QMessageBox::information(this, "数据错误", "MJD"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,09", ui->sgMJDDateSet->text()); + ui->sgMJDDateSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeSet->text(); + if (value.length() != 6) + { + QMessageBox::information(this, "数据错误", "hhmmss"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLF,10", ui->sgTimeSet->text()); + ui->sgTimeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgKeyControlSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgKeyControlSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,01", ui->sgKeyControlSet->text()); + ui->sgKeyControlSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} + +void DevStatusWindow::on_sgTimeTypeSetButt_clicked() +{ + sigGenDevice->setDevCode(ui->devSelect->currentData().toJsonObject().find("deviceNo")->toString()); + QString value = ui->sgTimeTypeSet->text(); + if (value != "0" && value != "1") + { + QMessageBox::information(this, "数据错误", "0 / 1"); + } else + { + QByteArray setBytes = sigGenDevice->protocol->generateSettingCommand("GLC,02", ui->sgTimeTypeSet->text()); + ui->sgTimeTypeSetRaw->setText(setBytes); + sigGenDevice->sendDataToSerial(setBytes); + } +} diff --git a/DevStatusAcq/DevStatusWindow.h b/DevStatusAcq/DevStatusWindow.h index f3e7068..d27b5c6 100644 --- a/DevStatusAcq/DevStatusWindow.h +++ b/DevStatusAcq/DevStatusWindow.h @@ -64,6 +64,20 @@ void on_sgBacRatioSetButt_clicked(); + void on_sgBacRangeSetButt_clicked(); + + void on_sgOppsPhaseShiftSetButt_clicked(); + + void on_sgLeapTimestampSetButt_clicked(); + + void on_sgMJDDateSetButt_clicked(); + + void on_sgTimeSetButt_clicked(); + + void on_sgKeyControlSetButt_clicked(); + + void on_sgTimeTypeSetButt_clicked(); + private: int initHttpToken(); int initDictDeviceTypes(); diff --git a/DevStatusAcq/DevStatusWindow.ui b/DevStatusAcq/DevStatusWindow.ui index 07a560c..e40b997 100644 --- a/DevStatusAcq/DevStatusWindow.ui +++ b/DevStatusAcq/DevStatusWindow.ui @@ -1791,7 +1791,7 @@ 控制状态 - + 100 @@ -1801,7 +1801,7 @@ - + 230 @@ -1814,7 +1814,7 @@ true - + 460 @@ -1871,7 +1871,7 @@ 1PPS移相 - + 1050 @@ -1890,7 +1890,7 @@ send - + 690 @@ -1900,7 +1900,7 @@ - + 820 @@ -1913,7 +1913,7 @@ true - + 690 @@ -1923,7 +1923,7 @@ - + 1050 @@ -1942,7 +1942,7 @@ send - + 1050 @@ -1961,7 +1961,7 @@ send - + 690 @@ -1971,7 +1971,7 @@ - + 820 @@ -1984,7 +1984,7 @@ true - + 690 @@ -1994,7 +1994,7 @@ - + 820 @@ -2007,7 +2007,7 @@ true - + 820 @@ -2020,7 +2020,7 @@ true - + 1050 @@ -2039,7 +2039,7 @@ send - + 820 @@ -2071,7 +2071,7 @@ 儒略日设置 - + 1050 @@ -2090,7 +2090,7 @@ send - + 820 @@ -2103,7 +2103,7 @@ true - + 1050 @@ -2141,7 +2141,7 @@ AC码幅度 - + 690 @@ -2189,7 +2189,7 @@ 时间显示 - + 690 diff --git a/DevStatusAcq/common/common.pri b/DevStatusAcq/common/common.pri index 84f57ae..6280f64 100644 --- a/DevStatusAcq/common/common.pri +++ b/DevStatusAcq/common/common.pri @@ -3,7 +3,7 @@ SOURCES += $$PWD/utils/QByteUtil.cpp SOURCES += $$PWD/utils/QSerialPortUtil.cpp SOURCES += $$PWD/utils/QLogUtil.cpp -#SOURCES += $$PWD/utils/QKafkaUtil.cpp +SOURCES += $$PWD/utils/QKafkaUtil.cpp SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp @@ -12,7 +12,7 @@ HEADERS += $$PWD/utils/QByteUtil.h HEADERS += $$PWD/utils/QSerialPortUtil.h HEADERS += $$PWD/utils/QLogUtil.h -#HEADERS += $$PWD/utils/QKafkaUtil.h +HEADERS += $$PWD/utils/QKafkaUtil.h HEADERS += $$PWD/utils/HttpRequestUtil.h HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h diff --git a/DevStatusAcq/conf/config.ini b/DevStatusAcq/conf/config.ini index 0b568d6..c37ba1c 100644 --- a/DevStatusAcq/conf/config.ini +++ b/DevStatusAcq/conf/config.ini @@ -2,16 +2,16 @@ baudRate=115200 [kafka] -needKafka=0 +needKafka=1 brokers="111.198.10.15:12502" dataTopic="cppTest" [client] -clientId="phase" +clientId="dev-status" appKey="bd593bdd20943d2db8af217c3712a460" [http] baseUrl="http://111.198.10.15:11410" [log] -basePath="D:/Workspace Qt/ZXSSCJ-Release/DevStatus/logs/" +basePath="/home/admin/Qt/ZXSSCJ-Release/DevStatus/logs/" diff --git a/DevStatusAcq/device/BCodeTerminal.cpp b/DevStatusAcq/device/BCodeTerminal.cpp index a299297..19d33fd 100644 --- a/DevStatusAcq/device/BCodeTerminal.cpp +++ b/DevStatusAcq/device/BCodeTerminal.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &BCodeTerminal::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/DeviceBase.h b/DevStatusAcq/device/DeviceBase.h index cba1ace..8cd10d6 100644 --- a/DevStatusAcq/device/DeviceBase.h +++ b/DevStatusAcq/device/DeviceBase.h @@ -3,7 +3,7 @@ #include #include "common/utils/QSerialPortUtil.h" -//#include "common/utils/QKafkaUtil.h" +#include "common/utils/QKafkaUtil.h" #include "common/utils/QByteUtil.h" #include "common/utils/QLogUtil.h" #include "common/utils/SettingConfig.h" @@ -37,7 +37,7 @@ int baudRate; QSerialPortUtil serialUtil; -// QKafkaUtil kafkaUtil; + QKafkaUtil kafkaUtil; QByteArray dataBuff; }; diff --git a/DevStatusAcq/device/FreqReplicator.cpp b/DevStatusAcq/device/FreqReplicator.cpp index 6acfbb8..b4046fe 100644 --- a/DevStatusAcq/device/FreqReplicator.cpp +++ b/DevStatusAcq/device/FreqReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FreqSwitcher.cpp b/DevStatusAcq/device/FreqSwitcher.cpp index 23311ee..57b440d 100644 --- a/DevStatusAcq/device/FreqSwitcher.cpp +++ b/DevStatusAcq/device/FreqSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FreqSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,8 +72,8 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/FrequencyTuning.cpp b/DevStatusAcq/device/FrequencyTuning.cpp index 3812fd8..8e36d3a 100644 --- a/DevStatusAcq/device/FrequencyTuning.cpp +++ b/DevStatusAcq/device/FrequencyTuning.cpp @@ -7,9 +7,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &FrequencyTuning::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -89,7 +89,7 @@ QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); jsonObj.insert("deviceId", deviceId); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } // 4. 在界面上简单显示相差数据结果 diff --git a/DevStatusAcq/device/SignalGenerator.cpp b/DevStatusAcq/device/SignalGenerator.cpp index aa76efb..577db52 100644 --- a/DevStatusAcq/device/SignalGenerator.cpp +++ b/DevStatusAcq/device/SignalGenerator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &SignalGenerator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -73,7 +73,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeReplicator.cpp b/DevStatusAcq/device/TimeReplicator.cpp index b15e2b7..1ba0db4 100644 --- a/DevStatusAcq/device/TimeReplicator.cpp +++ b/DevStatusAcq/device/TimeReplicator.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeReplicator::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/device/TimeSwitcher.cpp b/DevStatusAcq/device/TimeSwitcher.cpp index 0cf4bc7..ecf4d5a 100644 --- a/DevStatusAcq/device/TimeSwitcher.cpp +++ b/DevStatusAcq/device/TimeSwitcher.cpp @@ -8,9 +8,9 @@ connect(&this->serialUtil, &QSerialPortUtil::dataRecieved, this, &TimeSwitcher::dataReceivedHandler); -// kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); -// kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); -// kafkaUtil.createProducer(); + kafkaUtil.setBrokers(SettingConfig::getInstance().KAFKA_BROKERS); + kafkaUtil.setTopic(SettingConfig::getInstance().KAFKA_DATA_TOPIC); + kafkaUtil.createProducer(); this->protocol = DeviceStatusProtocolBase::deviceStatusProtocolFactory(typeid (this).name()); } @@ -72,7 +72,7 @@ { QJsonObject jsonObj = frameDto->toJSON(); jsonObj.insert("clientId", SettingConfig::getInstance().CLIENT_ID); - jsonObj.insert("deviceId", devCode); -// kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); + jsonObj.insert("deviceId", deviceId); + kafkaUtil.produceMessage(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact))); } } diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp index 0a86047..2c35e96 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.cpp @@ -43,6 +43,21 @@ return nullptr; } +QByteArray DeviceStatusProtocolBase::generateSettingCommand(QString commandType, QString valueSet) +{ + QByteArray commandBytes; + commandBytes.append(commandType).append(","); + commandBytes.append(valueSet); + + QString xorValue = this->calculateXOR(commandBytes); + + commandBytes.prepend("$"); + commandBytes.append("*"); + commandBytes.append(xorValue); + + return commandBytes; +} + QString DeviceStatusProtocolBase::calculateXOR(QByteArray byteArray) { quint8 xorValue = 0; diff --git a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h index 667c30c..ae3d4cb 100644 --- a/DevStatusAcq/protocol/DeviceStatusProtocolBase.h +++ b/DevStatusAcq/protocol/DeviceStatusProtocolBase.h @@ -115,6 +115,7 @@ virtual int checkFrame(QByteArray rawData) = 0; virtual QList extractFrameList(QByteArray rawData) = 0; virtual bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) = 0; + virtual QByteArray generateSettingCommand(QString commandType, QString valueSet); signals: diff --git a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp index 3277e17..36fbbd7 100644 --- a/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp +++ b/DevStatusAcq/protocol/FreqReplicatorProtocolTX.cpp @@ -28,8 +28,8 @@ QByteArray outputACByte = content.mid(5, 8); QByteArray outputBDByte = content.mid(13, 8); - QString inputAC = QString("%1,%2"); - QString inputBD = QString("%1,%2"); + QString inputAC = ""; + QString inputBD = ""; QString outputAC = ""; QString outputBD = ""; @@ -37,8 +37,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "AB"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputAC); ((FreqReplicatorStatusDto *) frameData)->inValid.append(inputBD); @@ -59,8 +59,8 @@ { ((FreqReplicatorStatusDto *) frameData)->abOrCd = "CD"; - inputAC.arg(inputACByte.at(1)).arg(inputACByte.at(0)); - inputBD.arg(inputBDByte.at(1)).arg(inputBDByte.at(0)); + inputAC = QString("%1,%2").arg(inputACByte.at(1) == 0x01 ? "1" : "0").arg(inputACByte.at(0) == 0x01 ? "1" : "0"); + inputBD = QString("%1,%2").arg(inputBDByte.at(1) == 0x01 ? "1" : "0").arg(inputBDByte.at(0) == 0x01 ? "1" : "0"); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); ((FreqReplicatorStatusDto *) frameData)->inValid.append(""); diff --git a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp index 9d8f261..51b6542 100644 --- a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp +++ b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.cpp @@ -30,86 +30,6 @@ return frameData; } -// 生成频率微调设置指令 -QByteArray FrequencyTuningProtocolBM::generateFreqTunSetCommand(qlonglong freqTunSet) -{ - QByteArray command; - command.append("GLF,20,"); - command.append(QString("%1").arg(freqTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成相位微调设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseTunSetCommand(qlonglong phaseTunSet) -{ - QByteArray command; - command.append("GLF,21,"); - command.append(QString("%1").arg(phaseTunSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成移相设置指令 -QByteArray FrequencyTuningProtocolBM::generatePhaseShiftSetCommand(qlonglong phaseShiftSet) -{ - QByteArray command; - command.append("GLP,01,"); - command.append(QString("%1").arg(phaseShiftSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成单次同步设置指令 -QByteArray FrequencyTuningProtocolBM::generateSingleSynchSetCommand(qint8 singleSynchSet) -{ - QByteArray command; - command.append("GLP,02,"); - command.append(QString("%1").arg(singleSynchSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成秒脉宽设置指令 -QByteArray FrequencyTuningProtocolBM::generateSecondWidthSetCommand(qlonglong secondWidthSet) -{ - QByteArray command; - command.append("GLP,03,"); - command.append(QString("%1").arg(secondWidthSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - bool FrequencyTuningProtocolBM::parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType) { // get the raw data between ',' and '*' diff --git a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h index 9fd65aa..1937f92 100644 --- a/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h +++ b/DevStatusAcq/protocol/FrequencyTuningProtocolBM.h @@ -19,21 +19,6 @@ bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * ftFrameData, int frameType); DeviceFrameBaseDto * frameFactory(int frameType); - // 生成频率微调设置指令 - QByteArray generateFreqTunSetCommand(qlonglong freqTunSet); - - // 生成相位微调设置指令 - QByteArray generatePhaseTunSetCommand(qlonglong phaseTunSet); - - // 生成移相设置指令 - QByteArray generatePhaseShiftSetCommand(qlonglong phaseShiftSet); - - // 生成单次同步设置指令 - QByteArray generateSingleSynchSetCommand(qint8 singleSynchSet); - - // 生成秒脉宽设置指令 - QByteArray generateSecondWidthSetCommand(qlonglong secondWidthSet); - // QList extractFrameList(QByteArray rawData); diff --git a/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp b/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp index db30632..6fc9ed8 100644 --- a/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp +++ b/DevStatusAcq/protocol/SignalGeneratorProtocolBM.cpp @@ -98,70 +98,6 @@ return true; } -// 生成闰秒设置指令 -QByteArray SignalGeneratorProtocolBM::generateLeapSecondSetCommand(qint8 leapSecondSet) -{ - QByteArray command; - command.append("GLF,01,"); - command.append(QString("%1").arg(leapSecondSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成单次同步设置指令 -QByteArray SignalGeneratorProtocolBM::generateSingleSynchSetCommand(qint8 singleSynchSet) -{ - QByteArray command; - command.append("GLF,02,"); - command.append(QString("%1").arg(singleSynchSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成年月日设置指令 -QByteArray SignalGeneratorProtocolBM::generateDateSetCommand(QString dateSet) -{ - QByteArray command; - command.append("GLF,03,"); - command.append(dateSet); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - -// 生成秒脉宽设置指令 -QByteArray SignalGeneratorProtocolBM::generateSecondWidthSetCommand(qlonglong secondWidthSet) -{ - QByteArray command; - command.append("GLF,04,"); - command.append(QString("%1").arg(secondWidthSet)); - - QString xorValue = this->calculateXOR(command); - - command.prepend("$"); - command.append("*"); - command.append(xorValue); - - return command; -} - QList SignalGeneratorProtocolBM::extractFrameList(QByteArray rawData) { QList resultList; diff --git a/DevStatusAcq/protocol/SignalGeneratorProtocolBM.h b/DevStatusAcq/protocol/SignalGeneratorProtocolBM.h index 55e9378..475e3ec 100644 --- a/DevStatusAcq/protocol/SignalGeneratorProtocolBM.h +++ b/DevStatusAcq/protocol/SignalGeneratorProtocolBM.h @@ -20,28 +20,6 @@ bool parseDeviceFrameData(QByteArray rawData, DeviceFrameBaseDto * sgFrameData, int frameType); DeviceFrameBaseDto * frameFactory(int frameType); - // 生成闰秒设置指令 - QByteArray generateLeapSecondSetCommand(qint8 leapSecondSet); - // 生成单次同步设置指令 - QByteArray generateSingleSynchSetCommand(qint8 singleSynchSet); - // 生成年月日设置指令 - QByteArray generateDateSetCommand(QString dateSet); - // 生成秒脉宽设置指令 - QByteArray generateSecondWidthSetCommand(qlonglong secondWidthSet); - // 生成AC码调制比设置指令 - QByteArray generateBacRatioSetCommand(qint8 bacRatioSet); - // 生成AC码幅度设置指令 - QByteArray generateBacRangeSetCommand(float bacRangeSet); - // 生成1PPS相位移相设置指令 - QByteArray generateOppsPhaseShiftSetCommand(qlonglong oppsPhaseShiftSet); - // 生成闰秒时刻设置指令 - QByteArray generateLeapTimestampSetSetCommand(QString leapTimestampSet); - // 生成儒略日设置指令 - QByteArray generateMJDDateSetSetCommand(QString mjdDateSet); - // 生成时分秒设置指令 - QByteArray generateTimeSetSetCommand(QString timeSet); - - // QList extractFrameList(QByteArray rawData);