From 0db40d2998f728687a6a701e4a8b1e4a8424e5d6 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Wed, 14 Apr 2021 01:28:19 +0800 Subject: [PATCH] no message --- protoDebuger/ProtoDebug.qml | 70 +++++++++++++++++++++++++++++++ protoDebuger/SerialSelect.qml | 7 +++- protoDebuger/lua_wraper.h | 14 +++++++ protoDebuger/main.cpp | 1 + protoDebuger/main.qml | 8 +--- protoDebuger/qml.qrc | 1 + protoDebuger/serialcontroller.cpp | 1 + protoDebuger/sharedata.cpp | 7 +++- 8 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 protoDebuger/ProtoDebug.qml diff --git a/protoDebuger/ProtoDebug.qml b/protoDebuger/ProtoDebug.qml new file mode 100644 index 0000000..0c4749f --- /dev/null +++ b/protoDebuger/ProtoDebug.qml @@ -0,0 +1,70 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.14 +import QtQuick.Layouts 1.0 + + +Item { + objectName: "ProtoDebug" + width: parent.width - 80 + height: parent.height +// width: 800 +// height: 600 + property var comlist: [] + visible: true + property bool uart_open: false + + ColorAnimation { + from: "white" + to: "black" + duration: 200 + } + Rectangle{ + width: parent.width + height: parent.height + color: "#aeaeae" + scale: 1 + transformOrigin: Item.Center + + Label { + id: label + x: 49 + y: 30 + text: qsTr("lua脚本:") + Layout.preferredHeight: 26 + Layout.preferredWidth: 179 + } + + TextArea { + id: text_output + x: 8 + y: 75 + width: parent.width/2.1 + height: parent.height - 150 + color: "black" + text: qsTr("") + + } + + TextEdit { + id: lua_script + x: 411 + y: 75 + width: parent.width/2.1 + height: parent.height - 150 + text: qsTr("") + Layout.columnSpan: 2 + + font.pixelSize: 12 + } + + Button { + id: button + x: 344 + y: 540 + text: qsTr("更新lua脚本") + Layout.preferredHeight: 41 + Layout.preferredWidth: 116 + } + + } +} diff --git a/protoDebuger/SerialSelect.qml b/protoDebuger/SerialSelect.qml index 283a3b5..1e2641d 100644 --- a/protoDebuger/SerialSelect.qml +++ b/protoDebuger/SerialSelect.qml @@ -195,8 +195,11 @@ Item { button.text = "关闭串口" } }else{ - - + let ret = DataWrap.CloseSerial(); + if(ret == 0){ + button.text = "打开串口" + uart_open = false + } } diff --git a/protoDebuger/lua_wraper.h b/protoDebuger/lua_wraper.h index 3027286..55a8c50 100644 --- a/protoDebuger/lua_wraper.h +++ b/protoDebuger/lua_wraper.h @@ -17,6 +17,20 @@ void TestLua(){ printf("shit is nullptr"); } luaL_openlibs(L); //打开标准库 + int ret = luaL_dofile(L, "Test.lua"); + if (ret > 0){ + printf("lua error"); + } + int sum; + //code5 + lua_getglobal(L, "add"); + //code6 + char * data = "hell"; + lua_pushstring(L, data); + //code7 + lua_pushnumber(L, 4); + //code8 + lua_call(L, 2, 1); lua_close(L); } diff --git a/protoDebuger/main.cpp b/protoDebuger/main.cpp index 3cfc4d8..3def8d3 100644 --- a/protoDebuger/main.cpp +++ b/protoDebuger/main.cpp @@ -40,6 +40,7 @@ int main(int argc, char *argv[]) view.rootContext()->setContextProperty("DataWrap",&gGlobal); view.show(); + TestLua(); QObject *qmlObject = view.findChild("SerialSelect",Qt::FindChildOption::FindChildrenRecursively); qmlObject->setProperty("comlist",comList); diff --git a/protoDebuger/main.qml b/protoDebuger/main.qml index 5abc0dc..68d151b 100644 --- a/protoDebuger/main.qml +++ b/protoDebuger/main.qml @@ -9,8 +9,6 @@ Rectangle { width: 800 height: 600 visible: true -// minimumHeight: 600 -// minimumWidth: 800 Flow{ @@ -109,15 +107,13 @@ Rectangle { id: net_choose } - - Rectangle { + ProtoDebug{ id: proto_debug width: parent.width - 80 height: parent.height - color: "grey" visible: false - } + } } diff --git a/protoDebuger/qml.qrc b/protoDebuger/qml.qrc index 985b2a2..30dbee3 100644 --- a/protoDebuger/qml.qrc +++ b/protoDebuger/qml.qrc @@ -6,5 +6,6 @@ res/proto.svg SerialSelect.qml NetSelect.qml + ProtoDebug.qml diff --git a/protoDebuger/serialcontroller.cpp b/protoDebuger/serialcontroller.cpp index cf182e9..a6cc9ba 100644 --- a/protoDebuger/serialcontroller.cpp +++ b/protoDebuger/serialcontroller.cpp @@ -3,6 +3,7 @@ SerialController::SerialController(QObject *parent) : QObject(parent) ,mCurrentPort(nullptr) ,mProto(nullptr) + ,mConnected(false) { } diff --git a/protoDebuger/sharedata.cpp b/protoDebuger/sharedata.cpp index 29b0ac3..6a3b6fd 100644 --- a/protoDebuger/sharedata.cpp +++ b/protoDebuger/sharedata.cpp @@ -19,5 +19,10 @@ int ShareData::OpenUart(QString port, QString baudRate, QString dataBits, QStrin int ShareData::CloseSerial() { - + if(mSerialController->CloseSerial() == 0){ + qDebug()<<"close serial ok"; + return 0; + } + qDebug()<<"cloase serial failed"; + return -1; }