Global.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. #pragma once
  2. #include <stdio.h>
  3. #include <locale.h>
  4. #include <stdlib.h>
  5. #include <time.h> //或者 #include <ctime>
  6. #include <io.h>
  7. #pragma comment(lib, "version.lib")
  8. #include "../cJson/cJSON.h"
  9. #include "tinyxml2.h"
  10. #include "Log4c.h"
  11. #include <vector>
  12. #include <string>
  13. namespace Global
  14. {
  15. //////////////////////////////////////////////////////////////////////////
  16. // 升级包请求体;
  17. typedef struct
  18. {
  19. std::string appid;
  20. std::string devicemodel;
  21. std::string dnum;
  22. std::string ver;
  23. std::string type;
  24. } __update_post__;
  25. // 升级包返回体;
  26. typedef struct
  27. {
  28. std::string servertime;
  29. std::string callid;
  30. std::string status;
  31. std::string note;
  32. std::string language;
  33. std::string apiversion;
  34. typedef struct
  35. {
  36. std::string now;
  37. std::string type;
  38. std::string appid;
  39. std::string apptype;
  40. std::string version;
  41. std::string verid;
  42. std::string md5;
  43. std::string size;
  44. std::string minicon;
  45. std::string midicon;
  46. std::string fileurl;
  47. std::string increment;
  48. std::string appendver;
  49. std::string updatetime;
  50. } __upcontent__;
  51. __upcontent__ upcontent;
  52. } __update_result__;
  53. // 烧录数据请求体;
  54. typedef struct
  55. {
  56. std::string clienttype;
  57. //std::string projectid;
  58. std::string version;
  59. std::string bid; //批次号;
  60. std::string mac; // mac地址;
  61. } __burndata_post__;
  62. typedef struct
  63. {
  64. std::string name;
  65. std::string type;
  66. } __burndata__;
  67. typedef struct
  68. {
  69. std::string message;
  70. std::string code;
  71. std::string factoryname;
  72. std::string factoryip;
  73. std::string factoryNum;
  74. std::string version;
  75. std::string projectid;
  76. std::string clienttype;
  77. std::string host;
  78. std::vector<__burndata__> obj;
  79. } __burndata_result__;
  80. typedef struct CHASSIS
  81. {
  82. bool IsCopyDID;
  83. bool IsCopyMAC;
  84. bool IsCopyKEY;
  85. bool IsCopyESN;
  86. bool IsCopyWiDi;
  87. bool IsCopyWidevine;
  88. bool IsCopyKEY2_2;
  89. bool IsCopyKEY2_3;
  90. bool IsCopyCikey;
  91. bool IsCopyChannel;
  92. bool IsCopyWB;
  93. bool IsDisplayClientType;
  94. bool IsWritePID;
  95. bool IsWBInit;
  96. bool IsMTKInit;
  97. bool IsOsdLanguage;
  98. bool IsShopLanguage;
  99. bool IsCopyClientType;
  100. bool IsMGKKeyEnb;
  101. bool IsNovaTakHDCPEnb;
  102. int Delay;
  103. unsigned int ProjectID;
  104. std::string Channel;
  105. std::string WBFile;
  106. std::string CheckString;
  107. std::string ClientType;
  108. std::string MACType;
  109. std::string HDCPKeyType;
  110. std::string HDCPKey22Type;
  111. std::string HDCPKey23Type;
  112. std::string ESNType;
  113. std::string WiDiType;
  114. std::string WidevineType;
  115. std::string CIKeyType;
  116. std::string OsdLanguage;
  117. std::string ShopLanguage;
  118. std::string MGKKeyType;
  119. std::string NovaTakHDCPType;
  120. std::string url; // 在线服务器;
  121. std::string name; // chassis name;
  122. CHASSIS& operator=(const CHASSIS& that)
  123. {
  124. if (this != &that)
  125. {
  126. url = that.url;
  127. name = that.name;
  128. IsCopyDID = that.IsCopyDID;
  129. IsCopyMAC = that.IsCopyMAC;
  130. IsCopyKEY = that.IsCopyKEY;
  131. IsCopyESN = that.IsCopyESN;
  132. IsCopyWiDi = that.IsCopyWiDi;
  133. IsCopyWidevine = that.IsCopyWidevine;
  134. IsCopyKEY2_2 = that.IsCopyKEY2_2;
  135. IsCopyKEY2_3 = that.IsCopyKEY2_3;
  136. IsCopyCikey = that.IsCopyCikey;
  137. IsCopyChannel = that.IsCopyChannel;
  138. IsCopyWB = that.IsCopyWB;
  139. IsDisplayClientType = that.IsDisplayClientType;
  140. IsWritePID = that.IsWritePID;
  141. IsWBInit = that.IsWBInit;
  142. IsMTKInit = that.IsMTKInit;
  143. IsOsdLanguage = that.IsOsdLanguage;
  144. IsShopLanguage = that.IsShopLanguage;
  145. IsCopyClientType = that.IsCopyClientType;
  146. IsMGKKeyEnb = that.IsMGKKeyEnb;
  147. IsNovaTakHDCPEnb = that.IsNovaTakHDCPEnb;
  148. Delay = that.Delay;
  149. ProjectID = that.ProjectID;
  150. Channel = that.Channel;
  151. WBFile = that.WBFile;
  152. CheckString = that.CheckString;
  153. ClientType = that.ClientType;
  154. MACType = that.MACType;
  155. HDCPKeyType = that.HDCPKeyType;
  156. HDCPKey22Type = that.HDCPKey22Type;
  157. HDCPKey23Type = that.HDCPKey23Type;
  158. ESNType = that.ESNType;
  159. WiDiType = that.WiDiType;
  160. WidevineType = that.WidevineType;
  161. CIKeyType = that.CIKeyType;
  162. OsdLanguage = that.OsdLanguage;
  163. ShopLanguage = that.ShopLanguage;
  164. MGKKeyType = that.MGKKeyType;
  165. NovaTakHDCPType = that.NovaTakHDCPType;
  166. }
  167. return *this;
  168. }
  169. } TChassis, * pTChassis;
  170. typedef struct __READCHECK__
  171. {
  172. bool IsPID = true;
  173. bool IsCHANNEL = true;
  174. bool IsOSD = true;
  175. bool IsSHOP = true;
  176. bool IsDID = true;
  177. bool IsMAC = true;
  178. bool IsHDCP = true;
  179. bool IsHDCP22 = true;
  180. bool IsWIDI = true;
  181. bool IsWIDEVINE = true;
  182. bool IsESN = true;
  183. bool IsCI = true;
  184. }TReadCheck, * pTReadCheck;
  185. typedef struct __WRITECHECK__
  186. {
  187. //bool IsPID = true;
  188. //bool IsCHANNEL = true;
  189. //bool IsOSD = true;
  190. //bool IsSHOP = true;
  191. bool IsDID = true;
  192. bool IsMAC = true;
  193. bool IsHDCP = true;
  194. bool IsHDCP22 = true;
  195. bool IsWIDI = true;
  196. bool IsWIDEVINE = true;
  197. bool IsESN = true;
  198. bool IsCI = true;
  199. }TWriteCheck, * pWriteCheck;
  200. typedef struct __WRITEDONE__
  201. {
  202. bool IsPID = true;
  203. bool IsCHANNEL = true;
  204. bool IsOSD = true;
  205. bool IsSHOP = true;
  206. bool IsDID = true;
  207. bool IsMAC = true;
  208. bool IsHDCP = true;
  209. bool IsHDCP22 = true;
  210. bool IsWIDI = true;
  211. bool IsWIDEVINE = true;
  212. bool IsESN = true;
  213. bool IsCI = true;
  214. }TWriteDone, * pTWriteDone;
  215. extern Global::TChassis g_AutoOnlineChassis;
  216. // 配置文件;
  217. typedef struct TCONFIG
  218. {
  219. std::string com;
  220. std::string baudrate;
  221. std::string chassis;
  222. int mode;
  223. int warncount = 200;
  224. int waitboot = 5000;
  225. bool bootread = false;
  226. int waitend = 1000; // 结束后等待毫秒;
  227. std::string siacpcmdfile;
  228. std::string serverurl;
  229. std::map<std::string, std::string> channel;
  230. std::map<std::string, std::string> language;
  231. std::map<std::string, std::string> keyfolder;
  232. std::map<std::string, TChassis> chassislist;
  233. TReadCheck readcheck;
  234. TWriteCheck writecheck;
  235. TWriteDone writedone;
  236. } TConfig, * pTConfig;
  237. // 网卡类型;
  238. enum NICKIND
  239. {
  240. // pci网卡;
  241. NIC_PCI,
  242. // usb网卡;
  243. NIC_USB,
  244. // 虚拟网卡;
  245. NIC_ROOT,
  246. // 仿真网卡;
  247. NIC_SWD,
  248. // 未知类型;
  249. NIC_UNK
  250. };
  251. typedef struct __MAC_ADDRESS__
  252. {
  253. INT nNICKind;
  254. TCHAR szNICKind[16];
  255. TCHAR szMacAddress[MAX_PATH];
  256. TCHAR szDevicePath[MAX_PATH];
  257. } MacAddress, * pMacAddress;
  258. //////////////////////////////////////////////////////////////////////////
  259. // 全局变量;
  260. extern BOOL g_bTestHost;
  261. extern TCHAR g_szCurModuleDir[MAX_PATH];
  262. extern TCHAR g_szCurModulePath[MAX_PATH];
  263. extern TCHAR g_szFna[MAX_PATH];
  264. extern TCHAR g_szConfig[MAX_PATH];
  265. extern std::string g_strMacs;
  266. extern std::vector<MacAddress> g_vtMac;
  267. extern TConfig g_tConfig;
  268. //////////////////////////////////////////////////////////////////////////
  269. // 全局函数;
  270. void GetConfig();
  271. void SetConfig();
  272. bool GetVersion(IN const TCHAR* fname, OUT WORD* pdwFileVersion, OUT WORD* pdwProductVerion);
  273. BOOL GetVersion(IN HMODULE hModule, OUT DWORD(&dwFVArray)[4], OUT DWORD(&dwPVArray)[4]);
  274. void WriteTextLog(const TCHAR* format, ...);
  275. void WriteReportLog(int type, std::string des, const TCHAR* format, ...);
  276. std::string EnCode_UTF8URL(IN const CHAR* pText);
  277. std::string& trim(std::string& str);
  278. // 获取网卡地址;
  279. INT GetMacAddress();
  280. // 字符串是否由数字、字母、符号组成;
  281. BOOL IsValidString(LPCTSTR lpszString);
  282. // 获取系统当前串口数量;
  283. BOOL GetSysSerialPort(std::vector<std::string>& vtports);
  284. }; // namespace Global