modulecomm.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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)
  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. default:
  27. break;
  28. }
  29. return pmi;
  30. }
  31. void * RegisterRecv(const char * strcommname,SMCallBack pCall,ModuleComm_TYPE xmctype)
  32. {
  33. iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
  34. pmi->mmctype = xmctype;
  35. pmi->mphandle = 0;
  36. switch (xmctype) {
  37. case ModuleComm_SHAREMEM:
  38. pmi->mphandle = iv::modulecomm_shm::RegisterRecv(strcommname,pCall);
  39. break;
  40. case ModuleComm_FASTRTPS:
  41. pmi->mphandle = iv::modulecomm_fastrtps::RegisterRecv(strcommname,pCall);
  42. break;
  43. case ModuleComm_INTERIOR:
  44. pmi->mphandle = iv::modulecomm_inter::RegisterRecv(strcommname,pCall);
  45. break;
  46. default:
  47. break;
  48. }
  49. return pmi;
  50. }
  51. void * RegisterRecvPlus(const char * strcommname,ModuleFun xFun,
  52. ModuleComm_TYPE xmctype)
  53. {
  54. iv::modulecomm::ModeduleInfo * pmi = new iv::modulecomm::ModeduleInfo;
  55. pmi->mmctype = xmctype;
  56. pmi->mphandle = 0;
  57. switch (xmctype) {
  58. case ModuleComm_SHAREMEM:
  59. pmi->mphandle = iv::modulecomm_shm::RegisterRecvPlus(strcommname,xFun);
  60. break;
  61. case ModuleComm_FASTRTPS:
  62. pmi->mphandle = iv::modulecomm_fastrtps::RegisterRecvPlus(strcommname,xFun);
  63. break;
  64. case ModuleComm_INTERIOR:
  65. pmi->mphandle = iv::modulecomm_inter::RegisterRecvPlus(strcommname,xFun);
  66. break;
  67. default:
  68. break;
  69. }
  70. return pmi;
  71. }
  72. void ModuleSendMsg(void * pHandle,const char * strdata,const unsigned int nDataLen)
  73. {
  74. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  75. switch (pmi->mmctype) {
  76. case ModuleComm_SHAREMEM:
  77. iv::modulecomm_shm::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
  78. break;
  79. case ModuleComm_FASTRTPS:
  80. iv::modulecomm_fastrtps::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
  81. break;
  82. case ModuleComm_INTERIOR:
  83. iv::modulecomm_inter::ModuleSendMsg(pmi->mphandle,strdata,nDataLen);
  84. break;
  85. default:
  86. break;
  87. }
  88. }
  89. void Unregister(void * pHandle)
  90. {
  91. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  92. switch (pmi->mmctype) {
  93. case ModuleComm_SHAREMEM:
  94. iv::modulecomm_shm::Unregister(pmi->mphandle);
  95. break;
  96. case ModuleComm_FASTRTPS:
  97. iv::modulecomm_fastrtps::Unregister(pmi->mphandle);
  98. break;
  99. case ModuleComm_INTERIOR:
  100. iv::modulecomm_inter::Unregister(pmi->mphandle);
  101. break;
  102. default:
  103. break;
  104. }
  105. }
  106. void PauseComm(void *pHandle)
  107. {
  108. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  109. switch (pmi->mmctype) {
  110. case ModuleComm_SHAREMEM:
  111. iv::modulecomm_shm::PauseComm(pmi->mphandle);
  112. break;
  113. case ModuleComm_FASTRTPS:
  114. iv::modulecomm_fastrtps::PauseComm(pmi->mphandle);
  115. break;
  116. case ModuleComm_INTERIOR:
  117. iv::modulecomm_inter::PauseComm(pmi->mphandle);
  118. break;
  119. default:
  120. break;
  121. }
  122. }
  123. void ContintuComm(void *pHandle)
  124. {
  125. iv::modulecomm::ModeduleInfo * pmi = (iv::modulecomm::ModeduleInfo * )pHandle;
  126. switch (pmi->mmctype) {
  127. case ModuleComm_SHAREMEM:
  128. iv::modulecomm_shm::ContintuComm(pmi->mphandle);
  129. break;
  130. case ModuleComm_FASTRTPS:
  131. iv::modulecomm_fastrtps::ContintuComm(pmi->mphandle);
  132. break;
  133. case ModuleComm_INTERIOR:
  134. iv::modulecomm_inter::ContintuComm(pmi->mphandle);
  135. break;
  136. default:
  137. break;
  138. }
  139. }
  140. }
  141. }