123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- // pch.h: 这是预编译标头文件。
- // 下方列出的文件仅编译一次,提高了将来生成的生成性能。
- // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
- // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
- // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
- #pragma once
- #ifndef PCH_H
- #define PCH_H
- // 添加要在此处预编译的标头
- #include "targetver.h"
- #define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
- // Windows 头文件
- #include <mutex>
- #include <map>
- //V3需要用到的公共定义
- #include "CcosGeneralDefine_V3.h"
- #include "CcosMouldGenerator_V3.h"
- #include "CcosUnitComm_V3.h"
- #include "DeliverModule.h"
- #include "PlatformInteraction.h"
- //日志类
- #include "Log4CPP.Logger.hpp"
- #include "Log4CPP.TLSLog.Tracing.hpp"
- #include "mLog.Log4CPP.hpp"
- extern HMODULE hMyModule;
- #ifdef CCOS_GEN_IDETEC_Almax_EXPORTS
- #define _CCOS_GEN_IDETEC_Almax_API __declspec(dllexport)
- #else
- #define _CCOS_GEN_IDETEC_Almax_API __declspec(dllimport)
- #endif
- //设置相关常量
- #define msTimeOut_Lock 500 //通讯接口锁定时间
- #define TIMEOUTVALUE 100
- #define Almax_Com_HeadLen 3
- #define Almax_Com_ReSendLen 64
- #define Almax_STX 0x02
- #define Almax_ETX 0x03
- #define Almax_ACK 0x06
- #define Almax_NAK 0x15
- //callBackFun define
- using callBackFun = std::function <void(std::string, std::string)>;
- namespace nsSerialGPM = CCOS::Dev::MODLE::SerialGPM;
- //响应操作对照表
- using tbFun = std::function <void(char*, int)>;
- struct tFrameMapItem
- {
- tbFun m_fFun; //与指令id绑定的处理函数
- tFrameMapItem();
- tFrameMapItem(tbFun f);
- tFrameMapItem& operator =(const tFrameMapItem& value);
- };
- //map比较函数
- #if 0 //有的设备指令ID并非统一长度,所以自定义map的key的比较规则
- template <>
- struct less<std::string>
- {
- public:
- bool operator()(const std::string& p1, const std::string& p2) const
- {
- if (p1.at(0) == Almax_STX)
- {
- int smallLengh = p1.length() <= p2.length() ? p1.length() : p2.length();
- int res = p1.compare(1, smallLengh, p2, 0, smallLengh);
- if (res < 0)
- return true;
- else
- return false;
- }
- else if (p2.at(0) == Almax_STX)
- {
- int smallLengh = p1.length() <= p2.length() ? p1.length() : p2.length();
- int res = p1.compare(0, smallLengh, p2, 1, smallLengh);
- if (res < 0)
- return true;
- else
- return false;
- }
- else
- {
- return p1 < p2;
- }
- }
- };
- #endif
- extern nsSCF::CcosConnect glo_obCommObj; //公共的设备连接通信对象
- extern std::map <string, tFrameMapItem> glo_arFrame; //响应操作对照表
- extern nsSerialGPM::CDeliverModule glo_tDelivermodule; //统一的串口指令处理类
- extern int glo_nCMDType_WaitTime; //指令类型1:发送后等待固定时间
- extern int glo_nCMDType_HB; //指令类型2:心跳
- extern int glo_nCMDType_WaitACK; //指令类型3:发送后等待ACK返回
- #endif //PCH_H
|