-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
coderZMR
committed
Feb 27, 2021
1 parent
043c071
commit fc10d56
Showing
28 changed files
with
63,242 additions
and
6,229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,81 @@ | ||
#ifndef DATA_H | ||
#define DATA_H | ||
|
||
#include <QByteArray> | ||
#include <QString> | ||
#include <QObject> | ||
|
||
class Data : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(float agx READ getanX WRITE setanX NOTIFY sendagXChange) | ||
Q_PROPERTY(float agy READ getanY WRITE setanY NOTIFY sendagYChange) | ||
Q_PROPERTY(float agz READ getanZ WRITE setanZ NOTIFY sendagZChange) | ||
|
||
public: | ||
static Data *getInstance(); | ||
void init(); | ||
void analyze(QByteArray &data); | ||
|
||
void setacX(float acX); | ||
float getacX(); | ||
void setacY(float acY); | ||
float getacY(); | ||
void setacZ(float acZ); | ||
float getacZ(); | ||
|
||
void setavX(float avX); | ||
float getavX(); | ||
void setavY(float avY); | ||
float getavY(); | ||
void setavZ(float avZ); | ||
float getavZ(); | ||
|
||
void setanX(float anX); | ||
float getanX(); | ||
void setanY(float anY); | ||
float getanY(); | ||
void setanZ(float anZ); | ||
float getanZ(); | ||
|
||
void setgunValue(float gunValue); | ||
float getgunValue(); | ||
|
||
void settemperatureValue(float temperatureValue); | ||
float gettemperatureValue(); | ||
|
||
void setltf(float staute); | ||
float getltf(); | ||
|
||
void setlts(float statue); | ||
float getlts(); | ||
|
||
// 测试 | ||
void test(); | ||
private: | ||
Data(); | ||
static Data *myData; | ||
float acX; | ||
float acY; | ||
float acZ; | ||
float avX; | ||
float avY; | ||
float avZ; | ||
float anX; | ||
float anY; | ||
float anZ; | ||
float ltf; | ||
float lts; | ||
float gunValue; | ||
float temperatureValue; | ||
QString getData; | ||
|
||
signals: | ||
void sendagXChange(void); | ||
void sendagYChange(void); | ||
void sendagZChange(void); | ||
}; | ||
|
||
#endif // DATA_H | ||
#ifndef DATA_H | ||
#define DATA_H | ||
|
||
#include <QByteArray> | ||
#include <QString> | ||
#include <QtGlobal> | ||
#include <QObject> | ||
|
||
class Data : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(float agx READ getanX WRITE setanX NOTIFY sendagXChange) | ||
Q_PROPERTY(float agy READ getanY WRITE setanY NOTIFY sendagYChange) | ||
Q_PROPERTY(float agz READ getanZ WRITE setanZ NOTIFY sendagZChange) | ||
|
||
public: | ||
static Data *getInstance(); | ||
void init(); | ||
void analyze(QByteArray &data); | ||
|
||
void setacX(float acX); | ||
float getacX(); | ||
void setacY(float acY); | ||
float getacY(); | ||
void setacZ(float acZ); | ||
float getacZ(); | ||
|
||
void setavX(float avX); | ||
float getavX(); | ||
void setavY(float avY); | ||
float getavY(); | ||
void setavZ(float avZ); | ||
float getavZ(); | ||
|
||
void setanX(float anX); | ||
Q_INVOKABLE float getanX(); | ||
void setanY(float anY); | ||
Q_INVOKABLE float getanY(); | ||
void setanZ(float anZ); | ||
Q_INVOKABLE float getanZ(); | ||
|
||
void setgunValue(float gunValue); | ||
float getgunValue(); | ||
|
||
void settemperatureValue(float temperatureValue); | ||
float gettemperatureValue(); | ||
|
||
void setltf(float staute); | ||
float getltf(); | ||
|
||
void setlts(float statue); | ||
float getlts(); | ||
|
||
// 测试 | ||
void test(); | ||
private: | ||
Data(); | ||
static Data *myData; | ||
float acX; | ||
float acY; | ||
float acZ; | ||
float avX; | ||
float avY; | ||
float avZ; | ||
float anX; | ||
float anY; | ||
float anZ; | ||
float ltf; | ||
float lts; | ||
float gunValue; | ||
float temperatureValue; | ||
QString getData; | ||
|
||
signals: | ||
void sendagXChange(void); | ||
void sendagYChange(void); | ||
void sendagZChange(void); | ||
}; | ||
|
||
#endif // DATA_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,70 @@ | ||
#include "mainwindow.h" | ||
#include <QApplication> | ||
#include <QDesktopWidget> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
//使程序可处理中文 | ||
// QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); | ||
// QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf_8")); | ||
|
||
// 界面加载 | ||
MainWindow w; | ||
|
||
w.show(); | ||
w.move((QApplication::desktop()->width() - w.width()) / 2, | ||
(QApplication::desktop()->height() - w.height()) / 2); | ||
|
||
|
||
return a.exec(); | ||
} | ||
|
||
// 要先打开串口再对它进行设置,不然设置就不会起作用 | ||
// 正确的顺序:先定义Win_QextSerialPort类对象,然后打开串口,再用那几个设置函数对串口进行设置 | ||
// 事件驱动EventDriven下设置串口的延迟不会起作用,一旦有数据来到即会触发readyRead()信号 | ||
// 查询模式Polling下设置串口的延迟会决定读取串口数据的时间间隔 | ||
// timeout 底层读串口数据将读到的数据写入串口缓冲区(myCom->setTimeout(间隔时间ms));间隔时间应该较小 | ||
// readTime->start(间隔时间ms)设置的是读串口缓冲区中的数据,间隔时间应该比timeout大 | ||
#include "mainwindow.h" | ||
#include <QApplication> | ||
#include <QTextCodec> | ||
#include <QDesktopWidget> | ||
#include <QPixmap> | ||
#include <QSplashScreen> | ||
#include <QTimer> | ||
#include <QPropertyAnimation> | ||
|
||
// 3D | ||
#include <window.h> | ||
#include <Qt3DRenderer/qrenderaspect.h> | ||
#include <Qt3DInput/QInputAspect> | ||
#include <Qt3DQuick/QQmlAspectEngine> | ||
#include <QGuiApplication> | ||
#include <QQmlContext> | ||
#include <QQmlEngine> | ||
#include <data.h> | ||
|
||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
//使程序可处理中文 | ||
// QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); | ||
// QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf_8")); | ||
// 数据流加载 | ||
Data *startData = Data::getInstance(); | ||
|
||
// 3D加载 | ||
Window view; | ||
Qt3D::Quick::QQmlAspectEngine engine; | ||
|
||
view.resize(700, 500); | ||
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect()); | ||
engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect()); | ||
engine.aspectEngine()->initialize(); | ||
QVariantMap data; | ||
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view))); | ||
data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); | ||
engine.aspectEngine()->setData(data); | ||
engine.qmlEngine()->rootContext()->setContextProperty("_window", &view); | ||
engine.qmlEngine()->rootContext()->setContextProperty("_data", startData); | ||
engine.setSource(QUrl("qrc:/main.qml")); | ||
|
||
// 界面加载 | ||
MainWindow w; | ||
|
||
QPixmap pixmap(":/new/prefix1/uwrPic"); | ||
QSplashScreen splash(pixmap); | ||
|
||
// 显示所有窗口 | ||
splash.show(); | ||
|
||
QTimer::singleShot(1500, &splash, SLOT(hide())); | ||
QTimer::singleShot(2000, &w, SLOT(show())); | ||
QTimer::singleShot(2500, &view, SLOT(show())); | ||
w.move((QApplication::desktop()->width() - w.width()) / 2, | ||
(QApplication::desktop()->height() - w.height()) / 2); | ||
|
||
|
||
return a.exec(); | ||
} | ||
|
||
// 要先打开串口再对它进行设置,不然设置就不会起作用 | ||
// 正确的顺序:先定义Win_QextSerialPort类对象,然后打开串口,再用那几个设置函数对串口进行设置 | ||
// 事件驱动EventDriven下设置串口的延迟不会起作用,一旦有数据来到即会触发readyRead()信号 | ||
// 查询模式Polling下设置串口的延迟会决定读取串口数据的时间间隔 | ||
// timeout 底层读串口数据将读到的数据写入串口缓冲区(myCom->setTimeout(间隔时间ms));间隔时间应该较小 | ||
// readTime->start(间隔时间ms)设置的是读串口缓冲区中的数据,间隔时间应该比timeout大 |
Oops, something went wrong.