no message

This commit is contained in:
zcy 2023-03-27 22:47:17 +08:00
parent 3ef7dd2fb5
commit e911a8a799
6 changed files with 146 additions and 156 deletions

View File

@ -12,7 +12,7 @@
</HBox> </HBox>
<Box> <Box>
<VBox margin="0,0,0,0" valign="center" halign="center" width="auto" height="auto"> <VBox margin="0,0,0,0" valign="center" halign="center" width="auto" height="auto">
<Label name="tooltip" text="dfasdfasd"/> <Label name="tooltip" text="一个简单窗口,带有标题栏和常规按钮。"/>
</VBox> </VBox>
</Box> </Box>
</VBox> </VBox>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Window caption="0,0,180,30" roundcorner="5,5" sizebox="10,10,10,10" mininfo="280,70" maxinfo="300,700"> <Window>
<ListContainerElement class="listitem" height="auto"> <ListContainerElement class="listitem" height="auto">
<HBox height="auto" mouse="false" padding="10,5,10,5"> <HBox height="auto" mouse="false" padding="10,5,10,5">
<Control name="control_img" width="auto" height="auto" margin="0,0,10" mouse="false"/> <Control name="control_img" width="auto" height="auto" margin="0,0,10" mouse="false"/>

View File

@ -1,75 +1,88 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<Window size="1200,800" caption="0,0,0,35"> <Window size="1200,800" caption="0,0,0,35">
<VBox bkcolor="bk_wnd_darkcolor"> <VBox bkcolor="bk_wnd_darkcolor">
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor"> <HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
<Label text="TileBox数据懒加载实现" font="system_14" valign="center" margin="8" /> <Label text="TileBox数据懒加载实现" font="system_14" valign="center" margin="8"/>
<Control /> <Control />
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0" /> <Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0"/>
<Box width="21" margin="4,6,0,0"> <Box width="21" margin="4,6,0,0">
<Button class="btn_wnd_max" name="maxbtn" /> <Button class="btn_wnd_max" name="maxbtn"/>
<Button class="btn_wnd_restore" name="restorebtn" visible="false" /> <Button class="btn_wnd_restore" name="restorebtn" visible="false"/>
</Box> </Box>
<Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0" /> <Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0"/>
</HBox> </HBox>
<HBox childmargin="5" bkcolor="white" padding="5,5,5,10"> <HBox childmargin="5" bkcolor="white" padding="5,5,5,10">
<VBox width="300" bordersize="1" bordercolor="splitline_level2" padding="5,10,5,10" childmargin="10"> <VBox width="300" bordersize="1" bordercolor="splitline_level2" padding="5,10,5,10" childmargin="10">
<HBox height="30" childmargin="10"> <HBox height="30" childmargin="10">
<Label font="system_bold_14" text="列设置:" width="auto" height="auto" valign="center" /> <Label font="system_bold_14" text="列设置:" width="auto" height="auto" valign="center" />
<Option class="circle_option_2" name="option_column_auto" group="option_group" text="自动计算" margin="0,5,0,10" selected="true" /> <Option class="circle_option_2" name="option_column_auto" group="option_group" text="自动计算" margin="0,5,0,10" selected="true"/>
<Option class="circle_option_2" name="option_column_fix" group="option_group" text="固定列数" margin="0,5,0,10"> <Option class="circle_option_2" name="option_column_fix" group="option_group" text="固定列数" margin="0,5,0,10">
<Event type="select" receiver="box_column_op" applyattribute="visible=&quot;true&quot;" /> <Event type="select" receiver="box_column_op" applyattribute="visible=&quot;true&quot;" />
<Event type="unselect" receiver="box_column_op" applyattribute="visible=&quot;false&quot;" /> <Event type="unselect" receiver="box_column_op" applyattribute="visible=&quot;false&quot;" />
</Option> </Option>
</HBox> </HBox>
<HBox name="box_column_op" height="30" childmargin="10" visible="false">
<Control width="45" /> <HBox name="box_column_op" height="30" childmargin="10" visible="false">
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26"> <Control width="45" />
<RichEdit name="edit_column" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="列数" align="vcenter,hcenter" text="3" promptcolor="splitline_level1" autohscroll="true" /> <Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
</Box> <RichEdit name="edit_column" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="列数" align="vcenter,hcenter" text="3" promptcolor="splitline_level1" autohscroll="true" />
<CheckBox class="checkbox_font12" name="checkbox_item_center" text="列表居中" margin="0,5,0,10" selected="true" /> </Box>
</HBox> <CheckBox class="checkbox_font12" name="checkbox_item_center" text="列表居中" margin="0,5,0,10" selected="true" />
<Control height="1" bkcolor="splitline_level2" /> </HBox>
<HBox height="30" childmargin="10"> <Control height="1" bkcolor="splitline_level2" />
<Label font="system_bold_14" text="子项间隙:" width="auto" height="auto" valign="center" /> <HBox height="30" childmargin="10">
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26"> <Label font="system_bold_14" text="子项间隙:" width="auto" height="auto" valign="center" />
<RichEdit name="edit_child_margin" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="子项间隙" align="vcenter,hcenter" text="" promptcolor="splitline_level1" autohscroll="true" /> <Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
</Box> <RichEdit name="edit_child_margin" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="子项间隙" align="vcenter,hcenter" text="" promptcolor="splitline_level1" autohscroll="true" />
</HBox> </Box>
<HBox height="30" childmargin="10"> </HBox>
<Label font="system_bold_14" text="总数据:" width="auto" height="auto" valign="center" /> <HBox height="30" childmargin="10">
<Box bordersize="1" bordercolor="splitline_level1" width="180"> <Label font="system_bold_14" text="总数据:" width="auto" height="auto" valign="center" />
<RichEdit name="edit_total" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="总数据" promptcolor="splitline_level1" autohscroll="true" /> <Box bordersize="1" bordercolor="splitline_level1" width="180" >
</Box> <RichEdit name="edit_total" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="总数据" promptcolor="splitline_level1" autohscroll="true" />
</HBox> </Box>
<Box height="30" childmargin="10" width="stretch">
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_set_total" text="更改/设置" /> </HBox>
</Box>
<Control height="1" bkcolor="splitline_level2" /> <Box height="30" childmargin="10" width="stretch">
<HBox height="30" childmargin="10"> <Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_set_total" text="更改/设置" />
<Label font="system_bold_14" text="改变数据:" width="auto" height="auto" valign="center" /> </Box>
<Box bordersize="1" bordercolor="splitline_level1" height="26">
<RichEdit name="edit_update" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" /> <Control height="1" bkcolor="splitline_level2" />
</Box>
<Box bordersize="1" bordercolor="splitline_level1" height="26"> <HBox height="30" childmargin="10">
<RichEdit name="edit_task_name" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="新的任务名称" promptcolor="splitline_level1" autohscroll="true" /> <Label font="system_bold_14" text="改变数据:" width="auto" height="auto" valign="center" />
</Box> <Box bordersize="1" bordercolor="splitline_level1" height="26">
</HBox> <RichEdit name="edit_update" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
<Box height="30" childmargin="10" width="stretch"> </Box>
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_update" text="更新数据" /> <Box bordersize="1" bordercolor="splitline_level1" height="26">
</Box> <RichEdit name="edit_task_name" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="新的任务名称" promptcolor="splitline_level1" autohscroll="true" />
<Control height="1" bkcolor="splitline_level2" /> </Box>
<HBox height="30" childmargin="10"> </HBox>
<Label font="system_bold_14" text="删除数据:" width="auto" height="auto" valign="center" />
<Box bordersize="1" bordercolor="splitline_level1">
<RichEdit name="edit_delete" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" /> <Box height="30" childmargin="10" width="stretch">
</Box> <Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_update" text="更新数据" />
<Button class="btn_global_red_80x30" halign="center" valign="center" name="btn_delete" text="删除数据" /> </Box>
</HBox>
</VBox> <Control height="1" bkcolor="splitline_level2" />
<!--column="3" width="auto" halign="center" childmargin="10" -->
<Box> <HBox height="30" childmargin="10">
<VirtualTileBox class="list" name="list" vscrollunit="70" itemsize="220,60" bordersize="1" bordercolor="splitline_level2" padding="1,1,1,1" /> <Label font="system_bold_14" text="删除数据:" width="auto" height="auto" valign="center" />
</Box> <Box bordersize="1" bordercolor="splitline_level1" >
</HBox> <RichEdit name="edit_delete" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
</VBox> </Box>
</Window> <Button class="btn_global_red_80x30" halign="center" valign="center" name="btn_delete" text="删除数据" />
</HBox>
</VBox>
<!--column="3" width="auto" halign="center" childmargin="10" -->
<Box>
<VirtualTileBox class="list" name="list" vscrollunit="70" itemsize="220,60" bordersize="1" bordercolor="splitline_level2" padding="1,1,1,1">
</VirtualTileBox>
</Box>
</HBox>
</VBox>
</Window>

