中间件底层,websocket

TaskIvrPlayVoice.cpp 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include "stdafx.h"
  2. #include "TaskIvrPlayVoice.h"
  3. #include "LineHolder.h"
  4. #include "LogicLine.h"
  5. #include "SessionHolder.h"
  6. #include "CallSession.h"
  7. #include "CtiCore.h"
  8. CTaskIvrPlayVoice::CTaskIvrPlayVoice(CPduEntity &PduEntity): CTask(PduEntity)
  9. {
  10. }
  11. CTaskIvrPlayVoice::~CTaskIvrPlayVoice(void)
  12. {
  13. }
  14. /*****************************************************************
  15. **【函数名称】 DoTask
  16. **【函数功能】 Task处理
  17. **【参数】
  18. **【返回值】 void
  19. ****************************************************************/
  20. BOOL CTaskIvrPlayVoice::DoTask()
  21. {
  22. // 显示日志
  23. ShowLog();
  24. // 校验
  25. if(!Verify()) return FALSE;
  26. // 设置当前操作类型
  27. if (m_pCurrLine == NULL)return FALSE;
  28. m_pCurrLine->opType() = PDU_CMD_IVR_PLAY_DTMF;
  29. UINT t_lineId = m_pCurrLine->lineId();
  30. // 向底层设备发送放音收号命令
  31. LineOpParam pLineOpParam;
  32. memset(&pLineOpParam,0,sizeof(pLineOpParam));
  33. pLineOpParam.nParam1 = m_CurrCmd.GetDataInt(4); // 放音收号模式,1:放音收号,2:只放音,3:只收号
  34. pLineOpParam.nParam2 = m_CurrCmd.GetDataInt(5); // 放音内容类型
  35. pLineOpParam.nParam3 = m_CurrCmd.GetDataInt(6); // 数字播报模式
  36. pLineOpParam.nParam4 = m_CurrCmd.GetDataInt(7); // 引擎音库
  37. pLineOpParam.nParam5 = m_CurrCmd.GetDataInt(8); // 语速
  38. pLineOpParam.nParam6 = m_CurrCmd.GetDataInt(9); // 音量
  39. pLineOpParam.nParam7 = m_CurrCmd.GetDataInt(10); // 收号位数
  40. pLineOpParam.nParam8 = m_CurrCmd.GetDataInt(12); // 收号时间间隔
  41. pLineOpParam.nParam9 = m_CurrCmd.GetDataInt(13); // 收号时是否放音
  42. pLineOpParam.nParam10 = m_CurrCmd.GetDataInt(18) <= 0 ? 1 : m_CurrCmd.GetDataInt(18); //放音收号时播放次数 2023 - 03 - 15
  43. lstrcpy(pLineOpParam.szParam1, m_CurrCmd.GetDataString(11)); // 结束标识
  44. lstrcpy(pLineOpParam.szParam3, m_CurrCmd.GetDataString(15)); // 放音内容
  45. return CCtiCore::GetInstance().getDevLink().exec((long)this, LINE_OP_PLAY_VOICE, t_lineId, &pLineOpParam);
  46. }
  47. /*****************************************************************
  48. **【函数名称】 Verify
  49. **【函数功能】 校验
  50. **【参数】
  51. **【返回值】 BOOL
  52. ****************************************************************/
  53. BOOL CTaskIvrPlayVoice::Verify()
  54. {
  55. // 线路绑定校验
  56. if(!_bindLogicLine(m_CurrCmd.GetDataUInt(3)))
  57. return FALSE;
  58. // 放音内容校验
  59. if(m_CurrCmd.GetDataInt(4) != PVM_WAIT_DIGIT && m_CurrCmd.GetDataString(15) == "")
  60. {
  61. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_WARNING, _T("{Task}: 线路[%d]执行IVR放音收号任务校验时失败:放音内容为空"), m_pCurrLine->lineId());
  62. return FALSE;
  63. }
  64. return TRUE;
  65. }
  66. /*****************************************************************
  67. **【函数名称】 ShowLog
  68. **【函数功能】 显示日志
  69. **【参数】
  70. **【返回值】 void
  71. ****************************************************************/
  72. void CTaskIvrPlayVoice::ShowLog()
  73. {
  74. // 显示日志
  75. ILogger::getInstance().log(LOG_CLASS_SOCKET, LOG_LEVEL_NORMAL,
  76. _T("IVR->CTI, CMD = [IVR放音收号],IVR = %d, Line = %u, FileName = %s"),
  77. m_CurrCmd.GetDataInt(1),
  78. m_CurrCmd.GetDataUInt(3),
  79. m_CurrCmd.GetDataString(15));
  80. }
  81. /*****************************************************************
  82. **【函数名称】 ProcTaskResult
  83. **【函数功能】 处理Pdu命令返回
  84. **【参数】 成功还是失败
  85. **【返回值】 void
  86. ****************************************************************/
  87. BOOL CTaskIvrPlayVoice::OnDevOpResult(EventOpResult &EvtInfo)
  88. {
  89. // 设置按键数据
  90. m_CurrCmd.SetDataString(16, EvtInfo.szData);
  91. // 命令返回
  92. _ProcCmdReturn(EvtInfo.bIsSucceed, true);
  93. return TRUE;
  94. }