eBus.h 2.5 KB

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