#ifndef PROCSM_IF_H #define PROCSM_IF_H #include #include #include #include #include #ifdef USEDBUS #include #include #endif #include "procsm.h" typedef void (* SMCallBack)(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname); using namespace std::placeholders; typedef std::function ModuleFun; class procsm_if_readthread:public QThread { Q_OBJECT public: #ifdef USELCM #endif procsm_if_readthread(procsm * pPSM,SMCallBack pCall,const char * strsmname); procsm_if_readthread(procsm * pPSM,ModuleFun xFun,const char * strsmname); void puaseread(); void continueread(); private slots: #ifdef USEDBUS void onNewMsg(int x); #endif private: #ifdef USELCM lcm::LCM mlcm; void handlerMethod(const lcm::ReceiveBuffer *rbuf,const std::string &channel); int mxindex = 0; #endif void run(); procsm * mpPSM; SMCallBack mpCall; ModuleFun mFun; char mstrsmname[256]; QWaitCondition mwc; QMutex mWaitMutex; bool mbFunPlus = false; bool mbRun = true; bool mbDBUSOK = true; }; class procsm_if { public: procsm_if(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode); ~procsm_if(); int writemsg(const char * str,const unsigned int nSize); int listenmsg(SMCallBack pCall); int listenmsg(ModuleFun xFun); void stoplisten(); void pausecomm(); void continuecomm(); private: procsm * mpPSM; int mnType; procsm_if_readthread * mpReadThread; QTimer mTimer; char mstrsmname[256]; bool mbRun = true; #ifdef USELCM lcm::LCM mlcm; void handlerMethod(const lcm::ReceiveBuffer *rbuf,const std::string &channel); #endif }; #endif // PROCSM_IF_H