123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- #pragma once
- #include <stdio.h>
- #include <locale.h>
- #include <stdlib.h>
- #include <time.h> //或者 #include <ctime>
- #include <io.h>
- #pragma comment(lib, "version.lib")
- #include "../cJson/cJSON.h"
- #include "tinyxml2.h"
- #include "Log4c.h"
- #include <vector>
- #include <string>
- namespace Global
- {
- //////////////////////////////////////////////////////////////////////////
- // 升级包请求体;
- typedef struct
- {
- std::string appid;
- std::string devicemodel;
- std::string dnum;
- std::string ver;
- std::string type;
- } __update_post__;
- // 升级包返回体;
- typedef struct
- {
- std::string servertime;
- std::string callid;
- std::string status;
- std::string note;
- std::string language;
- std::string apiversion;
- typedef struct
- {
- std::string now;
- std::string type;
- std::string appid;
- std::string apptype;
- std::string version;
- std::string verid;
- std::string md5;
- std::string size;
- std::string minicon;
- std::string midicon;
- std::string fileurl;
- std::string increment;
- std::string appendver;
- std::string updatetime;
- } __upcontent__;
- __upcontent__ upcontent;
- } __update_result__;
- // 烧录数据请求体;
- typedef struct
- {
- std::string clienttype;
- //std::string projectid;
- std::string version;
- std::string bid; //批次号;
- std::string mac; // mac地址;
- } __burndata_post__;
- typedef struct
- {
- std::string name;
- std::string type;
- } __burndata__;
- typedef struct
- {
- std::string message;
- std::string code;
- std::string factoryname;
- std::string factoryip;
- std::string factoryNum;
- std::string version;
- std::string projectid;
- std::string clienttype;
- std::string host;
- std::vector<__burndata__> obj;
- } __burndata_result__;
- typedef struct CHASSIS
- {
- bool IsCopyDID;
- bool IsCopyMAC;
- bool IsCopyKEY;
- bool IsCopyESN;
- bool IsCopyWiDi;
- bool IsCopyWidevine;
- bool IsCopyKEY2_2;
- bool IsCopyKEY2_3;
- bool IsCopyCikey;
- bool IsCopyChannel;
- bool IsCopyWB;
- bool IsDisplayClientType;
- bool IsWritePID;
- bool IsWBInit;
- bool IsMTKInit;
- bool IsOsdLanguage;
- bool IsShopLanguage;
- bool IsCopyClientType;
- bool IsMGKKeyEnb;
- bool IsNovaTakHDCPEnb;
- int Delay;
- unsigned int ProjectID;
- std::string Channel;
- std::string WBFile;
- std::string CheckString;
- std::string ClientType;
- std::string MACType;
- std::string HDCPKeyType;
- std::string HDCPKey22Type;
- std::string HDCPKey23Type;
- std::string ESNType;
- std::string WiDiType;
- std::string WidevineType;
- std::string CIKeyType;
- std::string OsdLanguage;
- std::string ShopLanguage;
- std::string MGKKeyType;
- std::string NovaTakHDCPType;
- std::string url; // 在线服务器;
- std::string name; // chassis name;
- CHASSIS& operator=(const CHASSIS& that)
- {
- if (this != &that)
- {
- url = that.url;
- name = that.name;
- IsCopyDID = that.IsCopyDID;
- IsCopyMAC = that.IsCopyMAC;
- IsCopyKEY = that.IsCopyKEY;
- IsCopyESN = that.IsCopyESN;
- IsCopyWiDi = that.IsCopyWiDi;
- IsCopyWidevine = that.IsCopyWidevine;
- IsCopyKEY2_2 = that.IsCopyKEY2_2;
- IsCopyKEY2_3 = that.IsCopyKEY2_3;
- IsCopyCikey = that.IsCopyCikey;
- IsCopyChannel = that.IsCopyChannel;
- IsCopyWB = that.IsCopyWB;
- IsDisplayClientType = that.IsDisplayClientType;
- IsWritePID = that.IsWritePID;
- IsWBInit = that.IsWBInit;
- IsMTKInit = that.IsMTKInit;
- IsOsdLanguage = that.IsOsdLanguage;
- IsShopLanguage = that.IsShopLanguage;
- IsCopyClientType = that.IsCopyClientType;
- IsMGKKeyEnb = that.IsMGKKeyEnb;
- IsNovaTakHDCPEnb = that.IsNovaTakHDCPEnb;
- Delay = that.Delay;
- ProjectID = that.ProjectID;
- Channel = that.Channel;
- WBFile = that.WBFile;
- CheckString = that.CheckString;
- ClientType = that.ClientType;
- MACType = that.MACType;
- HDCPKeyType = that.HDCPKeyType;
- HDCPKey22Type = that.HDCPKey22Type;
- HDCPKey23Type = that.HDCPKey23Type;
- ESNType = that.ESNType;
- WiDiType = that.WiDiType;
- WidevineType = that.WidevineType;
- CIKeyType = that.CIKeyType;
- OsdLanguage = that.OsdLanguage;
- ShopLanguage = that.ShopLanguage;
- MGKKeyType = that.MGKKeyType;
- NovaTakHDCPType = that.NovaTakHDCPType;
- }
- return *this;
- }
- } TChassis, * pTChassis;
- typedef struct __READCHECK__
- {
- bool IsPID = true;
- bool IsCHANNEL = true;
- bool IsOSD = true;
- bool IsSHOP = true;
- bool IsDID = true;
- bool IsMAC = true;
- bool IsHDCP = true;
- bool IsHDCP22 = true;
- bool IsWIDI = true;
- bool IsWIDEVINE = true;
- bool IsESN = true;
- bool IsCI = true;
- }TReadCheck, * pTReadCheck;
- typedef struct __WRITECHECK__
- {
- //bool IsPID = true;
- //bool IsCHANNEL = true;
- //bool IsOSD = true;
- //bool IsSHOP = true;
- bool IsDID = true;
- bool IsMAC = true;
- bool IsHDCP = true;
- bool IsHDCP22 = true;
- bool IsWIDI = true;
- bool IsWIDEVINE = true;
- bool IsESN = true;
- bool IsCI = true;
- }TWriteCheck, * pWriteCheck;
- typedef struct __WRITEDONE__
- {
- bool IsPID = true;
- bool IsCHANNEL = true;
- bool IsOSD = true;
- bool IsSHOP = true;
- bool IsDID = true;
- bool IsMAC = true;
- bool IsHDCP = true;
- bool IsHDCP22 = true;
- bool IsWIDI = true;
- bool IsWIDEVINE = true;
- bool IsESN = true;
- bool IsCI = true;
- }TWriteDone, * pTWriteDone;
- extern Global::TChassis g_AutoOnlineChassis;
- // 配置文件;
- typedef struct TCONFIG
- {
- std::string com;
- std::string baudrate;
- std::string chassis;
- int mode;
- int warncount = 200;
- int waitboot = 5000;
- bool bootread = false;
- int waitend = 1000; // 结束后等待毫秒;
- std::string siacpcmdfile;
- std::string serverurl;
- std::map<std::string, std::string> channel;
- std::map<std::string, std::string> language;
- std::map<std::string, std::string> keyfolder;
- std::map<std::string, TChassis> chassislist;
- TReadCheck readcheck;
- TWriteCheck writecheck;
- TWriteDone writedone;
- } TConfig, * pTConfig;
- // 网卡类型;
- enum NICKIND
- {
- // pci网卡;
- NIC_PCI,
- // usb网卡;
- NIC_USB,
- // 虚拟网卡;
- NIC_ROOT,
- // 仿真网卡;
- NIC_SWD,
- // 未知类型;
- NIC_UNK
- };
- typedef struct __MAC_ADDRESS__
- {
- INT nNICKind;
- TCHAR szNICKind[16];
- TCHAR szMacAddress[MAX_PATH];
- TCHAR szDevicePath[MAX_PATH];
- } MacAddress, * pMacAddress;
- //////////////////////////////////////////////////////////////////////////
- // 全局变量;
- extern BOOL g_bTestHost;
- extern TCHAR g_szCurModuleDir[MAX_PATH];
- extern TCHAR g_szCurModulePath[MAX_PATH];
- extern TCHAR g_szFna[MAX_PATH];
- extern TCHAR g_szConfig[MAX_PATH];
- extern std::string g_strMacs;
- extern std::vector<MacAddress> g_vtMac;
- extern TConfig g_tConfig;
- //////////////////////////////////////////////////////////////////////////
- // 全局函数;
- void GetConfig();
- void SetConfig();
- bool GetVersion(IN const TCHAR* fname, OUT WORD* pdwFileVersion, OUT WORD* pdwProductVerion);
- BOOL GetVersion(IN HMODULE hModule, OUT DWORD(&dwFVArray)[4], OUT DWORD(&dwPVArray)[4]);
- void WriteTextLog(const TCHAR* format, ...);
- void WriteReportLog(int type, std::string des, const TCHAR* format, ...);
- std::string EnCode_UTF8URL(IN const CHAR* pText);
- std::string& trim(std::string& str);
- // 获取网卡地址;
- INT GetMacAddress();
- // 字符串是否由数字、字母、符号组成;
- BOOL IsValidString(LPCTSTR lpszString);
- // 获取系统当前串口数量;
- BOOL GetSysSerialPort(std::vector<std::string>& vtports);
- }; // namespace Global
|