stdafx.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_ContainerExample_EXPORTS
  27. #define _CCOS_GEN_ContainerExample_API __declspec(dllexport)
  28. #else
  29. #define _CCOS_GEN_ContainerExample_API __declspec(dllimport)
  30. #endif
  31. //设置相关常量
  32. #define msTimeOut_Lock 500 //通讯接口锁定时间
  33. #define Example_Com_ReSendLen 64
  34. #define Example_STX 0x02
  35. #define Example_ETX 0x03
  36. #define Example_ACK 0x06
  37. #define Example_NAK 0x15
  38. //callBackFun define
  39. using callBackFun = std::function <void(std::string, std::string)>;
  40. namespace nsSerialGPM = CCOS::Dev::MODLE::SerialGPM;
  41. //响应操作对照表
  42. using tbFun = std::function <void(char*, int)>;
  43. struct tFrameMapItem
  44. {
  45. tbFun m_fFun; //与指令id绑定的处理函数
  46. tFrameMapItem();
  47. tFrameMapItem(tbFun f);
  48. tFrameMapItem& operator =(const tFrameMapItem& value);
  49. };
  50. //map比较函数
  51. #if 0 //有的设备指令ID并非统一长度,所以自定义map的key的比较规则
  52. template <>
  53. struct less<std::string>
  54. {
  55. public:
  56. bool operator()(const std::string& p1, const std::string& p2) const
  57. {
  58. int smallLengh = p1.length() <= p2.length() ? p1.length() : p2.length();
  59. int res = p1.compare(0, smallLengh, p2, 0, smallLengh);
  60. if (res == 0)
  61. if (p1.length() < p2.length())
  62. return true;
  63. else if (p1.length() > p2.length())
  64. return false;
  65. else
  66. return false;
  67. else if (res < 0)
  68. return true;
  69. else
  70. return false;
  71. }
  72. };
  73. #endif
  74. extern std::map <string, tFrameMapItem> glo_arFrame; //响应操作对照表
  75. extern nsSerialGPM::CDeliverModule glo_tDelivermodule; //统一的串口指令处理类
  76. extern nsSCF::CcosConnect glo_obCommObj; //公共的设备连接通信对象
  77. #endif //PCH_H