eBus.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  3. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 EBUS_EXPORTS
  4. // 符号编译的。在使用此 DLL 的
  5. // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  6. // EBUS_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  7. // 符号视为是被导出的。
  8. #ifndef EBUS_EXPORTS
  9. #ifdef _WIN64
  10. #ifdef _DEBUG
  11. #pragma comment(lib, "eBusX64D.lib")
  12. #else
  13. #pragma comment(lib, "eBusX64.lib")
  14. #endif
  15. #else
  16. #ifdef _DEBUG
  17. #pragma comment(lib, "eBusD.lib")
  18. #else
  19. #pragma comment(lib, "eBus.lib")
  20. #endif
  21. #endif
  22. #endif
  23. #ifdef EBUS_EXPORTS
  24. #define EBUS_API __declspec(dllexport)
  25. #define EBUS_C_API extern "C" __declspec(dllexport)
  26. #else
  27. #define EBUS_API __declspec(dllimport)
  28. #define EBUS_C_API extern "C" __declspec(dllimport)
  29. #endif
  30. #include "DeviceBus.h"
  31. #define EBUS_CONNECTION_LOCAL ("Local")
  32. #define EBUS_CONNECTION_BUSID ("BusId")
  33. #define EBUS_CONNECTION_PORT ("Port")
  34. #define EBUS_CONNECTION_ROUTERIP ("RouterIp")
  35. /// <summary>
  36. /// 完成eBus服务的初始化
  37. /// </summary>
  38. /// <param name="EnableLog"> 使能日志 </param>
  39. /// <returns></returns>
  40. EBUS_C_API void InitEbusEnv(bool EnableLog);
  41. /// <summary>
  42. /// 清理eBus服务
  43. /// </summary>
  44. /// <returns></returns>
  45. EBUS_C_API void QuitEbusEnv(); //
  46. /// <summary>
  47. /// 设备bus实现,使用eBus和p2p 两个通道;完成ccos包的收发,含大对象(图像),p2p收到的包转回 Service处理
  48. /// </summary>
  49. class EBUS_API eBus : public DeviceBUS
  50. {
  51. HANDLE m_pBusService; //实际的eBus实现服务对象
  52. bool TryGetConnectOptions(ResDataObject &connection, const char *pKey, ResDataObject &result);
  53. public:
  54. eBus(void);
  55. virtual ~eBus(void);
  56. //Local Connection
  57. //Local:1
  58. //Port:xxx (OPTIONAL)
  59. //srcBusId:BusId
  60. //Ethernet Connection
  61. //Local:0
  62. //Port:xxx (OPTIONAL)
  63. //RouterIp:ipaddress
  64. //srcBusId:BusId
  65. /*
  66. if RouterIp is empty,eBus will find one .
  67. if eBus found more than one,it will fail and return false.
  68. */
  69. virtual bool Connect(ResDataObject &connection);
  70. virtual void DisConnect();
  71. virtual bool IsConnected();
  72. virtual void Quit();
  73. virtual void SetLogPath(const char *pPath);
  74. virtual bool SendSMPacket(const char *pTargetID, const char *pContext, unsigned long long nShareMemID);
  75. virtual bool SendRawPacket(const char *pTargetID, const char *pContext, DWORD ChannelId);
  76. virtual bool SendPacket(const char *pTargetID, const char *pContext, const char *pBlock = NULL, DWORD BlockSize = 0);
  77. virtual void BlobDataArrived(const char *pMsg, unsigned char *pBlockData, DWORD BlockDataLen);
  78. virtual void InitP2P(const char *pszIp, const char *pszLocalBusId, bool AsServer);
  79. virtual void UnRegistThread(DWORD Tid);
  80. };