Global.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #pragma once
  2. #include <stdio.h>
  3. #include <locale.h>
  4. #include <stdlib.h>
  5. //#include <time.h> //或者 #include <ctime>
  6. #include <ctime>
  7. #include <io.h>
  8. #pragma comment(lib,"version.lib")
  9. #include <vector>
  10. #include <string>
  11. // GDI+
  12. #include <gdiplus.h>
  13. using namespace Gdiplus;
  14. #pragma comment(lib, "gdiplus.lib")
  15. #ifndef _UNICODE
  16. typedef string TString;
  17. #else
  18. typedef wstring TString;
  19. #endif
  20. // usb;
  21. static GUID UsbClassGuid = { 0xA5DCBF10L, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED} };
  22. // mac;
  23. static GUID MacClassGuid = { 0xAD498944, 0x762F, 0x11D0, {0x8D, 0xCB, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C} };
  24. // hdd;
  25. static GUID HDDClassGuid = { 0x53F56307, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B} };
  26. namespace Global
  27. {
  28. typedef struct __ST_CONFIG__
  29. {
  30. int nLanguage; // 0:Chinese, 1:english
  31. // 是否启用测试精灵;
  32. bool enableTW;
  33. bool useTW;
  34. bool useUB530;
  35. std::string strMIInitBat;
  36. std::string strSCBCInitBat;
  37. // script、tester、resource保存目录;
  38. std::string svnScriptSavePath;
  39. std::string svnTesterSavePath;
  40. std::string svnResourceSavePath;
  41. std::string svnUpdateUrl;
  42. // test wizard
  43. int twPort;
  44. std::string twSignaldir;
  45. std::string twUseSignal;
  46. // usb change;
  47. int usbPort;
  48. bool enableUSB;
  49. // ir-device;
  50. std::string redratpath;
  51. bool bGenerics;
  52. std::string signaldir;
  53. std::string use_signal;
  54. // SATService;
  55. bool bAutoLogin;
  56. std::string strSATUserName;
  57. std::string strSATPassword;
  58. std::string strActuator;
  59. std::string strServiceIP;
  60. std::string strServicePort;
  61. // UB530
  62. bool bAutoReconnect; // 是否启用自动重连;
  63. int nReconnectCycle; // 重连周期;
  64. // 电源控制Lan;
  65. int nPowerLanIndex;
  66. // 是否启动TV串口;
  67. bool enableTVPort;
  68. int tvPort;
  69. // 是否记住ftp信息;
  70. bool bRememberFTPInfo;
  71. std::string strFtpUser;
  72. std::string strFtpPassword;
  73. // 是否要实时更新svn信息;
  74. bool bSVNRealTimeUpdate;
  75. // 测试精灵端口控制类型:开关、切换;
  76. // 0 = 开关; 1 = 切换;
  77. int nTWPortControltype;
  78. }STConfig, * pSTConfig;
  79. // 读取baidu.cfg配置文件内容;
  80. typedef struct __COUNT_INFO__
  81. {
  82. std::string app_id;
  83. std::string api_key;
  84. std::string secret_key;
  85. std::string ret_count;
  86. }CountInfo, * pCountInfo;
  87. typedef struct __BAIDU_CFG__
  88. {
  89. std::string cur_count;
  90. std::string reset_time;
  91. std::map<std::string, __COUNT_INFO__> list_count;
  92. }BaiduCfg, * pBaiduCfg;
  93. // 读取resource_run.cfg配置文件内容;
  94. typedef struct __RS_RUN_CFG__
  95. {
  96. std::string sound_list; // 声音级别;
  97. std::string sound1;
  98. std::string sound2;
  99. std::string full_cut; // 是否全步骤截图;('True/False')
  100. //....
  101. std::string tg39_port;
  102. std::string tv_port;
  103. std::string sat_home;
  104. std::string sat_result_dir;
  105. std::string chroma22293;
  106. //...
  107. std::string menutree_chip;
  108. std::string menutree_style;
  109. std::string menutree_channel;
  110. //...
  111. std::string chroma1;
  112. std::string chroma2;
  113. // 是否监听电视;
  114. bool bWatchTV;
  115. }RsRunCfg, * pRsRunCfg;
  116. //////////////////////////////////////////////////////////////////////////
  117. // 全局变量;
  118. extern HINSTANCE g_hLanguageDLL;
  119. extern TCHAR g_szCurModuleDir[MAX_PATH];
  120. extern TCHAR g_szCurModulePath[MAX_PATH];
  121. extern TCHAR g_szFna[MAX_PATH];
  122. extern TCHAR g_szConfig[MAX_PATH];
  123. extern TCHAR g_szResuorceCfg[MAX_PATH];
  124. extern STConfig g_Config;
  125. extern TCHAR g_szPython27Dir[MAX_PATH];
  126. extern ULONGLONG g_ulWaitTime;
  127. extern int g_nSysZoomRatio;
  128. extern TCHAR g_szVersion[MAX_PATH];
  129. extern BaiduCfg g_bdcfg;
  130. extern RsRunCfg g_rscfg;
  131. //////////////////////////////////////////////////////////////////////////
  132. // 全局函数;
  133. void GetConfig();
  134. int ReadReg(char* path, char* key, char* value);
  135. BOOL Python27Dir();
  136. BOOL GetSysSerialPort(std::vector<std::string>& vtports);
  137. void WriteTextLog(const TCHAR* format, ...);
  138. void WriteTextLogEx(int nType, const TCHAR* format, ...);
  139. BOOL LoadImgFromFile(IN Image** pImg, LPCTSTR lpPath);
  140. BOOL LoadImgFromBuffer(IN Image** pImg, IN BYTE* pBuffer, IN CONST INT& nBufLen);
  141. BOOL LoadImgFromBuffer(IN Image** pImg, LPCTSTR lpPath);
  142. int GetEncoderClsid(IN CONST WCHAR* format, OUT CLSID* pClsid);
  143. Image* LoadImgFromResource(IN HMODULE hModule, IN LPCTSTR lpName, IN LPCTSTR lpType);
  144. BOOL SaveImgByRotate(LPCTSTR lpszFileName, BYTE* pBuffer, CONST INT& nBufLen, BOOL bHoriontal, BOOL bVertically);
  145. void MKDIR(LPCTSTR dir);
  146. bool GetVersion(OUT WORD* pdwFileVersion, OUT WORD* pdwProductVerion);
  147. void GetSysZoomRatio();
  148. BOOL EnumUSBDevice(OUT char acDevPath[MAX_PATH][MAX_PATH], OUT int& nDevNum);
  149. INT EnumUSBDevice(CONST GUID* pClassGuid);
  150. };