From 7d94a0331c79d01e5c0dcf12eebad786b49a0525 Mon Sep 17 00:00:00 2001 From: wangxx1809 Date: Wed, 22 Oct 2025 17:02:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=85=E5=AD=98=E6=B3=84?= =?UTF-8?q?=E6=BC=8F=E7=AD=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InfraredTemp/InfraredTemp.vcxproj | 10 +- InfraredTemp/InfraredTemp.vcxproj.filters | 18 -- InfraredTemp/logs/InfraredTemp.log | 0 InfraredTemp/main.cpp | 14 +- InfraredTemp/src/CommonStructs.h | 103 ------- InfraredTemp/src/InfraredTemp.cpp | 39 ++- InfraredTemp/src/InfraredTemp.h | 47 ++-- InfraredTemp/src/InfraredTempCfg.cpp | 310 ---------------------- InfraredTemp/src/InfraredTempCfg.h | 43 +-- InfraredTemp/src/LayerTempPointConfig.cpp | 31 --- InfraredTemp/src/LayerTempPointConfig.h | 29 -- InfraredTemp/src/SocketServer.cpp | 8 +- InfraredTemp/src/SocketServer.h | 1 - InfraredTemp/src/TempRegion.cpp | 33 --- InfraredTemp/src/TempRegion.h | 56 ---- 15 files changed, 71 insertions(+), 671 deletions(-) create mode 100644 InfraredTemp/logs/InfraredTemp.log delete mode 100644 InfraredTemp/src/CommonStructs.h delete mode 100644 InfraredTemp/src/InfraredTempCfg.cpp delete mode 100644 InfraredTemp/src/LayerTempPointConfig.cpp delete mode 100644 InfraredTemp/src/LayerTempPointConfig.h delete mode 100644 InfraredTemp/src/TempRegion.cpp delete mode 100644 InfraredTemp/src/TempRegion.h diff --git a/InfraredTemp/InfraredTemp.vcxproj b/InfraredTemp/InfraredTemp.vcxproj index 5480a9b..beb6089 100644 --- a/InfraredTemp/InfraredTemp.vcxproj +++ b/InfraredTemp/InfraredTemp.vcxproj @@ -110,7 +110,7 @@ Level3 true - _DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) + _DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;ELPP_THREAD_SAFE;ELPP_UNICODE;%(PreprocessorDefinitions) true true @@ -126,7 +126,7 @@ true true true - NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;ELPP_THREAD_SAFE;ELPP_UNICODE;%(PreprocessorDefinitions) true @@ -142,10 +142,7 @@ - - - @@ -155,12 +152,9 @@ - - - diff --git a/InfraredTemp/InfraredTemp.vcxproj.filters b/InfraredTemp/InfraredTemp.vcxproj.filters index 154c9a3..6de6f4d 100644 --- a/InfraredTemp/InfraredTemp.vcxproj.filters +++ b/InfraredTemp/InfraredTemp.vcxproj.filters @@ -21,18 +21,9 @@ 源文件 - - 源文件 - - - 源文件 - 源文件 - - 源文件 - 源文件 @@ -47,24 +38,15 @@ 头文件 - - 头文件 - 头文件 - - 头文件 - 头文件 头文件 - - 头文件 - 头文件 diff --git a/InfraredTemp/logs/InfraredTemp.log b/InfraredTemp/logs/InfraredTemp.log new file mode 100644 index 0000000..e69de29 diff --git a/InfraredTemp/main.cpp b/InfraredTemp/main.cpp index 9236942..ad7659c 100644 --- a/InfraredTemp/main.cpp +++ b/InfraredTemp/main.cpp @@ -3,12 +3,14 @@ #include "utils/StringHelper.h" #include "src/InfraredTemp.h" #include "src/SocketServer.h" +#include +#define ELPP_THREAD_SAFE #include "easylogging++.h" using namespace std; INITIALIZE_EASYLOGGINGPP -//easylogging++ 多线程可能有问题 + void EasyLogConf() { string confPath = StringHelper::GetAppPath() + "\\log.conf"; @@ -25,13 +27,13 @@ int main(int argc,char** argv) { return -1; } - SocketServer* server = new SocketServer(); - - server->Init(); - server->StartRun(); + unique_ptr serverptr(new SocketServer()); + + serverptr->Init(); + serverptr->StartRun(); Sleep(1000); - server->WaitStop(); + serverptr->WaitStop(); return 0; diff --git a/InfraredTemp/src/CommonStructs.h b/InfraredTemp/src/CommonStructs.h deleted file mode 100644 index d4b3e22..0000000 --- a/InfraredTemp/src/CommonStructs.h +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once -#include -#include -#include "InfraredTempCfg.h" - - -class CfgData { -public: - InfraredTempCfg ifCfg; -}; - -class MousePointInfo { -public: - int x; - int y; - float temp; - -}; - -//struct IFConfig { -// MessageHeader header; -// InfraredTempCfg ifCfg; -//}; -// -//struct MOUSEPOINTINFO { -// MessageHeader header; -// int x; -// int y; -// float temp; -//}; - - - - - - - - - - - - - - -//// 温度数据消息 -//struct TemperatureData { -// MessageHeader header; -// int imageWidth; -// int imageHeight; -// float minTemperature; -// float maxTemperature; -// float averageTemperature; -// // 温度数据数组(动态数据) -//}; -// -//// 图像数据消息 -//struct ImageData { -// MessageHeader header; -// int width; -// int height; -// int channels; -// int imageSize; // 图像数据大小 -// // 图像数据数组(动态数据) -//}; -// -//// 完整的红外数据消息 -//struct InfraredData { -// MessageHeader header; -// int imageWidth; -// int imageHeight; -// float* temperatureData; // 温度数据 -// unsigned char* imageData; // JPEG图像数据 -// int imageDataLength; -// -// InfraredData() : temperatureData(nullptr), imageData(nullptr), imageDataLength(0) { -// header.messageType = 1; -// header.dataSize = sizeof(InfraredData) - sizeof(MessageHeader); -// } -//}; -// -//// 命令消息 -//struct CommandMessage { -// MessageHeader header; -// uint32_t command; -// uint32_t parameter; -// -// CommandMessage() { -// header.messageType = 100; -// header.dataSize = sizeof(CommandMessage) - sizeof(MessageHeader); -// } -//}; -// -//// 响应消息 -//struct ResponseMessage { -// MessageHeader header; -// uint32_t resultCode; -// char message[256]; -// -// ResponseMessage() { -// header.messageType = 200; -// header.dataSize = sizeof(ResponseMessage) - sizeof(MessageHeader); -// } -//}; \ No newline at end of file diff --git a/InfraredTemp/src/InfraredTemp.cpp b/InfraredTemp/src/InfraredTemp.cpp index 21e0c05..3b27e10 100644 --- a/InfraredTemp/src/InfraredTemp.cpp +++ b/InfraredTemp/src/InfraredTemp.cpp @@ -176,8 +176,6 @@ void InfraredTemp::Connect() //GetGain(); //UpdateAutoFocus(); - - SendCfgInfo(); //发送一次配置 } void InfraredTemp::Startup() @@ -218,35 +216,47 @@ void InfraredTemp::Run() { while (m_RunFlag) { #if _DEBUG - SendCfgInfo(); //发送一次配置 test - + unique_lock lck(m_RunMtx); if (!m_FunQue.empty()) { string funNameStr = m_FunQue.front(); m_FunQue.pop(); - if ("UpdateEnv" == funNameStr) { + if ("Connect" == funNameStr) { //配置信息收到后,才进行设备连接 + LOG(DEBUG) << "Connect function is called"; + Connect(); + SendCfgInfo(); //发送一次配置 + } + else if ("UpdateEnv" == funNameStr) { + LOG(DEBUG) << "UpdateEnv function is called"; UpdateEnv(); } else if ("SetOSD" == funNameStr) { + LOG(DEBUG) << "SetOSD function is called"; SetOSD(); } else if ("UpdateOSD" == funNameStr) { + LOG(DEBUG) << "UpdateOSD function is called"; UpdateOSD(); } else if ("UpdateColorPalette" == funNameStr) { + LOG(DEBUG) << "UpdateColorPalette function is called"; UpdateColorPalette(); } else if ("UpdateOverTurn" == funNameStr) { + LOG(DEBUG) << "UpdateOverTurn function is called"; UpdateOverTurn(); } else if ("UpdateAutoFocus" == funNameStr) { + LOG(DEBUG) << "UpdateAutoFocus function is called"; UpdateAutoFocus(); } else if ("UpdateTempUnit" == funNameStr) { + LOG(DEBUG) << "UpdateTempUnit function is called"; UpdateTempUnit(); } else if ("SaveTempData" == funNameStr) { + LOG(DEBUG) << "SaveTempData function is called"; SaveTempData(); } } @@ -280,29 +290,42 @@ void InfraredTemp::Run() if (!m_FunQue.empty()) { string funNameStr = m_FunQue.front(); m_FunQue.pop(); - - if ("UpdateEnv" == funNameStr) { + + if ("Connect" == funNameStr) { //配置信息收到后,才进行设备连接 + LOG(DEBUG) << "Connect function is called"; + Connect(); + SendCfgInfo(); //发送一次配置 + } + else if ("UpdateEnv" == funNameStr) { + LOG(DEBUG) << "UpdateEnv function is called"; UpdateEnv(); } else if ("SetOSD" == funNameStr) { + LOG(DEBUG) << "SetOSD function is called"; SetOSD(); } else if ("UpdateOSD" == funNameStr) { + LOG(DEBUG) << "UpdateOSD function is called"; UpdateOSD(); } else if ("UpdateColorPalette" == funNameStr) { + LOG(DEBUG) << "UpdateColorPalette function is called"; UpdateColorPalette(); } else if ("UpdateOverTurn" == funNameStr) { + LOG(DEBUG) << "UpdateOverTurn function is called"; UpdateOverTurn(); } else if ("UpdateAutoFocus" == funNameStr) { + LOG(DEBUG) << "UpdateAutoFocus function is called"; UpdateAutoFocus(); } else if ("UpdateTempUnit" == funNameStr) { + LOG(DEBUG) << "UpdateTempUnit function is called"; UpdateTempUnit(); } else if ("SaveTempData" == funNameStr) { + LOG(DEBUG) << "SaveTempData function is called"; SaveTempData(); } } @@ -413,14 +436,12 @@ void InfraredTemp::MessageCallBackHandle(IRNETHANDLE hHandle, WPARAM wParam, LPA case 0: { //连接成功 it->SetConnect(true); - //g_log->TraceKeyInfo(u8"热成像连接成功"); LOG(DEBUG) << u8"热成像连接成功"; }break; case 1: { //用户停止连接 it->SetConnect(false); - //g_log->TraceKeyInfo(u8"热成像用户停止连接"); LOG(DEBUG) << u8"热成像用户停止连接"; }break; case 2: { diff --git a/InfraredTemp/src/InfraredTemp.h b/InfraredTemp/src/InfraredTemp.h index 04417ee..6fc12ea 100644 --- a/InfraredTemp/src/InfraredTemp.h +++ b/InfraredTemp/src/InfraredTemp.h @@ -6,7 +6,6 @@ #include #include #include -#include "TempRegion.h" #include #include @@ -14,7 +13,7 @@ struct HEADER { uchar flag[2]{}; uchar funCode{}; uchar funName[30]{}; - int32_t dataLen; + int32_t dataLen{0}; }; struct SendData { @@ -72,29 +71,29 @@ public: int ymax; }; - struct InfraredTempAssist { - unsigned int layerStartIndex; - unsigned int layerEndIndex; - int trSelectIndex; - int layerSelect; - TempRegion* selectTR; - LayerTempPointConfig::LayerRegion* selectLR; + //struct InfraredTempAssist { + // unsigned int layerStartIndex; + // unsigned int layerEndIndex; + // int trSelectIndex; + // int layerSelect; + // TempRegion* selectTR; + // LayerTempPointConfig::LayerRegion* selectLR; - int pointAddX; - int pointAddY; - bool addPointClick; - InfraredTempAssist() { - layerStartIndex = 1; - layerEndIndex = 2; - trSelectIndex = -1; - layerSelect = -1; - selectTR = NULL; - selectLR = NULL; - pointAddX = 0; - pointAddY = 0; - addPointClick = false; - } - }; + // int pointAddX; + // int pointAddY; + // bool addPointClick; + // InfraredTempAssist() { + // layerStartIndex = 1; + // layerEndIndex = 2; + // trSelectIndex = -1; + // layerSelect = -1; + // selectTR = NULL; + // selectLR = NULL; + // pointAddX = 0; + // pointAddY = 0; + // addPointClick = false; + // } + //}; InfraredTemp(); ~InfraredTemp(); diff --git a/InfraredTemp/src/InfraredTempCfg.cpp b/InfraredTemp/src/InfraredTempCfg.cpp deleted file mode 100644 index 6e8e575..0000000 --- a/InfraredTemp/src/InfraredTempCfg.cpp +++ /dev/null @@ -1,310 +0,0 @@ -//#include "InfraredTempCfg.h" -////#include "BaseConfig.h" -// -// -//InfraredTempCfg::InfraredTempCfg() -//{ -// m_Emissivity=9500; -// m_AirTemp=250000; -// m_ReflectTemp=250000; -// m_Humidity=10000; -// m_Distance = 7000; -// m_ColorPalette = 0; -// -// /*m_PlatformStartX = 50; -// m_PlatformStartY = 50; -// m_PlatformEndX = 600; -// m_PlatformEndY = 450;*/ -// -// m_PlatformAX=0; -// m_PlatformAY=0; -// -// m_PlatformBX=630; -// m_PlatformBY=0; -// -// m_PlatformCX=630; -// m_PlatformCY=510; -// -// m_PlatformDX=0; -// m_PlatformDY=510; -// -// m_ChillDowmTemp = 200.0f; -// m_TempCtrlType = WAIT_TEMP; -// -// m_DeltaTemp = 5.0f; -// m_DeltaPower = 0.5f; -// -// m_LayerWaitMil = 0; -// m_OverTurn = 0; -// -// m_IsAvgCalcValue = true; -// m_AvgCalcValueType = AVG_5; -// -// m_IsForceConnect = false; -// m_IsEnable = false; -// m_UseManualPoints = false; -// -// //m_ForceConnectIP = "192.168.1.29"; -// memset(m_szIpAssist, '\0', sizeof(m_szIpAssist)); -// -// m_IsConnect = false; -//} -// -// -//InfraredTempCfg::~InfraredTempCfg() -//{ -//} -// -// -////void InfraredTempCfg::GetUpdateSql(vector& ups) -////{ -//// char buffer[512]; -//// sprintf_s(buffer, sizeof(buffer), "UPDATE %s set %s=", -//// BaseConfig::TABLE_NAME.c_str(), -//// BaseConfig::FIELD_CONFIG_VALUE.c_str() -//// ); -//// string strhead(buffer); -//// sprintf_s(buffer, sizeof(buffer), " WHERE %s='%s' AND %s=", -//// BaseConfig::FIELD_CONFIG_NAME.c_str(), -//// CONFIG_NAME.c_str(), -//// BaseConfig::FIELD_CONFIG_CODE.c_str() -//// ); -//// string strtail(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_IsEnable?"1":"0", -//// strtail.c_str(), FIELD_IS_ENABLE.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_Emissivity).c_str(), -//// strtail.c_str(), FIELD_EMISSIVITY.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_AirTemp).c_str(), -//// strtail.c_str(), FIELD_AIR_TEMP.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_ReflectTemp).c_str(), -//// strtail.c_str(), FIELD_REFLECT_TEMP.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_Humidity).c_str(), -//// strtail.c_str(), FIELD_HUMIDITY.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_Distance).c_str(), -//// strtail.c_str(), FIELD_DISTANCE.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_OSDSwitch?"1":"0", -//// strtail.c_str(), FIELD_OSD_SWITCH.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_GlobalTempAdd ? "1" : "0", -//// strtail.c_str(), FIELD_GLOBAL_TEMP_ADD.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_GlobalTempParamAdd ? "1" : "0", -//// strtail.c_str(), FIELD_GLOBAL_TEMP_PARAM_ADD.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_PseudoColorBarsAdd ? "1" : "0", -//// strtail.c_str(), FIELD_PSEUDO_COLOR_BAR_ADD.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_HighLowTempCursorAdd ? "1" : "0", -//// strtail.c_str(), FIELD_HIGH_LOW_TEMP_CURSOR_ADD.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_ColorPalette).c_str(), -//// strtail.c_str(), FIELD_COLOR_PALETTE.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_GainType).c_str(), -//// strtail.c_str(), FIELD_GAIN_TYPE.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_TempUnit).c_str(), -//// strtail.c_str(), FIELD_TEMP_UNIT.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_ChillDowmTemp).c_str(), -//// strtail.c_str(), FIELD_CHILL_DOWN_TEMP.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_TempCtrlType).c_str(), -//// strtail.c_str(), FIELD_SURFACE_TEMP_CTRL_TYPE.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformAX).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_A_X.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformAY).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_A_Y.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformBX).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_B_X.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformBY).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_B_Y.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformCX).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_C_X.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformCY).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_C_Y.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformDX).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_D_X.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_PlatformDY).c_str(), -//// strtail.c_str(), FIELD_PLATFORM_D_Y.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_DeltaTemp).c_str(), -//// strtail.c_str(), FIELD_DELTA_TEMP.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_DeltaPower).c_str(), -//// strtail.c_str(), FIELD_DELTA_POWER.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_LayerWaitMil).c_str(), -//// strtail.c_str(), FIELD_LAYER_WAIT_MIL.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_IsAvgCalcValue?"1":"0", -//// strtail.c_str(), FIELD_IS_AVG_CALC_VALUE.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_AvgCalcValueType).c_str(), -//// strtail.c_str(), FIELD_AVG_CALC_VALUE.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_IsForceConnect?"1":"0", -//// strtail.c_str(), FIELD_IS_FORCE_CONNECT.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_UseManualPoints ? "1" : "0", -//// strtail.c_str(), FIELD_USE_MANUAL_POINTS.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// m_ForceConnectIP.c_str(), -//// strtail.c_str(), FIELD_FORCE_CONNECT_IP.c_str()); -//// ups.push_back(buffer); -//// -//// sprintf_s(buffer, sizeof(buffer), "%s'%s'%s'%s'", -//// strhead.c_str(), -//// to_string(m_OverTurn).c_str(), -//// strtail.c_str(), FIELD_OVER_TURN.c_str()); -//// ups.push_back(buffer); -////} -// -////string InfraredTempCfg::CONFIG_NAME="InfraredTempCfg"; -////string InfraredTempCfg::FIELD_IS_ENABLE = "IsEnable"; -////string InfraredTempCfg::FIELD_EMISSIVITY = "Emissivity"; -////string InfraredTempCfg::FIELD_AIR_TEMP = "AirTemp"; -////string InfraredTempCfg::FIELD_REFLECT_TEMP = "ReflectTemp"; -////string InfraredTempCfg::FIELD_HUMIDITY = "Humidity"; -////string InfraredTempCfg::FIELD_DISTANCE = "Distance"; -////string InfraredTempCfg::FIELD_OSD_SWITCH="OSDSwitch"; -////string InfraredTempCfg::FIELD_GLOBAL_TEMP_ADD="GlobalTempAdd"; -////string InfraredTempCfg::FIELD_GLOBAL_TEMP_PARAM_ADD="GlobalTempParamAdd"; -////string InfraredTempCfg::FIELD_PSEUDO_COLOR_BAR_ADD="PseudoColorBarAdd"; -////string InfraredTempCfg::FIELD_HIGH_LOW_TEMP_CURSOR_ADD="HighLowTempCursorAdd"; -////string InfraredTempCfg::FIELD_COLOR_PALETTE="ColorPalette"; -////string InfraredTempCfg::FIELD_GAIN_TYPE="GainType"; -////string InfraredTempCfg::FIELD_TEMP_UNIT="TempUnit"; -/////*string InfraredTempCfg::FIELD_PLATFORM_START_X="PlatformStartX"; -////string InfraredTempCfg::FIELD_PLATFORM_START_Y="PlatformStartY"; -////string InfraredTempCfg::FIELD_PLATFORM_END_X="PlatformEndX"; -////string InfraredTempCfg::FIELD_PLATFORM_END_Y="PlatformEndY";*/ -////string InfraredTempCfg::FIELD_CHILL_DOWN_TEMP = "ChilleDownTemp"; -////string InfraredTempCfg::FIELD_SURFACE_TEMP_CTRL_TYPE = "SurfaceTempCtrlType"; -////string InfraredTempCfg::FIELD_PLATFORM_A_X="PlatFormAX"; -////string InfraredTempCfg::FIELD_PLATFORM_A_Y = "PlatFormAY"; -////string InfraredTempCfg::FIELD_PLATFORM_B_X = "PlatFormBX"; -////string InfraredTempCfg::FIELD_PLATFORM_B_Y = "PlatFormBY"; -////string InfraredTempCfg::FIELD_PLATFORM_C_X = "PlatFormCX"; -////string InfraredTempCfg::FIELD_PLATFORM_C_Y = "PlatFormCY"; -////string InfraredTempCfg::FIELD_PLATFORM_D_X = "PlatFormDX"; -////string InfraredTempCfg::FIELD_PLATFORM_D_Y = "PlatFormDY"; -////string InfraredTempCfg::FIELD_DELTA_TEMP="DeltaTemp"; -////string InfraredTempCfg::FIELD_DELTA_POWER="DeltaPower"; -////string InfraredTempCfg::FIELD_LAYER_WAIT_MIL="LayerWaitMil"; -////string InfraredTempCfg::FIELD_IS_AVG_CALC_VALUE = "IsAvgCalcValue"; -////string InfraredTempCfg::FIELD_AVG_CALC_VALUE = "AvgCalcValue"; -////string InfraredTempCfg::FIELD_IS_FORCE_CONNECT = "IsForceConnect"; -////string InfraredTempCfg::FIELD_USE_MANUAL_POINTS="UseManualPoints"; -////string InfraredTempCfg::FIELD_FORCE_CONNECT_IP = "ForceConnectIP"; -////string InfraredTempCfg::FIELD_OVER_TURN = "OverTurn"; \ No newline at end of file diff --git a/InfraredTemp/src/InfraredTempCfg.h b/InfraredTemp/src/InfraredTempCfg.h index 251deb3..22c5729 100644 --- a/InfraredTemp/src/InfraredTempCfg.h +++ b/InfraredTemp/src/InfraredTempCfg.h @@ -20,13 +20,6 @@ enum AvgCalcType { struct InfraredTempCfg { -//public: - - - //InfraredTempCfg(); - //~InfraredTempCfg(); - -//public: bool m_IsEnable; int m_Emissivity; //发射率 int m_AirTemp; //空气温度 @@ -81,40 +74,6 @@ struct InfraredTempCfg char m_szIpAssist[16]; bool m_IsConnect; //是否连接 -//public: - //static string CONFIG_NAME; - //static string FIELD_IS_ENABLE; - //static string FIELD_EMISSIVITY; - //static string FIELD_AIR_TEMP; - //static string FIELD_REFLECT_TEMP; - //static string FIELD_HUMIDITY; - //static string FIELD_DISTANCE; - //static string FIELD_OSD_SWITCH; - //static string FIELD_GLOBAL_TEMP_ADD; - //static string FIELD_GLOBAL_TEMP_PARAM_ADD; - //static string FIELD_PSEUDO_COLOR_BAR_ADD; - //static string FIELD_HIGH_LOW_TEMP_CURSOR_ADD; - //static string FIELD_COLOR_PALETTE; - //static string FIELD_GAIN_TYPE; - //static string FIELD_TEMP_UNIT; - //static string FIELD_CHILL_DOWN_TEMP; - //static string FIELD_SURFACE_TEMP_CTRL_TYPE; - //static string FIELD_PLATFORM_A_X; - //static string FIELD_PLATFORM_A_Y; - //static string FIELD_PLATFORM_B_X; - //static string FIELD_PLATFORM_B_Y; - //static string FIELD_PLATFORM_C_X; - //static string FIELD_PLATFORM_C_Y; - //static string FIELD_PLATFORM_D_X; - //static string FIELD_PLATFORM_D_Y; - //static string FIELD_DELTA_TEMP; - //static string FIELD_DELTA_POWER; - //static string FIELD_LAYER_WAIT_MIL; - //static string FIELD_IS_AVG_CALC_VALUE; - //static string FIELD_AVG_CALC_VALUE; - //static string FIELD_IS_FORCE_CONNECT; - //static string FIELD_USE_MANUAL_POINTS; - //static string FIELD_FORCE_CONNECT_IP; - //static string FIELD_OVER_TURN; + }; diff --git a/InfraredTemp/src/LayerTempPointConfig.cpp b/InfraredTemp/src/LayerTempPointConfig.cpp deleted file mode 100644 index ecbbec1..0000000 --- a/InfraredTemp/src/LayerTempPointConfig.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "LayerTempPointConfig.h" - - - -LayerTempPointConfig::LayerTempPointConfig() -{ -} - - -LayerTempPointConfig::~LayerTempPointConfig() -{ - for (map*>::iterator it = m_LayerTempPoints.begin(); it != m_LayerTempPoints.end();it++) { - list* tps = it->second; - for (list::iterator it2 = tps->begin(); it2 != tps->end();it2++) { - TempPoint* tp = (*it2); - delete tp; - tp = NULL; - } - tps->clear(); - delete tps; - tps = NULL; - } - m_LayerTempPoints.clear(); - - for (map::iterator it = m_LayerRegions.begin(); it != m_LayerRegions.end();it++) { - LayerRegion* lr = it->second; - delete lr; - lr = NULL; - } - m_LayerRegions.clear(); -} diff --git a/InfraredTemp/src/LayerTempPointConfig.h b/InfraredTemp/src/LayerTempPointConfig.h deleted file mode 100644 index 0755b3c..0000000 --- a/InfraredTemp/src/LayerTempPointConfig.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include -#include -#include -using namespace std; - - -class LayerTempPointConfig -{ -public: - struct LayerRegion - { - unsigned int startIndex=0; - unsigned int endIndex=0; - }; - - struct TempPoint { - int x=0; - int y=0; - }; - - LayerTempPointConfig(); - ~LayerTempPointConfig(); - - map m_LayerRegions; - - map*> m_LayerTempPoints; -}; - diff --git a/InfraredTemp/src/SocketServer.cpp b/InfraredTemp/src/SocketServer.cpp index e61c0ae..85966c3 100644 --- a/InfraredTemp/src/SocketServer.cpp +++ b/InfraredTemp/src/SocketServer.cpp @@ -145,6 +145,10 @@ void SocketServer::run() { closeSocketSet.insert(client); } } + if (sendData.data) { + delete[] sendData.data; + sendData.data = nullptr; + } } } @@ -205,6 +209,8 @@ void SocketServer::CallFun(const HEADER& header, const string& data) { InfraredTempCfg cfgData; memcpy_s(&cfgData, sizeof(InfraredTempCfg), data.c_str(), data.size()); m_InfraredTemp->SetInfraredTempCfg(cfgData); + + m_InfraredTemp->AddFunQue("Connect"); } else if ("SetVideoFlag" == funNameStr) { bool flag = false; @@ -213,7 +219,7 @@ void SocketServer::CallFun(const HEADER& header, const string& data) { m_InfraredTemp->SetVideoFlag(flag); } else { - LOG(DEBUG) << "recv "<< funNameStr<<" function"; + //LOG(DEBUG) << "recv "<< funNameStr<<" function"; m_InfraredTemp->AddFunQue(funNameStr); } diff --git a/InfraredTemp/src/SocketServer.h b/InfraredTemp/src/SocketServer.h index 43118b8..2afa02d 100644 --- a/InfraredTemp/src/SocketServer.h +++ b/InfraredTemp/src/SocketServer.h @@ -3,7 +3,6 @@ #include #include #include -#include "CommonStructs.h" #include #include #include "InfraredTemp.h" diff --git a/InfraredTemp/src/TempRegion.cpp b/InfraredTemp/src/TempRegion.cpp deleted file mode 100644 index 9bd8a66..0000000 --- a/InfraredTemp/src/TempRegion.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "TempRegion.h" - -TempRegion::TempRegion(int id) - :m_Id(id) -{ - m_Pa.x = 0; - m_Pa.y = 0; - m_Pb.x = 0; - m_Pb.y = 0; - m_Pc.x = 0; - m_Pc.y = 0; - m_Pd.x = 0; - m_Pd.y = 0; - - m_MinTemp = 0.0f; - m_MaxTemp = 0.0f; - m_AvgTemp = 0.0f; - m_PartMinX = 0.0f; - m_PartMaxX = 0.0f; - m_PartMinY = 0.0f; - m_PartMaxY = 0.0f; - m_LastWaitTemp = 0.0f; - m_DifPower = 0.0f; - m_DifTemp = 0.0f; - m_HadWait = false; - m_LayerTempPointConfig = new LayerTempPointConfig(); -} - - -TempRegion::~TempRegion() -{ - delete m_LayerTempPointConfig; -} diff --git a/InfraredTemp/src/TempRegion.h b/InfraredTemp/src/TempRegion.h deleted file mode 100644 index ddbab52..0000000 --- a/InfraredTemp/src/TempRegion.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include -#include "../utils/Average.h" -#include -#include "LayerTempPointConfig.h" -using namespace std; - - -class TempRegion -{ -public: - TempRegion(int id); - ~TempRegion(); - - void SetAvgSize(int isize) { - int avgSize = (isize + 1) * 5; - m_AvgMinTemp.SetValueSize(avgSize); - m_AvgMaxTemp.SetValueSize(avgSize); - m_AvgAvgTemp.SetValueSize(avgSize); - } - -public: - int m_Id; - //int m_Pid; - cv::Point m_Pa; - cv::Point m_Pb; - cv::Point m_Pc; - cv::Point m_Pd; - vector m_RegionPoints; - - float m_MinTemp; - float m_MaxTemp; - float m_AvgTemp; - - float m_PartMinX; - float m_PartMaxX; - float m_PartMinY; - float m_PartMaxY; - - bool m_IsRecorderMaxTemp; - float m_PrintMaxTemp; - - float m_DifPower; - float m_DifTemp; - float m_LastWaitTemp; - - bool m_HadWait; - - Average2 m_AvgMinTemp; - Average2 m_AvgMaxTemp; - Average2 m_AvgAvgTemp; - - LayerTempPointConfig* m_LayerTempPointConfig; -}; -