|
@@ -1,12 +1,20 @@
|
|
|
#include "modulecomm.h"
|
|
|
#include <iostream>
|
|
|
|
|
|
+#include "modulecomm_shm.h"
|
|
|
+
|
|
|
+#include "modulecomm_inter.h"
|
|
|
+#ifdef USE_FASTRTPS
|
|
|
+#include "modulecomm_fastrtps_shm.h"
|
|
|
+#include "modulecomm_fastrtps_tcp.h"
|
|
|
+#endif
|
|
|
+
|
|
|
namespace iv {
|
|
|
namespace modulecomm {
|
|
|
|
|
|
struct ModeduleInfo
|
|
|
{
|
|
|
- void * mphandle;
|
|
|
+ modulecomm_base * mphandle;
|
|
|
ModuleComm_TYPE mmctype;
|
|
|
};
|
|
|
|
|
@@ -19,17 +27,37 @@ void * RegisterSend(const char * strcommname,const unsigned int nBufSize,const
|
|
|
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);
|
|
|
+ {
|
|
|
+ iv::modulecomm_shm * p = new iv::modulecomm_shm();
|
|
|
+ p->RegisterSend(strcommname,nBufSize,nMsgBufCount);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
case ModuleComm_INTERIOR:
|
|
|
- pmi->mphandle = iv::modulecomm_inter::RegisterSend(strcommname,nBufSize,nMsgBufCount);
|
|
|
+ {
|
|
|
+ iv::modulecomm_inter * p = new iv::modulecomm_inter();
|
|
|
+ p->RegisterSend(strcommname,nBufSize,nMsgBufCount);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+#ifdef USE_FASTRTPS
|
|
|
+ case ModuleComm_FASTRTPS:
|
|
|
+ {
|
|
|
+ iv::modulecomm_fastrtps_shm * p = new iv::modulecomm_fastrtps_shm();
|
|
|
+ p->RegisterSend(strcommname,nBufSize,nMsgBufCount);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
+
|
|
|
case ModuleComm_FASTRTPS_TCP:
|
|
|
- pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterSend(strcommname,nBufSize,nMsgBufCount,nport);
|
|
|
+ {
|
|
|
+ iv::modulecomm_fastrtps_tcp * p = new iv::modulecomm_fastrtps_tcp();
|
|
|
+ p->RegisterSend(strcommname,nBufSize,nMsgBufCount,nport);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
+#endif
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -44,17 +72,37 @@ void * RegisterRecv(const char * strcommname,SMCallBack pCall,ModuleComm_TYPE
|
|
|
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);
|
|
|
+ {
|
|
|
+ iv::modulecomm_shm * p = new iv::modulecomm_shm();
|
|
|
+ p->RegisterRecv(strcommname,pCall);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
case ModuleComm_INTERIOR:
|
|
|
- pmi->mphandle = iv::modulecomm_inter::RegisterRecv(strcommname,pCall);
|
|
|
+ {
|
|
|
+ iv::modulecomm_inter * p = new iv::modulecomm_inter();
|
|
|
+ p->RegisterRecv(strcommname,pCall);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+#ifdef USE_FASTRTPS
|
|
|
+ case ModuleComm_FASTRTPS:
|
|
|
+ {
|
|
|
+ iv::modulecomm_fastrtps_shm * p = new iv::modulecomm_fastrtps_shm();
|
|
|
+ p->RegisterRecv(strcommname,pCall);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
+
|
|
|
case ModuleComm_FASTRTPS_TCP:
|
|
|
- pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterRecv(strcommname,pCall,strip,nPort);
|
|
|
+ {
|
|
|
+ iv::modulecomm_fastrtps_tcp * p = new iv::modulecomm_fastrtps_tcp();
|
|
|
+ p->RegisterRecv(strcommname,pCall,strip,nPort);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
+#endif
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -70,17 +118,36 @@ void * RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
|
|
|
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);
|
|
|
+ {
|
|
|
+ iv::modulecomm_shm * p = new iv::modulecomm_shm();
|
|
|
+ p->RegisterRecvPlus(strcommname,xFun);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
case ModuleComm_INTERIOR:
|
|
|
- pmi->mphandle = iv::modulecomm_inter::RegisterRecvPlus(strcommname,xFun);
|
|
|
+ {
|
|
|
+ iv::modulecomm_inter * p = new iv::modulecomm_inter();
|
|
|
+ p->RegisterRecvPlus(strcommname,xFun);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+#ifdef USE_FASTRTPS
|
|
|
+ case ModuleComm_FASTRTPS:
|
|
|
+ {
|
|
|
+ iv::modulecomm_fastrtps_shm * p = new iv::modulecomm_fastrtps_shm();
|
|
|
+ p->RegisterRecvPlus(strcommname,xFun);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
+
|
|
|
case ModuleComm_FASTRTPS_TCP:
|
|
|
- pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterRecvPlus(strcommname,xFun,strip,nPort);
|
|
|
+ {
|
|
|
+ iv::modulecomm_fastrtps_tcp * p = new iv::modulecomm_fastrtps_tcp();
|
|
|
+ p->RegisterRecvPlus(strcommname,xFun,strip,nPort);
|
|
|
+ pmi->mphandle = (iv::modulecomm_base *)p;
|
|
|
+ }
|
|
|
break;
|
|
|
+#endif
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -90,85 +157,45 @@ void * RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
|
|
|
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;
|
|
|
+ if(pmi->mphandle == 0)
|
|
|
+ {
|
|
|
+ qDebug("handler error. use fastrtps but not define.");
|
|
|
+ return;
|
|
|
}
|
|
|
+ pmi->mphandle->ModuleSendMsg(strdata,nDataLen);
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
+ if(pmi->mphandle == 0)
|
|
|
+ {
|
|
|
+ qDebug("handler error. use fastrtps but not define.");
|
|
|
+ return;
|
|
|
}
|
|
|
+ pmi->mphandle->Unregister();
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
+ if(pmi->mphandle == 0)
|
|
|
+ {
|
|
|
+ qDebug("handler error. use fastrtps but not define.");
|
|
|
+ return;
|
|
|
}
|
|
|
+ pmi->mphandle->PauseComm();
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
+ if(pmi->mphandle == 0)
|
|
|
+ {
|
|
|
+ qDebug("handler error. use fastrtps but not define.");
|
|
|
+ return;
|
|
|
}
|
|
|
+ pmi->mphandle->ContintuComm();
|
|
|
}
|
|
|
|
|
|
}
|