no message
This commit is contained in:
parent
fef52d423f
commit
17cff75119
@ -31,6 +31,13 @@ std::wstring BasicForm::GetWindowClassName() const
|
|||||||
|
|
||||||
LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
if (uMsg == WM_ADD_UART_RECVDATA) {
|
||||||
|
printf("WM_ADD_UART_RECVDATA");
|
||||||
|
this->Paint();
|
||||||
|
for (auto itr = mUartForm.begin(); itr != mUartForm.end(); itr++) {
|
||||||
|
itr->second->OnUpdateUart();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (uMsg == WM_USER_POS_CHANGED) {
|
if (uMsg == WM_USER_POS_CHANGED) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -47,13 +54,12 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
mMonitor->GetRootNode()->GetChildNode(0)->AddChildNode(node);
|
mMonitor->GetRootNode()->GetChildNode(0)->AddChildNode(node);
|
||||||
|
|
||||||
if (mUartForm.find(p->name) == mUartForm.end()) {
|
if (mUartForm.find(p->name) == mUartForm.end()) {
|
||||||
auto form = new UartForm(this->m_hWnd,p->name, p->baurate,
|
auto form = new UartForm(this,p->name, p->baurate,
|
||||||
p->data_bits, p->stop_bits, p->verify, p->flow_control);
|
p->data_bits, p->stop_bits, p->verify, p->flow_control);
|
||||||
form->SetChildLayoutXML(L"basic/uart_form.xml");
|
form->SetChildLayoutXML(L"basic/uart_form.xml");
|
||||||
form->SetVisible(false);
|
form->SetVisible(false);
|
||||||
mUartForm[p->name] = form;
|
mUartForm[p->name] = form;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->AttachAllEvents([this](ui::EventArgs* ev){
|
node->AttachAllEvents([this](ui::EventArgs* ev){
|
||||||
if (ui::EventType::kEventSelect == ev->Type) {
|
if (ui::EventType::kEventSelect == ev->Type) {
|
||||||
mRightSide->RemoveAll();
|
mRightSide->RemoveAll();
|
||||||
|
@ -54,8 +54,6 @@ private:
|
|||||||
NewMonitorForm* mMonitorNewSelect;
|
NewMonitorForm* mMonitorNewSelect;
|
||||||
ui::TabBox *mRightSide;
|
ui::TabBox *mRightSide;
|
||||||
ui::TreeView *mMonitor;
|
ui::TreeView *mMonitor;
|
||||||
|
|
||||||
|
|
||||||
std::map<std::wstring,UartForm*> mUartForm;
|
std::map<std::wstring,UartForm*> mUartForm;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#define WM_ADD_UART_RECVDATA (WM_USER + 4)
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
wstring name;
|
wstring name;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#include "uart_process.h"
|
#include "uart_process.h"
|
||||||
|
|
||||||
|
|
||||||
#define WM_ADD_UART_RECVDATA (WM_USER + 4)
|
|
||||||
|
|
||||||
wstring string2wstring(string str)
|
wstring string2wstring(string str)
|
||||||
{
|
{
|
||||||
wstring result;
|
wstring result;
|
||||||
@ -33,13 +30,13 @@ std::string wstring2string(std::wstring wstr)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
UartForm::UartForm(HWND hwnd,std::wstring name,
|
UartForm::UartForm(ui::Window* hwnd,std::wstring name,
|
||||||
uint32_t baurate,
|
uint32_t baurate,
|
||||||
uint8_t data_bits, uint8_t stop_bits,
|
uint8_t data_bits, uint8_t stop_bits,
|
||||||
uint8_t verify, uint8_t flow_control):
|
uint8_t verify, uint8_t flow_control):
|
||||||
m_thread_recv(nullptr)
|
m_thread_recv(nullptr),
|
||||||
|
mEditRecv(nullptr)
|
||||||
{
|
{
|
||||||
m_hwnd = hwnd;
|
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_baurate = baurate;
|
m_baurate = baurate;
|
||||||
m_data_bits = data_bits;
|
m_data_bits = data_bits;
|
||||||
@ -58,16 +55,24 @@ UartForm::UartForm(HWND hwnd,std::wstring name,
|
|||||||
while (this->m_runing) {
|
while (this->m_runing) {
|
||||||
if (0 < SerialPort::ReadPort(PortNum, recv, 1024)) {
|
if (0 < SerialPort::ReadPort(PortNum, recv, 1024)) {
|
||||||
printf("recv data: %s", recv);
|
printf("recv data: %s", recv);
|
||||||
this->m_show_recv += wstring(L"123");
|
this->m_show_recv += string2wstring(recv);
|
||||||
this->UpdateRecvEdit();
|
::PostMessage(this->GetWindow()->GetHWND(), WM_ADD_UART_RECVDATA, 0, 0);
|
||||||
::PostMessage(m_hwnd, WM_ADD_UART_RECVDATA, 0, 0);
|
|
||||||
this->Invalidate();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Sleep(30);
|
Sleep(30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (nullptr != hwnd) {
|
||||||
|
this->SetWindow(hwnd, nullptr, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UartForm::OnUpdateUart()
|
||||||
|
{
|
||||||
|
if(mEditRecv != nullptr)
|
||||||
|
this->mEditRecv->SetText(this->m_show_recv.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,12 +17,14 @@
|
|||||||
class UartForm : public ui::ChildBox
|
class UartForm : public ui::ChildBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UartForm(HWND hwnd,std::wstring name, uint32_t baurate,
|
UartForm(ui::Window* window,std::wstring name, uint32_t baurate,
|
||||||
uint8_t data_bits,
|
uint8_t data_bits,
|
||||||
uint8_t stop_bits,
|
uint8_t stop_bits,
|
||||||
uint8_t verify,
|
uint8_t verify,
|
||||||
uint8_t flow_control);
|
uint8_t flow_control);
|
||||||
|
|
||||||
|
void OnUpdateUart();
|
||||||
|
|
||||||
/// 重写父类方法,提供个性化功能,请参考父类声明
|
/// 重写父类方法,提供个性化功能,请参考父类声明
|
||||||
virtual void Init() override;
|
virtual void Init() override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user