CcosUnitComm_V3.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <functional>
  3. #include <thread>
  4. #include "SCF.hpp"
  5. #include "SyncEvent.hpp"
  6. //-----------------------------------------------------------------------------
  7. // DiosConnect
  8. //-----------------------------------------------------------------------------
  9. namespace nsSCF = DIOS::Dev::Communication;
  10. namespace DIOS::Dev::Communication
  11. {
  12. #define CMD_LEN_MAX 1024
  13. // Linux兼容类型定义
  14. using DWORD = unsigned long;
  15. using tbDataFun = std::function <void(const char* Packet, const DWORD Length)>;
  16. class DiosConnect
  17. {
  18. public:
  19. DiosConnect(int millisecond = 200);
  20. ~DiosConnect();
  21. void Prepare(std::string DllName);
  22. bool Connect(std::string strProfile, tPacketPredate Pr, _SCF_Transfertype TransferType, DWORD msTimeOut);
  23. bool Run(tbDataFun Dequeue);
  24. bool DecodePack(bool action);
  25. void Disconnect();
  26. bool isConnected();
  27. bool TryReconnect();
  28. bool isActDecodeFun{ true };
  29. nsSCF::SCF m_SCF; //�����շ���������
  30. protected:
  31. SyncEvent::Auto m_NewPacket; //��������ͬ���¼�
  32. //HANDLE m_DataThread; //���������߳�
  33. tbDataFun m_tbFunction; //�������ݻص�����
  34. int m_iWaitSCFTimeOut; //��������ʱ����
  35. std::string m_tConnectParam; //���Ӳ���
  36. tPacketPredate m_tCallbackFun;
  37. std::thread::id m_TID; //ThreadID
  38. };
  39. }