From c73e26c0bfd6036ca6a818e38475336f9bc9c38c Mon Sep 17 00:00:00 2001
From: zcy <290198252@qq.com>
Date: Sun, 22 Jan 2023 00:01:26 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84modbus=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
examples/libmodbus/libmodbus.vcxproj | 1 +
examples/proto_debuger/base_form.cpp | 2 +-
examples/proto_debuger/lua_bind.cpp | 9 +++------
examples/proto_debuger/modbus_form.cpp | 14 ++++++++------
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/examples/libmodbus/libmodbus.vcxproj b/examples/libmodbus/libmodbus.vcxproj
index bca078d3..817507b3 100644
--- a/examples/libmodbus/libmodbus.vcxproj
+++ b/examples/libmodbus/libmodbus.vcxproj
@@ -79,6 +79,7 @@
true
D:\project\c++\nim_duilib\examples\libmodbus\;$(IncludePath)
+ D:\project\c++\nim_duilib\examples\libmodbus\src;$(PublicIncludeDirectories)
false
diff --git a/examples/proto_debuger/base_form.cpp b/examples/proto_debuger/base_form.cpp
index 19913e0c..34c8af66 100644
--- a/examples/proto_debuger/base_form.cpp
+++ b/examples/proto_debuger/base_form.cpp
@@ -561,7 +561,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (mModbusMasterForm.find(p->name) == mModbusMasterForm.end()) {
auto form = new ModbusMasterForm(this, p->name, p->baurate, p->port_num,
p->data_bits, p->stop_bits, p->verify, p->flow_control);
- form->SetChildLayoutXML(L"basic/uart_form.xml");
+ form->SetChildLayoutXML(L"basic/modbus_master_form.xml");
form->SetName(p->name);
form->SetVisible(false);
mModbusMasterForm[p->name] = form;
diff --git a/examples/proto_debuger/lua_bind.cpp b/examples/proto_debuger/lua_bind.cpp
index d14b9234..2e43bd23 100644
--- a/examples/proto_debuger/lua_bind.cpp
+++ b/examples/proto_debuger/lua_bind.cpp
@@ -4,8 +4,7 @@
#include "global.h"
// 在qml界面中显示lua层处理过的数据
-int LuaShowData(lua_State* vm)
-{
+int LuaShowData(lua_State* vm) {
// 获取函数参数:从栈底取一个参数
const char* k = lua_tostring(vm, 1);
if (nullptr != k) {
@@ -21,15 +20,13 @@ int LuaShowData(lua_State* vm)
}
//
-int LuaWriteUart(lua_State* vm)
-{
+int LuaWriteUart(lua_State* vm) {
// 获取函数参数:从栈底取一个参数
const char* k = lua_tostring(vm, 1);
if (nullptr != k) {
//todo qml显示添加
}
- //gGlobal.SendUartData(k);
- //qDebug() << "send data " << QString(k);
return 0;
}
+
diff --git a/examples/proto_debuger/modbus_form.cpp b/examples/proto_debuger/modbus_form.cpp
index 6ea5f8c1..7305f927 100644
--- a/examples/proto_debuger/modbus_form.cpp
+++ b/examples/proto_debuger/modbus_form.cpp
@@ -1,6 +1,8 @@
#include "modbus_form.h"
#include "lua_bind.h"
#include "msgdef.h"
+#include "modbus.h"
+
ModbusMasterForm::ModbusMasterForm(ui::Window* hwnd, std::wstring name,
uint32_t baurate, UINT portnum,
@@ -67,7 +69,8 @@ ModbusMasterForm::~ModbusMasterForm() {
void ModbusMasterForm::Init() {
ui::ChildBox::Init();
- /*
+
+
auto mRightSide = dynamic_cast (FindSubControl(L"uart_info_label"));
wchar_t p[100] = { 0 };
wsprintf(p, L"串口号: %s 波特率%d 数据位: %d 停止位: %d ",
@@ -75,10 +78,8 @@ void ModbusMasterForm::Init() {
m_data_bits, m_stop_bits);
mRightSide->SetText(std::wstring(p));
+ /*
mEditSend = dynamic_cast(FindSubControl(L"uart_send_edit"));
- mEditRecv = dynamic_cast(FindSubControl(L"uart_recv_eidt"));
- mEditLua = dynamic_cast(FindSubControl(L"lua_script"));
- mEditLua->SetRich(true);
mEditLua->SetReturnMsgWantCtrl(true);
mEditLua->SetText(string2wstring(mLuaScript));
@@ -113,7 +114,7 @@ void ModbusMasterForm::Init() {
std::string lua = wstring2string(mEditLua->GetText());
if (0 == this->mLua->UpdateScript(lua)) {
this->mLuaScript = lua;
- mLuaFileEdit = std::ofstream(UART_LUA_SCRIPT, std::ios::out | std::ios::trunc);
+ mLuaFileEdit = std::ofstream(MODBUS_LUA_SCRIPT, std::ios::out | std::ios::trunc);
mLuaFileEdit.write(lua.c_str(), lua.size());
mLuaFileEdit.flush();
mLuaFileEdit.close();
@@ -135,7 +136,8 @@ void ModbusMasterForm::Init() {
WM_ADD_UART_CLOSE, (WPARAM)name, 0);
return true;
});
- }*/
+ }
+ */
}
void ModbusMasterForm::UpdateRecvEdit()