123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- // pch.h: 这是预编译标头文件。
- // 下方列出的文件仅编译一次,提高了将来生成的生成性能。
- // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
- // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
- // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
- #ifndef PCH_H
- #define PCH_H
- // 添加要在此处预编译的标头
- #include "framework.h"
- // Windows 头文件
- #include <windows.h>
- #include <assert.h>
- #include <string>
- #include <atomic>
- #include <thread>
- #include <map>
- #include "Log4CPP.Logger.hpp"
- #include "Log4CPP.TLSLog.Tracing.hpp"
- #include "mLog.Log4CPP.hpp"
- #include "ResDataObject.h"
- #include "DIOS.Dev.IODevice.hpp"
- //#include "CConfigDlg.h"
- //全局消息定义
- #define MSG_Dios_Notify_ModeInit (WM_USER+100)
- //主窗口句柄
- extern HWND gal_hTopWnd;
- //输出日志:可供下层模块调用
- using logFun = function <void(CString strlog)>;
- using msgFun = function <void(CString strKey, CString strText)>;
- extern logFun gal_pLogFun;
- extern msgFun gal_pMSGFun;
- void ToolsDlgLog(CString strlog);
- void ToolsDlgMSG(CString strKey, CString strText);
- //********************************属性定义********************************
- namespace nsDEV = DIOS::Dev;
- #define UnitTool_GenGUID "{123492D6-A546-4ACF-8EF1-2CCAA9EA974E}"
- #define UnitTool_Mech1GUID "{0C99B70A-F788-48E1-9728-403BFF6DF982}"
- #define UnitTool_Mech2GUID "{A6C288B9-8C4F-3A6C-9C5F-12345A0F7284}"
- #define UnitTool_Mech3GUID "{9A02D2A7-523D-4FE3-8EA0-C711AE7CA6C3}"
- #define UnitTool_Col1GUID "{566EC9F1-CE5A-4B31-9D2A-E9E80B4CA0CC}"
- #define UnitTool_Col2GUID "{DD98BBEB-0850-4BE7-997B-8DDECA6BD654}"
- #define UnitTool_SynGUID "{D1AF818B-72D0-400E-B780-DF58E2EF23D4}"
- #define UnitTool_FPDGUID "{A209866C-A049-4A17-B5C9-421974E59D68}"
- #define UnitTool_LogPath "\\DevToolConf\\Log4CPP.Config.Tool.xml"
- #define UnitTool_LogName "Tool.DiosUnit"
- #define UnitTool_configPath "\\DevToolConf\\UnitToolconfig.xml"
- #define UnitTool_UseJson 0
- #define UnitTool_PlatformModule "PlatformModule"
- #define UnitTool_DevErrorList "ErrorList"
- #define UnitTool_logKey_Null "(null)- "
- #define UnitTool_DevType_Null "null"
- #define UnitTool_logKey_UI "(DiosUnit)- "
- #define UnitTool_DevType_UI "DiosUnit"
- #define UnitTool_logKey_Gen "(GEN)- "
- #define UnitTool_DevType_Gen "Generator"
- #define UnitTool_logKey_Mech "(MECH)- "
- #define UnitTool_DevType_Mech "Mechanical"
- #define UnitTool_logKey_Col "(COLL)- "
- #define UnitTool_DevType_Col "Collimator"
- #define UnitTool_logKey_Syn "(SYN)- "
- #define UnitTool_DevType_Syn "SynBox"
- #define UnitTool_logKey_FPD "(FPD)- "
- #define UnitTool_DevType_FPD "Detector"
- #define UnitTool_logKey_SM "(SMachine)- "
- #define UnitTool_DevType_SM "SMachine"
- #define UnitTool_LogFileName "LogFileName"
- #define UnitTool_CONFIGURATION "CONFIGURATION"
- #define UnitTool_DriverConfigPath "DriverConfig"
- #define UnitTool_MajorID "MajorID"
- #define UnitTool_VendorID "VendorID"
- #define UnitTool_ProductID "ProductID"
- #define UnitTool_SerialID "SerialID"
- #define UnitTool_oemdriver "oemdriver"
- #define UnitTool_DeviceNumber "DeviceNumber"
- #define UnitTool_GenFileName "GenFileName"
- #define UnitTool_GenLibDLL "GenLibDLL"
- #define UnitTool_MechFileName "MechFileName"
- #define UnitTool_MechLibDLL "MechLibDLL"
- #define UnitTool_ColFileName "ColFileName"
- #define UnitTool_ColLibDLL "ColLibDLL"
- #define UnitTool_SynFileName "SynFileName"
- #define UnitTool_SynLibDLL "SynLibDLL"
- #define UnitTool_FPDFileName "FPDFileName"
- #define UnitTool_FPDLibDLL "FPDLibDLL"
- #define UnitTool_SMFileName "SMFileName"
- #define UnitTool_SMLibDLL "SMLibDLL"
- //逻辑设备类型
- enum Dev_Type {
- Dev_TypeNULL = -1,
- Dev_Generator,
- Dev_Mechanical,
- Dev_Collimator,
- Dev_SynBox,
- Dev_Detector,
- Dev_SMachine,
- Dev_TypeALL
- };
- //逻辑设备状态
- enum Dev_Status {
- Dev_StatusNULL = -1,
- Dev_Init = 0,
- Dev_OnLine = 1,
- Dev_OutLine = 2,
- Dev_Error = 3,
- Dev_StatusALL
- };
- //********************************公共方法定义********************************
- //获取进程路径
- string GetProcessDirectory(bool withPlatformModule = false);
- //获取模块版本
- bool GetVersion(string& version);
- //获取时间
- CString GetTimeStr();
- //读取文件夹下的所有文件路径
- void GetAllCFGFiles(string path, vector<string>& files);
- void GetAllLibrary(string path, vector<string>& dlls, string nameKey = "");
- //设置、删除临时环境变量
- bool AddEnvPath(const char* pPath);
- bool DelEnvPath(const char* pPath);
- //********************************指令查找表********************************
- using cmdFun = function <void(int NotifyCode, string key, string context)>;
- struct tFrameMapItem
- {
- cmdFun m_fFun; //处理函数
- tFrameMapItem();
- tFrameMapItem(cmdFun f);
- tFrameMapItem& operator =(const tFrameMapItem& value);
- };
- //********************************通用模块类********************************
- class Device
- {
- public:
- //通用
- Device(Dev_Type type = Dev_TypeNULL);
- //设备创建
- virtual bool CreatMode(bool act); //初始化设备模块
- virtual void SetMagMap(); //设置消息查找表
- //设备调用方法
- string DevActionValue(string action, initializer_list<string> args);//参数:方法名,数值列表
- string DevActionKeyValue(string action, map<string, string>& args, bool withP0 = false);//参数:方法名,字段-数值列表,外层是否带有P0层
- string DevAction(string action);//参数:方法名
- string DevGetValue(string action);//参数:方法名
- //设备返回通知
- void OnDiosNotify(int& NotifyCode, string& key, string& context);
- //获取配置文件及dll的绝对路径
- bool OpenCFGAndGetDllPath(string& CFGPath, string& DLLPath);
- //属性
- Dev_Type m_enuType{ Dev_TypeNULL }; //模块类型
- string m_strName{ UnitTool_DevType_Null }; //模块名称
- string m_strLogTitle{ UnitTool_logKey_Null }; //日志标题
- string m_strLibTitle{ "nullLibDLL" }; //DLL库标题
- string m_strCfgLib{ "dll" }; //DLL库名称(带后缀),仅用于显示
- string m_strFileTitle{ "nullFileName" }; //配置文件标题
- string m_strCfgFile{ "xml" }; //配置文件名称(带后缀)
- ResDataObject m_DeviceConfig; //配置文件结构体
- shared_ptr<nsDEV::IODriver> m_pDriver{ nullptr }; //驱动指针
- unique_ptr<nsDEV::IODevice> m_pDevice{ nullptr }; //设备指针
- Dev_Type m_BelongToOtherDriver{ Dev_TypeNULL }; //设备是否属于其它驱动
- HMODULE m_hDevLib{ NULL }; //LoadLibrary返回的DLL加载后的句柄
- map <string, tFrameMapItem> m_mapFrame; //指令消息动作映射表
- };
- //********************************通用对话框基类********************************
- class CDiosBasicDlg : public CDialogEx, public Device
- {
- public:
- CDiosBasicDlg(Dev_Type type, UINT nIDTemplate, CWnd* pParent = nullptr) :CDialogEx(nIDTemplate, pParent), Device(type){}; // 标准构造函数
- // 生成的消息映射函数
- virtual BOOL OnInitDialog() override;
- virtual void InitPageElements(bool act); //若模块已存在则直接初始化页面元素
- virtual void ShowPageElements(bool init = FALSE, bool exit = FALSE, bool cfg = FALSE,
- bool general = FALSE); //设置窗口元素显示
- //窗口滚动条:最好只修改窗口的高,窗口的宽不要动
- virtual void OnOK() override; //
- virtual void OnCancel() override; //
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); //
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); //
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); //
- void UpdateScrollInfo(int nWidthNeed, int nLengthNeed); //
- //悬停提示
- virtual BOOL PreTranslateMessage(MSG* pMsg) override;//悬停触发
- virtual void SetToolTipsMsgMap(); //悬停提示信息设置
- //关联模块
- //unique_ptr<Device> m_pDevice{ nullptr }; //窗口指针
- protected:
- //类属性
- CToolTipCtrl m_Ttc;//悬停提示
- };
- //********************************模块集合类********************************
- typedef map<Dev_Type, unique_ptr<CDiosBasicDlg>> _DeviceMape;
- class CDeviceSET
- {
- private:
- CDeviceSET() {}//该类不能在外被构造
- ~CDeviceSET() {}//该类不能在外被析构
- CDeviceSET(const CDeviceSET&) = delete;//该类不能在外被拷贝
- CDeviceSET& operator=(const CDeviceSET&) = delete;//该类不能在外被赋值
- static CDeviceSET glo_CDeviceSET;//该进程下唯一Singleton对象,即单例
- public:
- static CDeviceSET* GetInstance();//外部只能通过调用该函数拿到data
- //根据GUID确定设备类型
- Dev_Type CheckDeviceType(string GUID);
- //设置工具默认参数
- static void SetToolDefaultConfig();
- //获取工具默认参数
- static void GetToolDefaultConfig();
- static _DeviceMape m_CDeviceMap; //设备列表
- };
- //********************************康众智光器********************************
- #define COLL_CareRaySmartSys_Flag 1
- #if COLL_CareRaySmartSys_Flag
- using tDataPredate = std::function <int(const char* RecData, const int dataLength)>;
- typedef bool(*CallFunGetImageData)(char* imageData, int& imageSize);
- typedef bool(*CallFunBeginTransImage)(tDataPredate callback);
- typedef bool(*CallFunEndTransImage)();
- extern CallFunGetImageData FunGetImageData;
- extern CallFunBeginTransImage FunBeginTransImage;
- extern CallFunEndTransImage FunEndTransImage;
- #endif
- #endif //PCH_H
|