Global.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. namespace Global
  21. {
  22. typedef struct __ST_CONFIG__
  23. {
  24. int nLanguage; // 0:Chinese, 1:english
  25. // 是否启用测试精灵;
  26. bool enableTW;
  27. bool useTW;
  28. bool useUB530;
  29. std::string strMIInitBat;
  30. std::string strSCBCInitBat;
  31. // script、tester、resource保存目录;
  32. std::string svnScriptSavePath;
  33. std::string svnTesterSavePath;
  34. std::string svnResourceSavePath;
  35. std::string svnUpdateUrl;
  36. // test wizard
  37. int twPort;
  38. std::string twSignaldir;
  39. std::string twUseSignal;
  40. // usb change;
  41. int usbPort;
  42. bool enableUSB;
  43. // ir-device;
  44. std::string redratpath;
  45. bool bGenerics;
  46. std::string signaldir;
  47. std::string use_signal;
  48. // SATService;
  49. bool bAutoLogin;
  50. std::string strSATUserName;
  51. std::string strSATPassword;
  52. std::string strActuator;
  53. std::string strServiceIP;
  54. std::string strServicePort;
  55. // UB530
  56. bool bAutoReconnect; // 是否启用自动重连;
  57. int nReconnectCycle; // 重连周期;
  58. // 电源控制Lan;
  59. int nPowerLanIndex;
  60. // 是否启动TV串口;
  61. bool enableTVPort;
  62. int tvPort;
  63. // 是否记住ftp信息;
  64. bool bRememberFTPInfo;
  65. std::string strFtpUser;
  66. std::string strFtpPassword;
  67. // 是否要实时更新svn信息;
  68. bool bSVNRealTimeUpdate;
  69. }STConfig, * pSTConfig;
  70. // 读取baidu.cfg配置文件内容;
  71. typedef struct __COUNT_INFO__
  72. {
  73. std::string app_id;
  74. std::string api_key;
  75. std::string secret_key;
  76. std::string ret_count;
  77. }CountInfo, * pCountInfo;
  78. typedef struct __BAIDU_CFG__
  79. {
  80. std::string cur_count;
  81. std::string reset_time;
  82. std::map<std::string, __COUNT_INFO__> list_count;
  83. }BaiduCfg, * pBaiduCfg;
  84. // 读取resource_run.cfg配置文件内容;
  85. typedef struct __RS_RUN_CFG__
  86. {
  87. std::string sound_list; // 声音级别;
  88. std::string sound1;
  89. std::string sound2;
  90. std::string full_cut; // 是否全步骤截图;('True/False')
  91. //....
  92. std::string tg39_port;
  93. std::string tv_port;
  94. std::string sat_home;
  95. std::string sat_result_dir;
  96. std::string chroma22293;
  97. //...
  98. std::string menutree_chip;
  99. std::string menutree_style;
  100. std::string menutree_channel;
  101. //...
  102. std::string chroma1;
  103. std::string chroma2;
  104. // 是否监听电视;
  105. bool bWatchTV;
  106. }RsRunCfg, * pRsRunCfg;
  107. //////////////////////////////////////////////////////////////////////////
  108. // 全局变量;
  109. extern HINSTANCE g_hLanguageDLL;
  110. extern TCHAR g_szCurModuleDir[MAX_PATH];
  111. extern TCHAR g_szCurModulePath[MAX_PATH];
  112. extern TCHAR g_szFna[MAX_PATH];
  113. extern TCHAR g_szConfig[MAX_PATH];
  114. extern TCHAR g_szResuorceCfg[MAX_PATH];
  115. extern STConfig g_Config;
  116. extern TCHAR g_szPython27Dir[MAX_PATH];
  117. extern ULONGLONG g_ulWaitTime;
  118. extern int g_nSysZoomRatio;
  119. extern TCHAR g_szVersion[MAX_PATH];
  120. extern BaiduCfg g_bdcfg;
  121. extern RsRunCfg g_rscfg;
  122. //////////////////////////////////////////////////////////////////////////
  123. // 全局函数;
  124. void GetConfig();
  125. int ReadReg(char* path, char* key, char* value);
  126. BOOL Python27Dir();
  127. BOOL GetSysSerialPort(std::vector<std::string>& vtports);
  128. void WriteTextLog(const TCHAR* format, ...);
  129. void WriteTextLogEx(int nType, const TCHAR* format, ...);
  130. BOOL LoadImgFromFile(IN Image** pImg, LPCTSTR lpPath);
  131. BOOL LoadImgFromBuffer(IN Image** pImg, IN BYTE* pBuffer, IN CONST INT& nBufLen);
  132. BOOL LoadImgFromBuffer(IN Image** pImg, LPCTSTR lpPath);
  133. int GetEncoderClsid(IN CONST WCHAR* format, OUT CLSID* pClsid);
  134. Image* LoadImgFromResource(IN HMODULE hModule, IN LPCTSTR lpName, IN LPCTSTR lpType);
  135. BOOL SaveImgByRotate(LPCTSTR lpszFileName, BYTE* pBuffer, CONST INT& nBufLen, BOOL bHoriontal, BOOL bVertically);
  136. void MKDIR(LPCTSTR dir);
  137. bool GetVersion(OUT WORD* pdwFileVersion, OUT WORD* pdwProductVerion);
  138. void GetSysZoomRatio();
  139. };