|
@@ -3,21 +3,16 @@ package broadcast
|
|
|
import (
|
|
import (
|
|
|
"bytes"
|
|
"bytes"
|
|
|
"context"
|
|
"context"
|
|
|
- "encoding/binary"
|
|
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"io"
|
|
"io"
|
|
|
"net"
|
|
"net"
|
|
|
- "os/exec"
|
|
|
|
|
"pbx-api-gin/internal/app/ami/action"
|
|
"pbx-api-gin/internal/app/ami/action"
|
|
|
"pbx-api-gin/internal/app/stc/active"
|
|
"pbx-api-gin/internal/app/stc/active"
|
|
|
msgdata "pbx-api-gin/internal/app/stc/data"
|
|
msgdata "pbx-api-gin/internal/app/stc/data"
|
|
|
"pbx-api-gin/internal/app/stc/priority"
|
|
"pbx-api-gin/internal/app/stc/priority"
|
|
|
alstatus "pbx-api-gin/internal/app/stc/sendstatus"
|
|
alstatus "pbx-api-gin/internal/app/stc/sendstatus"
|
|
|
- "pbx-api-gin/pkg/lfshook"
|
|
|
|
|
"pbx-api-gin/pkg/utils"
|
|
"pbx-api-gin/pkg/utils"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
- "sync"
|
|
|
|
|
- "syscall"
|
|
|
|
|
"time"
|
|
"time"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -63,80 +58,6 @@ func HandleStcCmd(ctx context.Context, conn net.Conn) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// get train info and pacu info from heartbeat
|
|
|
|
|
-func getInfofromSTC(info []byte) {
|
|
|
|
|
- //dataCount := info[0]
|
|
|
|
|
- //Get train info
|
|
|
|
|
- value := binary.BigEndian.Uint16(info[2:4]) //info[2] + info[3] 列车号数据
|
|
|
|
|
- //value := 3
|
|
|
|
|
- active.TrainNum = "TS" + strconv.Itoa(int(value))
|
|
|
|
|
-
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("TrainNum: %s", active.TrainNum)
|
|
|
|
|
-
|
|
|
|
|
- //Get ICP volume
|
|
|
|
|
- icpBit8 := info[9] & 0xF
|
|
|
|
|
- icpBit1 := (info[9] >> 4) & 0xF
|
|
|
|
|
- icpVol1 := 0
|
|
|
|
|
- icpVol8 := 0
|
|
|
|
|
-
|
|
|
|
|
- if icpBit1 == 0xe {
|
|
|
|
|
- icpVol1 = 100
|
|
|
|
|
- } else {
|
|
|
|
|
- icpVol1 = int(icpBit1) * 7
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if icpBit8 == 0xe {
|
|
|
|
|
- icpVol8 = 100
|
|
|
|
|
- } else {
|
|
|
|
|
- icpVol8 = int(icpBit8) * 7
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- active.DeviceEndpoint.ICPInfo[0].Volume = fmt.Sprintf("%d", icpVol1)
|
|
|
|
|
- active.DeviceEndpoint.ICPInfo[0].ID = "1"
|
|
|
|
|
- active.DeviceEndpoint.ICPInfo[1].Volume = fmt.Sprintf("%d", icpVol8)
|
|
|
|
|
- active.DeviceEndpoint.ICPInfo[1].ID = "8"
|
|
|
|
|
-
|
|
|
|
|
- //Get Pacu info
|
|
|
|
|
- eidsStat := info[1] //PACU mute
|
|
|
|
|
- pacuStat := info[4] //PACU status
|
|
|
|
|
-
|
|
|
|
|
- pacuVolume := binary.BigEndian.Uint32(info[5:9]) //info[5]-info[8]
|
|
|
|
|
-
|
|
|
|
|
- //lfshook.NewLogger().Logger.Infof("=====pacuVolume====info[5:9]=======%x", info[5:9])
|
|
|
|
|
- //lfshook.NewLogger().Logger.Infof("=====pacuStatus====info[4]=======%x", info[4])
|
|
|
|
|
- for i := 0; i < 8; i++ {
|
|
|
|
|
- eidsBit := (eidsStat >> i) & 0x01 // 右移 i 位,再与 1 取最低位
|
|
|
|
|
- //fmt.Printf("eidsBit bit %d = %d\n", i, eidsBit) // bit 0 是 LSB(最低位,最右)
|
|
|
|
|
-
|
|
|
|
|
- //get 1 bit every time
|
|
|
|
|
- pacuStatBit := (pacuStat >> i) & 0x01
|
|
|
|
|
- //fmt.Printf("pacuStatBit bit %d = %d\n", i, pacuStatBit)
|
|
|
|
|
-
|
|
|
|
|
- //get 4 bit every time
|
|
|
|
|
- //var pacuVolBit byte
|
|
|
|
|
- pacuVolBit := (pacuVolume >> (i * 4)) & 0x0000000F
|
|
|
|
|
- //fmt.Printf("pacuVolBit bit %d = %x\n", i, pacuVolBit)
|
|
|
|
|
-
|
|
|
|
|
- active.DeviceEndpoint.PacuInfo[i].ID = strconv.Itoa(i + 1)
|
|
|
|
|
- if eidsBit == 1 {
|
|
|
|
|
- active.DeviceEndpoint.PacuInfo[i].Mute = true
|
|
|
|
|
- } else {
|
|
|
|
|
- active.DeviceEndpoint.PacuInfo[i].Mute = false
|
|
|
|
|
- }
|
|
|
|
|
- if pacuStatBit == 0 {
|
|
|
|
|
- active.DeviceEndpoint.PacuInfo[i].Status = "normal"
|
|
|
|
|
- } else {
|
|
|
|
|
- active.DeviceEndpoint.PacuInfo[i].Status = "abnormal"
|
|
|
|
|
- }
|
|
|
|
|
- if int(pacuVolBit) == 14 {
|
|
|
|
|
- active.DeviceEndpoint.PacuInfo[i].Volume = "100"
|
|
|
|
|
- } else {
|
|
|
|
|
- active.DeviceEndpoint.PacuInfo[i].Volume = strconv.Itoa(int(pacuVolBit) * 7)
|
|
|
|
|
- }
|
|
|
|
|
- //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)
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// 处理单个数据包(原 switch 逻辑迁移过来)
|
|
// 处理单个数据包(原 switch 逻辑迁移过来)
|
|
|
func processPacket(packet []byte) {
|
|
func processPacket(packet []byte) {
|
|
|
|
|
|
|
@@ -146,14 +67,53 @@ func processPacket(packet []byte) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//for recv data log debug
|
|
//for recv data log debug
|
|
|
- if packet[5] != 0x03 && packet[5] != 0x0c && packet[5] != 0x01 {
|
|
|
|
|
|
|
+ if packet[5] != 0x0b && packet[5] != 0x09 {
|
|
|
utils.LoggerDebug.Printf("Get data from STC:%x", packet)
|
|
utils.LoggerDebug.Printf("Get data from STC:%x", packet)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //check if the cmd type is avtive
|
|
|
|
|
- if packet[5] == 0x03 { // ACTIVE
|
|
|
|
|
- Active([3]byte{packet[8], packet[9], packet[10]})
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ //重联模式判断
|
|
|
|
|
+ if packet[5] == 0x0b {
|
|
|
|
|
+ active.TrainUnionID = int(packet[8])
|
|
|
|
|
+ active.TrainUnionMaster = int(packet[9])
|
|
|
|
|
+ active.TrainUnionMode = int(packet[10])
|
|
|
|
|
+
|
|
|
|
|
+ if active.TrainUnionID != 0 {
|
|
|
|
|
+ utils.LoggerDebug.Printf("active.TrainUnionID:%x active.TrainUnionMaster:%x active.TrainUnionMode:%x ", active.TrainUnionID, active.TrainUnionMaster, active.TrainUnionMode)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if active.TrainUnionMode == 1 && active.TrainUnionMaster == 1 { //尾--头,重联主车,6车服务器停用
|
|
|
|
|
+ if active.CabNum == "6" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if active.TrainUnionMode == 1 && active.TrainUnionMaster == 2 { //尾--头,重联从车,1车服务器停用
|
|
|
|
|
+ if active.CabNum == "1" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if active.TrainUnionMode == 2 && active.TrainUnionMaster == 1 { //尾--尾,重联主车,6车服务器停用
|
|
|
|
|
+ if active.CabNum == "6" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if active.TrainUnionMode == 2 && active.TrainUnionMaster == 2 { //尾--尾,重联从车,6车服务器停用
|
|
|
|
|
+ if active.CabNum == "6" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if active.TrainUnionMode == 3 && active.TrainUnionMaster == 1 { //头--头,重联主车,1车服务器停用
|
|
|
|
|
+ if active.CabNum == "1" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if active.TrainUnionMode == 3 && active.TrainUnionMaster == 2 { //头--头,重联从车,1车服务器停用
|
|
|
|
|
+ if active.CabNum == "1" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if active.TrainUnionMode == 4 && active.TrainUnionMaster == 1 { //头--尾,重联主车,1车服务器停用
|
|
|
|
|
+ if active.CabNum == "1" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if active.TrainUnionMode == 4 && active.TrainUnionMaster == 2 { //头--尾,重联从车,6车服务器停用
|
|
|
|
|
+ if active.CabNum == "6" {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//check if Master role
|
|
//check if Master role
|
|
@@ -167,499 +127,116 @@ func processPacket(packet []byte) {
|
|
|
tagLog = 0
|
|
tagLog = 0
|
|
|
|
|
|
|
|
switch packet[5] {
|
|
switch packet[5] {
|
|
|
- case 0x01: //heartbeat
|
|
|
|
|
|
|
+ case 0x01: //心跳
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
- case 0x02: // STN
|
|
|
|
|
- if active.ActivedCab != "" {
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("STN")
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("STN") {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("STN") //STN interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- StationAnn(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "STN" {
|
|
|
|
|
- utils.LoggerDebug.Printf("STN : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "STN", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "STN" {
|
|
|
|
|
- utils.LoggerDebug.Printf("STN : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- case 0x05: // SPC
|
|
|
|
|
- if active.ActivedCab != "" {
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("SPC")
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("SPC") {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("SPC") //SPC interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- SpecialAnn(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "SPC" {
|
|
|
|
|
- utils.LoggerDebug.Printf("SPC : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "SPC", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ case 0x02: // 自动报站
|
|
|
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "SPC" {
|
|
|
|
|
- utils.LoggerDebug.Printf("SPC : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
|
|
+ if priority.CheckPriority("STNA") {
|
|
|
|
|
+ action.HangupTask()
|
|
|
|
|
+ StationAnnAuto(packet[8:])
|
|
|
|
|
+ } else {
|
|
|
|
|
+ alstatus.PaStatus("", "STNA", "refuse")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- case 0x06: // EMG
|
|
|
|
|
-
|
|
|
|
|
- if active.ActivedCab != "" {
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("EMG")
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("EMG") {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("EMG") //EMG interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- EmgMsg(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "EMG" {
|
|
|
|
|
- utils.LoggerDebug.Printf("EMG : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "EMG", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ case 0x03: // 手动报站
|
|
|
|
|
+ if priority.CheckPriority("STNS") {
|
|
|
|
|
+ action.HangupTask()
|
|
|
|
|
+ StationAnnAuto(packet[8:])
|
|
|
|
|
+ } else {
|
|
|
|
|
+ alstatus.PaStatus("", "STNS", "refuse")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "EMG" {
|
|
|
|
|
- utils.LoggerDebug.Printf("EMG : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
|
|
+ case 0x04: // 手动服务消息、紧急广播
|
|
|
|
|
+ if priority.CheckPriority("SVM") {
|
|
|
|
|
+ action.HangupTask()
|
|
|
|
|
+ EmgMsg(packet[8:])
|
|
|
|
|
+ } else {
|
|
|
|
|
+ alstatus.PaStatus("", "SVM", "refuse")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- case 0x07: // STOP
|
|
|
|
|
|
|
+ case 0x05: // STOP
|
|
|
AnnStop([4]byte{packet[8], packet[9], packet[10], packet[11]})
|
|
AnnStop([4]byte{packet[8], packet[9], packet[10], packet[11]})
|
|
|
|
|
|
|
|
- case 0x08: // DCS
|
|
|
|
|
-
|
|
|
|
|
- if active.ActivedCab != "" {
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("DCS")
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("DCS") {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("DCS") //DCS interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- DcsAnn(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "DCS" {
|
|
|
|
|
- utils.LoggerDebug.Printf("DCS : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "DCS", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "DCS" {
|
|
|
|
|
- utils.LoggerDebug.Printf("DCS : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- case 0x09: // SELF CHECK
|
|
|
|
|
-
|
|
|
|
|
- if active.ActivedCab != "" {
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("CHK")
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("CHK") {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("CHK") //CHK interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- SelfCheck(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "CHK" {
|
|
|
|
|
- utils.LoggerDebug.Printf("CHK : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "CHK", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "CHK" {
|
|
|
|
|
- utils.LoggerDebug.Printf("CHK : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- case 0x0a: // Tone-test
|
|
|
|
|
- if active.ActivedCab != "" {
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("VOL")
|
|
|
|
|
-
|
|
|
|
|
- if priority.CheckPriority("VOL") {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("VOL") //VOL interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- ToneTest(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "VOL" {
|
|
|
|
|
- utils.LoggerDebug.Printf("VOL : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "VOL", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "VOL" {
|
|
|
|
|
- utils.LoggerDebug.Printf("VOL : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- case 0x0e: //TMS answer PAD
|
|
|
|
|
-
|
|
|
|
|
- handler := packet[8]
|
|
|
|
|
-
|
|
|
|
|
- //Drop other handler in 2 sec
|
|
|
|
|
- //PACUs---call---->ICP1
|
|
|
|
|
- //PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
|
|
|
|
|
- if handler == 0x01 { //answer PAD
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("PAD-TMS")
|
|
|
|
|
-
|
|
|
|
|
- //if packet[8] == 0x01 { //answer PAD
|
|
|
|
|
- if priority.CheckPriority("PAD-TMS") {
|
|
|
|
|
-
|
|
|
|
|
- //Before Answer PAD
|
|
|
|
|
- //if packet[8] == 0x01 {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("PAD-TMS") //PAD-TMS interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- //}
|
|
|
|
|
-
|
|
|
|
|
- if active.QueueTimer != nil {
|
|
|
|
|
- if active.QueueTimer.Stop() {
|
|
|
|
|
- utils.LoggerDebug.Printf("Stop PAD timer true !")
|
|
|
|
|
- } else {
|
|
|
|
|
- utils.LoggerDebug.Printf("Stop PAD timer false !")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- AlarmHandleTMS(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "PAD-TMS" {
|
|
|
|
|
- utils.LoggerDebug.Printf("PAD-TMS : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "PAD-TMS", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
- } else { //hangup + hold
|
|
|
|
|
- AlarmHandleTMS(packet)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "PAD-TMS" {
|
|
|
|
|
- utils.LoggerDebug.Printf("PAD-TMS : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- case 0x0b: // reset all PAD
|
|
|
|
|
- AlarmHoldResetAll(packet[8]) // reset all pad
|
|
|
|
|
-
|
|
|
|
|
- case 0x0c: // Set PAD timeout
|
|
|
|
|
- //lfshook.NewLogger().Logger.Infof("==type PADTimeout 0x0c===Get data from STC ====%x", packet)
|
|
|
|
|
- PadTimeOutSetting(packet[8:]) // timeout setting
|
|
|
|
|
-
|
|
|
|
|
- getInfofromSTC(packet[8:])
|
|
|
|
|
|
|
+ //case 0x06: // 关门提示(预留)
|
|
|
|
|
+ //DoorStatusNotice(packet[8:])
|
|
|
|
|
+ //case 0x07: // 司机室位置(预留)
|
|
|
|
|
|
|
|
- case 0x0d: // ICP answer PAD
|
|
|
|
|
|
|
+ case 0x08: // EED报警
|
|
|
|
|
+ EEDAlarm(packet[8:])
|
|
|
|
|
+ //case 0x09: // 列车运行模式(预留)
|
|
|
|
|
+ // RuningStatus(packet[8:])
|
|
|
|
|
|
|
|
- handler := packet[8]
|
|
|
|
|
|
|
+ //case 0x0a:(预留)
|
|
|
|
|
|
|
|
- //Drop other handler in 2 sec
|
|
|
|
|
- //PACUs---call---->ICP1
|
|
|
|
|
- //PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
|
|
|
|
|
- if handler == 0x01 {
|
|
|
|
|
-
|
|
|
|
|
- //检查是否有任务正在创建
|
|
|
|
|
- action.WaitTaskCreate("PAD-ICP")
|
|
|
|
|
-
|
|
|
|
|
- //if packet[8] == 0x01 { //answer PAD
|
|
|
|
|
- if priority.CheckPriority("PAD-ICP") {
|
|
|
|
|
-
|
|
|
|
|
- //Before Answer PAD
|
|
|
|
|
- //if packet[8] == 0x01 {
|
|
|
|
|
-
|
|
|
|
|
- runningTaskName := action.InterruptRunningTask("PAD-ICP") //PAD-ICP interrupt other
|
|
|
|
|
- if runningTaskName != "" {
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
- //}
|
|
|
|
|
-
|
|
|
|
|
- if active.QueueTimer != nil {
|
|
|
|
|
- utils.LoggerDebug.Printf("PAD Timeout timer != nil !")
|
|
|
|
|
- if active.QueueTimer.Stop() {
|
|
|
|
|
- utils.LoggerDebug.Printf("Stop PAD timer true !")
|
|
|
|
|
- } else {
|
|
|
|
|
- utils.LoggerDebug.Printf("Stop PAD timer false !")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- AlarmHandleICP(packet)
|
|
|
|
|
- } else {
|
|
|
|
|
- if priority.TaskCreating == "PAD-ICP" {
|
|
|
|
|
- utils.LoggerDebug.Printf("PAD-ICP : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
- alstatus.PaStatus("", "PAD-ICP", "refuse")
|
|
|
|
|
- }
|
|
|
|
|
- } else { //hangup + hold
|
|
|
|
|
- AlarmHandleICP(packet)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
|
|
- if priority.TaskCreating == "PAD-ICP" {
|
|
|
|
|
- utils.LoggerDebug.Printf("PAD-ICP : Clean priority.TaskCreating = '' !")
|
|
|
|
|
- priority.TaskCreating = ""
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /*case 0x11: //Set remote master
|
|
|
|
|
- if packet[8] == 1 {
|
|
|
|
|
- utils.LoggerDebug.Printf("TMS respond, Stop PAD timeout %d sec .", active.PADTimeout)
|
|
|
|
|
- if active.QueueTimer != nil {
|
|
|
|
|
- if active.QueueTimer.Stop() {
|
|
|
|
|
- utils.LoggerDebug.Printf("Stop PAD timer true !")
|
|
|
|
|
- } else {
|
|
|
|
|
- utils.LoggerDebug.Printf("Stop PAD timer false !")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- utils.LoggerDebug.Printf("TMS respond canceled, set PAD timeout %d sec .", active.PADTimeout)
|
|
|
|
|
- active.QueueTimer = time.AfterFunc(time.Duration(active.PADTimeout)*time.Second, func() { // check the PAD 30s timeout
|
|
|
|
|
-
|
|
|
|
|
- res, err := action.QueueStatus("0301", "") // check OCC queue , if empty OCC-PAD start
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Infof("OCC QueueStatus err:%+v", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- if res == nil {
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if res.Calls == "0" { // OCC queue empty
|
|
|
|
|
- priority.ICPAnswer = 0
|
|
|
|
|
- for _, ret := range alstatus.PadQueues {
|
|
|
|
|
- //order by pos
|
|
|
|
|
- action.RedirectInQueue(ret.Exten, "0301", "queues-occ", ret.Exten) // redirect All ICP-PAD redirect to OCC queue
|
|
|
|
|
- time.Sleep(time.Millisecond * 100)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }*/
|
|
|
|
|
- //default:
|
|
|
|
|
- //fmt.Printf("Unknown command: %x\n", packet[5])
|
|
|
|
|
|
|
+ //case 0x0b: // 重联方式
|
|
|
|
|
+ // active.TrainUnionMode = int(packet[9])
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func PadTimeOutSetting(data []byte) {
|
|
|
|
|
-
|
|
|
|
|
- Seconds := data[0]
|
|
|
|
|
- if Seconds != 0 {
|
|
|
|
|
- active.PADTimeout = int(Seconds)
|
|
|
|
|
- //lfshook.NewLogger().Logger.Infof("=========Set PAD Timeout seconds to %d ! ============", active.PADTimeout)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// EED报警,激活报警器到队列
|
|
|
|
|
+func EEDAlarm(data []byte) {
|
|
|
|
|
+ cab := data[0]
|
|
|
|
|
+ pos := data[1]
|
|
|
|
|
|
|
|
|
|
+ alarm := fmt.Sprintf("7%02d%d", cab, pos)
|
|
|
|
|
+ //utils.LoggerDebug.Printf("Type:STN FileName:%x Count:%x SpecialVoice:%+v Interval:%+v", filename, cycleCount, specialVoice, delay)
|
|
|
|
|
+ action.Dial(alarm, "0300", "queues", "", "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// STN , 自动报站广播
|
|
|
|
|
-func StationAnn(data []byte) (err error) {
|
|
|
|
|
-
|
|
|
|
|
- specialVoice := int(data[8])
|
|
|
|
|
- delay := data[9]
|
|
|
|
|
- cycleCount := data[10]
|
|
|
|
|
- datalen := int(data[11])
|
|
|
|
|
|
|
+// DSN ,开关门提示
|
|
|
|
|
+func DoorStatusNotice(data []byte) (err error) {
|
|
|
|
|
|
|
|
- filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
|
|
|
|
|
+ delay := data[0]
|
|
|
|
|
+ cycleCount := data[1]
|
|
|
|
|
+ FileLen := int(data[2])
|
|
|
|
|
+ filename := msgdata.SubstrByRune(string(data[3:]), 0, int(FileLen)-4)
|
|
|
|
|
|
|
|
- //set spc voice tag
|
|
|
|
|
- priority.SpecialVoice = specialVoice
|
|
|
|
|
|
|
+ //utils.LoggerDebug.Printf("Type:STN FileName:%x Count:%x SpecialVoice:%+v Interval:%+v", filename, cycleCount, specialVoice, delay)
|
|
|
|
|
|
|
|
- utils.LoggerDebug.Printf("Type:STN FileName:%x Count:%x SpecialVoice:%+v Interval:%+v", filename, cycleCount, specialVoice, delay)
|
|
|
|
|
-
|
|
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "STN")
|
|
|
|
|
|
|
+ action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "DCS")
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 激活信号
|
|
|
|
|
-func Active(data [3]byte) {
|
|
|
|
|
-
|
|
|
|
|
- //var info model.Sysinfo
|
|
|
|
|
- Signal := int(data[0])
|
|
|
|
|
- master := int(data[1])
|
|
|
|
|
- TrainInfo := int(data[2])
|
|
|
|
|
|
|
+// APA , 自动报站广播
|
|
|
|
|
+func StationAnnAuto(data []byte) (err error) {
|
|
|
|
|
|
|
|
- lfshook.NewLogger().Logger.Infof("=====active:%x======cab=%s Master=%d=====data:%x======ActivedCabDelay:%x", Signal, active.CabNum, master, data, active.ActivedCabDelay)
|
|
|
|
|
|
|
+ //StationStatus := int(data[0])
|
|
|
|
|
+ filelen := data[1]
|
|
|
|
|
+ filename := msgdata.SubstrByRune(string(data[2:]), 0, int(filelen)-4)
|
|
|
|
|
|
|
|
- //Set Master
|
|
|
|
|
- if master == 1 && active.CabNum == "1" {
|
|
|
|
|
-
|
|
|
|
|
- active.Master = true
|
|
|
|
|
- if !utils.CheckAsterisk() {
|
|
|
|
|
- lfshook.NewLogger().Infof("Check asterisk , if not running , run cmd service asterisk start !")
|
|
|
|
|
- cmd := exec.Command("service", "asterisk", "start")
|
|
|
|
|
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
|
|
|
- err := cmd.Run()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Infof("Failed to start asterisk: %v", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if master == 8 && active.CabNum == "8" {
|
|
|
|
|
-
|
|
|
|
|
- active.Master = true
|
|
|
|
|
- if !utils.CheckAsterisk() {
|
|
|
|
|
- lfshook.NewLogger().Infof("Check asterisk , if not running , run cmd service asterisk start !")
|
|
|
|
|
- cmd := exec.Command("service", "asterisk", "start")
|
|
|
|
|
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
|
|
|
- err := cmd.Run()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Infof("Failed to start asterisk: %v", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if master == 8 && active.CabNum == "1" {
|
|
|
|
|
-
|
|
|
|
|
- if utils.CheckAsterisk() {
|
|
|
|
|
- lfshook.NewLogger().Infof("Check asterisk , if running slave, run cmd service asterisk stop !")
|
|
|
|
|
- cmd := exec.Command("service", "asterisk", "stop")
|
|
|
|
|
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
|
|
|
- err := cmd.Run()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Infof("Failed to stop asterisk: %v", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if master == 1 && active.CabNum == "8" {
|
|
|
|
|
- active.Master = false
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //Set train info
|
|
|
|
|
- if TrainInfo != 0 {
|
|
|
|
|
- //Get train devide info
|
|
|
|
|
- DevideInfo := TrainInfo & 0x20
|
|
|
|
|
- if DevideInfo == 0x20 {
|
|
|
|
|
- active.TrainDevide = 1
|
|
|
|
|
-
|
|
|
|
|
- active.Master = true //列车断开,设置两边都Master
|
|
|
|
|
- if !utils.CheckAsterisk() {
|
|
|
|
|
- lfshook.NewLogger().Infof("Check asterisk , if not running , run cmd service asterisk start !")
|
|
|
|
|
- cmd := exec.Command("service", "asterisk", "start")
|
|
|
|
|
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
|
|
|
- err := cmd.Run()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- lfshook.NewLogger().Infof("Failed to start asterisk: %v", err)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- active.TrainDevide = 0
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //Radio fault
|
|
|
|
|
- active.RadioFault1 = TrainInfo & 0x03
|
|
|
|
|
- active.RadioFault8 = TrainInfo & 0x0c
|
|
|
|
|
- //if RadioFault1 == 2 || RadioFault8 == 2 {
|
|
|
|
|
- // active.RadioFault = 1
|
|
|
|
|
- //} else {
|
|
|
|
|
- // active.RadioFault = 0
|
|
|
|
|
- //}
|
|
|
|
|
- //utils.LoggerDebug.Printf("RadioFault1:%x RadioFault8:%x DevideInfo:%x", active.RadioFault1, active.RadioFault8, DevideInfo)
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- switch Signal {
|
|
|
|
|
- case 0:
|
|
|
|
|
-
|
|
|
|
|
- if active.ActivedCab != "" {
|
|
|
|
|
- active.ActivedCab = ""
|
|
|
|
|
- action.InActiveHangup()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- case 1:
|
|
|
|
|
- //active signal from 8 to 1
|
|
|
|
|
- if active.ActivedCab == "8" || active.ActivedCab == "" {
|
|
|
|
|
- active.ActivedCab = "1"
|
|
|
|
|
- active.ActivedCabDelay = "1"
|
|
|
|
|
-
|
|
|
|
|
- action.InActiveHangup()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //utils.LoggerDebug.Printf("Type:STN FileName:%x Count:%x SpecialVoice:%+v Interval:%+v", filename, cycleCount, specialVoice, delay)
|
|
|
|
|
|
|
|
- case 8:
|
|
|
|
|
- //active signal from 1 to 8
|
|
|
|
|
- if active.ActivedCab == "1" || active.ActivedCab == "" {
|
|
|
|
|
- active.ActivedCab = "8"
|
|
|
|
|
- active.ActivedCabDelay = "8"
|
|
|
|
|
-
|
|
|
|
|
- action.InActiveHangup()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ action.PlaybackPacu(strconv.Quote(filename), 1, 0, "STNA")
|
|
|
|
|
+ return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// SPC ,特殊服务消息广播
|
|
|
|
|
-func SpecialAnn(data []byte) {
|
|
|
|
|
|
|
+// SPA , 手动报站广播
|
|
|
|
|
+func StationAnnManu(data []byte) (err error) {
|
|
|
|
|
|
|
|
- delay := data[8]
|
|
|
|
|
- cycleCount := data[9]
|
|
|
|
|
- datalen := int(data[10])
|
|
|
|
|
|
|
+ //StationStatus := int(data[0])
|
|
|
|
|
+ filelen := data[1]
|
|
|
|
|
+ filename := msgdata.SubstrByRune(string(data[2:]), 0, int(filelen)-4)
|
|
|
|
|
|
|
|
- filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
|
|
|
|
|
+ //utils.LoggerDebug.Printf("Type:STN FileName:%x Count:%x SpecialVoice:%+v Interval:%+v", filename, cycleCount, specialVoice, delay)
|
|
|
|
|
|
|
|
- utils.LoggerDebug.Printf("Type:SPC FileName:%x Count:%x Interval:%+v", filename, cycleCount, delay)
|
|
|
|
|
- if int(cycleCount) == 255 {
|
|
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), 9999999, int(delay), "SPC")
|
|
|
|
|
- } else {
|
|
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "SPC")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ action.PlaybackPacu(strconv.Quote(filename), 1, 0, "STNS")
|
|
|
|
|
+ return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// EMG ,紧急服务消息广播
|
|
// EMG ,紧急服务消息广播
|
|
|
func EmgMsg(data []byte) {
|
|
func EmgMsg(data []byte) {
|
|
|
- delay := data[8]
|
|
|
|
|
- cycleCount := data[9]
|
|
|
|
|
- datalen := int(data[10])
|
|
|
|
|
|
|
+ delay := data[0]
|
|
|
|
|
+ cycleCount := data[1]
|
|
|
|
|
+ filelen := int(data[2])
|
|
|
|
|
|
|
|
- filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
|
|
|
|
|
+ filename := msgdata.SubstrByRune(string(data[3:]), 0, filelen-4)
|
|
|
|
|
|
|
|
utils.LoggerDebug.Printf("Type:EMG FileName:%x Count:%x Interval:%+v", filename, cycleCount, delay)
|
|
utils.LoggerDebug.Printf("Type:EMG FileName:%x Count:%x Interval:%+v", filename, cycleCount, delay)
|
|
|
if int(cycleCount) == 255 {
|
|
if int(cycleCount) == 255 {
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), 9999999, int(delay), "EMG")
|
|
|
|
|
|
|
+ action.PlaybackPacu(strconv.Quote(filename), 9999999, int(delay), "SVM")
|
|
|
} else {
|
|
} else {
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "EMG")
|
|
|
|
|
|
|
+ action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "SVM")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -667,232 +244,31 @@ func EmgMsg(data []byte) {
|
|
|
func AnnStop(data [4]byte) {
|
|
func AnnStop(data [4]byte) {
|
|
|
|
|
|
|
|
//lfshook.NewLogger().Logger.Infof("=========AnnStop Type %x", data[0])
|
|
//lfshook.NewLogger().Logger.Infof("=========AnnStop Type %x", data[0])
|
|
|
- utils.LoggerDebug.Printf("Stop PA Type:%x (DCS=3,EMG=4,SPC=7,STN=8,SelfCheck=9,ToneTest=10)", data[0])
|
|
|
|
|
|
|
+ utils.LoggerDebug.Printf("Stop PA Type:%x (自动报站=1,手动报站=2,服务信息=3)", data[0])
|
|
|
|
|
|
|
|
switch data[0] {
|
|
switch data[0] {
|
|
|
- case 0x03:
|
|
|
|
|
-
|
|
|
|
|
- action.HangupTask("DCS") //STOP DCS
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- case 0x04:
|
|
|
|
|
-
|
|
|
|
|
- action.HangupTask("EMG") //STOP EMG
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- case 0x07:
|
|
|
|
|
-
|
|
|
|
|
- action.HangupTask("SPC") //STOP SPC
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- case 0x08:
|
|
|
|
|
-
|
|
|
|
|
- action.HangupTask("STN") //STOP STN
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- case 0x09:
|
|
|
|
|
-
|
|
|
|
|
- action.HangupTask("CHK") //STOP CHK
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- case 0x0a:
|
|
|
|
|
-
|
|
|
|
|
- action.HangupTask("VOL") //STOP VOL
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- default:
|
|
|
|
|
- action.InterruptRunningTask("")
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// DCS 语音
|
|
|
|
|
-func DcsAnn(data []byte) {
|
|
|
|
|
- delay := data[8]
|
|
|
|
|
- cycleCount := data[9]
|
|
|
|
|
- datalen := int(data[10])
|
|
|
|
|
-
|
|
|
|
|
- filename := msgdata.SubstrByRune(string(data[11:]), 0, datalen-4)
|
|
|
|
|
-
|
|
|
|
|
- utils.LoggerDebug.Printf("Type:DCS FileName:%x Count:%x Interval:%+v", filename, cycleCount, delay)
|
|
|
|
|
- if int(cycleCount) == 255 {
|
|
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), 9999999, int(delay), "DCS")
|
|
|
|
|
- } else {
|
|
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "DCS")
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// tone-test广播
|
|
|
|
|
-func ToneTest(data []byte) {
|
|
|
|
|
-
|
|
|
|
|
- check := data[8]
|
|
|
|
|
- delay := data[9]
|
|
|
|
|
- cycleCount := data[10]
|
|
|
|
|
- datalen := int(data[11])
|
|
|
|
|
-
|
|
|
|
|
- filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
|
|
|
-
|
|
|
|
|
- utils.LoggerDebug.Printf("Type:ToneTest FileName:%x Count:%x Interval:%+v Action:%x (0x01=start/0x02=stop)", filename, cycleCount, delay, check)
|
|
|
|
|
- switch check {
|
|
|
|
|
- case 0x01: //start
|
|
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "VOL")
|
|
|
|
|
-
|
|
|
|
|
- case 0x02: //stop
|
|
|
|
|
- action.HangupAllExcept("")
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 自检广播
|
|
|
|
|
-func SelfCheck(data []byte) {
|
|
|
|
|
-
|
|
|
|
|
- check := data[8]
|
|
|
|
|
- delay := data[9]
|
|
|
|
|
- cycleCount := data[10]
|
|
|
|
|
- //cycleCount := 0x32
|
|
|
|
|
- datalen := int(data[11])
|
|
|
|
|
-
|
|
|
|
|
- filename := msgdata.SubstrByRune(string(data[12:]), 0, datalen-4)
|
|
|
|
|
-
|
|
|
|
|
- utils.LoggerDebug.Printf("Type:SelfCehck FileName:%x Count:%x Interval:%+v Action:%x (0x01=start/0x02=stop)", filename, cycleCount, delay, check)
|
|
|
|
|
- switch check {
|
|
|
|
|
- case 0x01: //start
|
|
|
|
|
-
|
|
|
|
|
- action.PlaybackPacu(strconv.Quote(filename), int(cycleCount), int(delay), "CHK")
|
|
|
|
|
- case 0x02: //stop
|
|
|
|
|
- action.HangupAllExcept("")
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 全局变量:记录正在抑制的 exten
|
|
|
|
|
-var (
|
|
|
|
|
- suppressedExts = sync.Map{} // map[string]struct{},值存在即表示被抑制
|
|
|
|
|
- //suppressionMu sync.Mutex // 保护初始化和清理操作(可选)
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
-// suppressKey 生成用于抑制的 key(可以根据需求扩展)
|
|
|
|
|
-func suppressKey(exten string, handler byte) string {
|
|
|
|
|
- return fmt.Sprintf("%s_h%x", exten, handler)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// ICP操作乘客报警(根据激活信息判断转到1车还是8车================)
|
|
|
|
|
-func AlarmHandleICP(data []byte) {
|
|
|
|
|
- handler := data[8]
|
|
|
|
|
- carr := data[12]
|
|
|
|
|
- pos := data[13]
|
|
|
|
|
- exten := fmt.Sprintf("24%c%c", carr, pos)
|
|
|
|
|
-
|
|
|
|
|
- utils.LoggerDebug.Printf("ICP Handle PAD:%s Action:%x (answer=1,hold=2,hangup=3)", exten, handler)
|
|
|
|
|
- switch handler {
|
|
|
|
|
- case 0x01: //answer(ICP+Alarm+PACU)
|
|
|
|
|
- //NotifyPaiu(exten, "answer")
|
|
|
|
|
- priority.ICPAnswer = 1
|
|
|
|
|
- //if priority.PADStart == 0 {
|
|
|
|
|
- //alstatus.PaStatus("", "PAD", "start")
|
|
|
|
|
- priority.InterruptedPad = ""
|
|
|
|
|
- // priority.PADStart = 1
|
|
|
|
|
- //}
|
|
|
|
|
- utils.LoggerDebug.Printf("ICP Answer PAD:%s .", exten)
|
|
|
|
|
-
|
|
|
|
|
- if active.ActivedCab == "1" {
|
|
|
|
|
- action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
|
|
|
|
|
- //goto ami event ConfbridgeJoin, ICP answer PAD
|
|
|
|
|
- } else if active.ActivedCab == "8" {
|
|
|
|
|
- action.Dial("0402", "0511", "pad-rule-pacus", "ani8", exten, "8") // PACUs dial ICP8
|
|
|
|
|
- //goto ami event ConfbridgeJoin, ICP answer PAD
|
|
|
|
|
- } else if active.ActivedCab == "" { // No cab occupied
|
|
|
|
|
- if active.ActivedCabDelay == "1" {
|
|
|
|
|
- action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
|
|
|
|
|
- } else if active.ActivedCabDelay == "8" {
|
|
|
|
|
- action.Dial("0402", "0511", "pad-rule-pacus", "ani8", exten, "8") // PACUs dial ICP8
|
|
|
|
|
- } else {
|
|
|
|
|
- action.Dial("0402", "0511", "pad-rule-pacus", "ani1", exten, "1") // PACUs dial ICP1
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- case 0x02: //hold 重新放回队列里面
|
|
|
|
|
- utils.LoggerDebug.Printf("ICP Hold PAD-ICP PAD:%s !", exten)
|
|
|
|
|
- active.NotifyPaiu(exten, "hold")
|
|
|
|
|
- err := action.RedirectInQueue(exten, "0300", "queues-icp-redirect", "1")
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- utils.LoggerDebug.Printf("RedirectInQueue err:%+v", err)
|
|
|
|
|
|
|
+ case 0x01: //停止自动广播(自动报站)
|
|
|
|
|
+ taskInfo, ok := priority.RegistryTask.Get("STNA")
|
|
|
|
|
+ if ok {
|
|
|
|
|
+ action.ConfbridgeKick(taskInfo.ConfbridgeID, "all")
|
|
|
|
|
+ action.Hangup(taskInfo.RunChannel)
|
|
|
}
|
|
}
|
|
|
- action.InterruptRunningTask("")
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
- //action.HangupICP()
|
|
|
|
|
-
|
|
|
|
|
- case 0x03: //hangup
|
|
|
|
|
- //NotifyPaiu(exten, "hangup")
|
|
|
|
|
- utils.LoggerDebug.Printf("STC Hangup PAD-ICP !")
|
|
|
|
|
- action.Hangup(exten) //Pad
|
|
|
|
|
- //action.HangupICP()
|
|
|
|
|
-
|
|
|
|
|
- action.HangupTask("PAD-ICP")
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ time.Sleep(time.Millisecond * 100)
|
|
|
|
|
|
|
|
-// TMS操作乘客报警(根据激活信息判断转到1车还是8车================)
|
|
|
|
|
-func AlarmHandleTMS(data []byte) {
|
|
|
|
|
- handler := data[8]
|
|
|
|
|
- //extlen := data[9]
|
|
|
|
|
- carr := data[12]
|
|
|
|
|
- pos := data[13]
|
|
|
|
|
- exten := fmt.Sprintf("24%c%c", carr, pos)
|
|
|
|
|
- PacuNum := fmt.Sprintf("21%c1", carr)
|
|
|
|
|
-
|
|
|
|
|
- utils.LoggerDebug.Printf("TMS Handle PAD:%s PACU:%s Action:%x (answer=1,hold=2,hangup=3)", exten, PacuNum, handler)
|
|
|
|
|
-
|
|
|
|
|
- switch handler {
|
|
|
|
|
- case 0x01: //answer(ICP+Alarm+PACU)
|
|
|
|
|
- //PACU---call---->ICP1
|
|
|
|
|
- //PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
|
|
|
|
|
- //if priority.PADStart == 0 {
|
|
|
|
|
- //alstatus.PaStatus("", "PAD", "start")
|
|
|
|
|
- priority.InterruptedPad = ""
|
|
|
|
|
- //priority.PADStart = 1
|
|
|
|
|
- //}
|
|
|
|
|
- priority.ICPAnswer = 1
|
|
|
|
|
- utils.LoggerDebug.Printf("TMS Answer PAD:%s PACU:%s", exten, PacuNum)
|
|
|
|
|
-
|
|
|
|
|
- if action.ExtenStatus(PacuNum) == "Idle" {
|
|
|
|
|
- if active.ActivedCab == "1" {
|
|
|
|
|
- action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
|
|
|
|
|
- //goto ami event BridgeEnter, ICP8 whisper ICP1
|
|
|
|
|
- } else if active.ActivedCab == "8" {
|
|
|
|
|
- action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "8") // PACU dial ICP8
|
|
|
|
|
- //goto ami event BridgeEnter, ICP1 whisper ICP8
|
|
|
|
|
- } else if active.ActivedCab == "" { // No cab occupied
|
|
|
|
|
- if active.ActivedCabDelay == "1" {
|
|
|
|
|
- action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
|
|
|
|
|
- } else if active.ActivedCabDelay == "8" {
|
|
|
|
|
- action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "8") // PACU dial ICP8
|
|
|
|
|
- } else {
|
|
|
|
|
- action.Dial("0403", PacuNum, "pad-tms-dial-pacu", PacuNum, exten, "1") // PACU dial ICP1
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- action.RedirectInQueue(exten, "0405", "default", exten) // PAD dial ICPs
|
|
|
|
|
|
|
+ case 0x02: //停止半自动广播(手动报站)
|
|
|
|
|
+ taskInfo, ok := priority.RegistryTask.Get("STNS")
|
|
|
|
|
+ if ok {
|
|
|
|
|
+ action.ConfbridgeKick(taskInfo.ConfbridgeID, "all")
|
|
|
|
|
+ action.Hangup(taskInfo.RunChannel)
|
|
|
}
|
|
}
|
|
|
|
|
+ time.Sleep(time.Millisecond * 100)
|
|
|
|
|
|
|
|
- case 0x02: //hold 重新放回队列里面
|
|
|
|
|
- utils.LoggerDebug.Printf("ICP Hold PAD-TMS PAD:%s !", exten)
|
|
|
|
|
- active.NotifyPaiu(exten, "hold")
|
|
|
|
|
- err := action.RedirectInQueue(exten, "0300", "queues-icp-redirect", "1")
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- utils.LoggerDebug.Printf("RedirectInQueue err:%+v", err)
|
|
|
|
|
|
|
+ case 0x03: //停止服务信息广播(紧急广播)
|
|
|
|
|
+ taskInfo, ok := priority.RegistryTask.Get("SVM")
|
|
|
|
|
+ if ok {
|
|
|
|
|
+ action.ConfbridgeKick(taskInfo.ConfbridgeID, "all")
|
|
|
|
|
+ action.Hangup(taskInfo.RunChannel)
|
|
|
}
|
|
}
|
|
|
- action.HangupAllLocalChan()
|
|
|
|
|
-
|
|
|
|
|
- case 0x03: //hangup
|
|
|
|
|
- //NotifyPaiu(exten, "hangup")
|
|
|
|
|
- utils.LoggerDebug.Printf("STC Hangup PAD-TMS !")
|
|
|
|
|
- action.Hangup(exten) //Pad
|
|
|
|
|
- action.HangupTask("PAD-TMS")
|
|
|
|
|
- //action.HangupTask("PAD-ICP")
|
|
|
|
|
|
|
+ time.Sleep(time.Millisecond * 100)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// 挂断所有报警器
|
|
|
|
|
-func AlarmHoldResetAll(handler byte) {
|
|
|
|
|
- utils.LoggerDebug.Printf("Alarm Hold/Reset All !")
|
|
|
|
|
- //hangup all actived PAD
|
|
|
|
|
- action.HangupAllPAD()
|
|
|
|
|
-
|
|
|
|
|
- //hangup running task
|
|
|
|
|
- action.InterruptRunningTask("AlarmHoldResetAll") //Reset PAD ALL
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
|
|
-}
|
|
|