ModuleClient.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "LogicClient.h"
  3. #define CONTAINERDPC_API
  4. #define CONTAINERDPC_C_API extern "C"
  5. class GrpcDeviceClient;
  6. class CONTAINERDPC_API ModuleClient :
  7. public LogicClient
  8. {
  9. protected:
  10. GrpcDeviceClient* m_pGrpcClient;
  11. int m_nWaitResultCount;
  12. map<string, unsigned long> m_mpNotifyIdx;
  13. public :
  14. ModuleClient(string szClientName, string szTransaction, string szType = "", bool bNeedNotify = false);
  15. virtual ~ModuleClient();
  16. RET_STATUS ConnectGrpc(string strDevHost, string devPath="");
  17. RET_STATUS ModuleReq(PACKET_CMD cmd, const char* pszResource, ResDataObject* pReqParam, ResDataObject& pResponse, const char* pszDevPath = nullptr);
  18. virtual RET_STATUS DevGet(const char* pszPropties, ResDataObject& pResponse, const char* pszDevPath = nullptr);
  19. virtual RET_STATUS DevSet(const char* pszPropties, ResDataObject* pNewValue, ResDataObject& pResponse, const char* pszDevPath = nullptr);
  20. virtual RET_STATUS DevAdd(const char* pszPropties, ResDataObject* pAddValue, ResDataObject& pResponse, const char* pszDevPath = nullptr);
  21. virtual RET_STATUS DevDel(const char* pszPropties, ResDataObject* pDelValue, ResDataObject& pResponse, const char* pszDevPath = nullptr);
  22. virtual RET_STATUS DevAction(const char* pszActionName, ResDataObject* pReqParam, ResDataObject& pResponse, const char* pszDevPath = nullptr);
  23. virtual RET_STATUS DevMessage(const char* pszTopics, ResDataObject* pMessage, ResDataObject& pResponse, const char* pszDevPath = nullptr);
  24. virtual int BeginAyncWait();
  25. virtual void WaitAllComplete();
  26. virtual int GetAsyncResult(int idx, string& devResource, string& devRes, string& calResMsg);
  27. virtual void EndAync();
  28. virtual int AsyncAction(string devResource, ResDataObject* pReqParam,
  29. string devUri = "", string calSection = "",
  30. string calClientID = "");
  31. virtual int AsyncMessage(string devResource, ResDataObject* pReqParam,
  32. string devUri = "", string calSection = "",
  33. string calClientID = "");
  34. bool SupportGrpc() { return m_pGrpcClient != nullptr; }
  35. int WaitingResultCount() { return m_nWaitResultCount; }
  36. int ClearFilter();
  37. int InstallFilterNotify(string strKey, bool install);
  38. void SplitCcosDevicePath(string DevicePath, vector<string>& resTopicParams);
  39. PACKET_CMD ReadFilterNotify(ResDataObject& CmdObject);
  40. int Notify(const char* pszTopic, const char* pszSender, const char *pszType, const char* pszCmd, const char* pMsg);
  41. };