stc-broadcast.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. package broadcast
  2. import (
  3. "bytes"
  4. "context"
  5. "encoding/binary"
  6. "fmt"
  7. "io"
  8. "log"
  9. "net"
  10. "pbx-api-gin/internal/app/ami/action"
  11. "pbx-api-gin/internal/app/stc/active"
  12. msgdata "pbx-api-gin/internal/app/stc/data"
  13. "pbx-api-gin/internal/app/stc/priority"
  14. alstatus "pbx-api-gin/internal/app/stc/sendstatus"
  15. "pbx-api-gin/pkg/lfshook"
  16. "pbx-api-gin/pkg/utils"
  17. "strconv"
  18. "sync"
  19. "time"
  20. )
  21. var tagLog = 0
  22. func HandleStcCmd(ctx context.Context, conn net.Conn) {
  23. for {
  24. select {
  25. case <-ctx.Done():
  26. return
  27. default:
  28. var buf bytes.Buffer
  29. tmp := make([]byte, 1024)
  30. if conn != nil {
  31. n, err := conn.Read(tmp)
  32. if err != nil {
  33. if err != io.EOF {
  34. conn.Close()
  35. }
  36. return
  37. }
  38. buf.Write(tmp[:n])
  39. }
  40. /*for {
  41. packet, err := msgdata.ExtractPacket(&buf)
  42. if err != nil {
  43. lfshook.NewLogger().Logger.Infof("ExtractPacket:%+v", err)
  44. break
  45. }
  46. go processPacket(packet)
  47. }*/
  48. //lfshook.NewLogger().Logger.Infof("buf:%x==============================", buf.Bytes())
  49. for {
  50. packet, err := msgdata.ExtractPacket(&buf)
  51. if err != nil {
  52. log.Printf("parse error: %v, resetting buffer", err)
  53. buf.Reset() // 解析失败,清空避免污染
  54. break
  55. }
  56. if packet == nil {
  57. break // 当前无完整包,等待下次 ReadFrom
  58. }
  59. //处理 packet...
  60. go processPacket(packet)
  61. }
  62. }
  63. }
  64. }
  65. // get train info and pacu info from heartbeat
  66. func processHeartbeat(info []byte) {
  67. //dataCount := info[0]
  68. //Get train info
  69. value := binary.BigEndian.Uint16(info[2:4]) //info[2] + info[3]
  70. active.TrainNum = "TS" + strconv.Itoa(int(value))
  71. //lfshook.NewLogger().Logger.Infof("TrainNum: %s", active.TrainNum)
  72. //Get ICP volume
  73. icpBit8 := info[9] & 0xF
  74. icpBit1 := (info[9] >> 4) & 0xF
  75. active.DeviceEndpoint.ICPInfo[0].Volume = fmt.Sprintf("%d", icpBit1)
  76. active.DeviceEndpoint.ICPInfo[0].ID = "1"
  77. active.DeviceEndpoint.ICPInfo[1].Volume = fmt.Sprintf("%d", icpBit8)
  78. active.DeviceEndpoint.ICPInfo[1].ID = "8"
  79. //Get Pacu info
  80. eidsStat := info[1] //PACU mute
  81. pacuStat := info[4] //PACU status
  82. pacuVolume := binary.BigEndian.Uint32(info[5:9]) //info[5]-info[8]
  83. //lfshook.NewLogger().Logger.Infof("=eidsStat:%x=======pacuStat:%x=====", eidsStat, pacuStat)
  84. for i := 0; i < 8; i++ {
  85. eidsBit := (eidsStat >> i) & 0x01 // 右移 i 位,再与 1 取最低位
  86. //fmt.Printf("eidsBit bit %d = %d\n", i, eidsBit) // bit 0 是 LSB(最低位,最右)
  87. //get 1 bit every time
  88. pacuStatBit := (pacuStat >> i) & 0x01
  89. //fmt.Printf("pacuStatBit bit %d = %d\n", i, pacuStatBit)
  90. //get 4 bit every time
  91. var pacuVolBit int8
  92. pacuVolBit = int8((pacuVolume >> i) & 0xF)
  93. //fmt.Printf("pacuVolBit bit %d = %x\n", i, pacuVolBit)
  94. active.DeviceEndpoint.PacuInfo[i].ID = strconv.Itoa(i + 1)
  95. if eidsBit == 1 {
  96. active.DeviceEndpoint.PacuInfo[i].Mute = true
  97. } else {
  98. active.DeviceEndpoint.PacuInfo[i].Mute = false
  99. }
  100. if pacuStatBit == 0 {
  101. active.DeviceEndpoint.PacuInfo[i].Status = "normal"
  102. } else {
  103. active.DeviceEndpoint.PacuInfo[i].Status = "abnormal"
  104. }
  105. active.DeviceEndpoint.PacuInfo[i].Volume = strconv.Itoa(int(pacuVolBit))
  106. //lfshook.NewLogger().Logger.Infof("PACU INFO===ID:%s===Mute:%+v===Stat:%s===Vol:%s", active.DeviceEndpoint.PacuInfo[i].ID, active.DeviceEndpoint.PacuInfo[i].Mute, active.DeviceEndpoint.PacuInfo[i].Status, active.DeviceEndpoint.PacuInfo[i].Volume)
  107. }
  108. }
  109. // 处理单个数据包(原 switch 逻辑迁移过来)
  110. func processPacket(packet []byte) {
  111. if len(packet) < 6 {
  112. lfshook.NewLogger().Logger.Infof("Get data wrong length from STC !")
  113. return
  114. }
  115. //for recv data log debug
  116. if packet[5] != 0x03 && packet[5] != 0x0c && packet[5] != 0x01 {
  117. lfshook.NewLogger().Logger.Infof("Get data from STC:%x", packet)
  118. }
  119. //check if the cmd type is avtive
  120. if packet[5] == 0x03 { // ACTIVE
  121. Active([2]byte{packet[8], packet[9]})
  122. return
  123. }
  124. //check if Master role
  125. if !active.Master {
  126. if tagLog == 0 {
  127. lfshook.NewLogger().Logger.Infof("=========Not Master Role Ignore data !=============")
  128. tagLog = 1
  129. }
  130. return
  131. }
  132. tagLog = 0
  133. switch packet[5] {
  134. case 0x01: //heartbeat
  135. dataLen := binary.BigEndian.Uint16(packet[6:8])
  136. if dataLen == 10 {
  137. processHeartbeat(packet[8:])
  138. } else {
  139. //lfshook.NewLogger().Logger.Infof("=========Heartbeat data err !====len < 10=========")
  140. }
  141. case 0x02: // STN
  142. if active.ActivedCab != "" {
  143. if priority.CheckPriority("STN") {
  144. action.InterruptRunningTask("STN") //STN interrupt other
  145. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  146. StationAnn(packet)
  147. } else {
  148. alstatus.PaStatus("", "STN", "refuse")
  149. }
  150. }
  151. case 0x05: // SPC
  152. if active.ActivedCab != "" {
  153. if priority.CheckPriority("SPC") {
  154. action.InterruptRunningTask("SPC") //SPC interrupt other
  155. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  156. SpecialAnn(packet)
  157. } else {
  158. alstatus.PaStatus("", "SPC", "refuse")
  159. }
  160. }
  161. case 0x06: // EMG
  162. if active.ActivedCab != "" {
  163. if priority.CheckPriority("EMG") {
  164. action.InterruptRunningTask("EMG") //EMG interrupt other
  165. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  166. EmgMsg(packet)
  167. } else {
  168. alstatus.PaStatus("", "EMG", "refuse")
  169. }
  170. }
  171. case 0x07: // STOP
  172. AnnStop([4]byte{packet[8], packet[9], packet[10], packet[11]})
  173. case 0x08: // DCS
  174. if active.ActivedCab != "" {
  175. if priority.CheckPriority("DCS") {
  176. action.InterruptRunningTask("DCS") //DCS interrupt other
  177. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  178. DcsAnn(packet)
  179. } else {
  180. alstatus.PaStatus("", "DCS", "refuse")
  181. }
  182. }
  183. case 0x09: // SELF CHECK
  184. if active.ActivedCab != "" {
  185. if priority.CheckPriority("CHK") {
  186. action.InterruptRunningTask("CHK") //CHK interrupt other
  187. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  188. SelfCheck(packet)
  189. } else {
  190. alstatus.PaStatus("", "CHK", "refuse")
  191. }
  192. }
  193. case 0x0a: // Tone-test
  194. if active.ActivedCab != "" {
  195. if priority.CheckPriority("VOL") {
  196. action.InterruptRunningTask("VOL") //VOL interrupt other
  197. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  198. ToneTest(packet)
  199. } else {
  200. alstatus.PaStatus("", "VOL", "refuse")
  201. }
  202. }
  203. case 0x0e: //TMS answer PAD
  204. if priority.CheckPriority("PAD-TMS") {
  205. //Before Answer PAD
  206. if packet[8] == 0x01 {
  207. action.InterruptRunningTask("PAD-TMS") //PAD-ICP interrupt other
  208. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  209. }
  210. AlarmHandleTMS(packet)
  211. if active.QueueTimer != nil {
  212. if active.QueueTimer.Stop() {
  213. lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
  214. } else {
  215. lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
  216. }
  217. }
  218. } else {
  219. alstatus.PaStatus("", "PAD-TMS", "refuse")
  220. }
  221. case 0x0b: // reset all PAD
  222. AlarmHoldResetAll(packet[8]) // reset all pad
  223. case 0x0c: // Set PAD time oute
  224. PadTimeOutSetting(packet[8:]) // timeout setting
  225. case 0x0d: // ICP answer PAD
  226. if priority.CheckPriority("PAD-ICP") {
  227. //Before Answer PAD
  228. if packet[8] == 0x01 {
  229. action.InterruptRunningTask("PAD-ICP") //PAD-ICP interrupt other
  230. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  231. }
  232. if active.QueueTimer != nil {
  233. if active.QueueTimer.Stop() {
  234. lfshook.NewLogger().Logger.Infof("=========Release PAD timer true !============")
  235. } else {
  236. lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
  237. }
  238. }
  239. AlarmHandleICP(packet)
  240. } else {
  241. alstatus.PaStatus("", "PAD-ICP", "refuse")
  242. }
  243. case 0xf1: //Set remote master
  244. //default:
  245. //fmt.Printf("Unknown command: %x\n", packet[5])
  246. }
  247. }
  248. func PadTimeOutSetting(data []byte) {
  249. Seconds := data[7]
  250. if Seconds != 0 {
  251. active.PADTimeout = int(Seconds)
  252. //lfshook.NewLogger().Logger.Infof("=========Set PAD Timeout seconds to %d ! ============", active.PADTimeout)
  253. }
  254. }
  255. // STN , 自动报站广播
  256. func StationAnn(data []byte) (err error) {
  257. specialVoice := int(data[8])
  258. delay := data[9]
  259. cycleCount := data[10]
  260. datalen := int(data[11])
  261. filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
  262. //set spc voice tag
  263. priority.SpecialVoice = specialVoice
  264. action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "STN")
  265. return nil
  266. }
  267. // 激活信号
  268. func Active(data [2]byte) {
  269. //var info model.Sysinfo
  270. Signal := int(data[0])
  271. //check asterisk available
  272. if active.Master { // master true
  273. if !utils.CheckAsterisk() { //check asterisk not available and set master false
  274. active.Master = false
  275. utils.ExecCmd("/etc/init.d/asterisk", "stop", "PBX")
  276. }
  277. } else { // master false, check and start asterisk
  278. //Master == false
  279. if !utils.CheckAsterisk() {
  280. if active.CabNum == "8" {
  281. utils.ExecCmd("/etc/init.d/asterisk", "start", "PBX")
  282. }
  283. }
  284. //Master == false cab == 1
  285. if active.CabNum == "1" {
  286. if utils.CheckAsterisk() {
  287. utils.ExecCmd("/etc/init.d/asterisk", "stop", "PBX")
  288. }
  289. }
  290. }
  291. switch Signal {
  292. case 0:
  293. if active.ActivedCab != "" {
  294. active.ActivedCab = ""
  295. action.InActiveHangup()
  296. }
  297. case 1:
  298. //active signal from 8 to 1
  299. if active.ActivedCab == "8" || active.ActivedCab == "" {
  300. active.ActivedCab = "1"
  301. action.InActiveHangup()
  302. }
  303. case 8:
  304. //active signal from 1 to 8
  305. if active.ActivedCab == "1" || active.ActivedCab == "" {
  306. active.ActivedCab = "8"
  307. action.InActiveHangup()
  308. }
  309. }
  310. }
  311. // SPC ,特殊服务消息广播
  312. func SpecialAnn(data []byte) {
  313. delay := data[8]
  314. cycleCount := data[9]
  315. datalen := int(data[10])
  316. filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
  317. if int(cycleCount) == 255 {
  318. action.PlaybackPacu(strconv.Quote(filename), 9999999, int(delay), "SPC")
  319. } else {
  320. action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "SPC")
  321. }
  322. }
  323. // EMG ,紧急服务消息广播
  324. func EmgMsg(data []byte) {
  325. delay := data[8]
  326. cycleCount := data[9]
  327. datalen := int(data[10])
  328. filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
  329. if int(cycleCount) == 255 {
  330. action.PlaybackPacu(strconv.Quote(filename), 9999999, int(delay), "EMG")
  331. } else {
  332. action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "EMG")
  333. }
  334. }
  335. // 停止指定类型广播
  336. func AnnStop(data [4]byte) {
  337. //lfshook.NewLogger().Logger.Infof("=========AnnStop Type %x", data[0])
  338. switch data[0] {
  339. case 0x03:
  340. action.HangupTask("DCS") //STOP DCS
  341. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  342. case 0x04:
  343. action.HangupTask("EMG") //STOP EMG
  344. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  345. case 0x07:
  346. action.HangupTask("SPC") //STOP SPC
  347. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  348. case 0x08:
  349. action.HangupTask("STN") //STOP STN
  350. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  351. case 0x09:
  352. action.HangupTask("CHK") //STOP CHK
  353. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  354. case 0x0a:
  355. action.HangupTask("VOL") //STOP VOL
  356. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  357. default:
  358. action.InterruptRunningTask("")
  359. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  360. }
  361. }
  362. // DCS 语音
  363. func DcsAnn(data []byte) {
  364. delay := data[8]
  365. cycleCount := data[9]
  366. datalen := int(data[10])
  367. filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
  368. if int(cycleCount) == 255 {
  369. action.PlaybackPacu(strconv.Quote(filename), 9999999, int(delay), "DCS")
  370. } else {
  371. action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "DCS")
  372. }
  373. }
  374. // tone-test广播
  375. func ToneTest(data []byte) {
  376. check := data[8]
  377. delay := data[9]
  378. cycleCount := data[10]
  379. datalen := int(data[11])
  380. filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
  381. switch check {
  382. case 0x01: //start
  383. action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "VOL")
  384. case 0x02: //stop
  385. action.HangupAllExcept("")
  386. }
  387. }
  388. // 自检广播
  389. func SelfCheck(data []byte) {
  390. check := data[8]
  391. delay := data[9]
  392. cycleCount := data[10]
  393. //cycleCount := 0x32
  394. datalen := int(data[11])
  395. filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
  396. switch check {
  397. case 0x01: //start
  398. action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "CHK")
  399. case 0x02: //stop
  400. action.HangupAllExcept("")
  401. }
  402. }
  403. // 全局变量:记录正在抑制的 exten
  404. var (
  405. suppressedExts = sync.Map{} // map[string]struct{},值存在即表示被抑制
  406. //suppressionMu sync.Mutex // 保护初始化和清理操作(可选)
  407. )
  408. // suppressKey 生成用于抑制的 key(可以根据需求扩展)
  409. func suppressKey(exten string, handler byte) string {
  410. return fmt.Sprintf("%s_h%x", exten, handler)
  411. }
  412. // ICP操作乘客报警(根据激活信息判断转到1车还是8车================)
  413. func AlarmHandleICP(data []byte) {
  414. handler := data[8]
  415. carr := data[12]
  416. pos := data[13]
  417. exten := fmt.Sprintf("24%c%c", carr, pos)
  418. key := suppressKey(exten, handler)
  419. //Drop other handler in 2 sec
  420. //PACUs---call---->ICP1
  421. //PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
  422. if handler == 0x01 {
  423. if _, loaded := suppressedExts.LoadOrStore(key, struct{}{}); loaded {
  424. lfshook.NewLogger().Logger.Infof("Suppressed duplicate ICP Alarm (handler=0x01) for exten: %s within 4 seconds", exten)
  425. return
  426. }
  427. time.AfterFunc(4*time.Second, func() {
  428. suppressedExts.Delete(key)
  429. lfshook.NewLogger().Logger.Debugf("Suppression released for key: %s", key)
  430. })
  431. }
  432. switch handler {
  433. case 0x01: //answer(ICP+Alarm+PACU)
  434. //NotifyPaiu(exten, "answer")
  435. priority.ICPAnswer = 1
  436. if priority.PADStart == 0 {
  437. alstatus.PaStatus("", "PAD", "start")
  438. priority.PADStart = 1
  439. }
  440. lfshook.NewLogger().Logger.Infof("================ ICP Answer PAD ================:%s ", exten)
  441. if active.ActivedCab == "1" {
  442. action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
  443. //goto ami event ConfbridgeJoin, ICP answer PAD
  444. } else if active.ActivedCab == "8" {
  445. action.Dial("0402", "0511", "pad-rule-pacus", "ani8", exten, "8") // PACUs dial ICP8
  446. //goto ami event ConfbridgeJoin, ICP answer PAD
  447. } else if active.ActivedCab == "" { // No cab occupied
  448. action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
  449. }
  450. case 0x02: //hold 重新放回队列里面
  451. active.NotifyPaiu(exten, "hold")
  452. err := action.RedirectInQueue(exten, "0300", "queues-icp-redirect", "1")
  453. if err != nil {
  454. lfshook.NewLogger().Info(err)
  455. }
  456. action.InterruptRunningTask("")
  457. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  458. //action.HangupICP()
  459. case 0x03: //hangup
  460. //NotifyPaiu(exten, "hangup")
  461. lfshook.NewLogger().Logger.Infof("============ Hangup PAD-ICP =============== ")
  462. action.Hangup(exten) //Pad
  463. //action.HangupICP()
  464. action.HangupTask("PAD-ICP")
  465. }
  466. }
  467. // TMS操作乘客报警(根据激活信息判断转到1车还是8车================)
  468. func AlarmHandleTMS(data []byte) {
  469. handler := data[8]
  470. //extlen := data[9]
  471. carr := data[12]
  472. pos := data[13]
  473. exten := fmt.Sprintf("24%c%c", carr, pos)
  474. PacuNum := fmt.Sprintf("21%c%c", carr, pos)
  475. key := suppressKey(exten, handler)
  476. //Drop other handler in 2 sec
  477. // 只对 handler == 0x01 做 2 秒去重
  478. if handler == 0x01 {
  479. if _, loaded := suppressedExts.LoadOrStore(key, struct{}{}); loaded {
  480. lfshook.NewLogger().Logger.Infof("Suppressed duplicate ICP Alarm (handler=0x01) for exten: %s within 4 seconds", exten)
  481. return // 已存在,说明在2秒窗口期内,直接丢弃
  482. }
  483. // 设置4秒后删除该 key,允许下次通过
  484. time.AfterFunc(4*time.Second, func() {
  485. suppressedExts.Delete(key)
  486. lfshook.NewLogger().Logger.Debugf("Suppression released for key: %s", key)
  487. })
  488. }
  489. switch handler {
  490. case 0x01: //answer(ICP+Alarm+PACU)
  491. //PACU---call---->ICP1
  492. //PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
  493. if priority.PADStart == 0 {
  494. alstatus.PaStatus("", "PAD", "start")
  495. priority.PADStart = 1
  496. }
  497. priority.ICPAnswer = 1
  498. lfshook.NewLogger().Logger.Infof("==============TMS Answer PAD Exten:%s PACU:%s==========", exten, PacuNum)
  499. if action.ExtenStatus(PacuNum) == "Idle" {
  500. if active.ActivedCab == "1" {
  501. action.Dial("0403", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP1
  502. //goto ami event BridgeEnter, ICP8 whisper ICP1
  503. } else if active.ActivedCab == "8" {
  504. action.Dial("0403", PacuNum, "default", PacuNum, exten, "8") // PACU dial ICP8
  505. //goto ami event BridgeEnter, ICP1 whisper ICP8
  506. } else if active.ActivedCab == "" { // No cab occupied
  507. action.Dial("0403", PacuNum, "default", PacuNum, exten, "1") // PACU dial ICP1
  508. }
  509. } else {
  510. action.RedirectInQueue(exten, "0405", "default", exten) // PAD dial ICPs
  511. }
  512. case 0x02: //hold 重新放回队列里面
  513. active.NotifyPaiu(exten, "hold")
  514. err := action.RedirectInQueue(exten, "0300", "queues-icp-redirect", "1")
  515. if err != nil {
  516. lfshook.NewLogger().Info(err)
  517. }
  518. action.HangupAllLocalChan()
  519. case 0x03: //hangup
  520. //NotifyPaiu(exten, "hangup")
  521. action.Hangup(exten) //Pad
  522. action.HangupTask("PAD-TMS")
  523. //action.HangupTask("PAD-ICP")
  524. }
  525. }
  526. // 挂断所有报警器
  527. func AlarmHoldResetAll(handler byte) {
  528. //hangup all actived PAD
  529. action.HangupAllPAD()
  530. //hangup running task
  531. action.InterruptRunningTask("AlarmHoldResetAll") //Reset PAD ALL
  532. time.Sleep(time.Millisecond * 100) //wait endpoimt release
  533. }