6 Revize fd504e2df7 ... 2b173de9ea

Autor SHA1 Zpráva Datum
  root 2b173de9ea update před 3 týdny
  root d526318852 Merge branch 'test-pri' into dev před 4 týdny
  root efe0a8e131 Revert "test" před 4 týdny
  root c819d4a63a update CPA před 4 týdny
  root 2fec841da5 update před 4 týdny
  root 83518917a6 test před 4 týdny

+ 43 - 5
internal/app/ami/action/call.go

@@ -227,9 +227,12 @@ func InterruptRunningTask(toRunTask string) string {
 		time.Sleep(time.Millisecond * 200)
 	case "EMG":
 		//kick EMG members
-		if toRunTask != "C2C" {
+		if toRunTask == "EMG" {
+			ConfbridgeKick(task.ConfbridgeID, "all")
+			//alstatus.PaStatus("", "EMG", "end")
+		} else if toRunTask != "C2C" {
 			EMGConfbridgeKick(task.ConfbridgeID)
-			alstatus.PaStatus("", "EMG", "end")
+			//alstatus.PaStatus("", "EMG", "end")
 		} else if toRunTask == "C2C" {
 			HangupICP()
 			//alstatus.PaStatus("", "EMG", "end")
@@ -297,6 +300,19 @@ func InterruptRunningTask(toRunTask string) string {
 		if priority.PADStart == 1 {
 			alstatus.PaStatus("", "PAD", "end")
 			priority.PADStart = 0
+
+			//check resume
+			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
+			if ok {
+				if taskName == "EMG" {
+					EMGConfbridgeReinvite(task.ConfbridgeID)
+					//alstatus.PaStatus("", "EMG", "start")
+				} else if taskName == "CPA" {
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
+				}
+			}
 		}
 
 	case "PAD-OCC": // Interrupt PAD-OCC task running,
@@ -683,12 +699,21 @@ func CPAConfbridgeKick(confnum string) (res map[string]string, err error) {
 	return res, nil
 }
 
-func CPAConfbridgeReinvite(confID string) {
+func CPAConfbridgeReinvite(confID string) bool {
+
 	utils.LoggerDebug.Printf("CPA CPAConfbridgeReinvite , resume CPA .")
-	time.Sleep(time.Millisecond * 500)
+	time.Sleep(time.Millisecond * 100)
 	for _, ext := range Speakers {
+		if utils.IsICP(ext) {
+			if priority.CABInterrupt == 1 || priority.PAInterrupt == 1 {
+				utils.LoggerDebug.Printf("CPA CPAConfbridgeReinvite , Get PA/CABCAB Interrupt resume CPA , ignore %s continue .", ext)
+				continue
+			}
+		}
+
 		ConfbridgeReinvite(ext, "call-speakers-cpa", confID)
 	}
+	return true
 }
 
 func EMGConfbridgeKick(confnum string) (res map[string]string, err error) {
@@ -707,9 +732,17 @@ func EMGConfbridgeKick(confnum string) (res map[string]string, err error) {
 }
 
 func EMGConfbridgeReinvite(confID string) {
+
 	utils.LoggerDebug.Printf("EMG ConfbridgeReinvite , resume EMG .")
-	time.Sleep(time.Millisecond * 500)
+	time.Sleep(time.Millisecond * 100)
 	for _, ext := range Speakers {
+		if utils.IsICP(ext) {
+			if priority.CABInterrupt == 1 || priority.PAInterrupt == 1 {
+				utils.LoggerDebug.Printf("EMG ConfbridgeReinvite , Get PA/CABCAB Interrupt resume EMG , ignore %s continue .", ext)
+				continue
+			}
+		}
+
 		ConfbridgeReinvite(ext, "call-speakers-emg", confID)
 	}
 }
@@ -767,6 +800,11 @@ func ConfbridgeReinvite(src, context, confID string) {
 
 func ICPConfbridgeReinvite(confID, paType string) {
 
+	if priority.CABInterrupt == 1 || priority.PAInterrupt == 1 {
+		utils.LoggerDebug.Printf("ICPConfbridgeReinvite, Get PA/CABCAB Interrupt resume %s faild .", paType)
+		return
+	}
+
 	switch paType {
 	case "PAD-OCC":
 		go DialICP("8", "2311", "confbridge-join", confID, "1") //ICP1---call

+ 136 - 57
internal/app/ami/action/index.go

@@ -36,6 +36,8 @@ func HandleAMI(event map[string]string) {
 			case "#":
 				//lfshook.NewLogger().Infof("===PA interrupt PAD====== ")
 				utils.LoggerDebug.Printf("Get DTMF '#', PA interrupt other !")
+				priority.PAInterrupt = 1
+
 				runningTaskName := InterruptRunningTask("PA")
 				if runningTaskName != "" {
 					time.Sleep(time.Millisecond * 200) //wait endpoint release
@@ -43,6 +45,8 @@ func HandleAMI(event map[string]string) {
 			case "*": //Cab cab interrupt PAD
 				//lfshook.NewLogger().Infof("===Cab cab interrupt PAD and====== ")
 				utils.LoggerDebug.Printf("Get DTMF '*', CabCab interrupt other !")
+				priority.CABInterrupt = 1
+
 				runningTaskName := InterruptRunningTask("C2C")
 				//Hangup("2311")
 				//Hangup("2381")
@@ -83,11 +87,17 @@ func HandleAMI(event map[string]string) {
 					}
 
 				} else {
+					if priority.TaskCreating == "PA" {
+						utils.LoggerDebug.Printf("PA : Clean priority.TaskCreating = '' !")
+						priority.TaskCreating = ""
+					}
+					utils.LoggerDebug.Printf("PA calling failed , check priority return false !")
 					Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
 				}
 
-				time.Sleep(2 * time.Second)
+				time.Sleep(1 * time.Second)
 				if priority.TaskCreating == "PA" {
+					utils.LoggerDebug.Printf("PA : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 			} else if utils.IsIO(event["CallerIDNum"]) { // CPA
@@ -106,10 +116,25 @@ func HandleAMI(event map[string]string) {
 						utils.LoggerDebug.Printf("CPA calling  , ActivedCab = %s !", active.ActivedCab)
 						if active.ActivedCab == "" { //No active Signal on both side,Hangup caller
 							Hangup(event["CallerIDNum"])
+							if priority.TaskCreating == "CPA" {
+								utils.LoggerDebug.Printf("CPA : Clean priority.TaskCreating = '' !")
+								priority.TaskCreating = ""
+							}
+							return
 						} else if active.ActivedCab == "1" && event["CallerIDNum"] == "1411" {
 							Hangup(event["CallerIDNum"])
+							if priority.TaskCreating == "CPA" {
+								utils.LoggerDebug.Printf("CPA : Clean priority.TaskCreating = '' !")
+								priority.TaskCreating = ""
+							}
+							return
 						} else if active.ActivedCab == "8" && event["CallerIDNum"] == "1481" {
 							Hangup(event["CallerIDNum"])
+							if priority.TaskCreating == "CPA" {
+								utils.LoggerDebug.Printf("CPA : Clean priority.TaskCreating = '' !")
+								priority.TaskCreating = ""
+							}
+							return
 						}
 					}
 
@@ -119,12 +144,17 @@ func HandleAMI(event map[string]string) {
 						time.Sleep(time.Millisecond * 100) //wait endpoint release
 					}
 				} else {
+					if priority.TaskCreating == "CPA" {
+						utils.LoggerDebug.Printf("CPA : Clean priority.TaskCreating = '' !")
+						priority.TaskCreating = ""
+					}
 					utils.LoggerDebug.Printf("CPA calling failed , check priority return false !")
 					Hangup(event["CallerIDNum"]) //lowwer priority ,hangup caller
 				}
 
-				time.Sleep(2 * time.Second)
+				time.Sleep(1 * time.Second)
 				if priority.TaskCreating == "CPA" {
+					utils.LoggerDebug.Printf("CPA : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 			}
@@ -146,29 +176,28 @@ func HandleAMI(event map[string]string) {
 						if runningTaskName != "" {
 							time.Sleep(time.Millisecond * 100) //wait endpoint release
 						}
-
+					} //else {
+					//lfshook.NewLogger().Infof("CabCab  hangup other the one caller %s", event["CallerIDNum"])
+					time.Sleep(time.Millisecond * 100) //wait endpoint release
+					utils.LoggerDebug.Printf("%s Start CabCab ,check and hangup the other ICP first", event["CallerIDNum"])
+					if event["CallerIDNum"] == "2311" {
+						Hangup("2381")
 					} else {
-						//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 {
-							Hangup("2311")
-						}
+						Hangup("2311")
 					}
+					//}
 				}
 
 			} else { // hangup caller; C2C start failed
 				//lfshook.NewLogger().Infof("CabCab  hangup caller %s", event["CallerIDNum"])
+				if priority.TaskCreating == "C2C" {
+					utils.LoggerDebug.Printf("C2C : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
 				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
@@ -337,7 +366,9 @@ func HandleAMI(event map[string]string) {
 					if taskName == "EMG" {
 						EMGConfbridgeReinvite(task.ConfbridgeID)
 					} else if taskName == "CPA" {
-						CPAConfbridgeReinvite(task.ConfbridgeID)
+						if CPAConfbridgeReinvite(task.ConfbridgeID) {
+							alstatus.PaStatus("", "CPA", "start")
+						}
 					}
 				}
 
@@ -502,10 +533,11 @@ func HandleAMI(event map[string]string) {
 						if ok {
 							if taskName == "EMG" {
 								EMGConfbridgeReinvite(task.ConfbridgeID)
-								alstatus.PaStatus("", "EMG", "start")
+								//alstatus.PaStatus("", "EMG", "start")
 							} else if taskName == "CPA" {
-								CPAConfbridgeReinvite(task.ConfbridgeID)
-								alstatus.PaStatus("", "CPA", "start")
+								if CPAConfbridgeReinvite(task.ConfbridgeID) {
+									alstatus.PaStatus("", "CPA", "start")
+								}
 							}
 						}
 					}
@@ -517,6 +549,29 @@ func HandleAMI(event map[string]string) {
 			}
 		}
 
+		//ICP 按下CABCAB,之后按RST取消,CABCAB建立失败
+		if utils.IsICP(event["CallerIDNum"]) && event["Exten"] == "0400" && event["ChannelStateDesc"] == "Ringing" {
+			utils.LoggerDebug.Printf("CABCAB Canceled !")
+
+			//time.Sleep(2 * time.Second)
+			if priority.TaskCreating == "C2C" {
+				utils.LoggerDebug.Printf("C2C : Clean priority.TaskCreating = '' !")
+				priority.TaskCreating = ""
+			}
+			//check resume
+			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
+			if ok {
+				if taskName == "EMG" {
+					EMGConfbridgeReinvite(task.ConfbridgeID)
+					//alstatus.PaStatus("", "EMG", "start")
+				} else if taskName == "CPA" {
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
+				}
+			}
+		}
+
 	case "QueueCallerJoin":
 		lfshook.NewLogger().Infof("=========%s", event["Event"])
 
@@ -654,11 +709,17 @@ func HandleAMI(event map[string]string) {
 				}
 
 			} else {
+				if priority.TaskCreating == "PAD-OCC" {
+					utils.LoggerDebug.Printf("PAD-OCC : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
+				utils.LoggerDebug.Printf("PAD-OCC calling failed , check priority return false !")
 				lfshook.NewLogger().Infof("====PAD-OCC Priority false===")
 			}
 
-			time.Sleep(2 * time.Second)
+			time.Sleep(1 * time.Second)
 			if priority.TaskCreating == "PAD-OCC" {
+				utils.LoggerDebug.Printf("PAD-OCC : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 		}
@@ -682,6 +743,7 @@ func HandleAMI(event map[string]string) {
 				utils.LoggerDebug.Printf("%s Runing , Set %s task info %+v .", event["CallerIDName"], event["CallerIDName"], task)
 				priority.RegistryTask.Register("EMG", task)
 				if priority.TaskCreating == "EMG" {
+					utils.LoggerDebug.Printf("EMG Connected : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 
@@ -714,6 +776,7 @@ func HandleAMI(event map[string]string) {
 				priority.RegistryTask.Register("SPC", task)
 				alstatus.PaStatus("", "SPC", "start")
 				if priority.TaskCreating == "SPC" {
+					utils.LoggerDebug.Printf("SPC Connected : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 
@@ -745,6 +808,7 @@ func HandleAMI(event map[string]string) {
 				priority.RegistryTask.Register("DCS", task)
 				alstatus.PaStatus("", "DCS", "start")
 				if priority.TaskCreating == "DCS" {
+					utils.LoggerDebug.Printf("DCS Connected : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 
@@ -777,6 +841,7 @@ func HandleAMI(event map[string]string) {
 				priority.RegistryTask.Register("STN", task)
 				alstatus.PaStatus("", "STN", "start")
 				if priority.TaskCreating == "STN" {
+					utils.LoggerDebug.Printf("STN Connected : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 
@@ -809,6 +874,7 @@ func HandleAMI(event map[string]string) {
 				priority.RegistryTask.Register("CHK", task)
 				alstatus.PaStatus("", "CHK", "start")
 				if priority.TaskCreating == "CHK" {
+					utils.LoggerDebug.Printf("CHK Connected : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 
@@ -839,6 +905,7 @@ func HandleAMI(event map[string]string) {
 				priority.RegistryTask.Register("VOL", task)
 				alstatus.PaStatus("", "VOL", "start")
 				if priority.TaskCreating == "VOL" {
+					utils.LoggerDebug.Printf("VOL Connected : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 
@@ -876,9 +943,12 @@ func HandleAMI(event map[string]string) {
 				ConfbridgeID: event["Conference"],
 				Running:      true,
 			}
+			priority.PAInterrupt = 0
+
 			utils.LoggerDebug.Printf("PA Runing , Set PA task info %+v .", task)
 			priority.RegistryTask.Register("PA", task)
 			if priority.TaskCreating == "PA" {
+				utils.LoggerDebug.Printf("PA Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 
@@ -912,6 +982,7 @@ func HandleAMI(event map[string]string) {
 			utils.LoggerDebug.Printf("CPA Runing , Set CPA task info %+v .", priority.RegistryTask.ListAll())
 
 			if priority.TaskCreating == "CPA" {
+				utils.LoggerDebug.Printf("CPA Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 			//check PAD timer
@@ -946,6 +1017,7 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.Register("PAD-ICP", task)
 			if priority.TaskCreating == "PAD-ICP" {
+				utils.LoggerDebug.Printf("PAD-ICP Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 			utils.LoggerDebug.Printf("PAD %s answered by ICP1 , set task info :%+v .", event["ConnectedLineName"], task)
@@ -971,6 +1043,7 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.Register("PAD-ICP", task)
 			if priority.TaskCreating == "PAD-ICP" {
+				utils.LoggerDebug.Printf("PAD-ICP Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 			utils.LoggerDebug.Printf("PAD %s answered by ICP8 , set task info :%+v .", event["ConnectedLineName"], task)
@@ -998,6 +1071,7 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.Register("PAD-OCC", task)
 			if priority.TaskCreating == "PAD-OCC" {
+				utils.LoggerDebug.Printf("PAD-OCC Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 			utils.LoggerDebug.Printf("PAD %s answered by OCC , set task info :%+v .", event["CallerIDNum"], task)
@@ -1017,10 +1091,11 @@ func HandleAMI(event map[string]string) {
 			if ok {
 				if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "EMG", "start")
+					//alstatus.PaStatus("", "EMG", "start")
 				} else if taskName == "CPA" {
-					CPAConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "CPA", "start")
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
 				}
 			}
 
@@ -1040,7 +1115,7 @@ func HandleAMI(event map[string]string) {
 			if ok {
 				if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "EMG", "start")
+					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1060,8 +1135,9 @@ func HandleAMI(event map[string]string) {
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					CPAConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "CPA", "start")
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
 				}
 			}
 
@@ -1080,11 +1156,12 @@ func HandleAMI(event map[string]string) {
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					CPAConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "CPA", "start")
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "EMG", "start")
+					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1103,11 +1180,11 @@ func HandleAMI(event map[string]string) {
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					CPAConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "CPA", "start")
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "EMG", "start")
 					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
@@ -1127,11 +1204,12 @@ func HandleAMI(event map[string]string) {
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					CPAConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "CPA", "start")
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "EMG", "start")
+					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1150,11 +1228,12 @@ func HandleAMI(event map[string]string) {
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					CPAConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "CPA", "start")
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "EMG", "start")
+					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 
@@ -1173,11 +1252,12 @@ func HandleAMI(event map[string]string) {
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
 				if taskName == "CPA" {
-					CPAConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "CPA", "start")
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
 				} else if taskName == "EMG" {
 					EMGConfbridgeReinvite(task.ConfbridgeID)
-					alstatus.PaStatus("", "EMG", "start")
+					//alstatus.PaStatus("", "EMG", "start")
 				}
 			}
 		}
@@ -1196,9 +1276,11 @@ func HandleAMI(event map[string]string) {
 				Running:      true,
 			}
 
+			priority.CABInterrupt = 0
 			priority.RegistryTask.Register("C2C", task)
 			alstatus.PaStatus(event["CallerIDNum"], "C2C", "start")
 			if priority.TaskCreating == "C2C" {
+				utils.LoggerDebug.Printf("C2C Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 
@@ -1242,6 +1324,7 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.Register("PAD-TMS", task)
 			if priority.TaskCreating == "PAD-TMS" {
+				utils.LoggerDebug.Printf("PAD-TMS Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 			lfshook.NewLogger().Infof("=========PAD-TMS answer==ListAll===%+v", priority.RegistryTask.ListAll())
@@ -1265,26 +1348,20 @@ func HandleAMI(event map[string]string) {
 
 			alstatus.PaStatus(event["CallerIDNum"], "C2C", "end")
 			priority.RegistryTask.StopAndUnregister("C2C")
-			time.Sleep(time.Millisecond * 300)
+			//time.Sleep(time.Millisecond * 100)
 			SetPadTimer()
 			//check resume
 			taskName, task, ok := priority.RegistryTask.HighestPriorityRunningTask1()
 			if ok {
-				ICPConfbridgeReinvite(task.ConfbridgeID, taskName)
-				//check resume
-				/*if taskName == "CPA" {
-					alstatus.PaStatus("", "CPA", "start")
-				} else if taskName == "EMG" {
-					alstatus.PaStatus("", "EMG", "start")
-				} else if taskName == "SPC" {
-					alstatus.PaStatus("", "SPC", "start")
-				} else if taskName == "DCS" {
-					alstatus.PaStatus("", "DCS", "start")
-				} else if taskName == "STN" {
-					alstatus.PaStatus("", "STN", "start")
-				} else if taskName == "CHK" {
-					alstatus.PaStatus("", "CHK", "start")
-				}*/
+				if taskName == "EMG" {
+					EMGConfbridgeReinvite(task.ConfbridgeID)
+				} else if taskName == "CPA" {
+					if CPAConfbridgeReinvite(task.ConfbridgeID) {
+						alstatus.PaStatus("", "CPA", "start")
+					}
+				} else {
+					ICPConfbridgeReinvite(task.ConfbridgeID, taskName)
+				}
 			}
 		}
 
@@ -1306,6 +1383,7 @@ func HandleAMI(event map[string]string) {
 			if priority.PADOccStart == 0 {
 
 				if priority.TaskCreating == "PAD-OCC" {
+					utils.LoggerDebug.Printf("PAD-OCC Connected : Clean priority.TaskCreating = '' !")
 					priority.TaskCreating = ""
 				}
 
@@ -1359,6 +1437,7 @@ func HandleAMI(event map[string]string) {
 			}
 			priority.RegistryTask.Register("PAD-TMS", task)
 			if priority.TaskCreating == "PAD-TMS" {
+				utils.LoggerDebug.Printf("PAD-TMS Connected : Clean priority.TaskCreating = '' !")
 				priority.TaskCreating = ""
 			}
 			lfshook.NewLogger().Infof("=========PAD-TMS answer==ListAll===%+v", priority.RegistryTask.ListAll())

+ 55 - 15
internal/app/stc/broadcast/stc-broadcast.go

@@ -183,12 +183,17 @@ func processPacket(packet []byte) {
 				}
 				StationAnn(packet)
 			} else {
+				if priority.TaskCreating == "STN" {
+					utils.LoggerDebug.Printf("STN : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
 				alstatus.PaStatus("", "STN", "refuse")
 			}
 		}
 
-		time.Sleep(3 * time.Second)
+		time.Sleep(1 * time.Second)
 		if priority.TaskCreating == "STN" {
+			utils.LoggerDebug.Printf("STN : Clean priority.TaskCreating = '' !")
 			priority.TaskCreating = ""
 		}
 
@@ -205,12 +210,17 @@ func processPacket(packet []byte) {
 				}
 				SpecialAnn(packet)
 			} else {
+				if priority.TaskCreating == "SPC" {
+					utils.LoggerDebug.Printf("SPC : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
 				alstatus.PaStatus("", "SPC", "refuse")
 			}
 		}
 
-		time.Sleep(3 * time.Second)
+		time.Sleep(1 * time.Second)
 		if priority.TaskCreating == "SPC" {
+			utils.LoggerDebug.Printf("SPC : Clean priority.TaskCreating = '' !")
 			priority.TaskCreating = ""
 		}
 
@@ -228,12 +238,17 @@ func processPacket(packet []byte) {
 				}
 				EmgMsg(packet)
 			} else {
+				if priority.TaskCreating == "EMG" {
+					utils.LoggerDebug.Printf("EMG : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
 				alstatus.PaStatus("", "EMG", "refuse")
 			}
 		}
 
-		time.Sleep(3 * time.Second)
+		time.Sleep(1 * time.Second)
 		if priority.TaskCreating == "EMG" {
+			utils.LoggerDebug.Printf("EMG : Clean priority.TaskCreating = '' !")
 			priority.TaskCreating = ""
 		}
 
@@ -254,13 +269,18 @@ func processPacket(packet []byte) {
 				}
 				DcsAnn(packet)
 			} else {
+				if priority.TaskCreating == "DCS" {
+					utils.LoggerDebug.Printf("DCS : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
 				alstatus.PaStatus("", "DCS", "refuse")
 			}
-		}
 
-		time.Sleep(3 * time.Second)
-		if priority.TaskCreating == "DCS" {
-			priority.TaskCreating = ""
+			time.Sleep(1 * time.Second)
+			if priority.TaskCreating == "DCS" {
+				utils.LoggerDebug.Printf("DCS : Clean priority.TaskCreating = '' !")
+				priority.TaskCreating = ""
+			}
 		}
 
 	case 0x09: // SELF CHECK
@@ -277,12 +297,17 @@ func processPacket(packet []byte) {
 				}
 				SelfCheck(packet)
 			} else {
+				if priority.TaskCreating == "CHK" {
+					utils.LoggerDebug.Printf("CHK : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
 				alstatus.PaStatus("", "CHK", "refuse")
 			}
 		}
 
-		time.Sleep(3 * time.Second)
+		time.Sleep(1 * time.Second)
 		if priority.TaskCreating == "CHK" {
+			utils.LoggerDebug.Printf("CHK : Clean priority.TaskCreating = '' !")
 			priority.TaskCreating = ""
 		}
 
@@ -299,12 +324,17 @@ func processPacket(packet []byte) {
 				}
 				ToneTest(packet)
 			} else {
+				if priority.TaskCreating == "VOL" {
+					utils.LoggerDebug.Printf("VOL : Clean priority.TaskCreating = '' !")
+					priority.TaskCreating = ""
+				}
 				alstatus.PaStatus("", "VOL", "refuse")
 			}
 		}
 
-		time.Sleep(3 * time.Second)
+		time.Sleep(1 * time.Second)
 		if priority.TaskCreating == "VOL" {
+			utils.LoggerDebug.Printf("VOL : Clean priority.TaskCreating = '' !")
 			priority.TaskCreating = ""
 		}
 
@@ -318,11 +348,11 @@ func processPacket(packet []byte) {
 		//PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
 		if handler == 0x01 { //answer PAD
 			if _, loaded := suppressedExts.LoadOrStore(key, struct{}{}); loaded {
-				utils.LoggerDebug.Printf("Suppressed duplicate ICP Alarm (handler=0x01) for PAD: within 2 seconds")
+				utils.LoggerDebug.Printf("Suppressed duplicate ICP Alarm (handler=0x01) for PAD: within 4 seconds")
 				return
 			}
 
-			time.AfterFunc(2*time.Second, func() {
+			time.AfterFunc(4*time.Second, func() {
 				suppressedExts.Delete(key)
 				utils.LoggerDebug.Printf("Suppression released .")
 			})
@@ -353,14 +383,19 @@ func processPacket(packet []byte) {
 
 				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(3 * time.Second)
+		time.Sleep(1 * time.Second)
 		if priority.TaskCreating == "PAD-TMS" {
+			utils.LoggerDebug.Printf("PAD-TMS : Clean priority.TaskCreating = '' !")
 			priority.TaskCreating = ""
 		}
 
@@ -383,11 +418,11 @@ func processPacket(packet []byte) {
 		//PAD---->Chanspy(WEq)-->ICP1;PAD--->Call---->ICP2
 		if handler == 0x01 {
 			if _, loaded := suppressedExts.LoadOrStore(key, struct{}{}); loaded {
-				utils.LoggerDebug.Printf("Suppressed duplicate ICP Alarm (handler=0x01) for PAD: within 2 seconds")
+				utils.LoggerDebug.Printf("Suppressed duplicate ICP Alarm (handler=0x01) for PAD: within 4 seconds")
 				return
 			}
 
-			time.AfterFunc(2*time.Second, func() {
+			time.AfterFunc(4*time.Second, func() {
 				suppressedExts.Delete(key)
 				utils.LoggerDebug.Printf("Suppression released for key: %s", key)
 			})
@@ -419,14 +454,19 @@ func processPacket(packet []byte) {
 
 				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(3 * time.Second)
+		time.Sleep(1 * time.Second)
 		if priority.TaskCreating == "PAD-ICP" {
+			utils.LoggerDebug.Printf("PAD-ICP : Clean priority.TaskCreating = '' !")
 			priority.TaskCreating = ""
 		}
 

+ 9 - 4
internal/app/stc/priority/index.go

@@ -9,22 +9,27 @@ import (
 	"gopkg.in/ini.v1"
 )
 
+// PAD 是否接通
 var ICPAnswer = 0
 var OCCAnswer = 0
 
 var SpecialVoice = 0
 
+// PAD是否发起
 var PADStart = 0
 var PADTMSStart = 0
 var PADOccStart = 0
 
+// 是否有任务正在创建
 var TaskCreating = ""
 
-var PACreating = 0
-var C2CCreating = 0
-var CPACreating = 0
-
+// 被打断的PAD类型
 var InterruptedPad = ""
+
+// 是否有PAD/CABCAB打断其他(DTMF */#)
+var PAInterrupt = 0
+var CABInterrupt = 0
+
 var filePath = "/etc/asterisk/priority.conf"
 
 type TaskInfo struct {