DeviceBUS.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  3. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 DEVICEBUS_EXPORTS
  4. // 符号编译的。在使用此 DLL 的
  5. // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  6. // DEVICEBUS_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  7. // 符号视为是被导出的。
  8. #ifndef DEVICEBUS_EXPORTS
  9. #ifdef _WIN64
  10. #ifdef _DEBUG
  11. #pragma comment(lib, "DeviceBusX64D.lib")
  12. #else
  13. #pragma comment(lib, "DeviceBusX64.lib")
  14. #endif
  15. #else
  16. #ifdef _DEBUG
  17. #pragma comment(lib, "DeviceBusD.lib")
  18. #else
  19. #pragma comment(lib, "DeviceBus.lib")
  20. #endif
  21. #endif
  22. #endif
  23. #ifdef DEVICEBUS_EXPORTS
  24. #define DEVICEBUS_API __declspec(dllexport)
  25. #else
  26. #define DEVICEBUS_API __declspec(dllimport)
  27. #endif
  28. #include "DiosThread.h"
  29. #include "ResDataObject.h"
  30. #include "ErrorInfoObject.h"
  31. #define DIOS_HW_CHANNEL (80000)
  32. #define DIOS_HW_COM_BUSID ("Dios.Hw.Dev.Bus")
  33. class DEVICEBUS_API DeviceBUS : public ErrorInfoObject
  34. {
  35. protected:
  36. bool m_Connected;
  37. Work_Thread *m_pPacketReceiveThread;//for receive packet
  38. public:
  39. PVOID m_pP2PModule;
  40. DeviceBUS(void);
  41. virtual ~DeviceBUS(void);
  42. void SetReceiveThread(Work_Thread *pThread);
  43. virtual bool Connect(ResDataObject &connection);//assume there will be a lots various connections
  44. virtual void DisConnect();
  45. virtual bool IsConnected();
  46. virtual void Quit();
  47. virtual void SetLogPath(const char *pPath);
  48. virtual bool SendSMPacket(const char *pTargetID, const char *pContext, unsigned long long nShareMemID);
  49. virtual bool SendRawPacket(const char *pTargetID, const char *pContext, DWORD ChannelId);
  50. virtual bool SendPacket(const char *pTargetID, const char *pContext, const char *pBlock = NULL, DWORD BlockSize = 0);
  51. virtual void PacketArrived(ResDataObject &packet);
  52. virtual void BlobDataArrived(const char *pMsg, unsigned char *pBlockData, DWORD BlockDataLen);
  53. virtual void InitP2P(const char *pszIp, const char *pszLocalBusId, bool AsServer);
  54. virtual void UnRegistThread(DWORD Tid);
  55. };