no message
This commit is contained in:
parent
5f70c4333f
commit
da3b7c0fc5
@ -371,6 +371,11 @@ LuaBindInterface* BasicForm::FindCurrentFormByLuaPointer(lua_State* pointer)
|
|||||||
return (LuaBindInterface*)itr->second;
|
return (LuaBindInterface*)itr->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto itr = mUdpForm.begin(); itr != mUdpForm.end(); itr++) {
|
||||||
|
if (itr->second->LuaVM()->VM() == pointer) {
|
||||||
|
return (LuaBindInterface*)itr->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,8 +193,6 @@
|
|||||||
<ClInclude Include="tcp_client_form.h" />
|
<ClInclude Include="tcp_client_form.h" />
|
||||||
<ClInclude Include="tcp_server_libevent.h" />
|
<ClInclude Include="tcp_server_libevent.h" />
|
||||||
<ClInclude Include="uart_process.h" />
|
<ClInclude Include="uart_process.h" />
|
||||||
<ClInclude Include="udp_form.h" />
|
|
||||||
<ClInclude Include="udp_libevent.h" />
|
|
||||||
<ClInclude Include="utils.h" />
|
<ClInclude Include="utils.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -204,6 +202,7 @@
|
|||||||
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_form.xml" />
|
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_form.xml" />
|
||||||
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_server_form.xml" />
|
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_server_form.xml" />
|
||||||
<Xml Include="..\x64\Debug\resources\themes\default\basic\udp_form.xml" />
|
<Xml Include="..\x64\Debug\resources\themes\default\basic\udp_form.xml" />
|
||||||
|
<Xml Include="Debug\themes\default\global.xml" />
|
||||||
<Xml Include="x64\Debug\themes\default\global.xml" />
|
<Xml Include="x64\Debug\themes\default\global.xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,29 +1,126 @@
|
|||||||
#include "udp_form.h"
|
#include "udp_form.h"
|
||||||
|
#include <functional>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "lua_bind.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define UDP_LUA_SCRIPT "udp_script.lua"
|
||||||
|
|
||||||
UdpForm::UdpForm(ui::Window* hwnd, string url, uint32_t port, UdpDataGramLibevent* p)
|
UdpForm::UdpForm(ui::Window* hwnd, string url, uint32_t port, UdpDataGramLibevent* p)
|
||||||
{
|
{
|
||||||
this->mUdpPeer = p;
|
this->mUdpPeer = p;
|
||||||
this->m_url = url;
|
this->m_url = url;
|
||||||
this->m_port = port;
|
this->m_port = port;
|
||||||
|
mLua = new LuaDelegate;
|
||||||
|
|
||||||
|
mLuaFile.open(UDP_LUA_SCRIPT);
|
||||||
|
std::string lua_script;
|
||||||
|
if (mLuaFile.is_open()) {
|
||||||
|
std::string s;
|
||||||
|
while (getline(mLuaFile, s)) {
|
||||||
|
lua_script += s + "\r\n";
|
||||||
|
}
|
||||||
|
mLuaFile.close();
|
||||||
|
}
|
||||||
|
mLuaScript = lua_script;
|
||||||
|
mLua->DoString(lua_script);
|
||||||
|
|
||||||
|
UdpDataGramLibevent::OnReadDataHandle onRecvCallBack([this](const char* dat, int len, struct sockaddr_in sendarr){
|
||||||
|
//this->LuaVM()->CallFuntion();
|
||||||
|
this->mLua->CallFuntion<std::string,std::string, LUA_INTEGER>("OnUdpData", std::string(dat),
|
||||||
|
inet_ntoa(sendarr.sin_addr),sendarr.sin_port);
|
||||||
|
});
|
||||||
|
if (mUdpPeer != nullptr) {
|
||||||
|
mUdpPeer->SetOnReadHandle(&onRecvCallBack);
|
||||||
|
}
|
||||||
|
this->mLua->BindFunction("showdata", LuaShowData);
|
||||||
|
|
||||||
|
std::cout << "lua script is " << lua_script << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpForm::~UdpForm()
|
UdpForm::~UdpForm()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpForm::Init()
|
void UdpForm::Init()
|
||||||
{
|
{
|
||||||
ui::ChildBox::Init();
|
ui::ChildBox::Init();
|
||||||
|
|
||||||
|
m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
||||||
|
m_rich_edit_1 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_recv_eidt"));
|
||||||
|
if (nullptr != m_rich_edit_1) {
|
||||||
|
m_rich_edit_1->SetReadOnly(true);
|
||||||
|
m_rich_edit_1->SetRich(false);
|
||||||
|
m_rich_edit_1->SetAttribute(L"autovscroll", L"true");
|
||||||
|
m_rich_edit_1->SetAttribute(L"multiline", L"true");
|
||||||
|
m_rich_edit_1->SetReturnMsgWantCtrl(true);
|
||||||
|
m_rich_edit_1->SetNeedReturnMsg(true);
|
||||||
|
m_rich_edit_1->SetWordWrap(true);
|
||||||
|
}
|
||||||
|
|
||||||
ui::Label* m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
m_rich_edit_2 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"lua_script"));
|
||||||
ui::RichEdit* m_rich_edit_1 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_recv_eidt"));
|
if (nullptr != m_rich_edit_2) {
|
||||||
ui::RichEdit* m_rich_edit_2 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"lua_script"));
|
m_rich_edit_2->SetRich(true);
|
||||||
ui::RichEdit* m_rich_edit_3 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_send_edit"));
|
m_rich_edit_2->SetReturnMsgWantCtrl(true);
|
||||||
ui::Button* m_button_1 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_send_data"));
|
m_rich_edit_2->SetText(string2wstring(mLuaScript));
|
||||||
ui::Button* m_button_2 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_close_uart"));
|
}
|
||||||
ui::Button* m_button_3 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_save_lua"));
|
|
||||||
ui::Button* m_button_4 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_do_lua"));
|
m_rich_edit_3 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_send_edit"));
|
||||||
|
m_button_1 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_send_data"));
|
||||||
|
m_button_2 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_close_uart"));
|
||||||
|
m_button_3 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_save_lua"));
|
||||||
|
m_button_4 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_do_lua"));
|
||||||
|
|
||||||
|
if (nullptr != m_label_1) {
|
||||||
|
m_label_1->SetText(wstring(L"udp:") + string2wstring(m_url)
|
||||||
|
+ L":" + std::to_wstring(m_port));
|
||||||
|
}
|
||||||
|
if (nullptr != m_button_1) {
|
||||||
|
m_button_1->AttachClick(
|
||||||
|
[this](ui::EventArgs*) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (nullptr != m_button_2) {
|
||||||
|
m_button_2->AttachClick(
|
||||||
|
[this](ui::EventArgs*) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (nullptr != m_button_3) {
|
||||||
|
m_button_3->AttachClick(
|
||||||
|
[this](ui::EventArgs*) {
|
||||||
|
std::cout << "±£´ælua½Å±¾\r\n";
|
||||||
|
std::string lua = wstring2string(m_rich_edit_2->GetText());
|
||||||
|
if (0 == this->mLua->UpdateScript(lua)) {
|
||||||
|
this->mLuaScript = lua;
|
||||||
|
mLuaFileEdit = std::ofstream(UDP_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;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (nullptr != m_button_4) {
|
||||||
|
m_button_4->AttachClick(
|
||||||
|
[this](ui::EventArgs* ev) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,8 +131,10 @@ LuaDelegate* UdpForm::LuaVM()
|
|||||||
|
|
||||||
void UdpForm::ShowDataInEdit(const char*)
|
void UdpForm::ShowDataInEdit(const char*)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpForm::HandleMessage(ui::EventArgs& msg)
|
void UdpForm::HandleMessage(ui::EventArgs& msg)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,8 @@ private:
|
|||||||
ui::Button* m_button_3;
|
ui::Button* m_button_3;
|
||||||
ui::Button* m_button_4;
|
ui::Button* m_button_4;
|
||||||
|
|
||||||
|
std::ifstream mLuaFile;
|
||||||
|
std::ofstream mLuaFileEdit;
|
||||||
|
|
||||||
virtual void HandleMessage(ui::EventArgs& msg);
|
virtual void HandleMessage(ui::EventArgs& msg);
|
||||||
std::string mLuaScript;
|
std::string mLuaScript;
|
||||||
|
Loading…
Reference in New Issue
Block a user