no message

This commit is contained in:
zcy 2022-02-20 11:55:16 +08:00
parent 905410fde2
commit 7417a488ed
5 changed files with 18 additions and 16 deletions

View File

@ -127,13 +127,13 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
}
mMonitor->GetRootNode()->GetChildNode(1)->RemoveChildNode(p);
delete mRightShow;
// delete mRightShow;
mRightShow = nullptr;
}
if (uMsg == WM_USER_TCP_SERVER_CLOSE) {
wprintf(L"close %s\r\n", ((wstring*)wParam)->c_str());
mRightShow->SetVisible(false);
mRightSide->SetAutoDestroy(true);
mRightSide->RemoveAll();
mTcpServerForm.erase(*(wstring*)(wParam));
@ -146,8 +146,9 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
}
mMonitor->GetRootNode()->GetChildNode(2)->RemoveChildNode(p);
delete mRightShow;
if(nullptr != p)
mMonitor->GetRootNode()->GetChildNode(2)->RemoveChildNode(p);
//delete mRightShow;
mRightShow = nullptr;
}
if (uMsg == WM_USER_POS_CHANGED) {
@ -393,7 +394,6 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
p->SetVisible(true);
mRightShow = p;
mRightSide->SelectItem(p->GetName());
}
else {
p->SetVisible(true);

View File

@ -5,7 +5,6 @@
using namespace std;
typedef struct{
wstring name;
UINT port_num;
@ -31,8 +30,6 @@ typedef struct {
class SerialPort
{
public:
SerialPort();
~SerialPort();
@ -65,16 +62,12 @@ public:
//检查指定串口状态
static int PortState(UINT PortNo);
//清空指定串口缓冲区
static void ClearCom(UINT PortNo);
//指定端口RTS信号检测用于脚踏开关信号触发
static int CheckRTS(UINT PortNo);
public:
//static UINT PortNum; //串口端口号
static map<int, HANDLE> ComMap;
};

View File

@ -40,10 +40,13 @@ int ThreadRun(TcpClientLibevent *p) {
//todo linux版本sleep
#endif
}else {
std::cout << "p->Dispatch()";
ret = p->Dispatch();
}
}
}
std::cout << "p->Dispatch() finished";
return 0;
}
@ -164,6 +167,8 @@ int TcpClientLibevent::ConnectServer() {
bufferevent_free(mBev);
mBev = nullptr;
printf("Connect failed\n");
mMux.unlock();
return -1;
}
this->mStatus = TcpClientLibevent::CONNECTING;
@ -223,6 +228,7 @@ int TcpClientLibevent::SetObserver(TcpClientLibevent::TcpClientObserver *ob) {
}
int TcpClientLibevent::Dispatch() {
std::cout << "Dispatch\r\n";
return event_base_dispatch(mBase);;
}

View File

@ -60,12 +60,15 @@ public:
TcpClientLibevent(std::string addrinfo, int port, TcpClientObserver* p);
~TcpClientLibevent() {
mMux.lock();
mStatus = STOP;
mStatus = TcpClientLibevent::STOP;
mMux.unlock();
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 10000;
event_base_loopexit(mBase,&tv);
mThread->join();
event_base_free(mBase);
std::cout << "12345\r\n";
};
friend void conn_eventcb(struct bufferevent*, short, void*);
int ConnectServer();

View File

@ -6,7 +6,7 @@
#define TCP_CLIENT_SCRIPT "tcp_client.lua"
TcpClientForm::~TcpClientForm() {
delete mClient;
std::cout << "45678\r\n";
}
TcpClientForm::TcpClientForm(ui::Window* hwnd,std::string url, uint32_t port, TcpClientLibevent* p):