proto-debuger/protoDebuger/sharedata.h

66 lines
1.4 KiB
C
Raw Normal View History

2021-04-11 03:28:04 +00:00
#ifndef SHAREDATA_H
#define SHAREDATA_H
2021-04-12 15:39:06 +00:00
#include "serialcontroller.h"
2021-04-16 18:27:32 +00:00
#include "qserialproto.h"
2021-04-11 03:28:04 +00:00
#include <QObject>
#include <QDebug>
2021-04-14 16:52:05 +00:00
#include "lua_wraper.h"
2021-04-17 17:57:39 +00:00
#include <QQuickView>
2021-04-11 03:28:04 +00:00
2021-04-17 17:57:39 +00:00
class ShareData;
extern ShareData gGlobal;
// 桥接Lua虚拟机和qml界面
class ShareData : public QObject ,SerialController::SerialListener
2021-04-11 03:28:04 +00:00
{
Q_OBJECT
2021-04-12 15:39:06 +00:00
Q_PROPERTY(QString _txt READ rtxt WRITE settxt NOTIFY txtchanged)
2021-04-11 03:28:04 +00:00
public:
explicit ShareData(QObject *parent = nullptr);
2021-04-17 17:57:39 +00:00
int SetQuickView(QQuickView *);
2021-04-12 15:39:06 +00:00
QString rtxt() const{
return _txt;
}
void settxt(QString s){
_txt = s;
emit txtchanged();
}
2021-04-17 17:57:39 +00:00
int OnDataRecv(QByteArray);
int ShowDataInQML(QString x);
2021-04-12 15:39:06 +00:00
2021-04-11 03:28:04 +00:00
Q_INVOKABLE void getValFromQml(int v) {
qDebug() << "value from qml is :" << v;
emit valueFromCpp(456);
}
2021-04-12 15:39:06 +00:00
Q_INVOKABLE int OpenUart(QString port,QString baudRate,QString dataBits,QString stopBits,
QString flow);
Q_INVOKABLE int CloseSerial();
2021-04-14 16:52:05 +00:00
Q_INVOKABLE int TestLua();
2021-04-16 18:27:32 +00:00
Q_INVOKABLE int TestShowData();
2021-04-14 16:52:05 +00:00
2021-04-12 15:39:06 +00:00
QString _txt = "hello world\r\n";
2021-04-11 03:28:04 +00:00
signals:
2021-04-12 15:39:06 +00:00
void txtchanged();
2021-04-11 03:28:04 +00:00
void valueFromCpp(int val);
2021-04-12 15:39:06 +00:00
private:
SerialController *mSerialController;
2021-04-14 16:52:05 +00:00
LuaDelegate mLua;
2021-04-16 18:27:32 +00:00
QObject *mProtoDebug;
2021-04-17 17:57:39 +00:00
QObject *mRootObj;
QString mLuaScript;
QQuickView *mView;
2021-04-11 03:28:04 +00:00
};
2021-04-17 17:57:39 +00:00
2021-04-11 03:28:04 +00:00
#endif // SHAREDATA_H