View File

@ -65,6 +65,7 @@ void ModbusMasterForm::Init() {
m_rich_edit_3 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"read_batch_cnt")); m_rich_edit_3 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"read_batch_cnt"));
auto mBtnSend = static_cast<ui::Button*>(FindSubControl(L"btn_send_modbus")); auto mBtnSend = static_cast<ui::Button*>(FindSubControl(L"btn_send_modbus"));
auto mBtnSend2 = static_cast<ui::Button*>(FindSubControl(L"btn_send_modbus_batch"));
if (NULL != mBtnSend) if (NULL != mBtnSend)
{ {
@ -86,9 +87,7 @@ void ModbusMasterForm::Init() {
ptr->tv_usec = 0; ptr->tv_usec = 0;
modbus_set_response_timeout(mModbus, ptr); modbus_set_response_timeout(mModbus, ptr);
uint16_t dest[32]; uint16_t dest[32];
if (m_rich_edit_1) {
}
uint16_t addr = 0; uint16_t addr = 0;
if (m_rich_edit_1) { if (m_rich_edit_1) {
int i = 0; int i = 0;
@ -109,96 +108,72 @@ void ModbusMasterForm::Init() {
m_list->Add(element); m_list->Add(element);
} }
} }
std::string str; std::string str;
modbus_flush(mModbus); modbus_flush(mModbus);
modbus_close(mModbus); modbus_close(mModbus);
} }
return false; return false;
}); });
} }
m_list = dynamic_cast<ui::ListBox*>(FindSubControl(L"list")); m_list = dynamic_cast<ui::ListBox*>(FindSubControl(L"list"));
if (nullptr != mBtnSend2) {
mBtnSend2->AttachClick([this](ui::EventArgs* arg) {
uint16_t addr = 0;
uint16_t cnt = 0;
/* if (m_rich_edit_2) {
ui::ListBox* list = dynamic_cast<ui::ListBox*>(FindSubControl(L"list")); int i = 0;
if (list != nullptr) { nbase::StringToInt(m_rich_edit_2->GetText(), &i);
for (auto i = 0; i < 30; i++) addr = uint16_t(i);
{ }
std::cout << "123"; if (m_rich_edit_3) {
ui::ListContainerElement* element = new ui::ListContainerElement; int i = 0;
element->SetText(nbase::StringPrintf(L"ListElement %d", i)); nbase::StringToInt(m_rich_edit_3->GetText(), &i);
element->SetClass(L"listitem"); cnt = uint16_t(i);
element->SetFixedHeight(20);
list->Add(element);
}
}
/*
mEditSend = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_send_edit"));
mEditLua->SetReturnMsgWantCtrl(true);
mEditLua->SetText(string2wstring(mLuaScript));
mEditRecv->SetReadOnly(true);
mEditRecv->SetRich(false);
mEditRecv->SetAttribute(L"autovscroll", L"true");
mEditRecv->SetAttribute(L"multiline", L"true");
mEditRecv->SetReturnMsgWantCtrl(true);
mEditRecv->SetNeedReturnMsg(true);
mEditRecv->SetWordWrap(true);
auto mBtnSend = static_cast<ui::Button*>(FindSubControl(L"btn_send_data"));
if (mBtnSend != nullptr) {
mBtnSend->AttachClick([this](ui::EventArgs*) {
UINT PortNum = 0;
for (int i = 3; m_name[i] != '\0'; i++) //转换为数字
{
PortNum = PortNum * 10 + (m_name[i] - '0');
} }
auto x = mEditSend->GetText(); wprintf(L"com is %s m_name", m_name.c_str());
auto tmp = wstring2string(x); printf("open ptr is %s %d %d %d ", wstring2string(m_name).c_str(), m_baurate, m_data_bits, m_stop_bits);
wprintf(L"%s\r\n", x.c_str()); mModbus = modbus_new_rtu(wstring2string(wstring(L"\\\\.\\") + m_name).c_str(),
SerialPort::WritePort(PortNum, tmp.c_str(), tmp.size()); m_baurate, 'N', m_data_bits, m_stop_bits);
return true;
}); if (mModbus != nullptr) {
} modbus_set_slave(mModbus, 9);
auto mBtnSaveLua = static_cast<ui::Button*>(FindSubControl(L"btn_save_lua")); modbus_set_debug(mModbus, true);
if (nullptr != mBtnSaveLua) { int ret = modbus_connect(mModbus);
mBtnSaveLua->AttachClick([this](ui::EventArgs*) { if (ret < 0) {
std::cout << "保存lua脚本\r\n"; printf("modbus_connect err %d\r\n", ret);
std::string lua = wstring2string(mEditLua->GetText()); }
if (0 == this->mLua->UpdateScript(lua)) { timeval* ptr = new timeval;
this->mLuaScript = lua; ptr->tv_sec = 1;
mLuaFileEdit = std::ofstream(MODBUS_LUA_SCRIPT, std::ios::out | std::ios::trunc); ptr->tv_usec = 0;
mLuaFileEdit.write(lua.c_str(), lua.size()); modbus_set_response_timeout(mModbus, ptr);
mLuaFileEdit.flush(); uint16_t dest[32];
mLuaFileEdit.close();
} ret = modbus_read_registers(mModbus, addr, cnt, dest);
else { if (ret < 0) {
MessageBox(0, L"lua脚本错误", L"", 0); printf("read %d timeout %d ", ret);
return true; }
} else {
std::cout << lua.c_str() << "\r\n"; m_list->RemoveAll();
return true; for (int i = 0; i < ret; i++) {
}); ui::ListContainerElement* element = new ui::ListContainerElement;
} element->SetText(nbase::StringPrintf(L"µØÖ·%d: %d", addr + i, dest[i]));
element->SetClass(L"listitem");
element->SetFixedHeight(30);
element->SetFont(L"system_20");
m_list->Add(element);
}
}
std::string str;
modbus_flush(mModbus);
modbus_close(mModbus);
}
auto mBtnClose = static_cast<ui::Button*>(FindSubControl(L"btn_close_uart"));
if (mBtnClose != nullptr) {
mBtnClose->AttachClick([this](ui::EventArgs*) {
wstring* name = new wstring(this->GetName());
::PostMessage(this->GetWindow()->GetHWND(),
WM_ADD_UART_CLOSE, (WPARAM)name, 0);
return true; return true;
}); });
} }
*/
} }
void ModbusMasterForm::UpdateRecvEdit() void ModbusMasterForm::UpdateRecvEdit()

View File

@ -81,7 +81,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\..\;$(ProjectDir)third\include\libevent\include;$(ProjectDir);$(ProjectDir)third\include\lua;$(ProjectDir)third\include\;D:\include</IncludePath> <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\..\;$(ProjectDir)third\include\libevent\include;$(ProjectDir);$(ProjectDir)third\include\lua;$(ProjectDir)third\include\;D:\include;D:\project\c++\nim_duilib\examples\proto_debuger\third\include</IncludePath>
<ReferencePath>$(ReferencePath)</ReferencePath> <ReferencePath>$(ReferencePath)</ReferencePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib</LibraryPath> <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib</LibraryPath>
</PropertyGroup> </PropertyGroup>
@ -168,6 +168,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="base_form.cpp" /> <ClCompile Include="base_form.cpp" />
<ClCompile Include="global.cpp" /> <ClCompile Include="global.cpp" />
<ClCompile Include="item.cpp" />
<ClCompile Include="loger.cpp" /> <ClCompile Include="loger.cpp" />
<ClCompile Include="lua_wraper.cpp" /> <ClCompile Include="lua_wraper.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
@ -193,6 +194,7 @@
<ClInclude Include="..\..\..\cppnetwork\websocket_client.h" /> <ClInclude Include="..\..\..\cppnetwork\websocket_client.h" />
<ClInclude Include="base_form.h" /> <ClInclude Include="base_form.h" />
<ClInclude Include="global.h" /> <ClInclude Include="global.h" />
<ClInclude Include="item.h" />
<ClInclude Include="lua_bind.h" /> <ClInclude Include="lua_bind.h" />
<ClInclude Include="lua_wraper.h" /> <ClInclude Include="lua_wraper.h" />
<ClInclude Include="main.h" /> <ClInclude Include="main.h" />

View File

@ -42,7 +42,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">