中间件标准版5.1git,去除基础模块

DevLink.cpp 2.6KB

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