1.添加数据库获取掌静脉特征值。
This commit is contained in:
@ -12,8 +12,8 @@ add_executable(Analyser Analyser.rc
|
||||
)
|
||||
|
||||
target_link_libraries(Analyser
|
||||
PRIVATE Universal
|
||||
PRIVATE QtComponets
|
||||
PRIVATE Database
|
||||
PRIVATE Ws2_32
|
||||
PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
|
||||
PRIVATE Qt${QT_VERSION_MAJOR}::SerialPort
|
||||
|
@ -138,6 +138,11 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
|
||||
LOG_CAT(info, GUI) << "用户ID: " << ntohs(info->userid)
|
||||
<< ", 用户名: " << std::string_view(reinterpret_cast<const char *>(info->username))
|
||||
<< ", 特征值长度: " << ntohs(info->featureTotalSize);
|
||||
PalmFeature feature;
|
||||
feature.username = std::string_view(reinterpret_cast<const char *>(info->username));
|
||||
const uint8_t *start = data + 7 + sizeof(PalmFeatureHeader);
|
||||
feature.feature = std::vector<uint8_t>(start, start + ntohs(info->featureTotalSize));
|
||||
emit newPalmFeature(feature);
|
||||
}
|
||||
LOG_CAT(info, GUI) << Separator;
|
||||
break;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef MODULECOMMUNICATION_H
|
||||
#define MODULECOMMUNICATION_H
|
||||
|
||||
#include "Database.h"
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
@ -99,6 +100,8 @@ public:
|
||||
void deleteAll();
|
||||
|
||||
void requestPalmFeature(uint16_t userid);
|
||||
signals:
|
||||
void newPalmFeature(const PalmFeature &feature);
|
||||
|
||||
protected:
|
||||
void processPackage(const uint8_t *data, uint16_t size);
|
||||
|
@ -67,9 +67,14 @@ Widget::Widget(QWidget *parent) : QWidget{parent} {
|
||||
layout->addLayout(operatorLayout, 1);
|
||||
layout->addWidget(tabWidget, 3);
|
||||
|
||||
m_database = std::make_shared<Database>();
|
||||
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
onSerialRefreshButtonClicked();
|
||||
m_commandGroupBox->setEnabled(false);
|
||||
if (!m_database->open("database.db")) {
|
||||
LOG(error) << "open database failed.";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -183,6 +188,17 @@ QGroupBox *Widget::initializeUvcGroupBox() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Widget::onNewPalmFeature(const PalmFeature &feature) {
|
||||
if (!m_database->addPalmFeature(feature)) {
|
||||
LOG(error) << "add palm feature failed.";
|
||||
}
|
||||
|
||||
auto palms = m_database->palmFeatures();
|
||||
for (auto &p : palms) {
|
||||
LOG(info) << p.id << " " << p.username << " " << p.feature.size();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::onSerialConnectButtonClicked() {
|
||||
auto button = dynamic_cast<QPushButton *>(sender());
|
||||
if (button == nullptr) return;
|
||||
@ -190,6 +206,7 @@ void Widget::onSerialConnectButtonClicked() {
|
||||
if (text == "连接") {
|
||||
auto portName = m_serialComboBox->currentText();
|
||||
m_communication = std::make_shared<ModuleCommunication>();
|
||||
connect(m_communication.get(), &ModuleCommunication::newPalmFeature, this, &Widget::onNewPalmFeature);
|
||||
bool status = m_communication->open(portName);
|
||||
if (status) {
|
||||
m_commandGroupBox->setEnabled(true);
|
||||
|
@ -1,13 +1,14 @@
|
||||
#ifndef WIDGET_H
|
||||
#define WIDGET_H
|
||||
|
||||
#include "qgroupbox.h"
|
||||
#include "Database.h"
|
||||
#include <QWidget>
|
||||
|
||||
class QPushButton;
|
||||
class QTextBrowser;
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QGroupBox;
|
||||
class ModuleCommunication;
|
||||
|
||||
class Widget : public QWidget {
|
||||
@ -37,6 +38,8 @@ protected:
|
||||
|
||||
QGroupBox *initializeUvcGroupBox();
|
||||
|
||||
void onNewPalmFeature(const PalmFeature &feature);
|
||||
|
||||
private:
|
||||
QComboBox *m_serialComboBox = nullptr;
|
||||
QPushButton *m_serialConnectButton = nullptr;
|
||||
@ -57,6 +60,7 @@ private:
|
||||
QLineEdit *m_palmFeatureEdit = nullptr;
|
||||
|
||||
std::shared_ptr<ModuleCommunication> m_communication;
|
||||
std::shared_ptr<Database> m_database;
|
||||
};
|
||||
|
||||
#endif // WIDGET_H
|
||||
|
Reference in New Issue
Block a user