private void ResetChnl(short wChnlNo) { D160A.StopPlay(wChnlNo); D160A.StartPlaySignal(wChnlNo, (int)SigType.SIG_STOP); // if (Lines[ChannelID].State == CHANNEL_STATE.CH_WELCOME || Lines[ChannelID].State == CHANNEL_STATE.CH_PASSWORD || Lines[ChannelID].State == CHANNEL_STATE.CH_SELECT) if ((Lines[wChnlNo].State == CHANNEL_STATE.CH_WELCOME) || (Lines[wChnlNo].State == CHANNEL_STATE.CH_ACCOUNT) || (Lines[wChnlNo].State == CHANNEL_STATE.CH_PASSWORD) || (Lines[wChnlNo].State == CHANNEL_STATE.CH_SELECT1) || (Lines[wChnlNo].State == CHANNEL_STATE.CH_OFFHOOK)) { D160A.StopPlayFile(wChnlNo);//停止播放文件 } else if (Lines[wChnlNo].State == CHANNEL_STATE.CH_PLAYRESULT) { D160A.StopIndexPlayFile(wChnlNo); } else if (Lines[wChnlNo].State == CHANNEL_STATE.CH_ACCOUNT1)//操作被叫通道流 { D160A.FeedPower(wChnlNo); } else if (Lines[wChnlNo].State == CHANNEL_STATE.CH_ACCOUNT3) //操作 { D160A.ClearLink(wChnlNo, Dtmf[wChnlNo]); } //拆分通道通路 //外线 if (Lines[wChnlNo].nType == CHANNEL_TYPE.Trunk) { //检测信号 D160A.StartSigCheck(wChnlNo); //外线挂机 D160A.HangUp(wChnlNo); D160A.Sig_ResetCheck(wChnlNo); } if (Lines[wChnlNo].nType == CHANNEL_TYPE.User) { D160A.FeedPower(wChnlNo); } bUser[wChnlNo] = true; SigCheck[wChnlNo] = (short)1; sWitCh[wChnlNo] = (short)-1; Dtmf[wChnlNo] = (short)-1; Lines[wChnlNo].Dtmf = ""; Lines[wChnlNo].CallerID = ""; Lines[wChnlNo].nTimeElapse = 0; //Lines[wChnlNo].State = CHANNEL_STATE.CH_FREE(0);//空闲 Lines[wChnlNo].State = (CHANNEL_STATE)(0); }
private void DaiWorkIng() { //239行对应475行 //D160A.PUSH_PLAY();//入口参数:无函数返回:无;功能描述:维持文件录放音的持续进行,需在处理函数的大循环中调用。 //D160A.FeedSigFunc();//维持断续振铃及信号音的函数;请在程序大循环中调用。 byte[] FileName;//原代码 short TmpDTMF, Code; for (short i = 0; i < TotalLine; i++) //TotalLine = D160A.CheckValidCh(); { ListViewState(i); switch (Lines[i].State) { case CHANNEL_STATE.CH_FREE: //DJ160Int.CH_FREE://0"空闲" //252对应267行 ch_free; if (D160A.RingDetect(i) == true) { if (Lines[i].nType == CHANNEL_TYPE.User) //内线 { // 某一通道开始挂机检测;当某通道摘机后,可以调用本函数。该函数只对内线通道有效。 D160A.StartHangUpDetect(i); Lines[i].State = CHANNEL_STATE.CH_OFFHOOK; Lines[i].nTimeElapse = 0; Lines[i].intTimeCount = 0; sWitCh[i] = i; } if (Lines[i].nType == CHANNEL_TYPE.Trunk) //外线 { //给通道状态赋值 Lines[i].State = CHANNEL_STATE.CH_RECEIVEID; D160A.ResetCallerIDBuffer(i); //清空主叫Buf,为外线收主叫作准备 Lines[i].nTimeElapse = 0; sWitCh[i] = i; } } break; //267对应252行 case CHANNEL_STATE.CH_RECEIVEID: //"接收主叫号码//268对应283行ch_receiveID; byte[] TmpCID = new byte[32]; int iResult = 0; iResult = D160A.GetCallerIDStr(i, TmpCID); //接收主叫号码 if (iResult == 3 || iResult == 4) //收完主叫,外线摘机使能 { for (int j = 0; j < TmpCID.Length; j++) //存储电话号 { Lines[i].CallerID = Lines[i].CallerID + ((char)TmpCID[j]).ToString(); intLY = 1; } //外线提机 string strin = Encoding.UTF8.GetString(TmpCID).Substring(8, 11); D160A.OffHook(i); D160A.StartSigCheck(i); Lines[i].State = CHANNEL_STATE.CH_OFFHOOK; tbTelRecordAdd(strin, (int)i); } break; //283对应268 case CHANNEL_STATE.CH_OFFHOOK: //ch_offhook; D160A.InitDtmfBuf(i); StartPlayFileEx(i, "Bank.001"); //放音 Lines[i].State = CHANNEL_STATE.CH_WELCOME; //欢迎 break; case CHANNEL_STATE.CH_WELCOME: //ch_welcome; TmpDTMF = D160A.GetDtmfCode(i); //接受按键,返回值-1 缓冲区中没有DTMF按键 if (TmpDTMF != -1) { D160A.StopPlayFile(i); //停止放音 Lines[i].Dtmf = Lines[i].Dtmf + CvtDTMF(TmpDTMF); //TmpDTMF.ToString();//DTMF号码转换ASCII Lines[i].State = CHANNEL_STATE.CH_SELECT; //请随意输入8位银行帐号 } else //后加代码 { if (D160A.CheckPlayEnd(i)) //检查指定通道放音是否结束0未结束1结束 { D160A.StopPlayFile(i); //停止放音 StartPlayFileEx(i, "Bank.004"); Lines[i].State = CHANNEL_STATE.CH_SELECT; } } break; case CHANNEL_STATE.CH_SELECT: //ch_select; TmpDTMF = D160A.GetDtmfCode(i); if (TmpDTMF != -1) { Lines[i].Dtmf = TmpDTMF.ToString(); switch (Lines[i].Dtmf) { case "1": D160A.StopPlayFile(i); D160A.RsetIndexPlayFile(i); FileName = GetFilePath("bank.005"); D160A.AddIndexPlayFile(i, FileName); FileName = GetFilePath("d5"); D160A.AddIndexPlayFile(i, FileName); D160A.StartIndexPlayFile(i); Lines[i].State = CHANNEL_STATE.CH_PLAYRESULT; break; case "2": D160A.StopPlayFile(i); D160A.RsetIndexPlayFile(i); FileName = GetFilePath("bank.006"); D160A.AddIndexPlayFile(i, FileName); FileName = GetFilePath("bank.008"); D160A.AddIndexPlayFile(i, FileName); D160A.StartIndexPlayFile(i); Lines[i].State = CHANNEL_STATE.CH_PLAYRESULT; break; case "3": D160A.StopPlayFile(i); D160A.RsetIndexPlayFile(i); FileName = GetFilePath("bank.007"); D160A.AddIndexPlayFile(i, FileName); FileName = GetFilePath("d3"); D160A.AddIndexPlayFile(i, FileName); D160A.StartIndexPlayFile(i); Lines[i].State = CHANNEL_STATE.CH_PLAYRESULT; break; case "4": //转人工 Lines[i].State = CHANNEL_STATE.CH_WELCOME1; break; } } else if (Lines[i].intTimeCount == 3) //判断重复播音次数 { Lines[i].State = CHANNEL_STATE.CH_PLAYRESULT; } else if (Lines[i].nTimeElapse != 1000) { Lines[i].nTimeElapse += 20; } else if (Lines[i].nTimeElapse == 1000) { Lines[i].State = CHANNEL_STATE.CH_WELCOME; Lines[i].nTimeElapse = 0; Lines[i].intTimeCount++; } break; case CHANNEL_STATE.CH_PLAYRESULT: //ch_playresult; if (D160A.CheckIndexPlayFile(i)) { D160A.StopIndexPlayFile(i); if (Lines[i].nType == CHANNEL_TYPE.Trunk) { ResetChnl(i); } else if (Lines[i].nType == CHANNEL_TYPE.User) { //控制信号音的播放。本函数实质上使用内存循环放音来实现的。其中: //拨号音的时间长度为响0.75秒,停止3秒; //忙音一的时间长度为响0.35秒,停止0.35秒; //忙音二的时间长度为响0.7秒,停止0.7秒; D160A.StartPlaySignal(i, (int)(SigType.SIG_BUSY1)); Lines[i].State = CHANNEL_STATE.CH_WAITUSERONHOOK; } } break; case CHANNEL_STATE.CH_WAITUSERONHOOK: //H_WAITUSERONHOOK if (!D160A.RingDetect(i)) { D160A.StartPlaySignal(i, (int)(SigType.SIG_STOP)); ResetChnl(i); } break; //转人工模块 case CHANNEL_STATE.CH_WELCOME1: D160A.InitDtmfBuf(sWitCh[i]); //清空摘机的线路通道 StartPlayFileEx(sWitCh[i], "Bank.001"); //播放音乐等待接通 Lines[i].State = CHANNEL_STATE.CH_WELCOME0; break; case CHANNEL_STATE.CH_WELCOME0: if (D160A.CheckPlayEnd(sWitCh[i])) //检查摘机的线路通道播放音乐是否完成 { D160A.StopPlayFile(sWitCh[i]); //停止摘机的线路通道播音 Lines[i].State = CHANNEL_STATE.CH_PASSWORD; //选择通道号 } break; case CHANNEL_STATE.CH_PASSWORD: //选择通道号 Code = D160A.GetDtmfCode(sWitCh[i]); //在摘机的线路通道中输入要连接的内绩通道 if (Code != -1) { Dtmf[i] = Code; //将选择联接的通道号赋值给数组 if (Dtmf[i] > 0 && Dtmf[i] < 8 || Dtmf[i] == 10) { D160A.StartPlaySignal(sWitCh[i], (int)SigType.SIG_STOP); //控制主叫通道的语音 Lines[i].State = CHANNEL_STATE.CH_SELECT1; //判断选择通道的状态 } } break; case CHANNEL_STATE.CH_SELECT1: //判断选择通道的状态 if (Lines[Dtmf[i]].State == CHANNEL_STATE.CH_FREE) //判断被叫通道是否空闲 { D160A.FeedRealRing(Dtmf[i]); //对被叫通道馈断续的铃流.选择的人工作席 D160A.StartPlaySignal(sWitCh[i], (int)SigType.SIG_RINGBACK); //控制信号音的播放,SIG_RINGBACK 回铃音 Lines[Dtmf[i]].State = CHANNEL_STATE.CH_RECEIVEID; //显示被叫通道的状态 Lines[i].State = CHANNEL_STATE.CH_ACCOUNT1; } else // { D160A.StartPlaySignal(sWitCh[i], (int)SigType.SIG_BUSY2); //控制主叫通道信号音的播放 Lines[Dtmf[i]].State = CHANNEL_STATE.CH_ConBusy0; //显示被叫通道的状态 Lines[i].State = CHANNEL_STATE.CH_ConBusy; } break; case CHANNEL_STATE.CH_ConBusy: //此功能显示通道忙 if (Lines[sWitCh[i]].nType == CHANNEL_TYPE.Trunk) { } else if (Lines[sWitCh[i]].nType == CHANNEL_TYPE.User) { bUser[Dtmf[i]] = false; Lines[i].State = CHANNEL_STATE.CH_ACCOUNT1; //下步操作 } break; case CHANNEL_STATE.CH_ACCOUNT1: //检测被叫通道是否摘机 if (D160A.OffHookDetect(Dtmf[i]) == 1 && bUser[Dtmf[i]] == true) //检测录音模块的摘挂机状态,只对录音模块有效。 { D160A.StartPlaySignal(sWitCh[i], (int)SigType.SIG_STOP); //控制信号音的播放,停止 D160A.StopPlay(sWitCh[i]); //控制文件的播放///////////////////// Lines[sWitCh[i]].State = CHANNEL_STATE.CH_Over; //请挂机 Lines[i].State = CHANNEL_STATE.CH_ACCOUNT2; //已挂机 break; } //检测二次拍叉簧动作 else if (D160A.HangUpDetect(Dtmf[i]) == (int)HangUp.HANG_UP_FLAG_PRESS_R && sWitCh[i] != i) { //检测某一通道的挂机状态,拍了一下叉簧 D160A.FeedPower(Dtmf[i]); //对被叫线通道馈电,同时停止馈铃流,同时停止溃电 ResetChnl(Dtmf[i]); //调用方法 D160A.StartPlaySignal(i, (int)SigType.SIG_STOP); //调用方法 D160A.StopPlay(sWitCh[i]); Dtmf[i] = sWitCh[i]; //将主叫号码赋值给被叫号码 Lines[Dtmf[i]].State = CHANNEL_STATE.CH_Connect; //正在转接 Lines[sWitCh[i]].State = CHANNEL_STATE.CH_PASSWORD1; //正在转接 Lines[i].State = CHANNEL_STATE.CH_ACCOUNT; bUser[Dtmf[i]] = true; break; } //在对方正在振铃时挂机处理 else if (Lines[i].nType == CHANNEL_TYPE.User) //内线 { if (D160A.HangUpDetect(sWitCh[i]) == (int)HangUp.HANG_UP_FLAG_TRUE) //已经挂机 { ResetPower(i); //调用自定义方法 ResetChnl(Dtmf[i]); //调用自定义方法 bUser[i] = true; break; } } //在对方正在振铃时挂机处理 break; case CHANNEL_STATE.CH_ACCOUNT2: //已挂 D160A.FeedPower(Dtmf[i]); //对某一路内线通道馈电,同时停止馈铃流 Lines[i].State = CHANNEL_STATE.CH_ACCOUNT; //停止文件 Lines[Dtmf[i]].State = CHANNEL_STATE.CH_PASSWORD1; //已接通 break; case CHANNEL_STATE.CH_ACCOUNT: //停止播放文件 D160A.StopPlay(i); //停止放音 sWitCh[i] = (short)-1; if (D160A.SetLink(i, Dtmf[i]) == 1) //两路连通。 { Lines[i].State = CHANNEL_STATE.CH_ACCOUNT3; } break; case CHANNEL_STATE.CH_ACCOUNT3: D160A.StartHangUpDetect(Dtmf[i]); //某一通道开始挂机检测;当某通道摘机后,可以调用本函数。该函数只对内线通道有效。 Lines[i].State = CHANNEL_STATE.CH_ACCOUNT4; break; case CHANNEL_STATE.CH_ACCOUNT4: // '检测转机用户拍叉簧 if (D160A.HangUpDetect(Dtmf[i]) == (int)HangUp.HANG_UP_FLAG_PRESS_R) //检测某一通道的挂机状态,拍了一下叉簧 { sWitCh[i] = Dtmf[i]; Lines[Dtmf[i]].State = CHANNEL_STATE.CH_Connect; //正在转接 D160A.ClearLink(i, Dtmf[i]); //两路拆除连通。 D160A.StopPlay(Dtmf[i]); Dtmf[i] = -1; Lines[i].State = CHANNEL_STATE.CH_WELCOME; StartPlayFileEx(sWitCh[i], "Dial.001"); //播放音乐等待接 } // '检测被叫用户挂机 if (D160A.HangUpDetect(Dtmf[i]) == (int)HangUp.HANG_UP_FLAG_TRUE) { SigCheck[Dtmf[i]] = (short)D160A.ClearLink(i, Dtmf[i]); //两路拆除连通。 if (SigCheck[Dtmf[i]] == 0) { D160A.StartPlaySignal(i, (int)SigType.SIG_BUSY1); //调用方法 } ResetPower(i); //自定义方法调用 ResetChnl(Dtmf[i]); //自定义方法2 Lines[i].State = CHANNEL_STATE.CH_IsOver; } //'检测为内线的主叫用户挂机 if (Lines[i].nType == CHANNEL_TYPE.User) { if (D160A.HangUpDetect(i) == (int)HangUp.HANG_UP_FLAG_TRUE) { SigCheck[Dtmf[i]] = (short)D160A.ClearLink(i, Dtmf[i]); //两路拆除连通。 if (D160A.ClearLink(i, Dtmf[i]) == 0) { D160A.StartPlaySignal(i, (int)SigType.SIG_BUSY1); //调用方法 } ResetChnl(i); //调用函数 } } break; } //473对应251行 //判断外线if (Lines[i].nType == CHANNEL_TYPE.Trunk && Lines[i].State != CHANNEL_STATE.CH_FREE) if (Lines[i].nType == CHANNEL_TYPE.Trunk && Lines[i].State != CHANNEL_STATE.CH_FREE && Lines[i].State != CHANNEL_STATE.CH_RECEIVEID) { if (D160A.Sig_CheckBusy(i) == 1) //进行挂机忙音检测,1 检测到忙音 { SigCheck[i] = (short)D160A.ClearLink(i, Dtmf[i]); // 两路拆除连通。 if (SigCheck[i] == 0) { D160A.StartPlaySignal(i, (int)SigType.SIG_BUSY1);//调用方法 Lines[Dtmf[i]].State = CHANNEL_STATE.CH_Over; } ResetChnl(i);//调用方法ResetChnl(i) } }//判断内线条件 else if (Lines[i].nType == CHANNEL_TYPE.User && Lines[i].State != CHANNEL_STATE.CH_FREE && Lines[i].State != CHANNEL_STATE.CH_RECEIVEID) { if (D160A.RingDetect(i)) { if (SigCheck[i] == 0) { Lines[i].State = CHANNEL_STATE.CH_Over; } } else if (D160A.HangUpDetect(i) == (int)HangUp.HANG_UP_FLAG_TRUE) { ResetChnl(i); } } } }