no message

master
zcy 2021-04-14 01:28:19 +08:00
parent 0fb27dff7b
commit 0db40d2998
8 changed files with 100 additions and 9 deletions

View File

@ -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
}
}
}

View File

@ -195,8 +195,11 @@ Item {
button.text = "关闭串口"
}
}else{
let ret = DataWrap.CloseSerial();
if(ret == 0){
button.text = "打开串口"
uart_open = false
}
}

View File

@ -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);
}

View File

@ -40,6 +40,7 @@ int main(int argc, char *argv[])
view.rootContext()->setContextProperty("DataWrap",&gGlobal);
view.show();
TestLua();
QObject *qmlObject = view.findChild<QObject*>("SerialSelect",Qt::FindChildOption::FindChildrenRecursively);
qmlObject->setProperty("comlist",comList);

View File

@ -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
}
}
}

View File

@ -6,5 +6,6 @@
<file>res/proto.svg</file>
<file>SerialSelect.qml</file>
<file>NetSelect.qml</file>
<file>ProtoDebug.qml</file>
</qresource>
</RCC>

View File

@ -3,6 +3,7 @@
SerialController::SerialController(QObject *parent) : QObject(parent)
,mCurrentPort(nullptr)
,mProto(nullptr)
,mConnected(false)
{
}

View File

@ -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;
}