#pragma once #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; std::string _rtnError; std::string _rtnContext; std::string _cmdContext; 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__& operator=(const __CMDPARAM__& cls) { if (this != &cls) { name = cls.name; head = cls.head; code = cls.code; param = cls.param; nOption = cls.nOption; bMulticode = cls.bMulticode; cmd_wait_time = cls.cmd_wait_time; read_wait_time = cls.read_wait_time; _rtnCode = cls._rtnCode; _rtnStatus = cls._rtnStatus; _rtnData = cls._rtnData; _rtnError = cls._rtnError; _rtnContext = cls._rtnContext; _cmdContext = cls._cmdContext; } return *this; } void Clean() { //_rtnCode = 0; _rtnStatus = 0x0E; #if _MSC_VER >= 1200 && _MSC_VER < 1500 _rtnData = ""; _rtnError = ""; _rtnContext = ""; _cmdContext = ""; #elif _MSC_VER >= 1500 _rtnData.clear(); _rtnError.clear(); _rtnContext.clear(); _cmdContext.clear(); #endif } __CMDPARAM__() { _rtnCode = 0; _rtnStatus = 0; nOption = 0; bMulticode = false; cmd_wait_time = 100; read_wait_time = 100; } } CommandParam, * pCommandParam; class TCLCommand :public CBaseSerial { static byte* m_pData; // 内部-低优先查找; std::vector m_vtInternalCMDParams; // 外部-高优先查找; std::vector m_vtExternalCMDParams; public: TCLCommand(bool bSync = true); ~TCLCommand(void); public: int pares_time_value(std::string strTime); bool parse_pair_key(std::string& RetValue, std::string strLine, TCHAR* lpszText); int parse_cmds_from_file(const TCHAR* file_name, std::vector& vtCommandParams); void parse_cmds_from_string(std::string str, std::vector& vtCommandParams); bool TheFirstPart(CommandParam& cmdPara, std::string data); bool TheSecondPart(CommandParam& cmdPara, std::string data); bool ParseResultString(CommandParam& cmdPara, std::string data, const int& dataLen); public: void SetInternalCMDParams(DWORD dwResouceID); void SetExternalCMDParams(LPCTSTR lpFileName); bool GetCommandParams(std::string name, CommandParam& cmdPara); bool SendCommand(CommandParam& cmdPara); void PackingCommand(CommandParam& cmdPara, std::string data = "", const int& dataLen = 0); bool EnterFactory(); bool LeaveFactory(); bool GetProjectId(int &pid); bool GetSoftVersion(std::string &strValue); bool GetDeviceId(std::string &strValue); bool GetClientType(std::string &strValue); bool GetMAC(std::string &strValue); bool GetHDCPKey(std::string &strValue); bool GetHDCPKey22(std::string &strValue); bool GetWidi(std::string &strValue); bool GetNetflixESN(std::string &strValue); bool GetWidevine(std::string &strValue); bool GetCiKey(std::string &strValue); bool GetOSDLanguage(std::string &strValue); bool GetShopLanguage(std::string &strValue); bool GetChannel(std::string &strValue); bool SetProjectId(int pid); bool SetProjectId(LPCTSTR lpPid); bool SetProjectId(const byte* pBuffer, const int& nLen); bool SetDeviceId(LPCTSTR lpDeviceId); bool SetDeviceId(const byte* pBuffer, const int &nLen); bool SetMAC(LPCTSTR lpMac); bool SetMAC(const byte* pBuffer, const int& nLen); bool SetHDCPKey(LPCTSTR lpHDCP, bool bHasSpace = FALSE); bool SetHDCPKey(const byte* pBuffer, const int& nLen); bool SetHDCPKey22(LPCTSTR lpHDCP22, bool bHasSpace = FALSE); bool SetHDCPKey22(const byte* pBuffer, const int& nLen); bool SetNetflixESN(LPCTSTR lpESN, bool bHasSpace = FALSE); bool SetNetflixESN(const byte* pBuffer, const int& nLen); bool SetWidi(LPCTSTR lpWidi, bool bHasSpace = FALSE); bool SetWidi(const byte* pBuffer, const int& nLen); bool SetWidevine(LPCTSTR lpWidevine, bool bHasSpace = FALSE); bool SetWidevine(const byte* pBuffer, const int& nLen); bool SetCiKey(LPCTSTR lpCiKey, bool bHasSpace = FALSE); bool SetCiKey(const byte* pBuffer, const int& nLen); bool SetOSDLanguage(LPCTSTR lan, bool bHasSpace = TRUE); bool SetOSDLanguage(const byte* pBuffer, const int& nLen); bool SetShopLanguage(LPCTSTR lan, bool bHasSpace = TRUE); bool SetShopLanguage(const byte* pBuffer, const int& nLen); bool SetChannel(LPCTSTR channel, bool bHasSpace = TRUE); bool SetChannel(const byte* pBuffer, const int& nLen); bool SetWBNormal(LPCTSTR data); bool SetWBNormal(const byte* pBuffer, const int& nLen); bool SetWBCool(LPCTSTR data); bool SetWBCool(const byte* pBuffer, const int& nLen); bool SetWBWarm(LPCTSTR data); bool SetWBWarm(const byte* pBuffer, const int& nLen); bool CheckDeviceId(); bool CheckMAC(); bool CheckHDCP(); bool CheckHDCP22(); bool CheckNetflixESN(); bool CheckWidi(); bool CheckWidevine(); bool CheckCikey(); bool StarWarmUpMode(); bool StopWarmUpMode(); // 工厂菜单显示与隐藏; bool ShowFactoryMenu(); bool HideFactoryMenu(); // 工厂信息内容显示与隐藏; bool ShowFactoryInformation(); bool HideFactoryInformation(); // 老化模式的开与关、老化时间读取; bool EnterAgingModel(); bool LeaveAgingModel(); bool ReadAgingTime(int &min); // 红绿蓝增益; bool SetRedGainRegister(int value); bool SetGreenGainRegister(int value); bool SetBlueGainRegister(int value); // 红绿蓝偏移; bool SetRedOffsetRegister(int value); bool SetGreenOffsetRegister(int value); bool SetBlueOffsetRegister(int value); };