add database support
This commit is contained in:
parent
12a45fc2d0
commit
3e1d78f54f
|
@ -4,6 +4,11 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
|
||||||
|
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
|
msvc{
|
||||||
|
QMAKE_CFLAGS += /utf-8
|
||||||
|
QMAKE_CXXFLAGS += /utf-8
|
||||||
|
}
|
||||||
|
|
||||||
# You can make your code fail to compile if it uses deprecated APIs.
|
# You can make your code fail to compile if it uses deprecated APIs.
|
||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
@ -25,7 +30,8 @@ SOURCES += \
|
||||||
src/cpp/interfaceTestWin.cpp \
|
src/cpp/interfaceTestWin.cpp \
|
||||||
src/cpp/msgInputWin.cpp \
|
src/cpp/msgInputWin.cpp \
|
||||||
src/cpp/statusTestWin.cpp \
|
src/cpp/statusTestWin.cpp \
|
||||||
src/cpp/precisionTestWin.cpp
|
src/cpp/precisionTestWin.cpp \
|
||||||
|
src/cpp/testThread.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/include/posTestWin.h \
|
src/include/posTestWin.h \
|
||||||
|
@ -39,6 +45,7 @@ HEADERS += \
|
||||||
src/include/serialport.h \
|
src/include/serialport.h \
|
||||||
src/include/sqlitedb.h \
|
src/include/sqlitedb.h \
|
||||||
src/include/statusTestWin.h \
|
src/include/statusTestWin.h \
|
||||||
|
src/include/testThread.h \
|
||||||
src/include/titlebar.h \
|
src/include/titlebar.h \
|
||||||
src/include/utils.h
|
src/include/utils.h
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,11 @@ namespace globalParams
|
||||||
{
|
{
|
||||||
QString curUserId;
|
QString curUserId;
|
||||||
QString curUserType;
|
QString curUserType;
|
||||||
|
QString configPath = "config/cfg.ini";
|
||||||
|
QString company;
|
||||||
|
QString bdType;
|
||||||
|
QString carType;
|
||||||
|
QString classGroup;
|
||||||
|
QString bdSN;
|
||||||
|
QString marker;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "interfaceTestWin.h"
|
#include "interfaceTestWin.h"
|
||||||
#include "ui_interfaceTestWin.h"
|
#include "ui_interfaceTestWin.h"
|
||||||
|
#include "testThread.h"
|
||||||
|
#include "globalParams.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
InterfaceTestWin::InterfaceTestWin(QWidget *parent)
|
InterfaceTestWin::InterfaceTestWin(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -78,9 +82,69 @@ InterfaceTestWin::InterfaceTestWin(QWidget *parent)
|
||||||
aItem->setTextAlignment(Qt::AlignCenter);
|
aItem->setTextAlignment(Qt::AlignCenter);
|
||||||
aItemList.append(aItem);
|
aItemList.append(aItem);
|
||||||
canModel->insertRow(canModel->rowCount(),aItemList);
|
canModel->insertRow(canModel->rowCount(),aItemList);
|
||||||
|
|
||||||
|
connect(&TestThread::getInstance(),SIGNAL(serialRecvResultSignal(bool)),this,SLOT(serialRecvResultHandle(bool)),Qt::QueuedConnection);
|
||||||
|
connect(&TestThread::getInstance(),SIGNAL(serialSendResultSignal(bool)),this,SLOT(serialSendResultHandle(bool)),Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceTestWin::~InterfaceTestWin()
|
InterfaceTestWin::~InterfaceTestWin()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterfaceTestWin::serialRecvResultHandle(bool result)
|
||||||
|
{
|
||||||
|
QMap<QString,QString> map;
|
||||||
|
map["BDSN"] = globalParams::bdSN;
|
||||||
|
map["TESTER"] = globalParams::curUserId;
|
||||||
|
QDateTime cur = QDateTime::currentDateTime();
|
||||||
|
map["TEST_TIME"] = cur.toString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
if(result){
|
||||||
|
serialModel->item(0,1)->setText("正常");
|
||||||
|
serialModel->item(0,1)->setForeground(QBrush(QColor(0,140,0)));
|
||||||
|
map["SERIAL_RECV"] = "PASS";
|
||||||
|
}else{
|
||||||
|
serialModel->item(0,1)->setText("不正常");
|
||||||
|
serialModel->item(0,1)->setForeground(QBrush(Qt::red));
|
||||||
|
map["SERIAL_RECV"] = "FAIL";
|
||||||
|
}
|
||||||
|
SQLITEDB::getInstance().saveRecord("INTERFACE_TEST",map);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterfaceTestWin::serialSendResultHandle(bool result)
|
||||||
|
{
|
||||||
|
QMap<QString,QString> map;
|
||||||
|
map["BDSN"] = globalParams::bdSN;
|
||||||
|
map["TESTER"] = globalParams::curUserId;
|
||||||
|
QDateTime cur = QDateTime::currentDateTime();
|
||||||
|
map["TEST_TIME"] = cur.toString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
if(result){
|
||||||
|
serialModel->item(1,1)->setText("正常");
|
||||||
|
serialModel->item(1,1)->setForeground(QBrush(QColor(0,140,0)));
|
||||||
|
map["SERIAL_SEND"] = "PASS";
|
||||||
|
}else{
|
||||||
|
serialModel->item(1,1)->setText("不正常");
|
||||||
|
serialModel->item(1,1)->setForeground(QBrush(Qt::red));
|
||||||
|
map["SERIAL_SEND"] = "FAIL";
|
||||||
|
}
|
||||||
|
SQLITEDB::getInstance().saveRecord("INTERFACE_TEST",map);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterfaceTestWin::on_btnSerialTest_clicked()
|
||||||
|
{
|
||||||
|
if(TestThread::getInstance().isOnTest()){
|
||||||
|
QMessageBox::warning(this,"警告","请等待其他测试项完成再开始测试!",QMessageBox::Ok,QMessageBox::NoButton);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
serialModel->item(0,1)->setText("");
|
||||||
|
serialModel->item(0,1)->setForeground(QBrush(Qt::black));
|
||||||
|
serialModel->item(1,1)->setText("");
|
||||||
|
serialModel->item(1,1)->setForeground(QBrush(Qt::black));
|
||||||
|
|
||||||
|
QVector<TEST_TYPE> testList;
|
||||||
|
testList.append(TEST_TYPE::SERIAL);
|
||||||
|
TestThread::getInstance().setTestList(testList);
|
||||||
|
TestThread::getInstance().start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ LoginWin::~LoginWin()
|
||||||
|
|
||||||
void LoginWin::windowCloseHandle()
|
void LoginWin::windowCloseHandle()
|
||||||
{
|
{
|
||||||
QSettings setting("config/cfg.ini",QSettings::IniFormat);
|
QSettings setting(globalParams::configPath,QSettings::IniFormat);
|
||||||
QString check;
|
QString check;
|
||||||
if(ui->ckbRemember->isChecked()){
|
if(ui->ckbRemember->isChecked()){
|
||||||
check = "1";
|
check = "1";
|
||||||
|
@ -197,7 +197,7 @@ bool LoginWin::nativeEvent(const QByteArray &eventType, void *message, long *res
|
||||||
|
|
||||||
void LoginWin::readCfg()
|
void LoginWin::readCfg()
|
||||||
{
|
{
|
||||||
QSettings setting("config/cfg.ini",QSettings::IniFormat);
|
QSettings setting(globalParams::configPath,QSettings::IniFormat);
|
||||||
QString names = setting.value("users/names").toString().trimmed();
|
QString names = setting.value("users/names").toString().trimmed();
|
||||||
QStringList nameList = names.split(";");
|
QStringList nameList = names.split(";");
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ void LoginWin::readCfg()
|
||||||
|
|
||||||
void LoginWin::saveCfg()
|
void LoginWin::saveCfg()
|
||||||
{
|
{
|
||||||
QSettings setting("config/cfg.ini",QSettings::IniFormat);
|
QSettings setting(globalParams::configPath,QSettings::IniFormat);
|
||||||
|
|
||||||
QString names;
|
QString names;
|
||||||
QString curname = ui->cmbName->currentText();
|
QString curname = ui->cmbName->currentText();
|
||||||
|
|
|
@ -12,6 +12,7 @@ int main(int argc, char *argv[])
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QFont font = a.font();
|
QFont font = a.font();
|
||||||
font.setFamily("Microsoft YaHei UI");
|
font.setFamily("Microsoft YaHei UI");
|
||||||
|
font.setPointSize(9);
|
||||||
a.setFont(font);
|
a.setFont(font);
|
||||||
LoginWin login;
|
LoginWin login;
|
||||||
login.show();
|
login.show();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "globalParams.h"
|
#include "globalParams.h"
|
||||||
#include "msgInputWin.h"
|
#include "msgInputWin.h"
|
||||||
|
#include "testThread.h"
|
||||||
#include <QSerialPortInfo>
|
#include <QSerialPortInfo>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -16,6 +17,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
this->setWindowTitle("北斗用户机测试软件");
|
this->setWindowTitle("北斗用户机测试软件");
|
||||||
//this->setPalette(QPalette(QColor(255,255,255)));
|
//this->setPalette(QPalette(QColor(255,255,255)));
|
||||||
//this->setPalette(QPalette(QColor(225,225,225)));
|
//this->setPalette(QPalette(QColor(225,225,225)));
|
||||||
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
serialPortInit();
|
serialPortInit();
|
||||||
|
|
||||||
//状态栏显示当前用户
|
//状态栏显示当前用户
|
||||||
|
@ -35,6 +38,38 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
userLayout->addWidget(lbCurUserId);
|
userLayout->addWidget(lbCurUserId);
|
||||||
userLayout->addWidget(lbUserSpaceRight);
|
userLayout->addWidget(lbUserSpaceRight);
|
||||||
ui->statusbar->addWidget(userBox);
|
ui->statusbar->addWidget(userBox);
|
||||||
|
|
||||||
|
//显示测试进度
|
||||||
|
QGroupBox *progressBox = new QGroupBox();
|
||||||
|
progressBox->setStyleSheet("QGroupBox{border:none;}");
|
||||||
|
QHBoxLayout *progressLayout = new QHBoxLayout(progressBox);
|
||||||
|
progressLayout->setMargin(0);
|
||||||
|
QLabel *lbProgressSpaceLeft = new QLabel();
|
||||||
|
QLabel *lbProgressSpaceMid1 = new QLabel();
|
||||||
|
QLabel *lbProgressSpaceMid2 = new QLabel();
|
||||||
|
QLabel *lbProgressSpaceMid3 = new QLabel();
|
||||||
|
QLabel *lbProgressSpaceRight = new QLabel();
|
||||||
|
lbProgressSpaceLeft->setFixedWidth(5);
|
||||||
|
lbProgressSpaceMid1->setFixedWidth(5);
|
||||||
|
lbProgressSpaceMid2->setFixedWidth(5);
|
||||||
|
lbProgressSpaceMid3->setFixedWidth(5);
|
||||||
|
lbProgressSpaceRight->setFixedWidth(5);
|
||||||
|
|
||||||
|
QLabel *lbCurTest = new QLabel("当前测试项:");
|
||||||
|
QLabel *lbTestTime = new QLabel("测试时间:");
|
||||||
|
lbCurTestItem = new QLabel("");
|
||||||
|
lbCurTestTimeCounts = new QLabel("");
|
||||||
|
|
||||||
|
progressLayout->addWidget(lbProgressSpaceLeft);
|
||||||
|
progressLayout->addWidget(lbCurTest);
|
||||||
|
progressLayout->addWidget(lbCurTestItem);
|
||||||
|
progressLayout->addWidget(lbProgressSpaceMid1);
|
||||||
|
progressLayout->addWidget(lbTestTime);
|
||||||
|
progressLayout->addWidget(lbCurTestTimeCounts);
|
||||||
|
progressLayout->addWidget(lbProgressSpaceRight);
|
||||||
|
|
||||||
|
ui->statusbar->addWidget(progressBox);
|
||||||
|
|
||||||
//状态栏显示接收比特数
|
//状态栏显示接收比特数
|
||||||
QGroupBox *byteBox = new QGroupBox();
|
QGroupBox *byteBox = new QGroupBox();
|
||||||
byteBox->setStyleSheet("QGroupBox{border:none;}");
|
byteBox->setStyleSheet("QGroupBox{border:none;}");
|
||||||
|
@ -80,6 +115,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
byteLayout->addWidget(lbByteSpaceRight);
|
byteLayout->addWidget(lbByteSpaceRight);
|
||||||
ui->statusbar->addWidget(byteBox);
|
ui->statusbar->addWidget(byteBox);
|
||||||
|
|
||||||
|
connect(&TestThread::getInstance(),SIGNAL(writeDataSignal(QByteArray)),this,SIGNAL(writeDataSignal(QByteArray)),Qt::QueuedConnection);
|
||||||
|
connect(&TestThread::getInstance(),SIGNAL(curTestInfoSignal(QString,int)),this,SLOT(curTestInfoHandle(QString,int)),Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -100,7 +137,13 @@ void MainWindow::receiverSerialDataHandle(const QByteArray &data)
|
||||||
qDebug()<<"new data can't append to buf";
|
qDebug()<<"new data can't append to buf";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::writeBytesHandle(int bytes)
|
||||||
|
{
|
||||||
|
long long totalLen = lbSendByte->text().toLongLong();
|
||||||
|
totalLen += bytes;
|
||||||
|
lbSendByte->setText(QString::number(totalLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loginHandle()
|
void MainWindow::loginHandle()
|
||||||
|
@ -109,6 +152,12 @@ void MainWindow::loginHandle()
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::curTestInfoHandle(const QString &item, int timeCounts)
|
||||||
|
{
|
||||||
|
lbCurTestItem->setText(item);
|
||||||
|
lbCurTestTimeCounts->setText(QString::number(timeCounts));
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::btnCleanClickedHandle()
|
void MainWindow::btnCleanClickedHandle()
|
||||||
{
|
{
|
||||||
lbSendByte->setText("0");
|
lbSendByte->setText("0");
|
||||||
|
@ -140,6 +189,9 @@ void MainWindow::serialPortInit()
|
||||||
{
|
{
|
||||||
serial = new SerialPort();
|
serial = new SerialPort();
|
||||||
connect(serial,SIGNAL(recvSerialDataSignal(QByteArray)),this,SLOT(receiverSerialDataHandle(QByteArray)),Qt::QueuedConnection);
|
connect(serial,SIGNAL(recvSerialDataSignal(QByteArray)),this,SLOT(receiverSerialDataHandle(QByteArray)),Qt::QueuedConnection);
|
||||||
|
connect(this,SIGNAL(writeDataSignal(QByteArray)),serial,SLOT(writeData(QByteArray)),Qt::QueuedConnection);
|
||||||
|
connect(serial,SIGNAL(writeBytesSignal(int)),this,SLOT(writeBytesHandle(int)),Qt::QueuedConnection);
|
||||||
|
connect(serial,SIGNAL(recvSerialDataSignal(QByteArray)),&TestThread::getInstance(),SLOT(receiverSerialDataHandle(QByteArray)),Qt::QueuedConnection);
|
||||||
QStringList nameList;
|
QStringList nameList;
|
||||||
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
|
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "msgInputWin.h"
|
#include "msgInputWin.h"
|
||||||
#include "ui_msgInputWin.h"
|
#include "ui_msgInputWin.h"
|
||||||
|
#include "globalParams.h"
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
MsgInputWin::MsgInputWin(QWidget *parent)
|
MsgInputWin::MsgInputWin(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -52,6 +55,7 @@ MsgInputWin::MsgInputWin(QWidget *parent)
|
||||||
aItemList.append(aItem);
|
aItemList.append(aItem);
|
||||||
msgModel->insertRow(msgModel->rowCount(),aItemList);
|
msgModel->insertRow(msgModel->rowCount(),aItemList);
|
||||||
QComboBox *carType = new QComboBox();
|
QComboBox *carType = new QComboBox();
|
||||||
|
carType->setEditable(true);
|
||||||
ui->tableView->setIndexWidget(msgModel->index(msgModel->rowCount()-1,1),carType);
|
ui->tableView->setIndexWidget(msgModel->index(msgModel->rowCount()-1,1),carType);
|
||||||
|
|
||||||
aItemList.clear();
|
aItemList.clear();
|
||||||
|
@ -83,9 +87,76 @@ MsgInputWin::MsgInputWin(QWidget *parent)
|
||||||
aItem = new QStandardItem("");
|
aItem = new QStandardItem("");
|
||||||
aItemList.append(aItem);
|
aItemList.append(aItem);
|
||||||
msgModel->insertRow(msgModel->rowCount(),aItemList);
|
msgModel->insertRow(msgModel->rowCount(),aItemList);
|
||||||
|
|
||||||
|
connect(msgModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(dataChangedHandle(QModelIndex,QModelIndex)),Qt::QueuedConnection);
|
||||||
|
connect(carType,SIGNAL(currentTextChanged(QString)),this,SLOT(currentCarTypeChangedHandle(QString)),Qt::QueuedConnection);
|
||||||
|
readCfg();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgInputWin::~MsgInputWin()
|
MsgInputWin::~MsgInputWin()
|
||||||
{
|
{
|
||||||
|
saveCfg();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MsgInputWin::dataChangedHandle(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
|
{
|
||||||
|
if(topLeft==bottomRight && bottomRight.row()==0){
|
||||||
|
globalParams::company = msgModel->item(0,1)->text();
|
||||||
|
}else if(topLeft==bottomRight && bottomRight.row()==1){
|
||||||
|
globalParams::classGroup = msgModel->item(1,1)->text();
|
||||||
|
}else if(topLeft==bottomRight && bottomRight.row()==3){
|
||||||
|
globalParams::bdType = msgModel->item(3,1)->text();
|
||||||
|
}else if(topLeft==bottomRight && bottomRight.row()==4){
|
||||||
|
globalParams::bdSN = msgModel->item(4,1)->text();
|
||||||
|
}else if(topLeft==bottomRight && bottomRight.row()==5){
|
||||||
|
globalParams::marker = msgModel->item(5,1)->text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MsgInputWin::currentCarTypeChangedHandle(const QString &text)
|
||||||
|
{
|
||||||
|
globalParams::carType = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MsgInputWin::readCfg()
|
||||||
|
{
|
||||||
|
QSettings setting(globalParams::configPath,QSettings::IniFormat);
|
||||||
|
QString company = setting.value("information/company").toString();
|
||||||
|
QString group = setting.value("information/class_group").toString();
|
||||||
|
QString curCarType = setting.value("information/current_car_type").toString();
|
||||||
|
QString bdType = setting.value("information/bd_type").toString();
|
||||||
|
QString bdSN = setting.value("information/bd_sn").toString();
|
||||||
|
QString marker = setting.value("information/marker").toString();
|
||||||
|
|
||||||
|
msgModel->item(0,1)->setText(company);
|
||||||
|
msgModel->item(1,1)->setText(group);
|
||||||
|
QComboBox *box = qobject_cast<QComboBox *>(ui->tableView->indexWidget(msgModel->index(2,1)));
|
||||||
|
box->setCurrentText(curCarType);
|
||||||
|
msgModel->item(3,1)->setText(bdType);
|
||||||
|
msgModel->item(4,1)->setText(bdSN);
|
||||||
|
msgModel->item(5,1)->setText(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MsgInputWin::saveCfg()
|
||||||
|
{
|
||||||
|
QString company = msgModel->item(0,1)->text();
|
||||||
|
QString group = msgModel->item(1,1)->text();
|
||||||
|
|
||||||
|
QComboBox *box = qobject_cast<QComboBox *>(ui->tableView->indexWidget(msgModel->index(2,1)));
|
||||||
|
|
||||||
|
QString curCarType = box->currentText();
|
||||||
|
QString bdType = msgModel->item(3,1)->text();
|
||||||
|
QString bdSN = msgModel->item(4,1)->text();
|
||||||
|
QString marker = msgModel->item(5,1)->text();
|
||||||
|
|
||||||
|
QSettings setting(globalParams::configPath,QSettings::IniFormat);
|
||||||
|
setting.setValue("information/company",company);
|
||||||
|
setting.setValue("information/class_group",group);
|
||||||
|
setting.setValue("information/current_car_type",curCarType);
|
||||||
|
setting.setValue("information/bd_type",bdType);
|
||||||
|
setting.setValue("information/bd_sn",bdSN);
|
||||||
|
setting.setValue("information/marker",marker);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
SerialPort::SerialPort(QObject *parent) : QObject(parent)
|
SerialPort::SerialPort(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
serial = new QSerialPort;
|
serial = new QSerialPort;
|
||||||
thread = new QThread;
|
//thread = new QThread;
|
||||||
this->moveToThread(thread);
|
//this->moveToThread(thread);
|
||||||
thread->start();
|
//thread->start();
|
||||||
connect(serial,SIGNAL(readyRead()),this,SLOT(readData()),Qt::QueuedConnection);
|
connect(serial,SIGNAL(readyRead()),this,SLOT(readData()),Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,17 +67,11 @@ int SerialPort::getBaud()
|
||||||
return curBaud;
|
return curBaud;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialPort::writeData(const QString &cmd)
|
|
||||||
{
|
|
||||||
if(serial && serial->isOpen()){
|
|
||||||
serial->write(cmd.toLocal8Bit());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SerialPort::writeData(const QByteArray &buf)
|
void SerialPort::writeData(const QByteArray &buf)
|
||||||
{
|
{
|
||||||
if(serial && serial->isOpen()){
|
if(serial && serial->isOpen()){
|
||||||
serial->write(buf);
|
int size = serial->write(buf);
|
||||||
|
writeBytesSignal(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ void SQLITEDB::openDateBase()
|
||||||
}else{
|
}else{
|
||||||
qDebug()<<"打开数据库成功";
|
qDebug()<<"打开数据库成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tableExist("USERS")){
|
if(!tableExist("USERS")){
|
||||||
QSqlQuery query(DB);
|
QSqlQuery query(DB);
|
||||||
query.prepare("CREATE TABLE [USERS](\
|
query.prepare("CREATE TABLE [USERS](\
|
||||||
|
@ -51,6 +52,83 @@ void SQLITEDB::openDateBase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!tableExist("INFORMATION")){
|
||||||
|
QSqlQuery query(DB);
|
||||||
|
query.prepare("CREATE TABLE [INFORMATION](\
|
||||||
|
[BDSN] TEXT(32) PRIMARY KEY NOT NULL, \
|
||||||
|
[TESTER] TEXT(255), \
|
||||||
|
[TEST_TIME] DATETIME, \
|
||||||
|
[COMPANY] TEXT(255), \
|
||||||
|
[GROUP] TEXT(255), \
|
||||||
|
[BD_TYPE] TEXT(255), \
|
||||||
|
[CAR_TYPE] TEXT(255), \
|
||||||
|
[MAKER] TEXT(255));");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tableExist("INTERFACE_TEST")){
|
||||||
|
QSqlQuery query(DB);
|
||||||
|
query.prepare("CREATE TABLE [INTERFACE_TEST](\
|
||||||
|
[BDSN] TEXT(32) PRIMARY KEY NOT NULL, \
|
||||||
|
[TESTER] TEXT(255), \
|
||||||
|
[TEST_TIME] DATETIME, \
|
||||||
|
[SERIAL_SEND] TEXT(10), \
|
||||||
|
[SERIAL_RECV] TEXT(10), \
|
||||||
|
[CAN_SEND] TEXT(10), \
|
||||||
|
[CAN_RECV] TEXT(10));");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tableExist("POSITION_PRECISION")){
|
||||||
|
QSqlQuery query(DB);
|
||||||
|
query.prepare("CREATE TABLE [POSITION_PRECISION](\
|
||||||
|
[BDSN] TEXT(32) NOT NULL, \
|
||||||
|
[TEST_TIME] DATETIME, \
|
||||||
|
[TESTER] TEXT(255), \
|
||||||
|
[MODE] TEXT(32) NOT NULL, \
|
||||||
|
[REF_LAT] TEXT(16), \
|
||||||
|
[REF_LON] TEXT(16), \
|
||||||
|
[SAMPLE_POINTS] TEXT(10), \
|
||||||
|
[HORIZONTAL_ERR] TEXT(10), \
|
||||||
|
[VERTICAL_ERR] TEXT(10));");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tableExist("POSITION_TEST")){
|
||||||
|
QSqlQuery query(DB);
|
||||||
|
query.prepare("CREATE TABLE [POSITION_TEST](\
|
||||||
|
[BDSN] TEXT(32) NOT NULL, \
|
||||||
|
[TESTER] TEXT(255), \
|
||||||
|
[TEST_TIME] DATETIME, \
|
||||||
|
[MODE] TEXT(32) NOT NULL, \
|
||||||
|
[TIME] TEXT(32), \
|
||||||
|
[LONGITUDE] TEXT(16), \
|
||||||
|
[LATITUDE] TEXT(16), \
|
||||||
|
[HEIGHT] TEXT(16), \
|
||||||
|
[PDOP] TEXT(8), \[VDOP] TEXT(8), \
|
||||||
|
[HDOP] TEXT(8), \
|
||||||
|
[SAT_NUM] TEXT(8), \
|
||||||
|
PRIMARY KEY([BDSN], [MODE]));");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tableExist("STATUS")){
|
||||||
|
QSqlQuery query(DB);
|
||||||
|
query.prepare("CREATE TABLE [STATUS](\
|
||||||
|
[BDSN] TEXT(32) PRIMARY KEY NOT NULL, \
|
||||||
|
[TESTER] TEXT(255), \
|
||||||
|
[TEST_TIME] DATETIME, \
|
||||||
|
[RNSS_SN] TEXT(32), \
|
||||||
|
[RDSS_SN] TEXT(32), \
|
||||||
|
[MPD009] TEXT(32), \
|
||||||
|
[MPD007] TEXT(32), \
|
||||||
|
[PRM] TEXT(32), \
|
||||||
|
[MPD007_VALID_DATE] TEXT(255), \
|
||||||
|
[PRM_VALID_DATE] TEXT(255), \
|
||||||
|
[BD_ID_NUM] TEXT(10), \
|
||||||
|
[BD_SERVICE_FEQ] TEXT(10), \
|
||||||
|
[BD_COMMUNICATION_LEVEL] TEXT(10), \
|
||||||
|
[BD_BROCAST_ADDRESS] TEXT(12), \
|
||||||
|
[BD_SECRECY_MARK] TEXT(10));");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQLITEDB::closeDateBase()
|
void SQLITEDB::closeDateBase()
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
#include "testThread.h"
|
||||||
|
|
||||||
|
bool TestThread::setTestList(const QVector<TEST_TYPE> &list)
|
||||||
|
{
|
||||||
|
if(onTest){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
testList = list;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestThread::stopTest()
|
||||||
|
{
|
||||||
|
quit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestThread::isOnTest()
|
||||||
|
{
|
||||||
|
return onTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
TestThread::TestThread() {}
|
||||||
|
|
||||||
|
TestThread::~TestThread() {}
|
||||||
|
|
||||||
|
void TestThread::receiverSerialDataHandle(const QByteArray &data)
|
||||||
|
{
|
||||||
|
if(!onTest){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unprocessData.append(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestThread::run()
|
||||||
|
{
|
||||||
|
onTest = true;
|
||||||
|
quit = false;
|
||||||
|
for(int i=0;i<testList.size();i++){
|
||||||
|
if(quit){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TEST_TYPE type = testList[i];
|
||||||
|
switch (type) {
|
||||||
|
case SERIAL:
|
||||||
|
{
|
||||||
|
for(int i=0;i<11;i++){//等10秒后看看是否串口有输出
|
||||||
|
if(quit){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
emit curTestInfoSignal("串口接收",i);
|
||||||
|
if(i<9){//9秒前把数据清空
|
||||||
|
unprocessData.clear();
|
||||||
|
}
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
if(unprocessData.size()>0){
|
||||||
|
emit serialRecvResultSignal(true);
|
||||||
|
}else{
|
||||||
|
emit serialRecvResultSignal(false);
|
||||||
|
}
|
||||||
|
unprocessData.clear();
|
||||||
|
//todo
|
||||||
|
bool bsend = false;
|
||||||
|
for(int i=0;i<5;i++){//测试串口发送
|
||||||
|
if(quit){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
emit curTestInfoSignal("串口发送",i);
|
||||||
|
emit writeDataSignal("version\r\n");
|
||||||
|
sleep(1);
|
||||||
|
QString txt = QString::fromLatin1(unprocessData);
|
||||||
|
if(txt.contains("v")){
|
||||||
|
bsend = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit serialSendResultSignal(bsend);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onTest = false;
|
||||||
|
}
|
|
@ -6,6 +6,13 @@ namespace globalParams
|
||||||
{
|
{
|
||||||
extern QString curUserId;
|
extern QString curUserId;
|
||||||
extern QString curUserType;
|
extern QString curUserType;
|
||||||
|
extern QString configPath;
|
||||||
|
extern QString company;
|
||||||
|
extern QString bdType;
|
||||||
|
extern QString carType;
|
||||||
|
extern QString classGroup;
|
||||||
|
extern QString bdSN;
|
||||||
|
extern QString marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // GLOBALPARAMS_H
|
#endif // GLOBALPARAMS_H
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
|
#include "sqlitedb.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class InterfaceTestWin;
|
class InterfaceTestWin;
|
||||||
|
@ -17,6 +18,11 @@ public:
|
||||||
explicit InterfaceTestWin(QWidget *parent = nullptr);
|
explicit InterfaceTestWin(QWidget *parent = nullptr);
|
||||||
~InterfaceTestWin();
|
~InterfaceTestWin();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void serialRecvResultHandle(bool result);
|
||||||
|
void serialSendResultHandle(bool result);
|
||||||
|
void on_btnSerialTest_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::InterfaceTestWin *ui;
|
Ui::InterfaceTestWin *ui;
|
||||||
QStandardItemModel *serialModel;
|
QStandardItemModel *serialModel;
|
||||||
|
|
|
@ -19,9 +19,14 @@ public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void writeDataSignal(const QByteArray &buf);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void receiverSerialDataHandle(const QByteArray &data);
|
void receiverSerialDataHandle(const QByteArray &data);
|
||||||
|
void writeBytesHandle(int bytes);
|
||||||
void loginHandle();
|
void loginHandle();
|
||||||
|
void curTestInfoHandle(const QString &item,int timeCounts);
|
||||||
void btnCleanClickedHandle();
|
void btnCleanClickedHandle();
|
||||||
void on_tbtnFresh_clicked();
|
void on_tbtnFresh_clicked();
|
||||||
void on_tbtnConnect_clicked();
|
void on_tbtnConnect_clicked();
|
||||||
|
@ -34,6 +39,8 @@ private:
|
||||||
QLabel *lbComStatus;
|
QLabel *lbComStatus;
|
||||||
QLabel *lbSendByte;
|
QLabel *lbSendByte;
|
||||||
QLabel *lbRecvByte;
|
QLabel *lbRecvByte;
|
||||||
|
QLabel *lbCurTestItem;
|
||||||
|
QLabel *lbCurTestTimeCounts;
|
||||||
bool bconnected = false;
|
bool bconnected = false;
|
||||||
void serialPortInit();
|
void serialPortInit();
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,10 +17,16 @@ public:
|
||||||
explicit MsgInputWin(QWidget *parent = nullptr);
|
explicit MsgInputWin(QWidget *parent = nullptr);
|
||||||
~MsgInputWin();
|
~MsgInputWin();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void dataChangedHandle(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
||||||
|
void currentCarTypeChangedHandle(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MsgInputWin *ui;
|
Ui::MsgInputWin *ui;
|
||||||
QStandardItemModel *msgModel;
|
QStandardItemModel *msgModel;
|
||||||
QItemSelectionModel *msgSelect;
|
QItemSelectionModel *msgSelect;
|
||||||
|
void readCfg();
|
||||||
|
void saveCfg();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MSGINPUTWIN_H
|
#endif // MSGINPUTWIN_H
|
||||||
|
|
|
@ -14,9 +14,9 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void recvSerialDataSignal(const QByteArray &buf);
|
void recvSerialDataSignal(const QByteArray &buf);
|
||||||
|
void writeBytesSignal(int bytes);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void writeData(const QString &cmd);
|
|
||||||
void writeData(const QByteArray &buf);
|
void writeData(const QByteArray &buf);
|
||||||
void readData();
|
void readData();
|
||||||
bool open();
|
bool open();
|
||||||
|
|
|
@ -34,9 +34,6 @@ public:
|
||||||
QVector<QMap<QString,QString>> getRecord(const QString &table,const QMap<QString,QString> &condition);
|
QVector<QMap<QString,QString>> getRecord(const QString &table,const QMap<QString,QString> &condition);
|
||||||
bool saveRecord(const QString &table,const QMap<QString,QString> &map);
|
bool saveRecord(const QString &table,const QMap<QString,QString> &map);
|
||||||
|
|
||||||
signals:
|
|
||||||
void synchronismPercentSignal(int per);
|
|
||||||
void displayLogSignal(const QString &txt,const QColor &color);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SQLITEDB_H
|
#endif // SQLITEDB_H
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef TESTTHREAD_H
|
||||||
|
#define TESTTHREAD_H
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SERIAL = 0,
|
||||||
|
CAN,
|
||||||
|
}TEST_TYPE;
|
||||||
|
|
||||||
|
class TestThread : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static TestThread& getInstance()
|
||||||
|
{
|
||||||
|
static TestThread instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
bool setTestList(const QVector<TEST_TYPE> &list);
|
||||||
|
void stopTest();
|
||||||
|
bool isOnTest();
|
||||||
|
private:
|
||||||
|
TestThread();
|
||||||
|
~TestThread();
|
||||||
|
TestThread(const TestThread&);
|
||||||
|
TestThread& operator=(const TestThread&);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void writeDataSignal(const QByteArray &buf);
|
||||||
|
void serialRecvResultSignal(bool result);
|
||||||
|
void serialSendResultSignal(bool result);
|
||||||
|
void curTestInfoSignal(const QString &item,int timeCounts);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void receiverSerialDataHandle(const QByteArray &data);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void run() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<TEST_TYPE> testList;
|
||||||
|
bool onTest = false;
|
||||||
|
bool quit = false;
|
||||||
|
QByteArray unprocessData;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TESTTHREAD_H
|
|
@ -136,6 +136,12 @@
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Microsoft YaHei</family>
|
<family>Microsoft YaHei</family>
|
||||||
|
|
Loading…
Reference in New Issue