TCLCommand.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #pragma once
  2. #include "serial.h"
  3. enum CMDOPT {
  4. CMDOPT_None = 0,
  5. CMDOPT_Get = 1,
  6. CMDOPT_Set = 2
  7. };
  8. typedef struct __CMDPARAM__ {
  9. std::string name; // 命令描述;
  10. std::string head; // 命令头;
  11. std::string code; // 命令码;
  12. std::string param; // 命令码参数;
  13. // 命令属性类型:
  14. // 0=None,只返回一段数据包;
  15. // 1=Get,返回一段或两段数据包(成功时返回2段,失败时返回1段);
  16. // 2=Set,返回一段或两段数据包(成功时返回1段,失败时返回1段);
  17. int nOption;
  18. bool bMulticode; // 命令码是否多参数;
  19. int cmd_wait_time; // 两条串口指令间隔时间;
  20. int read_wait_time; // 写完串口后,等待多久读;
  21. byte _rtnCode;
  22. byte _rtnStatus;
  23. std::string _rtnData;
  24. std::string _rtnError;
  25. std::string _rtnContext;
  26. std::string _cmdContext;
  27. void UpdateRtnCode() {
  28. if (!_tcsicmp(_T("AA"), head.c_str())) { // 调试用命令代码引导码;
  29. _rtnCode = 0xAB;
  30. }
  31. else if (!_tcsicmp(_T("AC"), head.c_str())) { // 软件配屏参数调整命令代码引导码;
  32. _rtnCode = 0xAD;
  33. }
  34. else if (!_tcsicmp(_T("AE"), head.c_str())) { // 保留命令发送类型引导码;
  35. _rtnCode = 0xAF;
  36. }
  37. }
  38. __CMDPARAM__& operator=(const __CMDPARAM__& cls) {
  39. if (this != &cls) {
  40. name = cls.name;
  41. head = cls.head;
  42. code = cls.code;
  43. param = cls.param;
  44. nOption = cls.nOption;
  45. bMulticode = cls.bMulticode;
  46. cmd_wait_time = cls.cmd_wait_time;
  47. read_wait_time = cls.read_wait_time;
  48. _rtnCode = cls._rtnCode;
  49. _rtnStatus = cls._rtnStatus;
  50. _rtnData = cls._rtnData;
  51. _rtnError = cls._rtnError;
  52. _rtnContext = cls._rtnContext;
  53. _cmdContext = cls._cmdContext;
  54. }
  55. return *this;
  56. }
  57. void Clean() {
  58. //_rtnCode = 0;
  59. _rtnStatus = 0x0E;
  60. #if _MSC_VER >= 1200 && _MSC_VER < 1500
  61. _rtnData = "";
  62. _rtnError = "";
  63. _rtnContext = "";
  64. _cmdContext = "";
  65. #elif _MSC_VER >= 1500
  66. _rtnData.clear();
  67. _rtnError.clear();
  68. _rtnContext.clear();
  69. _cmdContext.clear();
  70. #endif
  71. }
  72. __CMDPARAM__() {
  73. _rtnCode = 0;
  74. _rtnStatus = 0;
  75. nOption = 0;
  76. bMulticode = false;
  77. cmd_wait_time = 100;
  78. read_wait_time = 100;
  79. }
  80. } CommandParam, * pCommandParam;
  81. class TCLCommand :public CBaseSerial
  82. {
  83. static byte* m_pData;
  84. // 内部-低优先查找;
  85. std::vector<CommandParam> m_vtInternalCMDParams;
  86. // 外部-高优先查找;
  87. std::vector<CommandParam> m_vtExternalCMDParams;
  88. public:
  89. TCLCommand(bool bSync = true);
  90. ~TCLCommand(void);
  91. public:
  92. int pares_time_value(std::string strTime);
  93. bool parse_pair_key(std::string& RetValue, std::string strLine, TCHAR* lpszText);
  94. int parse_cmds_from_file(const TCHAR* file_name, std::vector<CommandParam>& vtCommandParams);
  95. void parse_cmds_from_string(std::string str, std::vector<CommandParam>& vtCommandParams);
  96. bool TheFirstPart(CommandParam& cmdPara, std::string data);
  97. bool TheSecondPart(CommandParam& cmdPara, std::string data);
  98. bool ParseResultString(CommandParam& cmdPara, std::string data, const int& dataLen);
  99. public:
  100. void SetInternalCMDParams(DWORD dwResouceID);
  101. void SetExternalCMDParams(LPCTSTR lpFileName);
  102. bool GetCommandParams(std::string name, CommandParam& cmdPara);
  103. bool SendCommand(CommandParam& cmdPara);
  104. void PackingCommand(CommandParam& cmdPara, std::string data = "", const int& dataLen = 0);
  105. bool EnterFactory();
  106. bool LeaveFactory();
  107. bool GetProjectId(int &pid);
  108. bool GetSoftVersion(std::string &strValue);
  109. bool GetDeviceId(std::string &strValue);
  110. bool GetClientType(std::string &strValue);
  111. bool GetMAC(std::string &strValue);
  112. bool GetHDCPKey(std::string &strValue);
  113. bool GetHDCPKey22(std::string &strValue);
  114. bool GetWidi(std::string &strValue);
  115. bool GetNetflixESN(std::string &strValue);
  116. bool GetWidevine(std::string &strValue);
  117. bool GetCiKey(std::string &strValue);
  118. bool GetOSDLanguage(std::string &strValue);
  119. bool GetShopLanguage(std::string &strValue);
  120. bool GetChannel(std::string &strValue);
  121. bool SetProjectId(int pid);
  122. bool SetProjectId(LPCTSTR lpPid);
  123. bool SetProjectId(const byte* pBuffer, const int& nLen);
  124. bool SetDeviceId(LPCTSTR lpDeviceId);
  125. bool SetDeviceId(const byte* pBuffer, const int &nLen);
  126. bool SetMAC(LPCTSTR lpMac);
  127. bool SetMAC(const byte* pBuffer, const int& nLen);
  128. bool SetHDCPKey(LPCTSTR lpHDCP, bool bHasSpace = FALSE);
  129. bool SetHDCPKey(const byte* pBuffer, const int& nLen);
  130. bool SetHDCPKey22(LPCTSTR lpHDCP22, bool bHasSpace = FALSE);
  131. bool SetHDCPKey22(const byte* pBuffer, const int& nLen);
  132. bool SetNetflixESN(LPCTSTR lpESN, bool bHasSpace = FALSE);
  133. bool SetNetflixESN(const byte* pBuffer, const int& nLen);
  134. bool SetWidi(LPCTSTR lpWidi, bool bHasSpace = FALSE);
  135. bool SetWidi(const byte* pBuffer, const int& nLen);
  136. bool SetWidevine(LPCTSTR lpWidevine, bool bHasSpace = FALSE);
  137. bool SetWidevine(const byte* pBuffer, const int& nLen);
  138. bool SetCiKey(LPCTSTR lpCiKey, bool bHasSpace = FALSE);
  139. bool SetCiKey(const byte* pBuffer, const int& nLen);
  140. bool SetOSDLanguage(LPCTSTR lan, bool bHasSpace = TRUE);
  141. bool SetOSDLanguage(const byte* pBuffer, const int& nLen);
  142. bool SetShopLanguage(LPCTSTR lan, bool bHasSpace = TRUE);
  143. bool SetShopLanguage(const byte* pBuffer, const int& nLen);
  144. bool SetChannel(LPCTSTR channel, bool bHasSpace = TRUE);
  145. bool SetChannel(const byte* pBuffer, const int& nLen);
  146. bool SetWBNormal(LPCTSTR data);
  147. bool SetWBNormal(const byte* pBuffer, const int& nLen);
  148. bool SetWBCool(LPCTSTR data);
  149. bool SetWBCool(const byte* pBuffer, const int& nLen);
  150. bool SetWBWarm(LPCTSTR data);
  151. bool SetWBWarm(const byte* pBuffer, const int& nLen);
  152. bool CheckDeviceId();
  153. bool CheckMAC();
  154. bool CheckHDCP();
  155. bool CheckHDCP22();
  156. bool CheckNetflixESN();
  157. bool CheckWidi();
  158. bool CheckWidevine();
  159. bool CheckCikey();
  160. bool StarWarmUpMode();
  161. bool StopWarmUpMode();
  162. // 工厂菜单显示与隐藏;
  163. bool ShowFactoryMenu();
  164. bool HideFactoryMenu();
  165. // 工厂信息内容显示与隐藏;
  166. bool ShowFactoryInformation();
  167. bool HideFactoryInformation();
  168. // 老化模式的开与关、老化时间读取;
  169. bool EnterAgingModel();
  170. bool LeaveAgingModel();
  171. bool ReadAgingTime(int &min);
  172. // 红绿蓝增益;
  173. bool SetRedGainRegister(int value);
  174. bool SetGreenGainRegister(int value);
  175. bool SetBlueGainRegister(int value);
  176. // 红绿蓝偏移;
  177. bool SetRedOffsetRegister(int value);
  178. bool SetGreenOffsetRegister(int value);
  179. bool SetBlueOffsetRegister(int value);
  180. };