中间件底层,websocket

DevLink.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #include "StdAfx.h"
  2. #include "DevLink.h"
  3. #include "MsgCenter.h"
  4. #include "LineHolder.h"
  5. #include "LogicLine.h"
  6. CDevLink::CDevLink(void) : m_pDevLink(NULL), m_LineExtNum(0), m_LineTrunkNum(0), m_FaxNum(0), m_VoipNum(0)
  7. {
  8. }
  9. CDevLink::~CDevLink(void)
  10. {
  11. }
  12. /*****************************************************************
  13. **【函数名称】 __onDevResourceDetail
  14. **【函数功能】 设备资源明细通知事件的处理函数
  15. **【参数】 pERD:事件内容
  16. **【返回值】
  17. ****************************************************************/
  18. void CDevLink::__onDevResourceDetail( EventResDetail* pERD )
  19. {
  20. ASSERT(pERD != NULL);
  21. switch(pERD->nResType)
  22. {
  23. case DEV_RES_TYPE_EXT: // 内线分机
  24. {
  25. UINT nExt = pERD->nResID;
  26. if (nExt & DEL_EXT_DETAIL)
  27. {
  28. m_LineExtNum--;
  29. }
  30. else
  31. {
  32. m_LineExtNum++;
  33. }
  34. }
  35. break;
  36. case DEV_RES_TYPE_TRUNK: // 外线
  37. {
  38. m_LineTrunkNum++;
  39. }
  40. break;
  41. case DEV_RES_TYPE_FAX:
  42. {
  43. m_FaxNum++; // 传真个数
  44. }
  45. break;
  46. case DEV_RES_TYPE_VOIP:
  47. {
  48. m_VoipNum++; // VOIP个数
  49. }
  50. break;
  51. default: // 未知线路类型
  52. break;
  53. } // end switch
  54. }
  55. /*****************************************************************
  56. **【函数名称】 onDeviceEvent
  57. **【函数功能】 设备事件的处理函数
  58. **【参数】 EvtType:事件类型
  59. Content:事件内容
  60. **【返回值】
  61. ****************************************************************/
  62. void CDevLink::onDeviceEvent( UINT EvtType, PARAM Content )
  63. {
  64. if(EvtType == DEV_EVENT_RES_DETAIL)
  65. __onDevResourceDetail((EventResDetail*)Content);
  66. CMsgCenter::GetInstance().pushMsg(EvtType, Content);
  67. }
  68. /*****************************************************************
  69. **【函数名称】 open
  70. **【函数功能】 打开与设备的连接
  71. **【参数】
  72. **【返回值】 成功true,失败false
  73. ****************************************************************/
  74. bool CDevLink::open( void )
  75. {
  76. IDeviceLink* pDevLink = &IDeviceLink::getInstance();
  77. if(pDevLink->open(this))
  78. {
  79. m_pDevLink = pDevLink;
  80. return true;
  81. }
  82. else return false;
  83. }
  84. /*****************************************************************
  85. **【函数名称】 close
  86. **【函数功能】 关闭与设备的连接
  87. **【参数】
  88. **【返回值】
  89. ****************************************************************/
  90. void CDevLink::close( void )
  91. {
  92. if(m_pDevLink != NULL)
  93. {
  94. m_pDevLink->close();
  95. m_pDevLink = NULL;
  96. }
  97. }
  98. /*****************************************************************
  99. **【函数名称】 exec
  100. **【函数功能】 设备控制接口
  101. **【参数】
  102. **【返回值】 成功true,失败false
  103. ****************************************************************/
  104. bool CDevLink::exec( LONG Instance, LINE_OP OpType, ULONG ResID, LineOpParam* pLineOpParam )
  105. {
  106. return m_pDevLink->operate(Instance, OpType, ResID, pLineOpParam);
  107. }
  108. BOOL CDevLink::IsRegExten(UINT ExtenID)
  109. {
  110. CLogicLine* pExtn = CLineHolder::GetInstance().getLogicLine(ExtenID);
  111. if (pExtn != NULL && pExtn->type() == DEV_RES_TYPE_EXT)
  112. {
  113. return TRUE;
  114. }
  115. return FALSE;
  116. }