diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/common/common.pri b/DeviceHub/common/common.pri index 86259e8..7b5affa 100644 --- a/DeviceHub/common/common.pri +++ b/DeviceHub/common/common.pri @@ -8,6 +8,7 @@ SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp +SOURCES += $$PWD/HttpServer.cpp HEADERS += $$PWD/utils/SettingConfig.h HEADERS += $$PWD/utils/QByteUtil.h @@ -19,4 +20,5 @@ HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h HEADERS += $$PWD/HttpRequestController.h +HEADERS += $$PWD/HttpServer.h HEADERS += $$PWD/ConstCache.h diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/common/common.pri b/DeviceHub/common/common.pri index 86259e8..7b5affa 100644 --- a/DeviceHub/common/common.pri +++ b/DeviceHub/common/common.pri @@ -8,6 +8,7 @@ SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp +SOURCES += $$PWD/HttpServer.cpp HEADERS += $$PWD/utils/SettingConfig.h HEADERS += $$PWD/utils/QByteUtil.h @@ -19,4 +20,5 @@ HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h HEADERS += $$PWD/HttpRequestController.h +HEADERS += $$PWD/HttpServer.h HEADERS += $$PWD/ConstCache.h diff --git a/DeviceHub/common/utils/QSerialPortUtil.cpp b/DeviceHub/common/utils/QSerialPortUtil.cpp index 87ba394..faa4cfa 100644 --- a/DeviceHub/common/utils/QSerialPortUtil.cpp +++ b/DeviceHub/common/utils/QSerialPortUtil.cpp @@ -4,14 +4,28 @@ #include #include #include "common/utils/QByteUtil.h" +#include "common/utils/SettingConfig.h" QSerialPortUtil::QSerialPortUtil(QObject *parent) : QObject(parent) { // 其他默认配置 serial.setDataBits(QSerialPort::Data8); - serial.setParity(QSerialPort::NoParity); serial.setStopBits(QSerialPort::OneStop); serial.setFlowControl(QSerialPort::NoFlowControl); + switch (SettingConfig::getInstance().PARITY) + { + case 2: + serial.setParity(QSerialPort::EvenParity); + break; + + case 3: + serial.setParity(QSerialPort::OddParity); + break; + + default: + serial.setParity(QSerialPort::NoParity); + break; + } // 绑定信号与槽 connect(&serial, &QSerialPort::readyRead, diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/common/common.pri b/DeviceHub/common/common.pri index 86259e8..7b5affa 100644 --- a/DeviceHub/common/common.pri +++ b/DeviceHub/common/common.pri @@ -8,6 +8,7 @@ SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp +SOURCES += $$PWD/HttpServer.cpp HEADERS += $$PWD/utils/SettingConfig.h HEADERS += $$PWD/utils/QByteUtil.h @@ -19,4 +20,5 @@ HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h HEADERS += $$PWD/HttpRequestController.h +HEADERS += $$PWD/HttpServer.h HEADERS += $$PWD/ConstCache.h diff --git a/DeviceHub/common/utils/QSerialPortUtil.cpp b/DeviceHub/common/utils/QSerialPortUtil.cpp index 87ba394..faa4cfa 100644 --- a/DeviceHub/common/utils/QSerialPortUtil.cpp +++ b/DeviceHub/common/utils/QSerialPortUtil.cpp @@ -4,14 +4,28 @@ #include #include #include "common/utils/QByteUtil.h" +#include "common/utils/SettingConfig.h" QSerialPortUtil::QSerialPortUtil(QObject *parent) : QObject(parent) { // 其他默认配置 serial.setDataBits(QSerialPort::Data8); - serial.setParity(QSerialPort::NoParity); serial.setStopBits(QSerialPort::OneStop); serial.setFlowControl(QSerialPort::NoFlowControl); + switch (SettingConfig::getInstance().PARITY) + { + case 2: + serial.setParity(QSerialPort::EvenParity); + break; + + case 3: + serial.setParity(QSerialPort::OddParity); + break; + + default: + serial.setParity(QSerialPort::NoParity); + break; + } // 绑定信号与槽 connect(&serial, &QSerialPort::readyRead, diff --git a/DeviceHub/common/utils/SettingConfig.cpp b/DeviceHub/common/utils/SettingConfig.cpp index 53b5a6c..a811606 100644 --- a/DeviceHub/common/utils/SettingConfig.cpp +++ b/DeviceHub/common/utils/SettingConfig.cpp @@ -7,6 +7,7 @@ PORT_NAMES = getProperty("com", "portNames").toString(); BAUD_RATE = getProperty("com", "baudRate").toUInt(); + PARITY = getProperty("com", "parity").toInt(); DEV_CODES = getProperty("com", "devCodes").toString(); NEED_KAFKA = getProperty("kafka", "needKafka").toUInt(); @@ -23,6 +24,8 @@ DEV_TYPES = getProperty("client", "devTypes").toString(); SYSTEM = getProperty("client", "system").toString(); WORK_MODE = getProperty("client", "workMode").toString(); + MASTER = getProperty("client", "master").toInt(); + SERVER_PORT = getProperty("client", "serverPort").toInt(); BASE_URL = getProperty("http", "baseUrl").toString(); diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/common/common.pri b/DeviceHub/common/common.pri index 86259e8..7b5affa 100644 --- a/DeviceHub/common/common.pri +++ b/DeviceHub/common/common.pri @@ -8,6 +8,7 @@ SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp +SOURCES += $$PWD/HttpServer.cpp HEADERS += $$PWD/utils/SettingConfig.h HEADERS += $$PWD/utils/QByteUtil.h @@ -19,4 +20,5 @@ HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h HEADERS += $$PWD/HttpRequestController.h +HEADERS += $$PWD/HttpServer.h HEADERS += $$PWD/ConstCache.h diff --git a/DeviceHub/common/utils/QSerialPortUtil.cpp b/DeviceHub/common/utils/QSerialPortUtil.cpp index 87ba394..faa4cfa 100644 --- a/DeviceHub/common/utils/QSerialPortUtil.cpp +++ b/DeviceHub/common/utils/QSerialPortUtil.cpp @@ -4,14 +4,28 @@ #include #include #include "common/utils/QByteUtil.h" +#include "common/utils/SettingConfig.h" QSerialPortUtil::QSerialPortUtil(QObject *parent) : QObject(parent) { // 其他默认配置 serial.setDataBits(QSerialPort::Data8); - serial.setParity(QSerialPort::NoParity); serial.setStopBits(QSerialPort::OneStop); serial.setFlowControl(QSerialPort::NoFlowControl); + switch (SettingConfig::getInstance().PARITY) + { + case 2: + serial.setParity(QSerialPort::EvenParity); + break; + + case 3: + serial.setParity(QSerialPort::OddParity); + break; + + default: + serial.setParity(QSerialPort::NoParity); + break; + } // 绑定信号与槽 connect(&serial, &QSerialPort::readyRead, diff --git a/DeviceHub/common/utils/SettingConfig.cpp b/DeviceHub/common/utils/SettingConfig.cpp index 53b5a6c..a811606 100644 --- a/DeviceHub/common/utils/SettingConfig.cpp +++ b/DeviceHub/common/utils/SettingConfig.cpp @@ -7,6 +7,7 @@ PORT_NAMES = getProperty("com", "portNames").toString(); BAUD_RATE = getProperty("com", "baudRate").toUInt(); + PARITY = getProperty("com", "parity").toInt(); DEV_CODES = getProperty("com", "devCodes").toString(); NEED_KAFKA = getProperty("kafka", "needKafka").toUInt(); @@ -23,6 +24,8 @@ DEV_TYPES = getProperty("client", "devTypes").toString(); SYSTEM = getProperty("client", "system").toString(); WORK_MODE = getProperty("client", "workMode").toString(); + MASTER = getProperty("client", "master").toInt(); + SERVER_PORT = getProperty("client", "serverPort").toInt(); BASE_URL = getProperty("http", "baseUrl").toString(); diff --git a/DeviceHub/common/utils/SettingConfig.h b/DeviceHub/common/utils/SettingConfig.h index 2bbbeb2..4cc00c9 100644 --- a/DeviceHub/common/utils/SettingConfig.h +++ b/DeviceHub/common/utils/SettingConfig.h @@ -29,6 +29,7 @@ /******** 以下为需要的各类参数 ********/ QString PORT_NAMES; int BAUD_RATE; + int PARITY; QString DEV_CODES; int NEED_KAFKA; @@ -45,6 +46,8 @@ QString DEV_TYPES; QString SYSTEM; QString WORK_MODE; + int MASTER; + quint16 SERVER_PORT; QString BASE_URL; diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/common/common.pri b/DeviceHub/common/common.pri index 86259e8..7b5affa 100644 --- a/DeviceHub/common/common.pri +++ b/DeviceHub/common/common.pri @@ -8,6 +8,7 @@ SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp +SOURCES += $$PWD/HttpServer.cpp HEADERS += $$PWD/utils/SettingConfig.h HEADERS += $$PWD/utils/QByteUtil.h @@ -19,4 +20,5 @@ HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h HEADERS += $$PWD/HttpRequestController.h +HEADERS += $$PWD/HttpServer.h HEADERS += $$PWD/ConstCache.h diff --git a/DeviceHub/common/utils/QSerialPortUtil.cpp b/DeviceHub/common/utils/QSerialPortUtil.cpp index 87ba394..faa4cfa 100644 --- a/DeviceHub/common/utils/QSerialPortUtil.cpp +++ b/DeviceHub/common/utils/QSerialPortUtil.cpp @@ -4,14 +4,28 @@ #include #include #include "common/utils/QByteUtil.h" +#include "common/utils/SettingConfig.h" QSerialPortUtil::QSerialPortUtil(QObject *parent) : QObject(parent) { // 其他默认配置 serial.setDataBits(QSerialPort::Data8); - serial.setParity(QSerialPort::NoParity); serial.setStopBits(QSerialPort::OneStop); serial.setFlowControl(QSerialPort::NoFlowControl); + switch (SettingConfig::getInstance().PARITY) + { + case 2: + serial.setParity(QSerialPort::EvenParity); + break; + + case 3: + serial.setParity(QSerialPort::OddParity); + break; + + default: + serial.setParity(QSerialPort::NoParity); + break; + } // 绑定信号与槽 connect(&serial, &QSerialPort::readyRead, diff --git a/DeviceHub/common/utils/SettingConfig.cpp b/DeviceHub/common/utils/SettingConfig.cpp index 53b5a6c..a811606 100644 --- a/DeviceHub/common/utils/SettingConfig.cpp +++ b/DeviceHub/common/utils/SettingConfig.cpp @@ -7,6 +7,7 @@ PORT_NAMES = getProperty("com", "portNames").toString(); BAUD_RATE = getProperty("com", "baudRate").toUInt(); + PARITY = getProperty("com", "parity").toInt(); DEV_CODES = getProperty("com", "devCodes").toString(); NEED_KAFKA = getProperty("kafka", "needKafka").toUInt(); @@ -23,6 +24,8 @@ DEV_TYPES = getProperty("client", "devTypes").toString(); SYSTEM = getProperty("client", "system").toString(); WORK_MODE = getProperty("client", "workMode").toString(); + MASTER = getProperty("client", "master").toInt(); + SERVER_PORT = getProperty("client", "serverPort").toInt(); BASE_URL = getProperty("http", "baseUrl").toString(); diff --git a/DeviceHub/common/utils/SettingConfig.h b/DeviceHub/common/utils/SettingConfig.h index 2bbbeb2..4cc00c9 100644 --- a/DeviceHub/common/utils/SettingConfig.h +++ b/DeviceHub/common/utils/SettingConfig.h @@ -29,6 +29,7 @@ /******** 以下为需要的各类参数 ********/ QString PORT_NAMES; int BAUD_RATE; + int PARITY; QString DEV_CODES; int NEED_KAFKA; @@ -45,6 +46,8 @@ QString DEV_TYPES; QString SYSTEM; QString WORK_MODE; + int MASTER; + quint16 SERVER_PORT; QString BASE_URL; diff --git a/DeviceHub/conf/config.ini b/DeviceHub/conf/config.ini index 94b28e3..2904619 100644 --- a/DeviceHub/conf/config.ini +++ b/DeviceHub/conf/config.ini @@ -1,5 +1,6 @@ [com] baudRate=115200 +parity=2 #0=NoParity;2=EvenParity;3=OddParity [kafka] needKafka=1 @@ -17,6 +18,8 @@ devTypes="09,10" system="clock,utc,phase" workMode="mock" +master=1 +serverPort=5906 [http] baseUrl="http://111.198.10.15:11410" diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/common/common.pri b/DeviceHub/common/common.pri index 86259e8..7b5affa 100644 --- a/DeviceHub/common/common.pri +++ b/DeviceHub/common/common.pri @@ -8,6 +8,7 @@ SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp +SOURCES += $$PWD/HttpServer.cpp HEADERS += $$PWD/utils/SettingConfig.h HEADERS += $$PWD/utils/QByteUtil.h @@ -19,4 +20,5 @@ HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h HEADERS += $$PWD/HttpRequestController.h +HEADERS += $$PWD/HttpServer.h HEADERS += $$PWD/ConstCache.h diff --git a/DeviceHub/common/utils/QSerialPortUtil.cpp b/DeviceHub/common/utils/QSerialPortUtil.cpp index 87ba394..faa4cfa 100644 --- a/DeviceHub/common/utils/QSerialPortUtil.cpp +++ b/DeviceHub/common/utils/QSerialPortUtil.cpp @@ -4,14 +4,28 @@ #include #include #include "common/utils/QByteUtil.h" +#include "common/utils/SettingConfig.h" QSerialPortUtil::QSerialPortUtil(QObject *parent) : QObject(parent) { // 其他默认配置 serial.setDataBits(QSerialPort::Data8); - serial.setParity(QSerialPort::NoParity); serial.setStopBits(QSerialPort::OneStop); serial.setFlowControl(QSerialPort::NoFlowControl); + switch (SettingConfig::getInstance().PARITY) + { + case 2: + serial.setParity(QSerialPort::EvenParity); + break; + + case 3: + serial.setParity(QSerialPort::OddParity); + break; + + default: + serial.setParity(QSerialPort::NoParity); + break; + } // 绑定信号与槽 connect(&serial, &QSerialPort::readyRead, diff --git a/DeviceHub/common/utils/SettingConfig.cpp b/DeviceHub/common/utils/SettingConfig.cpp index 53b5a6c..a811606 100644 --- a/DeviceHub/common/utils/SettingConfig.cpp +++ b/DeviceHub/common/utils/SettingConfig.cpp @@ -7,6 +7,7 @@ PORT_NAMES = getProperty("com", "portNames").toString(); BAUD_RATE = getProperty("com", "baudRate").toUInt(); + PARITY = getProperty("com", "parity").toInt(); DEV_CODES = getProperty("com", "devCodes").toString(); NEED_KAFKA = getProperty("kafka", "needKafka").toUInt(); @@ -23,6 +24,8 @@ DEV_TYPES = getProperty("client", "devTypes").toString(); SYSTEM = getProperty("client", "system").toString(); WORK_MODE = getProperty("client", "workMode").toString(); + MASTER = getProperty("client", "master").toInt(); + SERVER_PORT = getProperty("client", "serverPort").toInt(); BASE_URL = getProperty("http", "baseUrl").toString(); diff --git a/DeviceHub/common/utils/SettingConfig.h b/DeviceHub/common/utils/SettingConfig.h index 2bbbeb2..4cc00c9 100644 --- a/DeviceHub/common/utils/SettingConfig.h +++ b/DeviceHub/common/utils/SettingConfig.h @@ -29,6 +29,7 @@ /******** 以下为需要的各类参数 ********/ QString PORT_NAMES; int BAUD_RATE; + int PARITY; QString DEV_CODES; int NEED_KAFKA; @@ -45,6 +46,8 @@ QString DEV_TYPES; QString SYSTEM; QString WORK_MODE; + int MASTER; + quint16 SERVER_PORT; QString BASE_URL; diff --git a/DeviceHub/conf/config.ini b/DeviceHub/conf/config.ini index 94b28e3..2904619 100644 --- a/DeviceHub/conf/config.ini +++ b/DeviceHub/conf/config.ini @@ -1,5 +1,6 @@ [com] baudRate=115200 +parity=2 #0=NoParity;2=EvenParity;3=OddParity [kafka] needKafka=1 @@ -17,6 +18,8 @@ devTypes="09,10" system="clock,utc,phase" workMode="mock" +master=1 +serverPort=5906 [http] baseUrl="http://111.198.10.15:11410" diff --git a/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp b/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp index 2f7fa69..60d7a8a 100644 --- a/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp +++ b/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp @@ -68,6 +68,29 @@ QList FrequencyTuningProtocolBM::extractFrameList(QByteArray rawData) { QList resultList; + + int start = rawData.indexOf("$GL"); + if (start < 0) + { + return resultList; + } + int end = rawData.indexOf(QByteArray("\r\n"), start); + if (end < 0) + { + return resultList; + } + + while (start > 0 & end > 0) + { + QByteArray ba = rawData.mid(start, end - start + 2); + resultList.append(ba); + + rawData = rawData.right(end); + + start = rawData.indexOf("$GL"); + end = rawData.indexOf(QByteArray("\r\n"), start); + } +/* if (rawData.endsWith(QByteArray("\r\n")) == true && rawData.startsWith("$") == true) { QByteArray ba; @@ -91,7 +114,7 @@ } } } - +*/ return resultList; } diff --git a/DeviceHub/DeviceHubWindow.cpp b/DeviceHub/DeviceHubWindow.cpp index ae5be4c..bd7d338 100644 --- a/DeviceHub/DeviceHubWindow.cpp +++ b/DeviceHub/DeviceHubWindow.cpp @@ -55,6 +55,8 @@ // 2. 获取字典值:设备类型 retCode = this->initDictDeviceTypes(); this->initAllDeviceList(); + + HttpServer::instance().run(QHostAddress::Any, SettingConfig::getInstance().SERVER_PORT); } DeviceHubWindow::~DeviceHubWindow() diff --git a/DeviceHub/DeviceHubWindow.h b/DeviceHub/DeviceHubWindow.h index cdc100b..900835b 100644 --- a/DeviceHub/DeviceHubWindow.h +++ b/DeviceHub/DeviceHubWindow.h @@ -5,6 +5,7 @@ #include #include "common/HttpRequestController.h" +#include "common/HttpServer.h" #include "common/utils/QKafkaConsumer.h" #include "device/DeviceBase.h" #include "FrequencyTuningForm.h" diff --git a/DeviceHub/FrequencyTuningForm.cpp b/DeviceHub/FrequencyTuningForm.cpp index 668458a..b7669be 100644 --- a/DeviceHub/FrequencyTuningForm.cpp +++ b/DeviceHub/FrequencyTuningForm.cpp @@ -92,3 +92,8 @@ ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString()); } } + +void FrequencyTuningForm::on_ftSetFreqTurnButt_clicked() +{ + +} diff --git a/DeviceHub/FrequencyTuningForm.h b/DeviceHub/FrequencyTuningForm.h index 14cfad8..ab94a2e 100644 --- a/DeviceHub/FrequencyTuningForm.h +++ b/DeviceHub/FrequencyTuningForm.h @@ -23,6 +23,8 @@ private slots: void on_freqTunButt_clicked(); + void on_ftSetFreqTurnButt_clicked(); + private: Ui::FrequencyTuningForm *ui; }; diff --git a/DeviceHub/common/HttpServer.cpp b/DeviceHub/common/HttpServer.cpp new file mode 100644 index 0000000..c1a1b48 --- /dev/null +++ b/DeviceHub/common/HttpServer.cpp @@ -0,0 +1,68 @@ +#include "HttpServer.h" + +HttpServer::HttpServer(QObject *parent) : QObject(parent) +{ + httpServer = new QTcpServer(this); + httpServer->setMaxPendingConnections(1024); + QObject::connect(httpServer, &QTcpServer::newConnection, this, &HttpServer::newConnection); +} + +HttpServer::~HttpServer() +{ + +} + +HttpServer &HttpServer::instance() +{ + static HttpServer obj; + return obj; +} + +void HttpServer::run(const QHostAddress &address, const quint16 &port) +{ + httpServer->listen(address, port); +} + +void HttpServer::newConnection() +{ + QTcpSocket * m_socket = httpServer->nextPendingConnection(); + QObject::connect(m_socket, &QTcpSocket::readyRead, this, &HttpServer::readyRead); +} + +void HttpServer::readyRead() +{ + QTcpSocket * socket = qobject_cast(sender()); + if(socket) { + QByteArray request = socket->readAll(); + + qDebug() << "Request Data:" << request; + + QByteArray response = this->buildHeartBeatResponse().toUtf8(); + + QString http = "HTTP/1.1 200 OK\r\n"; + http += "Server: qt\r\n"; + http += "Content-Type: application/json;charset=utf-8\r\n"; + http += "Connection: keep-alive\r\n"; + http += QString("Content-Length: %1\r\n\r\n").arg(QString::number(response.size())); + + socket->write(http.toUtf8()); + socket->write(response); + socket->flush(); + socket->waitForBytesWritten(http.size() + response.size()); + socket->close(); + } +} + +QString HttpServer::buildHeartBeatResponse() +{ + QJsonObject resp; + resp.insert("code", 200); + resp.insert("success", true); + + QJsonObject data; + data.insert("status", "1"); + data.insert("remarks", ""); + resp.insert("data", data); + + return QString(QJsonDocument(resp).toJson(QJsonDocument::Compact)); +} diff --git a/DeviceHub/common/HttpServer.h b/DeviceHub/common/HttpServer.h new file mode 100644 index 0000000..7499987 --- /dev/null +++ b/DeviceHub/common/HttpServer.h @@ -0,0 +1,33 @@ +#ifndef HTTPSERVER_H +#define HTTPSERVER_H + +#include +#include +#include +#include + +class HttpServer : public QObject +{ + Q_OBJECT +public: + static HttpServer &instance(); + void run(const QHostAddress &address = QHostAddress::Any, const quint16 &port = 5905); + +private: + explicit HttpServer(QObject *parent = nullptr); + ~HttpServer(); + Q_DISABLE_COPY(HttpServer) + + QTcpServer * httpServer; + + QString buildHeartBeatResponse(); + +signals: + +public slots: +private slots: + void newConnection(); + void readyRead(); +}; + +#endif // HTTPSERVER_H diff --git a/DeviceHub/common/common.pri b/DeviceHub/common/common.pri index 86259e8..7b5affa 100644 --- a/DeviceHub/common/common.pri +++ b/DeviceHub/common/common.pri @@ -8,6 +8,7 @@ SOURCES += $$PWD/utils/HttpRequestUtil.cpp SOURCES += $$PWD/utils/MD5.cpp SOURCES += $$PWD/HttpRequestController.cpp +SOURCES += $$PWD/HttpServer.cpp HEADERS += $$PWD/utils/SettingConfig.h HEADERS += $$PWD/utils/QByteUtil.h @@ -19,4 +20,5 @@ HEADERS += $$PWD/utils/DefHead.h HEADERS += $$PWD/utils/MD5.h HEADERS += $$PWD/HttpRequestController.h +HEADERS += $$PWD/HttpServer.h HEADERS += $$PWD/ConstCache.h diff --git a/DeviceHub/common/utils/QSerialPortUtil.cpp b/DeviceHub/common/utils/QSerialPortUtil.cpp index 87ba394..faa4cfa 100644 --- a/DeviceHub/common/utils/QSerialPortUtil.cpp +++ b/DeviceHub/common/utils/QSerialPortUtil.cpp @@ -4,14 +4,28 @@ #include #include #include "common/utils/QByteUtil.h" +#include "common/utils/SettingConfig.h" QSerialPortUtil::QSerialPortUtil(QObject *parent) : QObject(parent) { // 其他默认配置 serial.setDataBits(QSerialPort::Data8); - serial.setParity(QSerialPort::NoParity); serial.setStopBits(QSerialPort::OneStop); serial.setFlowControl(QSerialPort::NoFlowControl); + switch (SettingConfig::getInstance().PARITY) + { + case 2: + serial.setParity(QSerialPort::EvenParity); + break; + + case 3: + serial.setParity(QSerialPort::OddParity); + break; + + default: + serial.setParity(QSerialPort::NoParity); + break; + } // 绑定信号与槽 connect(&serial, &QSerialPort::readyRead, diff --git a/DeviceHub/common/utils/SettingConfig.cpp b/DeviceHub/common/utils/SettingConfig.cpp index 53b5a6c..a811606 100644 --- a/DeviceHub/common/utils/SettingConfig.cpp +++ b/DeviceHub/common/utils/SettingConfig.cpp @@ -7,6 +7,7 @@ PORT_NAMES = getProperty("com", "portNames").toString(); BAUD_RATE = getProperty("com", "baudRate").toUInt(); + PARITY = getProperty("com", "parity").toInt(); DEV_CODES = getProperty("com", "devCodes").toString(); NEED_KAFKA = getProperty("kafka", "needKafka").toUInt(); @@ -23,6 +24,8 @@ DEV_TYPES = getProperty("client", "devTypes").toString(); SYSTEM = getProperty("client", "system").toString(); WORK_MODE = getProperty("client", "workMode").toString(); + MASTER = getProperty("client", "master").toInt(); + SERVER_PORT = getProperty("client", "serverPort").toInt(); BASE_URL = getProperty("http", "baseUrl").toString(); diff --git a/DeviceHub/common/utils/SettingConfig.h b/DeviceHub/common/utils/SettingConfig.h index 2bbbeb2..4cc00c9 100644 --- a/DeviceHub/common/utils/SettingConfig.h +++ b/DeviceHub/common/utils/SettingConfig.h @@ -29,6 +29,7 @@ /******** 以下为需要的各类参数 ********/ QString PORT_NAMES; int BAUD_RATE; + int PARITY; QString DEV_CODES; int NEED_KAFKA; @@ -45,6 +46,8 @@ QString DEV_TYPES; QString SYSTEM; QString WORK_MODE; + int MASTER; + quint16 SERVER_PORT; QString BASE_URL; diff --git a/DeviceHub/conf/config.ini b/DeviceHub/conf/config.ini index 94b28e3..2904619 100644 --- a/DeviceHub/conf/config.ini +++ b/DeviceHub/conf/config.ini @@ -1,5 +1,6 @@ [com] baudRate=115200 +parity=2 #0=NoParity;2=EvenParity;3=OddParity [kafka] needKafka=1 @@ -17,6 +18,8 @@ devTypes="09,10" system="clock,utc,phase" workMode="mock" +master=1 +serverPort=5906 [http] baseUrl="http://111.198.10.15:11410" diff --git a/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp b/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp index 2f7fa69..60d7a8a 100644 --- a/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp +++ b/DeviceHub/protocol/FrequencyTuningProtocolBM.cpp @@ -68,6 +68,29 @@ QList FrequencyTuningProtocolBM::extractFrameList(QByteArray rawData) { QList resultList; + + int start = rawData.indexOf("$GL"); + if (start < 0) + { + return resultList; + } + int end = rawData.indexOf(QByteArray("\r\n"), start); + if (end < 0) + { + return resultList; + } + + while (start > 0 & end > 0) + { + QByteArray ba = rawData.mid(start, end - start + 2); + resultList.append(ba); + + rawData = rawData.right(end); + + start = rawData.indexOf("$GL"); + end = rawData.indexOf(QByteArray("\r\n"), start); + } +/* if (rawData.endsWith(QByteArray("\r\n")) == true && rawData.startsWith("$") == true) { QByteArray ba; @@ -91,7 +114,7 @@ } } } - +*/ return resultList; } diff --git a/ZXSSCJ.pro b/ZXSSCJ.pro index 04b410c..1e18b47 100644 --- a/ZXSSCJ.pro +++ b/ZXSSCJ.pro @@ -7,5 +7,5 @@ #SUBDIRS += CounterAcqBM #6906计数器数据采集 SUBDIRS += PhaseCompAcq #比相仪数据采集 #SUBDIRS += DevStatusAcq -#SUBDIRS += DeviceHub # +SUBDIRS += DeviceHub # #SUBDIRS += HClockAcq #氢钟状态数据采集