no message
This commit is contained in:
parent
3ef7dd2fb5
commit
e911a8a799
@ -12,7 +12,7 @@
|
||||
</HBox>
|
||||
<Box>
|
||||
<VBox margin="0,0,0,0" valign="center" halign="center" width="auto" height="auto">
|
||||
<Label name="tooltip" text="dfasdfasd"/>
|
||||
<Label name="tooltip" text="一个简单窗口,带有标题栏和常规按钮。"/>
|
||||
</VBox>
|
||||
</Box>
|
||||
</VBox>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?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">
|
||||
<HBox height="auto" mouse="false" padding="10,5,10,5">
|
||||
<Control name="control_img" width="auto" height="auto" margin="0,0,10" mouse="false"/>
|
||||
|
@ -1,75 +1,88 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Window size="1200,800" caption="0,0,0,35">
|
||||
<VBox bkcolor="bk_wnd_darkcolor">
|
||||
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
|
||||
<Label text="TileBox数据懒加载实现" font="system_14" valign="center" margin="8" />
|
||||
<Control />
|
||||
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0" />
|
||||
<Box width="21" margin="4,6,0,0">
|
||||
<Button class="btn_wnd_max" name="maxbtn" />
|
||||
<Button class="btn_wnd_restore" name="restorebtn" visible="false" />
|
||||
</Box>
|
||||
<Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0" />
|
||||
</HBox>
|
||||
<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">
|
||||
<HBox height="30" childmargin="10">
|
||||
<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_fix" group="option_group" text="固定列数" margin="0,5,0,10">
|
||||
<Event type="select" receiver="box_column_op" applyattribute="visible="true"" />
|
||||
<Event type="unselect" receiver="box_column_op" applyattribute="visible="false"" />
|
||||
</Option>
|
||||
</HBox>
|
||||
<HBox name="box_column_op" height="30" childmargin="10" visible="false">
|
||||
<Control width="45" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<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>
|
||||
<CheckBox class="checkbox_font12" name="checkbox_item_center" text="列表居中" margin="0,5,0,10" selected="true" />
|
||||
</HBox>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="子项间隙:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<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>
|
||||
</HBox>
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="总数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="180">
|
||||
<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>
|
||||
</HBox>
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_set_total" text="更改/设置" />
|
||||
</Box>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="改变数据:" width="auto" height="auto" valign="center" />
|
||||
<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" />
|
||||
</Box>
|
||||
<Box bordersize="1" bordercolor="splitline_level1" height="26">
|
||||
<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" />
|
||||
</Box>
|
||||
</HBox>
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_update" text="更新数据" />
|
||||
</Box>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<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>
|
||||
<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" />
|
||||
</Box>
|
||||
</HBox>
|
||||
</VBox>
|
||||
</Window>
|
||||
<VBox bkcolor="bk_wnd_darkcolor">
|
||||
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
|
||||
<Label text="TileBox数据懒加载实现" font="system_14" valign="center" margin="8"/>
|
||||
<Control />
|
||||
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0"/>
|
||||
<Box width="21" margin="4,6,0,0">
|
||||
<Button class="btn_wnd_max" name="maxbtn"/>
|
||||
<Button class="btn_wnd_restore" name="restorebtn" visible="false"/>
|
||||
</Box>
|
||||
<Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0"/>
|
||||
</HBox>
|
||||
<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">
|
||||
<HBox height="30" childmargin="10">
|
||||
<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_fix" group="option_group" text="固定列数" margin="0,5,0,10">
|
||||
<Event type="select" receiver="box_column_op" applyattribute="visible="true"" />
|
||||
<Event type="unselect" receiver="box_column_op" applyattribute="visible="false"" />
|
||||
</Option>
|
||||
</HBox>
|
||||
|
||||
<HBox name="box_column_op" height="30" childmargin="10" visible="false">
|
||||
<Control width="45" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<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" />
|
||||
</Box>
|
||||
<CheckBox class="checkbox_font12" name="checkbox_item_center" text="列表居中" margin="0,5,0,10" selected="true" />
|
||||
</HBox>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="子项间隙:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<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" />
|
||||
</Box>
|
||||
</HBox>
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="总数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="180" >
|
||||
<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" />
|
||||
</Box>
|
||||
|
||||
</HBox>
|
||||
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_set_total" text="更改/设置" />
|
||||
</Box>
|
||||
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="改变数据:" width="auto" height="auto" valign="center" />
|
||||
<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" multiline="false" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
|
||||
</Box>
|
||||
<Box bordersize="1" bordercolor="splitline_level1" height="26">
|
||||
<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" />
|
||||
</Box>
|
||||
</HBox>
|
||||
|
||||
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_update" text="更新数据" />
|
||||
</Box>
|
||||
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
|
||||
<HBox height="30" childmargin="10">
|
||||
<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" multiline="false" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
|
||||
</Box>
|
||||
<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>
|
@ -65,6 +65,7 @@ void ModbusMasterForm::Init() {
|
||||
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 mBtnSend2 = static_cast<ui::Button*>(FindSubControl(L"btn_send_modbus_batch"));
|
||||
|
||||
if (NULL != mBtnSend)
|
||||
{
|
||||
@ -86,9 +87,7 @@ void ModbusMasterForm::Init() {
|
||||
ptr->tv_usec = 0;
|
||||
modbus_set_response_timeout(mModbus, ptr);
|
||||
uint16_t dest[32];
|
||||
if (m_rich_edit_1) {
|
||||
|
||||
}
|
||||
|
||||
uint16_t addr = 0;
|
||||
if (m_rich_edit_1) {
|
||||
int i = 0;
|
||||
@ -109,96 +108,72 @@ void ModbusMasterForm::Init() {
|
||||
m_list->Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string str;
|
||||
|
||||
modbus_flush(mModbus);
|
||||
modbus_close(mModbus);
|
||||
}
|
||||
return false;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
ui::ListBox* list = dynamic_cast<ui::ListBox*>(FindSubControl(L"list"));
|
||||
if (list != nullptr) {
|
||||
for (auto i = 0; i < 30; i++)
|
||||
{
|
||||
std::cout << "123";
|
||||
ui::ListContainerElement* element = new ui::ListContainerElement;
|
||||
element->SetText(nbase::StringPrintf(L"ListElement %d", i));
|
||||
element->SetClass(L"listitem");
|
||||
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');
|
||||
if (m_rich_edit_2) {
|
||||
int i = 0;
|
||||
nbase::StringToInt(m_rich_edit_2->GetText(), &i);
|
||||
addr = uint16_t(i);
|
||||
}
|
||||
if (m_rich_edit_3) {
|
||||
int i = 0;
|
||||
nbase::StringToInt(m_rich_edit_3->GetText(), &i);
|
||||
cnt = uint16_t(i);
|
||||
}
|
||||
|
||||
auto x = mEditSend->GetText();
|
||||
auto tmp = wstring2string(x);
|
||||
wprintf(L"%s\r\n", x.c_str());
|
||||
SerialPort::WritePort(PortNum, tmp.c_str(), tmp.size());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
auto mBtnSaveLua = static_cast<ui::Button*>(FindSubControl(L"btn_save_lua"));
|
||||
if (nullptr != mBtnSaveLua) {
|
||||
mBtnSaveLua->AttachClick([this](ui::EventArgs*) {
|
||||
std::cout << "保存lua脚本\r\n";
|
||||
std::string lua = wstring2string(mEditLua->GetText());
|
||||
if (0 == this->mLua->UpdateScript(lua)) {
|
||||
this->mLuaScript = lua;
|
||||
mLuaFileEdit = std::ofstream(MODBUS_LUA_SCRIPT, std::ios::out | std::ios::trunc);
|
||||
mLuaFileEdit.write(lua.c_str(), lua.size());
|
||||
mLuaFileEdit.flush();
|
||||
mLuaFileEdit.close();
|
||||
}
|
||||
else {
|
||||
MessageBox(0, L"lua脚本错误", L"", 0);
|
||||
return true;
|
||||
}
|
||||
std::cout << lua.c_str() << "\r\n";
|
||||
return true;
|
||||
});
|
||||
}
|
||||
wprintf(L"com is %s m_name", m_name.c_str());
|
||||
printf("open ptr is %s %d %d %d ", wstring2string(m_name).c_str(), m_baurate, m_data_bits, m_stop_bits);
|
||||
mModbus = modbus_new_rtu(wstring2string(wstring(L"\\\\.\\") + m_name).c_str(),
|
||||
m_baurate, 'N', m_data_bits, m_stop_bits);
|
||||
|
||||
if (mModbus != nullptr) {
|
||||
modbus_set_slave(mModbus, 9);
|
||||
modbus_set_debug(mModbus, true);
|
||||
int ret = modbus_connect(mModbus);
|
||||
if (ret < 0) {
|
||||
printf("modbus_connect err %d\r\n", ret);
|
||||
}
|
||||
timeval* ptr = new timeval;
|
||||
ptr->tv_sec = 1;
|
||||
ptr->tv_usec = 0;
|
||||
modbus_set_response_timeout(mModbus, ptr);
|
||||
uint16_t dest[32];
|
||||
|
||||
ret = modbus_read_registers(mModbus, addr, cnt, dest);
|
||||
if (ret < 0) {
|
||||
printf("read %d timeout %d ", ret);
|
||||
}
|
||||
else {
|
||||
m_list->RemoveAll();
|
||||
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;
|
||||
});
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void ModbusMasterForm::UpdateRecvEdit()
|
||||
|
@ -81,7 +81,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<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>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib</LibraryPath>
|
||||
</PropertyGroup>
|
||||
@ -168,6 +168,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="base_form.cpp" />
|
||||
<ClCompile Include="global.cpp" />
|
||||
<ClCompile Include="item.cpp" />
|
||||
<ClCompile Include="loger.cpp" />
|
||||
<ClCompile Include="lua_wraper.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
@ -193,6 +194,7 @@
|
||||
<ClInclude Include="..\..\..\cppnetwork\websocket_client.h" />
|
||||
<ClInclude Include="base_form.h" />
|
||||
<ClInclude Include="global.h" />
|
||||
<ClInclude Include="item.h" />
|
||||
<ClInclude Include="lua_bind.h" />
|
||||
<ClInclude Include="lua_wraper.h" />
|
||||
<ClInclude Include="main.h" />
|
||||
|
@ -42,7 +42,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
|
Loading…
Reference in New Issue
Block a user