123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // stdafx.h : 标准系统包含文件的包含文件,
- // 或是经常使用但不常更改的
- // 特定于项目的包含文件
- //
- #pragma once
- #include "targetver.h"
- #include <stdio.h>
- #include <tchar.h>
- #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
- #ifndef VC_EXTRALEAN
- #define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
- #endif
- #include <afx.h>
- #include <afxwin.h> // MFC 核心组件和标准组件
- #include <afxext.h> // MFC 扩展
- #ifndef _AFX_NO_OLE_SUPPORT
- #include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
- #endif
- #ifndef _AFX_NO_AFXCMN_SUPPORT
- #include <afxcmn.h> // MFC 对 Windows 公共控件的支持
- #endif // _AFX_NO_AFXCMN_SUPPORT
- #include <iostream>
- #include <string>
- #include <vector>
- #include "Serial.h"
- enum CMDOPT
- {
- CMDOPT_None = 0,
- CMDOPT_Get = 1,
- CMDOPT_Set = 2
- };
- typedef struct __CMDPARAM__ {
- std::string name; // 命令描述;
- std::string head; // 命令头;
- std::string code; // 命令码;
- std::string param; // 命令码参数;
- // 命令属性类型:
- // 0=None,只返回一段数据包;
- // 1=Get,返回一段或两段数据包(成功时返回2段,失败时返回1段);
- // 2=Set,返回一段或两段数据包(成功时返回1段,失败时返回1段);
- int nOption;
- bool bMulticode ; // 命令码是否多参数;
- int cmd_wait_time ; // 两条串口指令间隔时间;
- int read_wait_time ; // 写完串口后,等待多久读;
- byte _rtnCode;
- byte _rtnStatus;
- std::string _rtnData;
- void UpdateRtnCode()
- {
- if (!_tcsicmp(_T("AA"), head.c_str())) { // 调试用命令代码引导码;
- _rtnCode = 0xAB;
- }
- else if (!_tcsicmp(_T("AC"), head.c_str())) { // 软件配屏参数调整命令代码引导码;
- _rtnCode = 0xAD;
- }
- else if (!_tcsicmp(_T("AE"), head.c_str())) { // 保留命令发送类型引导码;
- _rtnCode = 0xAF;
- }
- }
- __CMDPARAM__() {
- _rtnCode = 0;
- _rtnStatus = 0;
- nOption = 0;
- bMulticode = false;
- cmd_wait_time = 100;
- read_wait_time = 100;
- }
- } CommandParam, *pCommandParam;
- VOID _dprintf(CHAR* pszStr, ...);
- int pares_time_value(std::string strTime);
- bool parse_key(std::string &value, std::string strLine, TCHAR *lpszText);
- int parse_cmd_param_from_file(TCHAR*file_name, std::vector<CommandParam> &vtCommandParams);
- unsigned char TwoHexCharToInteger(char high, char low);
- std::string PackingCommand(CommandParam &cmdPara, std::string data, const int &dataLen);
- std::string BytesToHexString(const unsigned char *pbuffer, int nLen);
- std::string BytesToHexString(const unsigned char *pbuffer, int nLen, char chSpace);
- // TODO: 在此处引用程序需要的其他头文件
|