123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- #include "modulecomm.h"
- #include <iostream>
- namespace iv {
- namespace modulecomm {
- struct ModeduleInfo
- {
- void * mphandle;
- ModuleComm_TYPE mmctype;
- };
- void * RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount,
- ModuleComm_TYPE xmctype,const unsigned short nport)
- {
- iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
- pmi->mmctype = xmctype;
- pmi->mphandle = 0;
- switch (xmctype) {
- case ModuleComm_SHAREMEM:
- pmi->mphandle = iv::modulecomm_shm::RegisterSend(strcommname,nBufSize,nMsgBufCount);
- break;
- case ModuleComm_FASTRTPS:
- pmi->mphandle = iv::modulecomm_fastrtps::RegisterSend(strcommname,nBufSize,nMsgBufCount);
- break;
- case ModuleComm_INTERIOR:
- pmi->mphandle = iv::modulecomm_inter::RegisterSend(strcommname,nBufSize,nMsgBufCount);
- break;
- case ModuleComm_FASTRTPS_TCP:
- pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterSend(strcommname,nBufSize,nMsgBufCount,nport);
- break;
- default:
- break;
- }
- return pmi;
- }
- void * RegisterRecv(const char * strcommname,SMCallBack pCall,ModuleComm_TYPE xmctype,const char * strip,
- const unsigned short nPort)
- {
- iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
- pmi->mmctype = xmctype;
- pmi->mphandle = 0;
- switch (xmctype) {
- case ModuleComm_SHAREMEM:
- pmi->mphandle = iv::modulecomm_shm::RegisterRecv(strcommname,pCall);
- break;
- case ModuleComm_FASTRTPS:
- pmi->mphandle = iv::modulecomm_fastrtps::RegisterRecv(strcommname,pCall);
- break;
- case ModuleComm_INTERIOR:
- pmi->mphandle = iv::modulecomm_inter::RegisterRecv(strcommname,pCall);
- break;
- case ModuleComm_FASTRTPS_TCP:
- pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterRecv(strcommname,pCall,strip,nPort);
- break;
- default:
- break;
- }
- return pmi;
- }
- void * RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
- ModuleComm_TYPE xmctype,const char * strip,
- const unsigned short nPort)
- {
- iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
- pmi->mmctype = xmctype;
- pmi->mphandle = 0;
- switch (xmctype) {
- case ModuleComm_SHAREMEM:
- pmi->mphandle = iv::modulecomm_shm::RegisterRecvPlus(strcommname,xFun);
- break;
- case ModuleComm_FASTRTPS:
- pmi->mphandle = iv::modulecomm_fastrtps::RegisterRecvPlus(strcommname,xFun);
- break;
- case ModuleComm_INTERIOR:
- pmi->mphandle = iv::modulecomm_inter::RegisterRecvPlus(strcommname,xFun);
- break;
- case ModuleComm_FASTRTPS_TCP:
- pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterRecvPlus(strcommname,xFun,strip,nPort);
- break;
- default:
- break;
- }
- return pmi;
- }
- void ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen)
- {
- iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
- switch (pmi->mmctype) {
- case ModuleComm_SHAREMEM:
- iv::modulecomm_shm::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
- break;
- case ModuleComm_FASTRTPS:
- iv::modulecomm_fastrtps::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
- break;
- case ModuleComm_INTERIOR:
- iv::modulecomm_inter::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
- break;
- case ModuleComm_FASTRTPS_TCP:
- iv::modulecomm_fastrtps_tcp::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
- break;
- default:
- break;
- }
- }
- void Unregister(void * pHandle)
- {
- iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
- switch (pmi->mmctype) {
- case ModuleComm_SHAREMEM:
- iv::modulecomm_shm::Unregister(pmi->mphandle);
- break;
- case ModuleComm_FASTRTPS:
- iv::modulecomm_fastrtps::Unregister(pmi->mphandle);
- break;
- case ModuleComm_INTERIOR:
- iv::modulecomm_inter::Unregister(pmi->mphandle);
- break;
- case ModuleComm_FASTRTPS_TCP:
- iv::modulecomm_fastrtps_tcp::Unregister(pmi->mphandle);
- break;
- default:
- break;
- }
- }
- void PauseComm(void *pHandle)
- {
- iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
- switch (pmi->mmctype) {
- case ModuleComm_SHAREMEM:
- iv::modulecomm_shm::PauseComm(pmi->mphandle);
- break;
- case ModuleComm_FASTRTPS:
- iv::modulecomm_fastrtps::PauseComm(pmi->mphandle);
- break;
- case ModuleComm_INTERIOR:
- iv::modulecomm_inter::PauseComm(pmi->mphandle);
- break;
- case ModuleComm_FASTRTPS_TCP:
- iv::modulecomm_fastrtps_tcp::PauseComm(pmi->mphandle);
- break;
- default:
- break;
- }
- }
- void ContintuComm(void *pHandle)
- {
- iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
- switch (pmi->mmctype) {
- case ModuleComm_SHAREMEM:
- iv::modulecomm_shm::ContintuComm(pmi->mphandle);
- break;
- case ModuleComm_FASTRTPS:
- iv::modulecomm_fastrtps::ContintuComm(pmi->mphandle);
- break;
- case ModuleComm_INTERIOR:
- iv::modulecomm_inter::ContintuComm(pmi->mphandle);
- break;
- case ModuleComm_FASTRTPS_TCP:
- iv::modulecomm_fastrtps_tcp::ContintuComm(pmi->mphandle);
- break;
- default:
- break;
- }
- }
- }
- }
|