stdafx.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // stdafx.h : 标准系统包含文件的包含文件,
  2. // 或是经常使用但不常更改的
  3. // 特定于项目的包含文件
  4. //
  5. #pragma once
  6. #include "targetver.h"
  7. #include <stdio.h>
  8. #include <tchar.h>
  9. #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
  10. #ifndef VC_EXTRALEAN
  11. #define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
  12. #endif
  13. #include <afx.h>
  14. #include <afxwin.h> // MFC 核心组件和标准组件
  15. #include <afxext.h> // MFC 扩展
  16. #ifndef _AFX_NO_OLE_SUPPORT
  17. #include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
  18. #endif
  19. #ifndef _AFX_NO_AFXCMN_SUPPORT
  20. #include <afxcmn.h> // MFC 对 Windows 公共控件的支持
  21. #endif // _AFX_NO_AFXCMN_SUPPORT
  22. #include <iostream>
  23. #include <string>
  24. #include <vector>
  25. #include "Serial.h"
  26. enum CMDOPT
  27. {
  28. CMDOPT_None = 0,
  29. CMDOPT_Get = 1,
  30. CMDOPT_Set = 2
  31. };
  32. typedef struct __CMDPARAM__ {
  33. std::string name; // 命令描述;
  34. std::string head; // 命令头;
  35. std::string code; // 命令码;
  36. std::string param; // 命令码参数;
  37. // 命令属性类型:
  38. // 0=None,只返回一段数据包;
  39. // 1=Get,返回一段或两段数据包(成功时返回2段,失败时返回1段);
  40. // 2=Set,返回一段或两段数据包(成功时返回1段,失败时返回1段);
  41. int nOption;
  42. bool bMulticode ; // 命令码是否多参数;
  43. int cmd_wait_time ; // 两条串口指令间隔时间;
  44. int read_wait_time ; // 写完串口后,等待多久读;
  45. byte _rtnCode;
  46. byte _rtnStatus;
  47. std::string _rtnData;
  48. void UpdateRtnCode()
  49. {
  50. if (!_tcsicmp(_T("AA"), head.c_str())) { // 调试用命令代码引导码;
  51. _rtnCode = 0xAB;
  52. }
  53. else if (!_tcsicmp(_T("AC"), head.c_str())) { // 软件配屏参数调整命令代码引导码;
  54. _rtnCode = 0xAD;
  55. }
  56. else if (!_tcsicmp(_T("AE"), head.c_str())) { // 保留命令发送类型引导码;
  57. _rtnCode = 0xAF;
  58. }
  59. }
  60. __CMDPARAM__() {
  61. _rtnCode = 0;
  62. _rtnStatus = 0;
  63. nOption = 0;
  64. bMulticode = false;
  65. cmd_wait_time = 100;
  66. read_wait_time = 100;
  67. }
  68. } CommandParam, *pCommandParam;
  69. VOID _dprintf(CHAR* pszStr, ...);
  70. int pares_time_value(std::string strTime);
  71. bool parse_key(std::string &value, std::string strLine, TCHAR *lpszText);
  72. int parse_cmd_param_from_file(TCHAR*file_name, std::vector<CommandParam> &vtCommandParams);
  73. unsigned char TwoHexCharToInteger(char high, char low);
  74. std::string PackingCommand(CommandParam &cmdPara, std::string data, const int &dataLen);
  75. std::string BytesToHexString(const unsigned char *pbuffer, int nLen);
  76. std::string BytesToHexString(const unsigned char *pbuffer, int nLen, char chSpace);
  77. // TODO: 在此处引用程序需要的其他头文件