stdafx.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // pch.h: 这是预编译标头文件。
  2. // 下方列出的文件仅编译一次,提高了将来生成的生成性能。
  3. // 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
  4. // 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
  5. // 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
  6. #pragma once
  7. #ifndef PCH_H
  8. #define PCH_H
  9. // 添加要在此处预编译的标头
  10. #include "targetver.h"
  11. #define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
  12. // Windows 头文件
  13. #include <mutex>
  14. #include <map>
  15. //V3需要用到的公共定义
  16. #include "CcosGeneralDefine_V3.h"
  17. #include "CcosMouldGenerator_V3.h"
  18. #include "CcosUnitComm_V3.h"
  19. #include "DeliverModule.h"
  20. #include "PlatformInteraction.h"
  21. //日志类
  22. #include "Log4CPP.Logger.hpp"
  23. #include "Log4CPP.TLSLog.Tracing.hpp"
  24. #include "mLog.Log4CPP.hpp"
  25. extern HMODULE hMyModule;
  26. #ifdef CCOS_GEN_IDETEC_Almax_EXPORTS
  27. #define _CCOS_GEN_IDETEC_Almax_API __declspec(dllexport)
  28. #else
  29. #define _CCOS_GEN_IDETEC_Almax_API __declspec(dllimport)
  30. #endif
  31. //设置相关常量
  32. #define msTimeOut_Lock 500 //通讯接口锁定时间
  33. #define TIMEOUTVALUE 100
  34. #define Almax_Com_HeadLen 3
  35. #define Almax_Com_ReSendLen 64
  36. #define Almax_STX 0x02
  37. #define Almax_ETX 0x03
  38. #define Almax_ACK 0x06
  39. #define Almax_NAK 0x15
  40. //callBackFun define
  41. using callBackFun = std::function <void(std::string, std::string)>;
  42. namespace nsSerialGPM = CCOS::Dev::MODLE::SerialGPM;
  43. //响应操作对照表
  44. using tbFun = std::function <void(char*, int)>;
  45. struct tFrameMapItem
  46. {
  47. tbFun m_fFun; //与指令id绑定的处理函数
  48. tFrameMapItem();
  49. tFrameMapItem(tbFun f);
  50. tFrameMapItem& operator =(const tFrameMapItem& value);
  51. };
  52. //map比较函数
  53. #if 0 //有的设备指令ID并非统一长度,所以自定义map的key的比较规则
  54. template <>
  55. struct less<std::string>
  56. {
  57. public:
  58. bool operator()(const std::string& p1, const std::string& p2) const
  59. {
  60. if (p1.at(0) == Almax_STX)
  61. {
  62. int smallLengh = p1.length() <= p2.length() ? p1.length() : p2.length();
  63. int res = p1.compare(1, smallLengh, p2, 0, smallLengh);
  64. if (res < 0)
  65. return true;
  66. else
  67. return false;
  68. }
  69. else if (p2.at(0) == Almax_STX)
  70. {
  71. int smallLengh = p1.length() <= p2.length() ? p1.length() : p2.length();
  72. int res = p1.compare(0, smallLengh, p2, 1, smallLengh);
  73. if (res < 0)
  74. return true;
  75. else
  76. return false;
  77. }
  78. else
  79. {
  80. return p1 < p2;
  81. }
  82. }
  83. };
  84. #endif
  85. extern nsSCF::CcosConnect glo_obCommObj; //公共的设备连接通信对象
  86. extern std::map <string, tFrameMapItem> glo_arFrame; //响应操作对照表
  87. extern nsSerialGPM::CDeliverModule glo_tDelivermodule; //统一的串口指令处理类
  88. extern int glo_nCMDType_WaitTime; //指令类型1:发送后等待固定时间
  89. extern int glo_nCMDType_HB; //指令类型2:心跳
  90. extern int glo_nCMDType_WaitACK; //指令类型3:发送后等待ACK返回
  91. #endif //PCH_H