modulecomm.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #include "modulecomm.h"
  2. #include <iostream>
  3. namespace iv {
  4. namespace modulecomm {
  5. struct ModeduleInfo
  6. {
  7. void * mphandle;
  8. ModuleComm_TYPE mmctype;
  9. };
  10. void * RegisterSend(const char * strcommname,const unsigned int nBufSize,const unsigned int nMsgBufCount,
  11. ModuleComm_TYPE xmctype,const unsigned short nport)
  12. {
  13. iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
  14. pmi->mmctype = xmctype;
  15. pmi->mphandle = 0;
  16. switch (xmctype) {
  17. case ModuleComm_SHAREMEM:
  18. pmi->mphandle = iv::modulecomm_shm::RegisterSend(strcommname,nBufSize,nMsgBufCount);
  19. break;
  20. case ModuleComm_FASTRTPS:
  21. pmi->mphandle = iv::modulecomm_fastrtps::RegisterSend(strcommname,nBufSize,nMsgBufCount);
  22. break;
  23. case ModuleComm_INTERIOR:
  24. pmi->mphandle = iv::modulecomm_inter::RegisterSend(strcommname,nBufSize,nMsgBufCount);
  25. break;
  26. case ModuleComm_FASTRTPS_TCP:
  27. pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterSend(strcommname,nBufSize,nMsgBufCount,nport);
  28. break;
  29. default:
  30. break;
  31. }
  32. return pmi;
  33. }
  34. void * RegisterRecv(const char * strcommname,SMCallBack pCall,ModuleComm_TYPE xmctype,const char * strip,
  35. const unsigned short nPort)
  36. {
  37. iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
  38. pmi->mmctype = xmctype;
  39. pmi->mphandle = 0;
  40. switch (xmctype) {
  41. case ModuleComm_SHAREMEM:
  42. pmi->mphandle = iv::modulecomm_shm::RegisterRecv(strcommname,pCall);
  43. break;
  44. case ModuleComm_FASTRTPS:
  45. pmi->mphandle = iv::modulecomm_fastrtps::RegisterRecv(strcommname,pCall);
  46. break;
  47. case ModuleComm_INTERIOR:
  48. pmi->mphandle = iv::modulecomm_inter::RegisterRecv(strcommname,pCall);
  49. break;
  50. case ModuleComm_FASTRTPS_TCP:
  51. pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterRecv(strcommname,pCall,strip,nPort);
  52. break;
  53. default:
  54. break;
  55. }
  56. return pmi;
  57. }
  58. void * RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
  59. ModuleComm_TYPE xmctype,const char * strip,
  60. const unsigned short nPort)
  61. {
  62. iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
  63. pmi->mmctype = xmctype;
  64. pmi->mphandle = 0;
  65. switch (xmctype) {
  66. case ModuleComm_SHAREMEM:
  67. pmi->mphandle = iv::modulecomm_shm::RegisterRecvPlus(strcommname,xFun);
  68. break;
  69. case ModuleComm_FASTRTPS:
  70. pmi->mphandle = iv::modulecomm_fastrtps::RegisterRecvPlus(strcommname,xFun);
  71. break;
  72. case ModuleComm_INTERIOR:
  73. pmi->mphandle = iv::modulecomm_inter::RegisterRecvPlus(strcommname,xFun);
  74. break;
  75. case ModuleComm_FASTRTPS_TCP:
  76. pmi->mphandle = iv::modulecomm_fastrtps_tcp::RegisterRecvPlus(strcommname,xFun,strip,nPort);
  77. break;
  78. default:
  79. break;
  80. }
  81. return pmi;
  82. }
  83. void ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen)
  84. {
  85. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  86. switch (pmi->mmctype) {
  87. case ModuleComm_SHAREMEM:
  88. iv::modulecomm_shm::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
  89. break;
  90. case ModuleComm_FASTRTPS:
  91. iv::modulecomm_fastrtps::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
  92. break;
  93. case ModuleComm_INTERIOR:
  94. iv::modulecomm_inter::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
  95. break;
  96. case ModuleComm_FASTRTPS_TCP:
  97. iv::modulecomm_fastrtps_tcp::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
  98. break;
  99. default:
  100. break;
  101. }
  102. }
  103. void Unregister(void * pHandle)
  104. {
  105. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  106. switch (pmi->mmctype) {
  107. case ModuleComm_SHAREMEM:
  108. iv::modulecomm_shm::Unregister(pmi->mphandle);
  109. break;
  110. case ModuleComm_FASTRTPS:
  111. iv::modulecomm_fastrtps::Unregister(pmi->mphandle);
  112. break;
  113. case ModuleComm_INTERIOR:
  114. iv::modulecomm_inter::Unregister(pmi->mphandle);
  115. break;
  116. case ModuleComm_FASTRTPS_TCP:
  117. iv::modulecomm_fastrtps_tcp::Unregister(pmi->mphandle);
  118. break;
  119. default:
  120. break;
  121. }
  122. }
  123. void PauseComm(void *pHandle)
  124. {
  125. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  126. switch (pmi->mmctype) {
  127. case ModuleComm_SHAREMEM:
  128. iv::modulecomm_shm::PauseComm(pmi->mphandle);
  129. break;
  130. case ModuleComm_FASTRTPS:
  131. iv::modulecomm_fastrtps::PauseComm(pmi->mphandle);
  132. break;
  133. case ModuleComm_INTERIOR:
  134. iv::modulecomm_inter::PauseComm(pmi->mphandle);
  135. break;
  136. case ModuleComm_FASTRTPS_TCP:
  137. iv::modulecomm_fastrtps_tcp::PauseComm(pmi->mphandle);
  138. break;
  139. default:
  140. break;
  141. }
  142. }
  143. void ContintuComm(void *pHandle)
  144. {
  145. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  146. switch (pmi->mmctype) {
  147. case ModuleComm_SHAREMEM:
  148. iv::modulecomm_shm::ContintuComm(pmi->mphandle);
  149. break;
  150. case ModuleComm_FASTRTPS:
  151. iv::modulecomm_fastrtps::ContintuComm(pmi->mphandle);
  152. break;
  153. case ModuleComm_INTERIOR:
  154. iv::modulecomm_inter::ContintuComm(pmi->mphandle);
  155. break;
  156. case ModuleComm_FASTRTPS_TCP:
  157. iv::modulecomm_fastrtps_tcp::ContintuComm(pmi->mphandle);
  158. break;
  159. default:
  160. break;
  161. }
  162. }
  163. }
  164. }