no message
This commit is contained in:
parent
d91dd21a2c
commit
af649dec3f
@ -22,6 +22,18 @@
|
||||
<Control width="stretch"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
<VBox bkcolor="bk_wnd_darkcolor" height="100" visible="false" name="modbus_config_master">
|
||||
<HBox width="stretch" height="35" margin="10,10,10,10">
|
||||
<Label name="title" text="串口:" valign="bottom" margin="30,0,0,0" width="70" height="30" font="arial_14"/>
|
||||
<Combo class="list" name="uart_type" height="30" width="110" bkimage="file='../public/combo/normal.png' corner='5,5,30,5'"/>
|
||||
<Control width="stretch"/>
|
||||
</HBox>
|
||||
<HBox width="stretch" height="35" margin="10,10,10,10">
|
||||
<Label name="title" text="波特率:" valign="bottom" margin="30,0,0,0" width="70" height="30" font="arial_14"/>
|
||||
<Combo class="list" name="uart_baurate_select" height="30" width="110" bkimage="file='../public/combo/normal.png' corner='5,5,30,5'"/>
|
||||
<Control width="stretch"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
<VBox bkcolor="bk_wnd_darkcolor" height="90" visible="false" name="ip_config">
|
||||
<HBox width="stretch" height="35" margin="10,0,0,0">
|
||||
<Label name="title" text="ip: " valign="bottom" margin="30,0,0,0" width="70" height="30" font="arial_14"/>
|
||||
|
@ -172,7 +172,6 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
//delete mRightShow;
|
||||
mRightShow = nullptr;
|
||||
}
|
||||
|
||||
if (uMsg == WM_ADD_TCPCLIENT_MONITOR) {
|
||||
TcpClientInfo* info = (TcpClientInfo*)wParam;
|
||||
TcpClientLibevent* cli = (TcpClientLibevent*)lParam;
|
||||
@ -218,7 +217,6 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
});
|
||||
mMonitorNewSelect->Close();
|
||||
}
|
||||
|
||||
if (uMsg == WM_ADD_WEBSOCKET_CLIENT) {
|
||||
TcpServerInfo* info = (TcpServerInfo*)wParam;
|
||||
ui::TreeNode* node = new ui::TreeNode;
|
||||
@ -275,7 +273,6 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (uMsg == WM_ADD_WEBSOCKET_SERVER) {
|
||||
TcpServerInfo* info = (TcpServerInfo*)wParam;
|
||||
ui::TreeNode* node = new ui::TreeNode;
|
||||
@ -550,6 +547,50 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
return true;
|
||||
});
|
||||
}
|
||||
if (uMsg == WM_ADD_UART_MODBUS_MASTER) {
|
||||
printf("add uart monitor");
|
||||
UartInfo* p = (UartInfo*)wParam;
|
||||
wprintf(L"%s", p->name.c_str());
|
||||
|
||||
ui::TreeNode* node = new ui::TreeNode;
|
||||
node->SetText(p->name);
|
||||
node->SetClass(L"listitem");
|
||||
|
||||
mMonitor->GetRootNode()->GetChildNode(7)->AddChildNode(node);
|
||||
|
||||
if (mModbusMasterForm.find(p->name) == mModbusMasterForm.end()) {
|
||||
auto form = new UartForm(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->SetName(p->name);
|
||||
form->SetVisible(false);
|
||||
mModbusMasterForm[p->name] = form;
|
||||
if (!mRightSide->Add(form))
|
||||
printf("erroer 1");
|
||||
}
|
||||
node->AttachAllEvents([this](ui::EventArgs* ev) {
|
||||
if (ui::EventType::kEventSelect == ev->Type) {
|
||||
wprintf(L"%s\r\n", dynamic_cast<ui::TreeNode*> (ev->pSender)->GetText().c_str());
|
||||
printf("GetCurSel %d\r\n", mRightSide->GetCurSel());
|
||||
UartForm* p = mModbusMasterForm[dynamic_cast<ui::TreeNode*> (ev->pSender)->GetText()];
|
||||
if (p != nullptr) {
|
||||
p->SetAutoDestroy(true);
|
||||
if (mRightShow != nullptr) {
|
||||
mRightShow->SetVisible(false);
|
||||
p->SetVisible(true);
|
||||
mRightShow = p;
|
||||
mRightSide->SelectItem(p->GetName());
|
||||
}
|
||||
else {
|
||||
p->SetVisible(true);
|
||||
mRightSide->SelectItem(p->GetName());
|
||||
mRightShow = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return WindowImplBase::HandleMessage(uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,7 @@ private:
|
||||
std::map<std::wstring, UdpGroupForm*> mUdpGroupForm;
|
||||
std::map<std::wstring, WebsocketClientForm*> mWebsocketClientForm;
|
||||
std::map<std::wstring, WebsocketServerForm*> mWebsocketServerForm;
|
||||
std::map<std::wstring, UartForm*> mModbusMasterForm;
|
||||
|
||||
ui::Control* mRightShow;
|
||||
};
|
||||
|
@ -18,3 +18,4 @@
|
||||
#define WM_ADD_WEBSOCKET_SERVER_CLOSE (WM_USER + 15)
|
||||
#define WM_ADD_WEBSOCKET_CLIENT (WM_USER + 16)
|
||||
#define WM_ADD_WEBSOCKET_CLIENT_CLOSE (WM_USER + 17)
|
||||
#define WM_ADD_UART_MODBUS_MASTER (WM_USER + 18)
|
||||
|
@ -253,6 +253,36 @@ void NewMonitorForm::InitWindow()
|
||||
printf("postmessage error :%d\r\n", GetLastError());
|
||||
}
|
||||
}
|
||||
if (m_combo_type->GetText() == L"modbus master") {
|
||||
UINT PortNum = 0;
|
||||
for (int i = 3; m_uart_select_combo->GetText()[i] != '\0'; i++) //转换为数字
|
||||
{
|
||||
PortNum = PortNum * 10 + (m_uart_select_combo->GetText()[i] - '0');
|
||||
}
|
||||
if (1 == SerialPort::InitPort(PortNum, 115200, 0, 8, 0)) {
|
||||
// 打开成功
|
||||
MessageBox(0, L"打开成功", L"", 0);
|
||||
UartInfo* p = new UartInfo;
|
||||
p->port_num = PortNum;
|
||||
p->name = m_uart_select_combo->GetText();
|
||||
p->baurate = 115200;
|
||||
p->data_bits = 8;
|
||||
p->flow_control = 0;
|
||||
p->verify = 0;
|
||||
p->stop_bits = 1;
|
||||
|
||||
auto succ = ::PostMessage(m_parent->GetHWND(), WM_ADD_UART_MODBUS_MASTER, (WPARAM)p, 0);
|
||||
if (!succ) {
|
||||
printf("postmessage error :%d\r\n", GetLastError());
|
||||
}
|
||||
this->Close();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -412,6 +442,7 @@ void NewMonitorForm::InitWindow()
|
||||
(text == L"udp") || (text == L"udp group")) {
|
||||
this->m_ip_config_vbox->SetVisible(true);
|
||||
this->m_uart_config_vbox->SetVisible(false);
|
||||
|
||||
m_port_select->SetVisible(true);
|
||||
m_ip_select->SetText(L"127.0.0.1");
|
||||
m_port_select->SetText(L"9001");
|
||||
@ -424,6 +455,50 @@ void NewMonitorForm::InitWindow()
|
||||
m_ip_select->SetText(L"wss://117.50.176.114:8080/echo");
|
||||
m_port_select->SetText(L"9001");
|
||||
}
|
||||
if (text == L"modbus master") {
|
||||
this->m_ip_config_vbox->SetVisible(false);
|
||||
this->m_uart_config_vbox->SetVisible(true);
|
||||
auto ports = EnumPortsWdm();
|
||||
this->m_uart_select_combo->RemoveAll();
|
||||
for (auto x : ports) {
|
||||
ui::ListContainerElement* element = new ui::ListContainerElement;
|
||||
element->SetClass(L"listitem");
|
||||
element->SetFixedHeight(30);
|
||||
element->SetBkColor(L"white");
|
||||
element->SetTextPadding({ 6,0,6,0 });
|
||||
element->SetText(nbase::StringPrintf(L"%s", &x.c_str()[x.find(L"COM")]));
|
||||
element->SetDataID(nbase::StringPrintf(L"%s", x.c_str()));
|
||||
this->m_uart_select_combo->Add(element);
|
||||
}
|
||||
vector<wstring> baurate;
|
||||
baurate.push_back(L"110");
|
||||
baurate.push_back(L"300");
|
||||
baurate.push_back(L"600");
|
||||
baurate.push_back(L"1200");
|
||||
baurate.push_back(L"2400");
|
||||
baurate.push_back(L"4800");
|
||||
baurate.push_back(L"9600");
|
||||
baurate.push_back(L"14400");
|
||||
baurate.push_back(L"19200");
|
||||
baurate.push_back(L"38400");
|
||||
baurate.push_back(L"56000");
|
||||
baurate.push_back(L"57600");
|
||||
baurate.push_back(L"115200");
|
||||
|
||||
baurate.push_back(L"128000");
|
||||
baurate.push_back(L"256000");
|
||||
|
||||
m_uart_baurate_select->RemoveAll();
|
||||
for (auto baus : baurate) {
|
||||
ui::ListContainerElement* element = new ui::ListContainerElement;
|
||||
element->SetClass(L"listitem");
|
||||
element->SetFixedHeight(30);
|
||||
element->SetBkColor(L"white");
|
||||
element->SetTextPadding({ 6,0,6,0 });
|
||||
element->SetText(nbase::StringPrintf(L"%s", baus.c_str()));
|
||||
this->m_uart_baurate_select->Add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
private:
|
||||
ui::VBox* m_ip_config_vbox;
|
||||
ui::VBox* m_uart_config_vbox;
|
||||
|
||||
ui::Combo* m_uart_select_combo;
|
||||
ui::Combo* m_uart_baurate_select;
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
<Control width="stretch"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
|
||||
<VBox bkcolor="bk_wnd_darkcolor" height="90" visible="false" name="ip_config">
|
||||
<HBox width="stretch" height="35" margin="10,0,0,0">
|
||||
<Label name="title" text="ip: " valign="bottom" margin="30,0,0,0" width="60" height="30" font="arial_14"/>
|
||||
|
Loading…
Reference in New Issue
Block a user