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-29 14:26:45 +00:00
|
|
|
#include "network_controller.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-05-01 06:09:18 +00:00
|
|
|
#include <QtQuickWidgets/QQuickWidget>
|
2021-04-11 03:28:04 +00:00
|
|
|
|
2021-07-19 15:52:38 +00:00
|
|
|
class QmlShareData;
|
2021-04-17 17:57:39 +00:00
|
|
|
|
2021-07-19 15:52:38 +00:00
|
|
|
extern QmlShareData gGlobal;
|
2021-04-17 17:57:39 +00:00
|
|
|
|
|
|
|
// 桥接Lua虚拟机和qml界面
|
2021-07-19 15:52:38 +00:00
|
|
|
class QmlShareData : 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:
|
2021-07-19 15:52:38 +00:00
|
|
|
explicit QmlShareData(QObject *parent = nullptr);
|
2021-05-01 06:09:18 +00:00
|
|
|
int SetQuickView(QQuickWidget *);
|
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-18 15:16:03 +00:00
|
|
|
int SendUartData(const char *);
|
2021-04-12 15:39:06 +00:00
|
|
|
|
2021-04-11 03:28:04 +00:00
|
|
|
Q_INVOKABLE void getValFromQml(int v) {
|
|
|
|
emit valueFromCpp(456);
|
|
|
|
}
|
2021-04-12 15:39:06 +00:00
|
|
|
|
2021-04-24 17:21:31 +00:00
|
|
|
Q_INVOKABLE int openUart(QString port,QString baudRate,QString dataBits,QString stopBits,
|
2021-04-12 15:39:06 +00:00
|
|
|
QString flow);
|
2021-05-01 15:41:40 +00:00
|
|
|
Q_INVOKABLE int openNetwork(QString ip,unsigned int port,bool is_ws,int type);
|
2021-05-03 05:50:07 +00:00
|
|
|
Q_INVOKABLE int closeNetwork();
|
|
|
|
|
2021-04-24 17:21:31 +00:00
|
|
|
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-24 17:21:31 +00:00
|
|
|
Q_INVOKABLE int updateLuaScript(QString);
|
|
|
|
Q_INVOKABLE int saveLuaScript(QString);
|
|
|
|
Q_INVOKABLE bool luaStatus();
|
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-08-29 15:50:41 +00:00
|
|
|
void sendToQml(int count);
|
|
|
|
void disConnected();
|
|
|
|
|
2021-05-03 08:49:33 +00:00
|
|
|
public slots:
|
|
|
|
void on_network_data_recv();
|
2021-08-29 15:50:41 +00:00
|
|
|
void on_network_conected();
|
|
|
|
void on_network_disconected();
|
|
|
|
|
2021-04-12 15:39:06 +00:00
|
|
|
private:
|
2021-04-29 14:26:45 +00:00
|
|
|
NetworkController *m_network_;
|
|
|
|
SerialController *m_serial_controller_;
|
|
|
|
LuaDelegate m_lua_;
|
|
|
|
QObject *m_qml_protodebug_;
|
|
|
|
QObject *m_root_obj_;
|
|
|
|
bool m_luavm_status_;
|
|
|
|
QString m_lua_string;
|
2021-05-01 06:09:18 +00:00
|
|
|
QQuickWidget *m_qml_view_;
|
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
|