DiosUnitComm_V3.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <windows.h>
  3. #include "SCF.hpp"
  4. #include "SyncEvent.hpp"
  5. //-----------------------------------------------------------------------------
  6. // DiosConnect
  7. //-----------------------------------------------------------------------------
  8. namespace nsSCF = DIOS::Dev::Communication;
  9. namespace DIOS::Dev::Communication
  10. {
  11. #define CMD_LEN_MAX 1024
  12. using tbDataFun = std::function <void(const char* Packet, const DWORD Length)>;
  13. class DiosConnect
  14. {
  15. public:
  16. DiosConnect(int millisecond = 200);
  17. ~DiosConnect();
  18. void Prepare(std::string DllName);
  19. bool Connect(std::string strProfile, tPacketPredate Pr, _SCF_Transfertype TransferType, DWORD msTimeOut);
  20. bool Run(tbDataFun Dequeue);
  21. bool DecodePack(bool action);
  22. void Disconnect();
  23. bool isConnected();
  24. bool TryReconnect();
  25. bool isActDecodeFun{ true };
  26. nsSCF::SCF m_SCF; //数据收发处理基类
  27. protected:
  28. SyncEvent::Auto m_NewPacket; //读、处理同步事件
  29. //HANDLE m_DataThread; //处理数据线程
  30. tbDataFun m_tbFunction; //处理数据回调函数
  31. int m_iWaitSCFTimeOut; //处理数据时间间隔
  32. std::string m_tConnectParam; //连接参数
  33. tPacketPredate m_tCallbackFun;
  34. std::thread::id m_TID; //ThreadID
  35. };
  36. }