|
|
@@ -35,14 +35,14 @@ func HandleAMI(event map[string]string) {
|
|
|
switch event["Digit"] {
|
|
|
case "#":
|
|
|
//lfshook.NewLogger().Infof("===PA interrupt PAD====== ")
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("Get DTMF '#', PA interrupt other !")
|
|
|
runningTaskName := InterruptRunningTask("PA")
|
|
|
if runningTaskName != "" {
|
|
|
time.Sleep(time.Millisecond * 200) //wait endpoint release
|
|
|
}
|
|
|
case "*": //Cab cab interrupt PAD
|
|
|
- lfshook.NewLogger().Infof("===Cab cab interrupt PAD and====== ")
|
|
|
-
|
|
|
+ //lfshook.NewLogger().Infof("===Cab cab interrupt PAD and====== ")
|
|
|
+ utils.LoggerDebug.Printf("Get DTMF '*', CabCab interrupt other !")
|
|
|
runningTaskName := InterruptRunningTask("C2C")
|
|
|
//Hangup("2311")
|
|
|
//Hangup("2381")
|
|
|
@@ -56,6 +56,7 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("========event:%s File:%s", event["Event"], event["FILENAME"])
|
|
|
|
|
|
if event["UserEvent"] == "CONTINUE" && event["Type"] != "" {
|
|
|
+ utils.LoggerDebug.Printf("Get UserEvent Type=CONTINUE , Send %s continue status !", event["Type"])
|
|
|
alstatus.PaStatus("", event["Type"], "continue")
|
|
|
return
|
|
|
}
|
|
|
@@ -63,20 +64,19 @@ func HandleAMI(event map[string]string) {
|
|
|
if event["UserEvent"] == "CallType" && (event["Type"] == "PA" || event["Type"] == "CPA") { //PA start; check manual PA priority
|
|
|
//PA & CPA interrupt others
|
|
|
if utils.IsICP(event["CallerIDNum"]) { //PA
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("Get UserEvent , %s calling !", event["Type"])
|
|
|
if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
Hangup(event["CallerIDNum"])
|
|
|
}
|
|
|
|
|
|
- active.WaitTaskCreate("PA")
|
|
|
- if active.TaskCreating == "" {
|
|
|
- active.TaskCreating = "PA"
|
|
|
- }
|
|
|
+ WaitTaskCreate("PA", event["CallerIDNum"])
|
|
|
|
|
|
if priority.CheckPriority("ManuPa") {
|
|
|
|
|
|
//hangup others if priority is higher
|
|
|
- lfshook.NewLogger().Infof("UserEvent event :PA start")
|
|
|
+ //lfshook.NewLogger().Infof("UserEvent event :PA start")
|
|
|
+ utils.LoggerDebug.Printf("PA calling, check priority return true !")
|
|
|
+
|
|
|
runningTaskName := InterruptRunningTask("PA") //PA interrupt other
|
|
|
if runningTaskName != "" {
|
|
|
time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
@@ -86,18 +86,24 @@ func HandleAMI(event map[string]string) {
|
|
|
Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
}
|
|
|
|
|
|
- } else if utils.IsIO(event["CallerIDNum"]) { // CPA
|
|
|
- active.WaitTaskCreate("CPA")
|
|
|
- if active.TaskCreating == "" {
|
|
|
- active.TaskCreating = "CPA"
|
|
|
+ time.Sleep(2 * time.Second)
|
|
|
+ if priority.TaskCreating == "PA" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
}
|
|
|
+ } else if utils.IsIO(event["CallerIDNum"]) { // CPA
|
|
|
+
|
|
|
+ utils.LoggerDebug.Printf("Get UserEvent , %s calling !", event["Type"])
|
|
|
+ WaitTaskCreate("CPA", event["CallerIDNum"])
|
|
|
|
|
|
if priority.CheckPriority("CPA") {
|
|
|
|
|
|
- lfshook.NewLogger().Infof("========event:%s ========devide:%d", event["Event"], active.TrainDevide)
|
|
|
+ //lfshook.NewLogger().Infof("========event:%s ========devide:%d", event["Event"], active.TrainDevide)
|
|
|
+ utils.LoggerDebug.Printf("CPA calling, check priority return true !")
|
|
|
if active.TrainDevide == 1 || active.RadioFault == 1 { // 列车没有断开的情况下限制如下;列车断开之后CPA无任何限制
|
|
|
- lfshook.NewLogger().Infof("===active.TrainDevide == 1 || active.RadioFault == 1====")
|
|
|
+ utils.LoggerDebug.Printf("TrainDevide = %d, RadioFault = %d , CPA calling unlimit !", active.TrainDevide, active.RadioFault)
|
|
|
+ //lfshook.NewLogger().Infof("===active.TrainDevide == 1 || active.RadioFault == 1====")
|
|
|
} else {
|
|
|
+ utils.LoggerDebug.Printf("CPA calling , ActivedCab = %s !", active.ActivedCab)
|
|
|
if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
|
|
|
Hangup(event["CallerIDNum"])
|
|
|
} else if active.ActivedCab == "1" && event["CallerIDNum"] == "1411" {
|
|
|
@@ -113,15 +119,18 @@ func HandleAMI(event map[string]string) {
|
|
|
time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
}
|
|
|
} else {
|
|
|
+ utils.LoggerDebug.Printf("CPA calling failed , check priority return false !")
|
|
|
Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
|
|
|
}
|
|
|
- }
|
|
|
- } else if event["UserEvent"] == "CallType" && event["Type"] == "C2C" { //CabCab start; check cab cab priority
|
|
|
|
|
|
- active.WaitTaskCreate("C2C")
|
|
|
- if active.TaskCreating == "" {
|
|
|
- active.TaskCreating = "C2C"
|
|
|
+ time.Sleep(2 * time.Second)
|
|
|
+ if priority.TaskCreating == "CPA" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
}
|
|
|
+ } else if event["UserEvent"] == "CallType" && event["Type"] == "C2C" { //CabCab start; check cab cab priority
|
|
|
+ utils.LoggerDebug.Printf("Get UserEvent , %s calling !", event["Type"])
|
|
|
+ WaitTaskCreate("C2C", event["CallerIDNum"])
|
|
|
|
|
|
if priority.CheckPriority("CabCab") { // interrupt OCC-PAD
|
|
|
//C2C start PAD interrupt
|
|
|
@@ -129,16 +138,18 @@ func HandleAMI(event map[string]string) {
|
|
|
taskName, _, ok := priority.RegistryTask.HighestPriorityRunningTask1()
|
|
|
|
|
|
lfshook.NewLogger().Infof("HighestPriorityRunningTask get task :%+v", taskName)
|
|
|
+ utils.LoggerDebug.Printf("C2C calling, check priority return true !")
|
|
|
if ok {
|
|
|
if taskName == "PAD-ICP" || taskName == "PAD-TMS" || taskName == "PA" {
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("%s Start CabCab ,interrupt other !", event["CallerIDNum"])
|
|
|
runningTaskName := InterruptRunningTask("C2C")
|
|
|
if runningTaskName != "" {
|
|
|
time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- lfshook.NewLogger().Infof("CabCab hangup other the one caller %s", event["CallerIDNum"])
|
|
|
+ //lfshook.NewLogger().Infof("CabCab hangup other the one caller %s", event["CallerIDNum"])
|
|
|
+ utils.LoggerDebug.Printf("%s Start CabCab ,check and hangup the other ICP first", event["CallerIDNum"])
|
|
|
if event["CallerIDNum"] == "2311" {
|
|
|
Hangup("2381")
|
|
|
} else {
|
|
|
@@ -148,37 +159,49 @@ func HandleAMI(event map[string]string) {
|
|
|
}
|
|
|
|
|
|
} else { // hangup caller; C2C start failed
|
|
|
- lfshook.NewLogger().Infof("CabCab hangup caller %s", event["CallerIDNum"])
|
|
|
+ //lfshook.NewLogger().Infof("CabCab hangup caller %s", event["CallerIDNum"])
|
|
|
+ utils.LoggerDebug.Printf("C2C calling failed , check priority return false !")
|
|
|
Hangup(event["CallerIDNum"])
|
|
|
}
|
|
|
+
|
|
|
+ time.Sleep(2 * time.Second)
|
|
|
+ if priority.TaskCreating == "C2C" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
+
|
|
|
break
|
|
|
|
|
|
//Get record file name ,encode and upload
|
|
|
} else if event["UserEvent"] == "SetRecordFile" {
|
|
|
|
|
|
- if configs.ConfigGlobal.ProcessRecord != "yes" {
|
|
|
- break
|
|
|
- }
|
|
|
+ if len(event["FILENAME"]) > 0 {
|
|
|
+ if configs.ConfigGlobal.ProcessRecord != "yes" {
|
|
|
+ break
|
|
|
+ }
|
|
|
|
|
|
- //检测录音文件是否存在;最多检测5次,每次间隔1秒
|
|
|
- var fileExists bool
|
|
|
- for i := 0; i < 5; i++ {
|
|
|
- time.Sleep(time.Second) // 等待1秒
|
|
|
+ //检测录音文件是否存在;最多检测5次,每次间隔1秒
|
|
|
+ var fileExists bool
|
|
|
+ for i := 0; i < 5; i++ {
|
|
|
+ time.Sleep(time.Second) // 等待1秒
|
|
|
|
|
|
- if _, err := os.Stat(event["FILENAME"]); err == nil {
|
|
|
- fileExists = true
|
|
|
- //lfshook.NewLogger().Infof("File found: %s", event["FILENAME"])
|
|
|
- break
|
|
|
- } else if os.IsNotExist(err) {
|
|
|
- //lfshook.NewLogger().Infof("File not found (attempt %d): %s", i+1, event["FILENAME"])
|
|
|
- } else {
|
|
|
- //lfshook.NewLogger().Infof("Error checking file: %v", err)
|
|
|
+ if _, err := os.Stat(event["FILENAME"]); err == nil {
|
|
|
+ fileExists = true
|
|
|
+ //lfshook.NewLogger().Infof("File found: %s", event["FILENAME"])
|
|
|
+ break
|
|
|
+ } else if os.IsNotExist(err) {
|
|
|
+ //lfshook.NewLogger().Infof("File not found (attempt %d): %s", i+1, event["FILENAME"])
|
|
|
+ } else {
|
|
|
+ //lfshook.NewLogger().Infof("Error checking file: %v", err)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if !fileExists { //5秒内没有生成录音文件
|
|
|
- lfshook.NewLogger().Infof("File %s not found after 5 attempts", event["FILENAME"])
|
|
|
- break
|
|
|
+ if !fileExists { //5秒内没有生成录音文件
|
|
|
+ //lfshook.NewLogger().Infof("File %s not found after 5 attempts", event["FILENAME"])
|
|
|
+ utils.LoggerDebug.Printf("Record File %s not found after 5 attempts", event["FILENAME"])
|
|
|
+ break
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
//获取录音文件时长,检测录音文件是否超过3min;
|
|
|
@@ -191,15 +214,17 @@ func HandleAMI(event map[string]string) {
|
|
|
//转wav文件的采样率到22kHz,并切割位180秒每段
|
|
|
var FileNames []string
|
|
|
if duration >= 2000 { //超过2000秒的超长文件,不处理
|
|
|
- lfshook.NewLogger().Infof("Audio file time length over 2000 seconds, Ignored !")
|
|
|
+ //lfshook.NewLogger().Infof("Audio file time length over 2000 seconds, Ignored !")
|
|
|
+ utils.LoggerDebug.Printf("Audio file time length over 2000 seconds, Ignored !")
|
|
|
break
|
|
|
} else if duration < 2000 { //小于2000秒文件进行转换和切割
|
|
|
FileNames, err = utils.ConvertAndSegmentWAV(event["FILENAME"], strings.Replace(event["FILENAME"], ".wav", "", -1))
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Infof("%s Get duration err: %+v", event["FILENAME"], err)
|
|
|
+ // lfshook.NewLogger().Infof("%s Get duration err: %+v", event["FILENAME"], err)
|
|
|
+ utils.LoggerDebug.Printf("Split and convert record file failed : %+v !", err)
|
|
|
break
|
|
|
}
|
|
|
- //lfshook.NewLogger().Infof("=============== File %+v found after convert", FileNames)
|
|
|
+ utils.LoggerDebug.Printf("Audio file split to file :%+v ", FileNames)
|
|
|
}
|
|
|
|
|
|
//执行加密操作,并将录音信息写入日志文件
|
|
|
@@ -210,10 +235,10 @@ func HandleAMI(event map[string]string) {
|
|
|
file := strings.Replace(filepathFull, ".wav", "", -1)
|
|
|
DstFile = fmt.Sprintf("%s-encrypted.wav", file)
|
|
|
|
|
|
- //lfshook.NewLogger().Infof("Bin file====%s", DstFile)
|
|
|
err = utils.AudioFileEncode(DstFile, filepathFull)
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Infof("Encode file: %s err: %+v", DstFile, err)
|
|
|
+ //lfshook.NewLogger().Infof("Encode file: %s err: %+v", DstFile, err)
|
|
|
+ utils.LoggerDebug.Printf("Encrypt file %s err: %+v", DstFile, err)
|
|
|
continue
|
|
|
}
|
|
|
//切割&加密之后发送生成的文件名到STC;
|
|
|
@@ -221,18 +246,14 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
trainInfo = fmt.Sprintf("TrainNumber %s ", active.TrainNum)
|
|
|
|
|
|
+ utils.LoggerDebug.Printf("Write record log !")
|
|
|
+
|
|
|
if strings.Contains(event["FILENAME"], "PAD") {
|
|
|
_, caller, callee := utils.GetPadInfo(event["FILENAME"])
|
|
|
|
|
|
carNum := int(caller[2] - '0')
|
|
|
- //carNum := 4
|
|
|
- //trainInfo = fmt.Sprintf("TrainNumber %s CarNumber %s ", active.TrainNum, active.TrainInfoMap[active.TrainNum][int(caller[2])])
|
|
|
- //lfshook.NewLogger().Infof("Train info carNum===caller[2]==========:%d===============", carNum)
|
|
|
-
|
|
|
trainInfo = fmt.Sprintf("TrainNumber %s CarNumber %s ", active.TrainNum, active.TrainInfoMap[active.TrainNum][carNum])
|
|
|
|
|
|
- //lfshook.NewLogger().Infof("Train info=============%s===============", trainInfo)
|
|
|
-
|
|
|
if len(caller) == 4 && len(caller) > 0 {
|
|
|
utils.Logger.Printf("Train Information: %s, MessageType: PAD , LocationCode: %c, Connected: %s, RecordFileName:%s", trainInfo, caller[3], callee, DstFile)
|
|
|
} else {
|
|
|
@@ -269,37 +290,38 @@ func HandleAMI(event map[string]string) {
|
|
|
xmlFileName := strings.Replace(rcdFileName, "wav", "xml", 1)
|
|
|
xmlFilePath := path + "/" + xmlFileName
|
|
|
|
|
|
- lfshook.NewLogger().Infof("Train info= xml path============%s===============", xmlFilePath)
|
|
|
+ //lfshook.NewLogger().Infof("Train info= xml path============%s===============", xmlFilePath)
|
|
|
+
|
|
|
+ utils.LoggerDebug.Printf("Write record info xml : %s !", xmlFilePath)
|
|
|
err := active.GenerateXML(xmlFilePath)
|
|
|
if err != nil {
|
|
|
- lfshook.NewLogger().Infof("Generate recording XML err:%+v", err)
|
|
|
+ //lfshook.NewLogger().Infof("Generate recording XML err:%+v", err)
|
|
|
+ utils.LoggerDebug.Printf("Write record info xml : %s ERR: %+v ", xmlFilePath, err)
|
|
|
+ break
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- lfshook.NewLogger().Infof("No files to upload!!!")
|
|
|
+ //lfshook.NewLogger().Infof("No files to upload!!!")
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
case "Hangup":
|
|
|
|
|
|
- lfshook.NewLogger().Infof("%s", event["Event"])
|
|
|
+ //lfshook.NewLogger().Infof("%s", event["Event"])
|
|
|
//OCC answer PAD, hangup, redirect the next PAD to OCC
|
|
|
if utils.IsIO(event["CallerIDNum"]) && (event["ConnectedLineNum"] == "ano1" || event["ConnectedLineNum"] == "ano8") && event["Context"] == "default" {
|
|
|
- lfshook.NewLogger().Infof("Hangup OCC-PAD event: %+v", event)
|
|
|
-
|
|
|
- // OCC hangup detected, hangup other running channels
|
|
|
- runningTaskName := InterruptRunningTask("PAD-OCC")
|
|
|
- if runningTaskName != "" {
|
|
|
- time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
- }
|
|
|
|
|
|
+ utils.LoggerDebug.Printf("Check PAD-OCC queue if there are PADs need to be redirect to OCC !")
|
|
|
res, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
if res == nil {
|
|
|
+ utils.LoggerDebug.Printf("Check PAD-OCC queue , return nill . exit !")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if res.Calls == "0" { //OCC queue is empty
|
|
|
+ utils.LoggerDebug.Printf("Check PAD-OCC queue no PAD now ! Send PAD-OCC end to STC .")
|
|
|
+
|
|
|
alstatus.OccPad("end")
|
|
|
priority.OCCAnswer = 0
|
|
|
priority.PADOccStart = 0
|
|
|
@@ -322,7 +344,14 @@ func HandleAMI(event map[string]string) {
|
|
|
//break
|
|
|
} else { //OCC queue is not empty
|
|
|
|
|
|
- time.Sleep(time.Millisecond * 100) //wait io idle
|
|
|
+ utils.LoggerDebug.Printf("PAD goto OCC , interrupt other task !")
|
|
|
+ // OCC hangup detected, hangup other running channels
|
|
|
+ runningTaskName := InterruptRunningTask("PAD-OCC")
|
|
|
+ if runningTaskName != "" {
|
|
|
+ time.Sleep(time.Millisecond * 100) //wait endpoint release
|
|
|
+ }
|
|
|
+
|
|
|
+ //time.Sleep(time.Millisecond * 100) //wait io idle
|
|
|
//lfshook.NewLogger().Infof("====Start OCC-PAD===next==%+v", res)
|
|
|
if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
time.Sleep(time.Second)
|
|
|
@@ -331,21 +360,25 @@ func HandleAMI(event map[string]string) {
|
|
|
if res.Entrys != nil {
|
|
|
for _, chanEntry := range res.Entrys {
|
|
|
lfshook.NewLogger().Infof("PAD answered by OCC1 pos:%s chan:%s", chanEntry.Position, chanEntry.Channel)
|
|
|
+
|
|
|
if chanEntry.Position == "1" {
|
|
|
PADChan = chanEntry.Channel
|
|
|
+ utils.LoggerDebug.Printf("PAD-OCC , Get the first PAD(%s) in the queue !", PADChan)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if PADChan != "" {
|
|
|
Ext := strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0]
|
|
|
-
|
|
|
alstatus.AlarmStatus(Ext, "connect")
|
|
|
+
|
|
|
+ utils.LoggerDebug.Printf("PAD goto OCC1 , redirect %s to OCC1 !", PADChan)
|
|
|
go RedirectInQueue(PADChan, "1411", "pad-page-occ-icp", Ext) //PAD Page(OCC+ICPs)
|
|
|
|
|
|
go Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
|
|
|
} else {
|
|
|
lfshook.NewLogger().Infof("OCC-QueueStatus PADCchan NULL")
|
|
|
+ utils.LoggerDebug.Printf("PAD-OCC , OCC Queue Status PADCchan return NULL .")
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
@@ -358,14 +391,16 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("PAD answered by OCC1 pos:%s chan:%s", chanEntry.Position, chanEntry.Channel)
|
|
|
if chanEntry.Position == "1" {
|
|
|
PADChan = chanEntry.Channel
|
|
|
+ utils.LoggerDebug.Printf("PAD-OCC , Get the first PAD(%s) in the queue !", PADChan)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if PADChan != "" {
|
|
|
Ext := strings.Split(strings.Split(res.Entrys[0].Channel, "/")[1], "-")[0]
|
|
|
-
|
|
|
alstatus.AlarmStatus(Ext, "connect")
|
|
|
+
|
|
|
+ utils.LoggerDebug.Printf("PAD goto OCC8 , redirect %s to OCC8 !", PADChan)
|
|
|
go RedirectInQueue(PADChan, "1481", "pad-page-occ-icp", Ext) //PAD Page(OCC+ICPs)
|
|
|
|
|
|
go Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC1
|
|
|
@@ -412,6 +447,7 @@ func HandleAMI(event map[string]string) {
|
|
|
res, _ := QueueStatus("0300", "") // check ICP queue ,if empty PAD end
|
|
|
res1, _ := QueueStatus("0301", "") // check OCC queue ,if empty PAD end
|
|
|
if res == nil || res1 == nil {
|
|
|
+ utils.LoggerDebug.Printf("PAD Hangup , check ICP|OCC queue return nil, exit.")
|
|
|
return
|
|
|
}
|
|
|
lfshook.NewLogger().Infof("===Hangup PAD====== ICP Queue calls:%s OCC Queue calls:%s", res.Calls, res1.Calls)
|
|
|
@@ -469,6 +505,7 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Infof("=========%s", event["Event"])
|
|
|
|
|
|
if priority.OCCAnswer == 1 && event["Queue"] == "0300" { //New PAD Goto the OCC queue in the first time, if OCC answered
|
|
|
+ utils.LoggerDebug.Printf("Redirect PAD %s to OCC queue .", event["CallerIDNum"])
|
|
|
alstatus.AlarmStatus(event["CallerIDNum"], "queue") //send status to STC
|
|
|
go RedirectInQueue(event["CallerIDNum"], "0301", "queues-occ", event["CallerIDNum"])
|
|
|
break
|
|
|
@@ -493,14 +530,11 @@ func HandleAMI(event map[string]string) {
|
|
|
if ok {
|
|
|
//lfshook.NewLogger().Infof("=1==QueueCallerJoin===runing:%d=====toRun:=%d==Status:%s", taskTmp, toRunpriority, event["ChannelStateDesc"])
|
|
|
if taskTmp.Priority < toRunpriority { //higher priority task running ,do not set timer
|
|
|
+ utils.LoggerDebug.Printf("The First PAD %s enter ICP queue , %s running do not set PAD timeout.", taskTmp.RunType, event["CallerIDNum"])
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //lfshook.NewLogger().Infof("==2=QueueCallerJoin===runing:%d=====toRun:=%d==Status:%s", taskTmp, toRunpriority, event["ChannelStateDesc"])
|
|
|
-
|
|
|
- //if (priority.RunningTypePriority > toRunpriority || priority.RunningTypePriority == 0) && event["ChannelStateDesc"] != "Up" {
|
|
|
- //active.SetTimer = true
|
|
|
//lfshook.NewLogger().Logger.Infof("=========Start PAD timer !=============")
|
|
|
if active.QueueTimer != nil {
|
|
|
if active.QueueTimer.Stop() {
|
|
|
@@ -509,7 +543,8 @@ func HandleAMI(event map[string]string) {
|
|
|
lfshook.NewLogger().Logger.Infof("=========Release PAD timer false ! ============")
|
|
|
}
|
|
|
}
|
|
|
- lfshook.NewLogger().Logger.Infof("=========Start PAD timer !======%d=======", active.PADTimeout)
|
|
|
+ //lfshook.NewLogger().Logger.Infof("=========Start PAD timer !======%d=======", active.PADTimeout)
|
|
|
+ utils.LoggerDebug.Printf("The first PAD %s enter ICP queue , set PAD timeout %d sec .", event["CallerIDNum"], active.PADTimeout)
|
|
|
active.QueueTimer = time.AfterFunc(time.Duration(active.PADTimeout)*time.Second, func() { // check the PAD 30s timeout
|
|
|
//active.QueueTimer = time.AfterFunc(30*time.Second, func() { // check the PAD 30s timeout
|
|
|
//if both not active , return
|
|
|
@@ -541,26 +576,13 @@ func HandleAMI(event map[string]string) {
|
|
|
for _, caller := range resCaller.Entrys {
|
|
|
priority.ICPAnswer = 0
|
|
|
//lfshook.NewLogger().Infof("====QueueCallerJoin==QueueTimer===%s", event["Event"])
|
|
|
- lfshook.NewLogger().Infof("Redirect to 0301 extension:%s Pos:%s", caller.CallerIDNum, caller.Position)
|
|
|
+ //lfshook.NewLogger().Infof("Redirect to 0301 extension:%s Pos:%s", caller.CallerIDNum, caller.Position)
|
|
|
//order by pos
|
|
|
+ utils.LoggerDebug.Printf("Redirect %s to OCC queue Pos:%s", caller.CallerIDNum, caller.Position)
|
|
|
RedirectInQueue(caller.CallerIDNum, "0301", "queues-occ", caller.CallerIDNum) // redirect All ICP-PAD redirect to OCC queue
|
|
|
time.Sleep(time.Millisecond * 100) //200 ms delay
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //==============test info =====================
|
|
|
- /*
|
|
|
- time.Sleep(2 * time.Second)
|
|
|
- occque, err1 := QueueStatus("0301", "") // check ICP queue, get entries
|
|
|
- if err1 != nil {
|
|
|
- lfshook.NewLogger().Infof("ICP QueueStatus err:%+v", err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- for _, caller := range occque.Entrys {
|
|
|
- lfshook.NewLogger().Infof("Q301====666666=SetPadTimer= entry:%s=Pos:%s==", caller.CallerIDNum, caller.Position)
|
|
|
- }*/
|
|
|
-
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -573,10 +595,8 @@ func HandleAMI(event map[string]string) {
|
|
|
//PAD Page OCC+ICPs;
|
|
|
if utils.IsPAIU(event["CallerIDNum"]) && event["Queue"] == "0301" && priority.OCCAnswer == 0 { // The first PAD to OCC ,caller is PAD
|
|
|
|
|
|
- active.WaitTaskCreate("PAD-OCC")
|
|
|
- if active.TaskCreating == "" {
|
|
|
- active.TaskCreating = "PAD-OCC"
|
|
|
- }
|
|
|
+ utils.LoggerDebug.Printf("The first PAD to OCC queue .")
|
|
|
+ WaitTaskCreate("PAD-OCC")
|
|
|
|
|
|
if priority.CheckPriority("PAD-OCC") {
|
|
|
|
|
|
@@ -589,20 +609,20 @@ func HandleAMI(event map[string]string) {
|
|
|
|
|
|
time.Sleep(time.Millisecond * 300)
|
|
|
|
|
|
- if active.TrainDevide == 0 { //列车没有断开
|
|
|
- if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
-
|
|
|
- alstatus.AlarmStatus(event["CallerIDNum"], "connect")
|
|
|
- go RedirectInQueue(event["Channel"], "1411", "pad-page-occ-icp", event["CallerIDNum"]) //PAD Page(OCC+ICPs)
|
|
|
- go Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
|
|
|
-
|
|
|
- } else if active.ActivedCab == "8" && ExtenStatus("1481") == "Idle" {
|
|
|
+ //if active.TrainDevide == 0 { //列车没有断开
|
|
|
+ if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
+ utils.LoggerDebug.Printf("PAD %s goto OCC1 .", event["CallerIDNum"])
|
|
|
+ alstatus.AlarmStatus(event["CallerIDNum"], "connect")
|
|
|
+ go RedirectInQueue(event["Channel"], "1411", "pad-page-occ-icp", event["CallerIDNum"]) //PAD Page(OCC+ICPs)
|
|
|
+ go Dial("0401", "0512", "pad-rule-pacus-occ", "ano1", "ano1", "1") // PACUs dial OCC1
|
|
|
|
|
|
- alstatus.AlarmStatus(event["CallerIDNum"], "connect")
|
|
|
- go RedirectInQueue(event["Channel"], "1481", "pad-page-occ-icp", event["CallerIDNum"]) //PAD Page(OCC+ICPs)
|
|
|
- go Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC8
|
|
|
- }
|
|
|
- } else { //列车断开模式下
|
|
|
+ } else if active.ActivedCab == "8" && ExtenStatus("1481") == "Idle" {
|
|
|
+ utils.LoggerDebug.Printf("PAD %s goto OCC8 .", event["CallerIDNum"])
|
|
|
+ alstatus.AlarmStatus(event["CallerIDNum"], "connect")
|
|
|
+ go RedirectInQueue(event["Channel"], "1481", "pad-page-occ-icp", event["CallerIDNum"]) //PAD Page(OCC+ICPs)
|
|
|
+ go Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC8
|
|
|
+ }
|
|
|
+ /*} else { //列车断开模式下
|
|
|
if active.ActivedCab == "1" && ExtenStatus("1411") == "Idle" { //check active and OCC status
|
|
|
|
|
|
alstatus.AlarmStatus(event["CallerIDNum"], "connect")
|
|
|
@@ -615,20 +635,20 @@ func HandleAMI(event map[string]string) {
|
|
|
go RedirectInQueue(event["Channel"], "1481", "pad-page-occ-icp", event["CallerIDNum"]) //PAD Page(OCC+ICPs)
|
|
|
go Dial("0401", "0512", "pad-rule-pacus-occ", "ano8", "ano8", "8") // PACUs dial OCC8
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
} else {
|
|
|
lfshook.NewLogger().Infof("====PAD-OCC Priority false===")
|
|
|
}
|
|
|
|
|
|
- time.Sleep(1 * time.Second)
|
|
|
- if active.TaskCreating == "PAD-OCC" {
|
|
|
- active.TaskCreating = ""
|
|
|
+ time.Sleep(2 * time.Second)
|
|
|
+ if priority.TaskCreating == "PAD-OCC" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
}
|
|
|
}
|
|
|
|
|
|
case "ConfbridgeJoin":
|
|
|
lfshook.NewLogger().Infof("=========%+v", event["Event"])
|
|
|
- lfshook.NewLogger().Infof("=========%+v", event)
|
|
|
+ //lfshook.NewLogger().Infof("=========%+v", event)
|
|
|
//set priority and send PA status msg
|
|
|
switch event["CallerIDName"] {
|
|
|
case "EMG":
|
|
|
@@ -642,10 +662,11 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
- if active.TaskCreating == "EMG" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
+ utils.LoggerDebug.Printf("%s Runing , Set %s task info %+v .", event["CallerIDName"], event["CallerIDName"], task)
|
|
|
priority.RegistryTask.Register("EMG", task)
|
|
|
+ if priority.TaskCreating == "EMG" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
|
|
|
alstatus.PaStatus("", "EMG", "start")
|
|
|
//check PAD timer
|
|
|
@@ -672,12 +693,12 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
- if active.TaskCreating == "SPC" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("%s Runing , Set %s task info %+v .", event["CallerIDName"], event["CallerIDName"], task)
|
|
|
priority.RegistryTask.Register("SPC", task)
|
|
|
alstatus.PaStatus("", "SPC", "start")
|
|
|
+ if priority.TaskCreating == "SPC" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.SPC.Priority {
|
|
|
@@ -703,12 +724,13 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
- if active.TaskCreating == "DCS" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("%s Runing , Set %s task info %+v .", event["CallerIDName"], event["CallerIDName"], task)
|
|
|
priority.RegistryTask.Register("DCS", task)
|
|
|
alstatus.PaStatus("", "DCS", "start")
|
|
|
+ if priority.TaskCreating == "DCS" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
+
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.DCS.Priority {
|
|
|
if active.QueueTimer != nil {
|
|
|
@@ -734,12 +756,12 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
- if active.TaskCreating == "STN" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("%s Runing , Set %s task info %+v .", event["CallerIDName"], event["CallerIDName"], task)
|
|
|
priority.RegistryTask.Register("STN", task)
|
|
|
alstatus.PaStatus("", "STN", "start")
|
|
|
+ if priority.TaskCreating == "STN" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.STN.Priority {
|
|
|
@@ -766,12 +788,12 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
- if active.TaskCreating == "CHK" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("%s Runing , Set %s task info %+v .", event["CallerIDName"], event["CallerIDName"], task)
|
|
|
priority.RegistryTask.Register("CHK", task)
|
|
|
alstatus.PaStatus("", "CHK", "start")
|
|
|
+ if priority.TaskCreating == "CHK" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.CHK.Priority {
|
|
|
@@ -796,12 +818,12 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
- if active.TaskCreating == "VOL" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
-
|
|
|
+ utils.LoggerDebug.Printf("%s Runing , Set %s task info %+v .", event["CallerIDName"], event["CallerIDName"], task)
|
|
|
priority.RegistryTask.Register("VOL", task)
|
|
|
alstatus.PaStatus("", "VOL", "start")
|
|
|
+ if priority.TaskCreating == "VOL" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.VOL.Priority {
|
|
|
@@ -826,9 +848,6 @@ func HandleAMI(event map[string]string) {
|
|
|
*/
|
|
|
//Send PA start msg to STC
|
|
|
if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0500" { // PA start
|
|
|
- if active.TaskCreating == "PA" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "PA", "start")
|
|
|
//================================
|
|
|
@@ -840,7 +859,11 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
+ utils.LoggerDebug.Printf("PA Runing , Set PA task info %+v .", task)
|
|
|
priority.RegistryTask.Register("PA", task)
|
|
|
+ if priority.TaskCreating == "PA" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.PA.Priority {
|
|
|
@@ -856,10 +879,6 @@ func HandleAMI(event map[string]string) {
|
|
|
break
|
|
|
} else if utils.IsIO(event["CallerIDNum"]) && event["Exten"] == "0501" { //CPA start
|
|
|
|
|
|
- if active.TaskCreating == "CPA" {
|
|
|
- active.TaskCreating = ""
|
|
|
- }
|
|
|
-
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "CPA", "start")
|
|
|
//================================
|
|
|
task := priority.TaskInfo{
|
|
|
@@ -870,8 +889,11 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: event["Conference"],
|
|
|
Running: true,
|
|
|
}
|
|
|
+ utils.LoggerDebug.Printf("CPA Runing , Set CPA task info %+v .", task)
|
|
|
priority.RegistryTask.Register("CPA", task)
|
|
|
-
|
|
|
+ if priority.TaskCreating == "CPA" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.CPA.Priority {
|
|
|
if active.QueueTimer != nil {
|
|
|
@@ -890,7 +912,7 @@ func HandleAMI(event map[string]string) {
|
|
|
//PAD chanspy ICP1
|
|
|
//ICP8 call PAD
|
|
|
if event["ConnectedLineNum"] == "ani1" && event["Exten"] == "0511" { //PAD answered by ICP; PACUs connected ICP1
|
|
|
- lfshook.NewLogger().Infof("====PAD answered by ICP1:%s=====", event["ConnectedLineName"])
|
|
|
+ //lfshook.NewLogger().Infof("====PAD answered by ICP1:%s=====", event["ConnectedLineName"])
|
|
|
alstatus.AlarmStatus(event["ConnectedLineName"], "connect")
|
|
|
|
|
|
//================================
|
|
|
@@ -903,11 +925,11 @@ func HandleAMI(event map[string]string) {
|
|
|
Running: true,
|
|
|
}
|
|
|
priority.RegistryTask.Register("PAD-ICP", task)
|
|
|
- if active.TaskCreating == "PAD-ICP" {
|
|
|
- active.TaskCreating = ""
|
|
|
+ if priority.TaskCreating == "PAD-ICP" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
}
|
|
|
-
|
|
|
- lfshook.NewLogger().Infof("=========PAD-ICP answer==ListAll===%+v", priority.RegistryTask.ListAll())
|
|
|
+ utils.LoggerDebug.Printf("PAD %s answered by ICP1 , set task info :%+v .", event["ConnectedLineName"], task)
|
|
|
+ //lfshook.NewLogger().Infof("=========PAD-ICP answer==ListAll===%+v", priority.RegistryTask.ListAll())
|
|
|
go RedirectInQueue(event["ConnectedLineName"], "2311", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) ICP1
|
|
|
|
|
|
if ExtenStatus("2381") == "Idle" {
|
|
|
@@ -928,11 +950,11 @@ func HandleAMI(event map[string]string) {
|
|
|
Running: true,
|
|
|
}
|
|
|
priority.RegistryTask.Register("PAD-ICP", task)
|
|
|
- if active.TaskCreating == "PAD-ICP" {
|
|
|
- active.TaskCreating = ""
|
|
|
+ if priority.TaskCreating == "PAD-ICP" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
}
|
|
|
-
|
|
|
- lfshook.NewLogger().Infof("=========PAD-ICP answer==ListAll===%+v", priority.RegistryTask.ListAll())
|
|
|
+ utils.LoggerDebug.Printf("PAD %s answered by ICP8 , set task info :%+v .", event["ConnectedLineName"], task)
|
|
|
+ //lfshook.NewLogger().Infof("=========PAD-ICP answer==ListAll===%+v", priority.RegistryTask.ListAll())
|
|
|
go RedirectInQueue(event["ConnectedLineName"], "2381", "chanspy-rule-whisper", event["ConnectedLineName"]) //PAD chanspy(EqW) ICP8
|
|
|
|
|
|
if ExtenStatus("2311") == "Idle" {
|
|
|
@@ -955,7 +977,10 @@ func HandleAMI(event map[string]string) {
|
|
|
Running: true,
|
|
|
}
|
|
|
priority.RegistryTask.Register("PAD-OCC", task)
|
|
|
-
|
|
|
+ if priority.TaskCreating == "PAD-OCC" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
+ utils.LoggerDebug.Printf("PAD %s answered by OCC , set task info :%+v .", event["CallerIDNum"], task)
|
|
|
break
|
|
|
}
|
|
|
|
|
|
@@ -1150,10 +1175,12 @@ func HandleAMI(event map[string]string) {
|
|
|
ConfbridgeID: "",
|
|
|
Running: true,
|
|
|
}
|
|
|
- active.TaskCreating = ""
|
|
|
- priority.RegistryTask.Register("C2C", task)
|
|
|
|
|
|
+ priority.RegistryTask.Register("C2C", task)
|
|
|
alstatus.PaStatus(event["CallerIDNum"], "C2C", "start")
|
|
|
+ if priority.TaskCreating == "C2C" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
+ }
|
|
|
|
|
|
//check PAD timer
|
|
|
if priority.AllTasks.PADOCC.Priority > priority.AllTasks.C2C.Priority {
|
|
|
@@ -1194,8 +1221,8 @@ func HandleAMI(event map[string]string) {
|
|
|
Running: true,
|
|
|
}
|
|
|
priority.RegistryTask.Register("PAD-TMS", task)
|
|
|
- if active.TaskCreating == "PAD-TMS" {
|
|
|
- active.TaskCreating = ""
|
|
|
+ if priority.TaskCreating == "PAD-TMS" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
}
|
|
|
lfshook.NewLogger().Infof("=========PAD-TMS answer==ListAll===%+v", priority.RegistryTask.ListAll())
|
|
|
|
|
|
@@ -1258,8 +1285,8 @@ func HandleAMI(event map[string]string) {
|
|
|
if utils.IsIO(event["CallerIDNum"]) && utils.IsPAIU(event["ConnectedLineNum"]) {
|
|
|
if priority.PADOccStart == 0 {
|
|
|
|
|
|
- if active.TaskCreating == "PAD-OCC" {
|
|
|
- active.TaskCreating = ""
|
|
|
+ if priority.TaskCreating == "PAD-OCC" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
}
|
|
|
|
|
|
alstatus.OccPad("start")
|
|
|
@@ -1311,8 +1338,8 @@ func HandleAMI(event map[string]string) {
|
|
|
Running: true,
|
|
|
}
|
|
|
priority.RegistryTask.Register("PAD-TMS", task)
|
|
|
- if active.TaskCreating == "PAD-TMS" {
|
|
|
- active.TaskCreating = ""
|
|
|
+ if priority.TaskCreating == "PAD-TMS" {
|
|
|
+ priority.TaskCreating = ""
|
|
|
}
|
|
|
lfshook.NewLogger().Infof("=========PAD-TMS answer==ListAll===%+v", priority.RegistryTask.ListAll())
|
|
|
|