#pragma once #include #include #include #include "Logger/LoggerModule.h" #pragma comment(lib, "../lib/Logger/Win64/Logger.lib") using namespace std; ///////////////////////////////////////////////////////////////// enum /*class*/ VAR_TYPE { ALL_Var, Bool_Var, //bool Int_Var, // int float_Var, //float Doublel_Var, //double CharP_Var, //char* String_Var, //string CString_Var, //CString IpImageP_Var, //lpImage* Mat_Var, //Mat HTuple_Var, //HTuple HObject_Vat, //HObject HImage_Var, //HImage ISocketP_Var, //ISocket* ArrayInP_Var, //ArrayIn* ArrayOutP_Var, //ArrayOut* ArrayRobotPos_Vat, //ArrayRobotPos* HTuple_Pos_Var, //HTuple_Pos HTuple_HomMat2D_Var, //HTuple_HomMat2D HTuple_Point_Var, //HTuple_Point HTuple_Line_Var, //HTuple_Line HTuple_Circle_Var, //HTuple_Circle HTuple_Disp_Var, //HTuple_Disp HTuple_Window_Var, //HTuple_Window HTuple_Ncc_Modle_Var, //HTuple_Ncc_Modle HTuple_Shape_Modle_Var, //HTuple_Shape_Modle QHalconWindow_Var, //QHalconWindow HTuple_Calibration_Var, //HTuple_Calibration HTuple_CamParam_PoseCalib_Var, //HTuple_CamParam_PoseCalib ////////////////////////////////////////////////////////////////////////// Control_Base, Control_ComboBox, Control_Button, Control_Radiobutton, Control_CheckBox, Control_ListCtrl, Control_Groupbox, Control_Static, Control_Listbox, Control_EditBox, Control_Text, Control_Image, ////////////////////////////////////////////////////////////////////////// Tool, }; typedef struct _tagArray { int nValidData = 100; float mData[512] = { 0 }; } Array1; typedef struct _tagEven { int nEvenTime = INFINITE; //超时时间 HANDLE hEvenHandle = NULL;// 事件句柄 } EVEN; typedef struct _tagHPos { HTuple hv_Row; HTuple hv_Column; HTuple hv_Angle; HTuple hv_HomMat2D; _tagHPos() { Clear(); } void Clear() { hv_Row.Clear(); hv_Column.Clear(); hv_Angle.Clear(); hv_HomMat2D.Clear(); } } HPOS; typedef struct _tagHCalibration { HTuple hv_HomMat2D; HTuple hv_Center_x;//旋转中心坐标(图像坐标系) HTuple hv_Center_y;//旋转中心坐标(图像坐标系) double nToolMark_X;//设定的中心点坐标(机器人坐标系) double nToolMark_Y;//设定的中心点坐标(机器人坐标系) double nToolMark_A;//设定的基准角度(机器人坐标系) bool b_IsAngleCalibration;//是否启用了旋转标定 _tagHCalibration() { Clear(); } void Clear() { hv_HomMat2D.Clear(); hv_Center_x.Clear(); hv_Center_y.Clear(); nToolMark_X = 0; nToolMark_Y = 0; nToolMark_A = 0; b_IsAngleCalibration = false; } } HCALIBRATION; typedef struct _tagHCamParam_PoseCalib { HTuple hv_CamParam; HTuple hv_PoseCalib; _tagHCamParam_PoseCalib() { Clear(); } void Clear() { hv_CamParam.Clear(); hv_PoseCalib.Clear(); } }HCAMPARAM_POSECALIB; typedef struct _tagHHCCModle { HObject hv_ROI; HObject ho_ModelRegion; HNCCModel hv_ModelID; HTuple hv_SubPixel; int m_nAngleStart2; int m_nAngleExtent2; int m_nMinScore; int m_nNumMatches; int m_nMaxOverlap; int m_nNumLevels; _tagHHCCModle() { Clear(); } void Clear() { hv_ROI.Clear(); ho_ModelRegion.Clear(); hv_ModelID.Clear(); hv_SubPixel.Clear(); m_nAngleStart2 = 0; m_nAngleExtent2 = 0; m_nMinScore = 0; m_nNumMatches = 0; m_nMaxOverlap = 0; m_nNumLevels = 0; } } HNCCMODLE; typedef struct _tagShapeModel { HObject hv_ROI; HObject ho_ModelRegion; HShapeModel hv_ModelID; HTuple hv_SubPixel; int m_nAngleStart2; int m_nAngleExtent2; int m_nMinScore; int m_nNumMatches; int m_nMaxOverlap; int m_nNumLevels; _tagShapeModel() { Clear(); } void Clear() { hv_ROI.Clear(); ho_ModelRegion.Clear(); hv_ModelID.Clear(); hv_SubPixel.Clear(); m_nAngleStart2 = 0; m_nAngleExtent2 = 0; m_nMinScore = 0; m_nNumMatches = 0; m_nMaxOverlap = 0; m_nNumLevels = 0; } } HSHAPEMODLE; typedef struct _tagHMessage { HTuple hv_Row; HTuple hv_Column; HTuple hv_Msg; HTuple hv_MsgSize; HTuple hv_MsgColor; _tagHMessage() { Clear(); } void addMsg(HTuple hvMsg, HTuple hvRow, HTuple hvColumn, HTuple hvMsgSize = 10, HTuple hvMsgColor = "green") { int nCon = hv_Row.TupleLength(); hv_Msg[nCon] = hvMsg; hv_Row[nCon] = hvRow; hv_Column[nCon] = hvColumn; hv_MsgSize[nCon] = hvMsgSize; hv_MsgColor[nCon] = hvMsgColor; } void Clear() { hv_Row = HTuple(); hv_Column = HTuple(); hv_Msg = HTuple(); hv_MsgSize = HTuple(); hv_MsgSize = HTuple(); hv_MsgColor = HTuple(); // hv_MsgSize = 10; // hv_MsgColor = "green"; } } HMESSAGE; typedef struct _tagHDISP { HObject ho_DispObj; HMESSAGE hv_Message; _tagHDISP() { Clear(); } void addMsg(HTuple hvMsg, HTuple hvRow, HTuple hvColumn, HTuple hvMsgSize = 10, HTuple hvMsgColor = "green") { hv_Message.addMsg(hvMsg, hvRow, hvColumn, hvMsgSize, hvMsgColor); } void AddObj(HObject hoObj) { ConcatObj(ho_DispObj, hoObj, &ho_DispObj); } void Clear() { GenEmptyObj(&ho_DispObj); hv_Message.Clear(); } } HDISP; typedef struct _tagHIMAGE { HObject ho_Image; } HIMAGE; typedef struct _tagHWINDOW { HTuple hv_Window; _tagHWINDOW() { Clear(); } void Clear() { hv_Window.Clear(); } } HWINDOW; typedef struct _tagHLine { void Clear() { hv_Row1.Clear(); hv_Column1.Clear(); hv_Row2.Clear(); hv_Column2.Clear(); } HTuple hv_Row1; HTuple hv_Column1; HTuple hv_Row2; HTuple hv_Column2; } HLine; typedef struct _tagHCircle { void Clear() { hv_Row.Clear(); hv_Column.Clear(); hv_Radius.Clear(); } HTuple hv_Row; HTuple hv_Column; HTuple hv_Radius; } HCircle; typedef struct _tagHPoint { void Clear() { hv_Row.Clear(); hv_Column.Clear(); } HTuple hv_Row; HTuple hv_Column; } HPoint; ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// #define FUNCTION_GETGLOBALFILEID ("GetGlobalFileID") #define FUNCTION_DESCRIPTION ("Description") #define FUNCTION_GETTOOLPTR ("GetToolPtr") #define FUNCTION_RELEASE ("Release") // Diagram的控件类型 #define CONTROL_BASE _T("Base") #define CONTROL_COMBOBOX _T("ComboBox") #define CONTROL_BUTTON _T("Button") #define CONTROL_RADIOBUTTON _T("Radiobutton") #define CONTROL_CHECKBOX _T("CheckBox") #define CONTROL_LISTCTRL _T("ListCtrl") #define CONTROL_GROUPBOX _T("Groupbox") #define CONTROL_STATIC _T("Static") #define CONTROL_LISTBOX _T("Listbox") #define CONTROL_EDITBOX _T("EditBox") #define CONTROL_TEXT _T("Text") // 同EditBox #define CONTROL_IMAGE _T("Image") // 同Edit ////////////////////////////////////////////////////////////////////////// // Dll 工作状态 #define TOOL_ERROR -1 #define TOOL_SUCCESS 0 #define TOOl_BUSY 1 #define TOOL_DONE 2 // Dll执行的返回值 #define RT_INVALID -2 // 工具无效 或被禁用 #define RT_NONE -1 // 工具尚未执行 #define RT_SUCCESS 0 // 工具执行成功 #define RT_ERROR 1 #define RT_TIMEOUT 2 #define RT_GOTO 3 // 返回跳转信号 // 接口相关错误码 // 接口已存在 #define RT_ERR_ALREADY_EXIST 0x2000 // 接口信息无效 #define RT_ERR_INVALID_INFO 0x2001 // 各种控件需要同步的消息 typedef enum _tagSyncMsg { SYNC_COMBO_SELCHANGE, SYNC_EDIT_CHANGE, SYNC_LIST_CHANGE, } SYNC_MSG; // 输入输出类型 typedef enum _tagInfDirection { INF_IN = 1, // 输入接口 INF_OUT = 2, // 输出接口 INF_INOUT = 3, INF_NONE = 5, } INF_DIRECTION; // 接口类型(值或控件) typedef enum _tagInfType { INF_VALUE_1 = 1, // 基础变量值类型 INF_VALUE_2 = 2, // 图像变量值类型 INF_VALUE_3 = 3, // 句柄、对象类型 INF_VALUE_4 = 4, // 地址类型 INF_CONTROL = 4, // 控件类型 INF_TOOL = 5, // 工具(跳转用) INF_TYPE_NONE = 6 // 未定义 } INF_TYPE; // 参数传递类型(传值或者传引用) typedef enum _tagInfWay { INF_BY_VALUE, // 传值 INF_BY_ADDRESS, // 传地址 INF_BY_NONE } INF_WAY; // 工具类型(工具或控件) typedef enum _tagToolType { TOOL_BY_TOOL, // 工具 TOOL_BY_PROT, // 端口 TOOL_BY_GOTO, // 跳转 TOOL_BY_NONE } TOOL_TYPE; ////////////////////////////////////////////// // Dll工具的接口描述信息 typedef struct _tagDllInterface { CString strName; // 接口名字 CString strAliasName; // 工具别名(通常为曾用名或者中文名) CString strInfo; // 接口的描述信息 VAR_TYPE VarType; // 接口的值类型 LPVOID* pValue; // 接口的值指针 INF_DIRECTION InfDirection; // 输入还是输出 INF_TYPE InfType; // 控件类型还是值类型 INF_WAY InfWay; // 传值还是传引用(2019-5-3增加) bool bShow; // 2019-3-26 是否隐藏此接口 bool bSmartLink; // 智能链接(添加工具到任务栏的时候,工具的输入接口自动向上搜素可用的输出端口.序列化的时候该功能不适用) _tagDllInterface() { Reset(); } void Reset() { strInfo = _T("Prot Info !"); InfDirection = INF_NONE; InfType = INF_TYPE_NONE;//INF_VALUE_1 InfWay = INF_BY_VALUE; bShow = true; bSmartLink = false; pValue = NULL; } // 重载 = _tagDllInterface& operator =(const _tagDllInterface& inf) { if (this != &inf) { this->strName = inf.strName; this->strAliasName = inf.strAliasName; this->strInfo = inf.strInfo; this->VarType = inf.VarType; this->InfDirection = inf.InfDirection; this->InfType = inf.InfType; this->InfWay = inf.InfWay; this->bShow = inf.bShow; } return *this; } ~_tagDllInterface() { } } DLL_INF, *LPDLL_INF; ////////////////////////////////////////////// // Dll工具的描述信息 typedef struct _tagDllToolDescription { TOOL_TYPE Type; // 工具的类型(工具、控件、跳转指令) CString strCategory; // 工具的分组 CString strName; // 工具名字 CString strAliasName; // 工具别名(通常为曾用名或者中文名) CString strVersion; // 工具版本 CString strInfo; // 描述信息 _tagDllToolDescription() { Type = TOOL_TYPE::TOOL_BY_TOOL; } } DLL_TOOL_DESC, *LPDLL_TOOL_DESC; typedef struct _tagDEUBGOBJ { HImage mImage; HObject mObj; _tagDEUBGOBJ() { mImage.Clear(); mObj.Clear(); } } DEUBGOBJ; // 接口类型 typedef enum _tagMsgType { _WARNING, // 警告 _ERROR, // 错误 _INFO, // 信息 _MSG, // Message } MSG_WAY; /// 工具状态 typedef void(__stdcall* receToolStateCallBack) (CString strToolName, int nState, long long userParam); /// Log typedef void(__stdcall* receLogCallBack) (CString strToolName, MSG_WAY nType, CString strMassage, long long userParam); /// OnExecute typedef void(__stdcall* receOnExecutegCallBack) (CString strToolName, long long userParam); /// ToolBusy typedef void(__stdcall* receToolBusyCallBack) (CString strToolName, int nState, CString strMassage, long long userParam); // dll操作向exe同步的回调函数 // CWnd:触发的控件指针 // nMSG:触发的消息 typedef std::function CONTROL_CALLBACK; class CDllTool { public: CDllTool() { //ControlCallback = NULL; m_Even.hEvenHandle = NULL; m_Even.nEvenTime = 0; } virtual ~CDllTool() { } public: virtual int InitTool(CWnd * pWnd, CString strTaskName, CString strToolName) { return 0; }; virtual void ShowDialog(CString strTaskName, CString strToolName) {}; virtual DEUBGOBJ GetDeubgDispObj() { DEUBGOBJ obj; return obj; }; virtual int Execute() { return 0; }; DLL_INF& Interface(const int nIndex) { return m_Interfaces[nIndex]; } UINT GetInterfaceSize() { return (UINT)m_Interfaces.size(); } void AddInterface(const DLL_INF dll_inf) { m_Interfaces.push_back(dll_inf); }; void InterfaceClear() { m_Interfaces.clear(); }; template T& Value(const int nIndex) { return *(T*)m_Interfaces[nIndex].pValue; } template void SetValue(const int nIndex, T& t, INF_WAY way = INF_BY_VALUE) { if (way == INF_BY_VALUE) { *(T*)m_Interfaces[nIndex].pValue = t; } else { *m_Interfaces[nIndex].pValue = &t; } } virtual void Trigger(bool bMode = false) { }; virtual void Running(bool bRun) {}; virtual void Serialize(CArchive& ar, const int nExeVersion, const int nDocVersion) {}; //设置接收 工具状态 数据回调函数 virtual void setReceToolStateCallBack(receToolStateCallBack callBack, long long userParam) {}; ///设置接收 LOG 数据回调函数 virtual void setReceLogCallBack(receLogCallBack callBack, long long userParam) {}; ///设置接收 OnExecute 回调函数 virtual void setOnExecuteCallBack(receOnExecutegCallBack callBack, long long userParam) {}; ///设置接收 ToolBusy 回调函数 virtual void setToolBusyCallBack(receToolBusyCallBack callBack, long long userParam) {}; EVEN m_Even; CONTROL_CALLBACK ControlCallback; // 控件用于双向同步的回调函数 protected: virtual void InitDefaultInterfaces() {}; protected: vector m_Interfaces; }; //////////////////////// /// 网络套接字 class ISocket { public: virtual ~ISocket() { } public: /// IP virtual CString ip(void) = 0; /// 端口号 virtual UINT port(void) = 0; /// 获取已经接收的消息数据大小 virtual BOOL msgSize(long &size) = 0; /// 接收消息 virtual BOOL receMsg(void** msg, long size) = 0; /// 发送消息 virtual BOOL sendMsg(const CString msg) = 0; /// 发送消息 virtual BOOL sendMsg(const void* msg, long size) = 0; }; //TRACE