2022-01-25 23:45:07 +08:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-11 00:00:10 +08:00
|
|
|
#include <string>
|
2021-11-19 00:37:35 +08:00
|
|
|
#include "msgdef.h"
|
2021-10-11 00:00:10 +08:00
|
|
|
|
|
|
|
// C runtime header
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <memory.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
|
|
|
|
// base header
|
|
|
|
#include "base/base.h"
|
|
|
|
#include "serial_port.h"
|
|
|
|
// duilib
|
|
|
|
#include "duilib/UIlib.h"
|
|
|
|
#include "tcp_client.h"
|
|
|
|
|
2022-01-23 01:02:13 +08:00
|
|
|
#include "lua_wraper.h"
|
2022-01-25 23:45:07 +08:00
|
|
|
#include "global.h"
|
2022-01-31 01:00:02 +08:00
|
|
|
#include <fstream>
|
|
|
|
#include <istream>
|
2022-01-23 01:02:13 +08:00
|
|
|
|
2021-10-11 00:00:10 +08:00
|
|
|
using namespace std;
|
2021-11-22 23:53:21 +08:00
|
|
|
class TcpClientForm :
|
|
|
|
public ui::ChildBox,
|
2022-01-25 23:45:07 +08:00
|
|
|
public TcpClientLibevent::TcpClientObserver,
|
|
|
|
public LuaBindInterface {
|
2021-10-11 00:00:10 +08:00
|
|
|
|
|
|
|
public:
|
2021-10-11 00:54:04 +08:00
|
|
|
TcpClientForm(ui::Window* hwnd,string url, uint32_t port, TcpClientLibevent* p);
|
2021-10-11 00:00:10 +08:00
|
|
|
virtual void Init() override;
|
2021-11-22 23:53:21 +08:00
|
|
|
TcpClientLibevent* ClientEvent();
|
2022-01-25 23:45:07 +08:00
|
|
|
LuaDelegate* LuaVM();
|
2021-11-22 23:53:21 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void OnConnected();
|
|
|
|
virtual void OnDisConnected(std::string) ;
|
|
|
|
virtual void OnData(uint8_t* dat, uint64_t len) ;
|
|
|
|
virtual void OnClose();
|
2022-01-25 23:45:07 +08:00
|
|
|
void ShowDataInEdit(const char*) override;
|
2021-11-22 23:53:21 +08:00
|
|
|
|
2021-10-11 00:00:10 +08:00
|
|
|
private:
|
|
|
|
ui::Label* m_label_1;
|
|
|
|
ui::RichEdit* m_rich_edit_1;
|
|
|
|
ui::RichEdit* m_rich_edit_2;
|
2021-11-22 23:53:21 +08:00
|
|
|
ui::RichEdit* m_uart_send_edit;
|
|
|
|
ui::Button* m_btn_send_data;
|
2022-02-01 00:19:32 +08:00
|
|
|
ui::Button* m_btn_save_lua;
|
2021-10-11 00:00:10 +08:00
|
|
|
ui::CheckBox* m_check_box_1;
|
|
|
|
ui::CheckBox* m_check_box_2;
|
|
|
|
ui::CheckBox* m_check_box_3;
|
|
|
|
ui::CheckBox* m_check_box_4;
|
2021-11-22 23:53:21 +08:00
|
|
|
TcpClientLibevent* mClient;
|
2022-01-31 01:00:02 +08:00
|
|
|
std::ifstream mLuaFile;
|
2021-10-11 00:00:10 +08:00
|
|
|
virtual void HandleMessage(ui::EventArgs& msg);
|
2022-01-31 01:00:02 +08:00
|
|
|
std::string mLuaScript;
|
2021-11-21 13:47:19 +08:00
|
|
|
std::string m_url;
|
|
|
|
int m_port;
|
2021-11-22 23:53:21 +08:00
|
|
|
bool m_connected;
|
2022-01-23 01:02:13 +08:00
|
|
|
LuaDelegate* mLua;
|
2021-10-11 00:00:10 +08:00
|
|
|
};
|