#pragma once #include #include "SCF.hpp" #include "SyncEvent.hpp" //----------------------------------------------------------------------------- // DiosConnect //----------------------------------------------------------------------------- namespace nsSCF = DIOS::Dev::Communication; namespace DIOS::Dev::Communication { #define CMD_LEN_MAX 1024 using tbDataFun = std::function ; class DiosConnect { public: DiosConnect(int millisecond = 200); ~DiosConnect(); void Prepare(std::string DllName); bool Connect(std::string strProfile, tPacketPredate Pr, _SCF_Transfertype TransferType, DWORD msTimeOut); bool Run(tbDataFun Dequeue); bool DecodePack(bool action); void Disconnect(); bool isConnected(); bool TryReconnect(); bool isActDecodeFun{ true }; nsSCF::SCF m_SCF; //数据收发处理基类 protected: SyncEvent::Auto m_NewPacket; //读、处理同步事件 //HANDLE m_DataThread; //处理数据线程 tbDataFun m_tbFunction; //处理数据回调函数 int m_iWaitSCFTimeOut; //处理数据时间间隔 std::string m_tConnectParam; //连接参数 tPacketPredate m_tCallbackFun; std::thread::id m_TID; //ThreadID }; }