259 lines
5.3 KiB
C++
259 lines
5.3 KiB
C++
#pragma once
|
|
|
|
#include <windows.h>
|
|
#include "InfraredTempSDK.h"
|
|
#include "../../config/bean/InfraredTempCfg.h"
|
|
#include "../../config/bean/MachineCfg.h"
|
|
#include <opencv2/core/core.hpp>
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <opencv2\imgproc\types_c.h>
|
|
#include "../../job/JobController.h"
|
|
#include "TempRegion.h"
|
|
#include "../../log/LogImage.h"
|
|
|
|
class InfraredTemp
|
|
{
|
|
public:
|
|
struct PartTempStat
|
|
{
|
|
int id;
|
|
//int pid;
|
|
float minTemp;
|
|
float maxTemp;
|
|
float avgTemp;
|
|
float printMaxTemp;
|
|
|
|
float difPower;
|
|
float difTemp;
|
|
|
|
|
|
PartTempStat() {
|
|
id = 0;
|
|
//pid = 0;
|
|
minTemp = 0.0f;
|
|
maxTemp = 0.0f;
|
|
avgTemp = 0.0f;
|
|
printMaxTemp = 0.0f;
|
|
difPower = 0.0f;
|
|
difTemp = 0.0f;
|
|
|
|
}
|
|
};
|
|
|
|
struct PrintPlatform {
|
|
cv::Point pa;
|
|
cv::Point pb;
|
|
cv::Point pc;
|
|
cv::Point pd;
|
|
vector<cv::Point> points;
|
|
|
|
int startX;
|
|
int startY;
|
|
int endX;
|
|
int endY;
|
|
};
|
|
|
|
struct Dimension {
|
|
int xmin;
|
|
int ymin;
|
|
int xmax;
|
|
int ymax;
|
|
};
|
|
|
|
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;
|
|
}
|
|
};
|
|
|
|
InfraredTemp();
|
|
~InfraredTemp();
|
|
|
|
bool Init();
|
|
void Startup();
|
|
void Shutdown();
|
|
|
|
|
|
bool IsConnect();
|
|
|
|
void UpdateEnv();
|
|
|
|
void SetOSD();
|
|
void UpdateOSD();
|
|
void UpdateColorPalette();
|
|
//void UpdateGain();
|
|
void UpdateOverTurn();
|
|
void UpdateAutoFocus();
|
|
//void GetGain();
|
|
void UpdateTempUnit();
|
|
|
|
unsigned int GetShowImage();
|
|
|
|
int GetWidth() { return m_ImageWidth; }
|
|
int GetHeight() { return m_ImageHeight; }
|
|
|
|
void AddTempRegion(TempRegion* tr);
|
|
void ClearTempRegion();
|
|
|
|
void CalcPrintPlatform();
|
|
//void TranRect(float stx,float sty,float edx,float edy,int& _stx,int& _sty,int& _edx,int& _edy);
|
|
void CalcRefRegion(TempRegion* tr);
|
|
|
|
void GetPartTemp(vector<PartTempStat>& pts);
|
|
void GetPartTempCtrlPower(vector<PartTempStat>& pts);
|
|
void GetPartTempCoveredWait(vector<PartTempStat>& pts);
|
|
string GetIp() { return string(m_ChanelInfo.szIP); }
|
|
|
|
bool IsOverChillDown();
|
|
void SaveTempData();
|
|
//void CalcTestTemp();
|
|
|
|
void ResetPrintMax();
|
|
|
|
//void FindContours(bool isPrint);
|
|
void SetJobCtrl(JobController* jc) { m_JobController = jc; }
|
|
|
|
void SetAvgSize();
|
|
|
|
void GetMousePointInfo(int* x, int* y, float* temp)
|
|
{
|
|
EnterCriticalSection(&m_ShowCS);
|
|
*x = m_MouseX;
|
|
*y = m_MouseY;
|
|
//int iTemp = (int)m_TempCalcData[m_MouseY*m_ImageWidth + m_MouseX];
|
|
float fK = m_TempCalcData[m_MouseY * m_ImageWidth + m_MouseX];
|
|
float fC = fK - 273.15f;
|
|
*temp = fC;
|
|
LeaveCriticalSection(&m_ShowCS);
|
|
}
|
|
|
|
void SetMouseXY(int x, int y) {
|
|
if (x < 0)x = 0;
|
|
if (y < 0)y = 0;
|
|
if (x >= m_ImageWidth)x = m_ImageWidth - 1;
|
|
if (y >= m_ImageHeight)y = m_ImageHeight - 1;
|
|
EnterCriticalSection(&m_ShowCS);
|
|
m_MouseX = x;
|
|
m_MouseY = y;
|
|
LeaveCriticalSection(&m_ShowCS);
|
|
}
|
|
|
|
float GetMouxeXYTemp() {
|
|
float temp = 0.0f;
|
|
EnterCriticalSection(&m_ShowCS);
|
|
temp = m_MouseXYTemp;
|
|
LeaveCriticalSection(&m_ShowCS);
|
|
return temp;
|
|
}
|
|
|
|
bool WaitTempReady(int partId);
|
|
void ResetWaitFlag();
|
|
bool IsPartWaited(int partid);
|
|
void SetPartWaited(int partid);
|
|
|
|
void Lock() {
|
|
EnterCriticalSection(&m_ShowCS);
|
|
}
|
|
void UnLock()
|
|
{
|
|
LeaveCriticalSection(&m_ShowCS);
|
|
}
|
|
|
|
vector<TempRegion*>* GetTempRegions() { return &m_TempRegions; }
|
|
|
|
bool InitLog(IFImage* ifimage);
|
|
|
|
unsigned int GetShowIFImage(unsigned char* data, unsigned long size, int* width, int* height);
|
|
private:
|
|
|
|
static void WINAPI MessageCallBackHandle(IRNETHANDLE hHandle, WPARAM wParam, LPARAM lParam, void *context);
|
|
static void TempCallBackHandle(char *pBuffer, long BufferLen, void* pContext);
|
|
static void VideoCallBackHandle(char *pBuffer, long BufferLen, int width, int height, void* pContext);
|
|
static void SerialCallBackHandle(char *pRecvDataBuff, int BuffSize, void* pContext);
|
|
|
|
static DWORD WINAPI RunPorc(InfraredTemp* _this);
|
|
void Run();
|
|
void Connect();
|
|
void GenTex(uint32_t *tex, unsigned int w, unsigned int h, void * data);
|
|
|
|
void SetConnect(bool bvalue);
|
|
|
|
int ReadPN(char* strPN);
|
|
public:
|
|
bool m_ShowFlag;
|
|
bool m_LogFlag;
|
|
InfraredTempAssist m_InfraredTempAssist;
|
|
private:
|
|
IRNETHANDLE m_Handle;
|
|
ChannelInfo m_ChanelInfo;
|
|
|
|
HANDLE m_Thread;
|
|
bool m_RunFlag;
|
|
CRITICAL_SECTION m_CS;
|
|
CRITICAL_SECTION m_ShowCS;
|
|
CRITICAL_SECTION m_WaitCS;
|
|
|
|
InfraredTempCfg* m_InfraredTempCfg;
|
|
MachineCfg* m_MachineCfg;
|
|
bool m_IsConnect;
|
|
|
|
int m_ImageWidth;
|
|
int m_ImageHeight;
|
|
float m_Aspect;
|
|
|
|
PrintPlatform m_PrintPlatform;
|
|
|
|
char* m_VideoSrcData;
|
|
char* m_VideoShowData;
|
|
int m_VideoDataLength;
|
|
bool m_VideoSrcDataUpdate;
|
|
|
|
int m_TempImageEnable;
|
|
bool m_IsNewNios;
|
|
//float m_TempValueFix;
|
|
unsigned short* m_TempSrcData;
|
|
float* m_TempSrcTraData;
|
|
float* m_TempCalcData;
|
|
|
|
bool m_TempSrcDataUpdate;
|
|
|
|
float m_MaxTemp;
|
|
|
|
cv::Mat m_MatSrc;
|
|
cv::Mat m_ShowMat;
|
|
uint32_t m_GLTex;
|
|
vector<TempRegion*> m_TempRegions;
|
|
JobController* m_JobController;
|
|
|
|
int m_MouseX;
|
|
int m_MouseY;
|
|
float m_MouseXYTemp;
|
|
|
|
double m_PlatformRef[3][3];
|
|
|
|
|
|
//int m_TempMeasType;
|
|
//int m_IComReadDataSize;
|
|
//unsigned char m_ComReadData[512];
|
|
uint32_t m_LogGLTex;
|
|
};
|