📄 pansr.cpp
字号:
case ST_OFFHOOK:
disp_status( channum, "Incoming call" );
if ((errcode = set_hkstate( channum, DX_OFFHOOK )) == -1)
errcode = set_hkstate( channum, DX_ONHOOK );
break;
case ST_GETR2MF:
disp_status( channum, "Get caller" );
break;
case ST_ERROR:
BuildName( channum, SVocDir, "ERR004.vox" );
errcode = PlayFile( channum, dxinfo[ channum ].msg_name );
break;
case ST_ONHOOK:
disp_status( channum, "Hang up" );
errcode = set_hkstate( channum, DX_ONHOOK );
break;
}
return( errcode );
}
void InitDialogic(void)
{
int mode;
mode = SR_POLLMODE;
if ( sr_setparm( SRL_DEVICE, SR_MODEID, &mode ) == -1 )
{
disp_msg( "Unable to set to Polled Mode" );
QUIT( 1 );
}
memset(dxinfo, 0, (sizeof( DX_INFO ) * (MAXCHANS+1)));
}
UINT RunDialogic(LPVOID info)
{
int rc;
int SRLevent, eventDev;
int channum;
int gammfax = 0;
ARG_STRUCT args;
args = *(ARG_STRUCT *)info;
hWnd = args.hWnd;
maxchans = args.maxchans;
faxchans = args.faxchans;
msichans = args.msichans;
d4xbdnum = args.d4xbdnum;
dtibdnum = args.dtibdnum;
faxbdnum = args.faxbdnum;
msibdnum = args.msibdnum;
frontend = args.frontend;
scbus = args.scbus;
routeag = args.routeag;
boardtag = args.boardtag;
sysinit(); // opening files, boards, etc.
//Add at 2002-12-5 by XYW
bool bs = 0;
bs = Ccs_sr_Init();
if( !bs ) AfxMessageBox("Load CCS DLL Failed");
bs = Ccs_sr_connectCCS();
if( !bs ) AfxMessageBox("Connect CCS Failed" );
Ccs_sr_SetInNo("17989,1189989");
//Add end
// main loop
while (WaitForSingleObject(ghDLGCEvent, 0) == WAIT_TIMEOUT) // global event not set
{
AnswerRequest(); //Answer scripts request
ProcessCCSMessage( hWnd ); //Process CCS Message
rc = sr_waitevt( 1 );
if ( rc != SR_TMOUT )
{
SRLevent = sr_getevttype(rc);
eventDev = sr_getevtdev( rc);
channum = FindChannel( eventDev, SRLevent );
if ( channum > 0 )
{
// Process the Event and Save the Next Channel State
if( SRLevent & DT_GC )
{
//rc = vProcessCallEvents( channum, SRLevent );
//if( rc<0 ) WriteReplyQueue( channum, GCEV_TASKFAIL );
continue;
}
else
{
dxinfo[ channum ].state = process( channum , SRLevent );
// Begin the New State Checking the Error Code Returned
if ( next_state( channum ) == -1 )
{
WriteReplyQueue( channum, GCEV_TASKFAIL );
continue;
}
}
//if (SendMessage(hWnd, WM_DLGC_STATE, channum, dxinfo[channum].state) == -1)
if (PostMessage(hWnd, WM_DLGC_STATE, channum, dxinfo[channum].state) == -1)
{
MessageBox(NULL, "Send Message Failed.", "Error", MB_ICONEXCLAMATION);
}
} // end of found
} // end of sr_waitevt != -1
if( gammfax )
{
//Process gammfax event;
}
} // end of Main while loop
//Add at 2002-12-05 by XYW
Cccs_sr_Exit();
//Add end
// Event must have been set
Cleanup(); // close down all of Dialogic because we have finished
if (!PostMessage(
hWnd, // handle of destination window
WM_DLGC_STOPPED, // message to post
0,// first message parameter
0)) // second message parameter
{
MessageBox(NULL, "Posting DLGC Stopped.", "Error", MB_ICONEXCLAMATION);
}
return 0;
}
void ForceCloseDialogic (int n)
{
//Add at 2002-12-05 by XYW
Cccs_sr_Exit();
//Add end
Cleanup(); // close down all of Dialogic because we have finished
if (!PostMessage(
hWnd, // handle of destination window
WM_DLGC_STOPPED, // message to post
0,// first message parameter
0)) // second message parameter
{
MessageBox(NULL, "Posting DLGC Stopped.", "Error", MB_ICONEXCLAMATION);
}
AfxEndThread( n );
}
//*******************pxm add**************************
int InitMakeCallBlk( MAKECALL_BLK *makecall_blk )
{
memset(makecall_blk,0xff,sizeof(MAKECALL_BLK));
makecall_blk->isdn.BC_xfer_cap=BEAR_CAP_SPEECH;
makecall_blk->isdn.BC_xfer_mode=ISDN_ITM_CIRCUIT;
makecall_blk->isdn.BC_xfer_rate=BEAR_RATE_64KBPS;
makecall_blk->isdn.facility_coding_value = 0xff;
//makecall_blk->isdn.facility_coding_value = ISDN_CPN;
makecall_blk->isdn.destination_number_type = NAT_NUMBER;
makecall_blk->isdn.destination_number_plan = ISDN_NUMB_PLAN;
makecall_blk->isdn.origination_number_type = ISDN_NOTUSED;
makecall_blk->isdn.origination_number_plan = ISDN_NOTUSED;
makecall_blk->isdn.origination_phone_number[0] = '\0';
makecall_blk->isdn.facility_feature_service = ISDN_SERVICE;
makecall_blk->isdn.usrinfo_layer1_protocol = ISDN_UIL1_G711ULAW;
makecall_blk->isdn.usr_rate = 0xff;
//makecall_blk->isdn.usr_rate = ISDN_NOTUSED;
makecall_blk->isdn.usrinfo_bufp = NULL;
makecall_blk->isdn.nsfc_bufp = NULL;
makecall_blk->isdn.destination_sub_number_type = OSI_SUB_ADDR;
makecall_blk->isdn.destination_sub_phone_number[0] = 1;
makecall_blk->isdn.destination_sub_phone_number[1] = 2;
makecall_blk->isdn.destination_sub_phone_number[2] = 3;
makecall_blk->isdn.destination_sub_phone_number[3] = '\0';
return(0);
}
//*******************end of pxm add**************************
int AnswerRequest(void)
{
int channum, rc, errcode=0;
int i, maxdigs, maskdig, maxwait, m_delete;
char Condition[500], *ptrStr;
struct ParamList *pParamList;
struct VoiceList *pVoc;
struct VoiceListMember *pMeb;
char ViewCtr[10],FuncCtr[10];
char rawdata[4096]="";
int oldstate=0;
VOCINFO *pTempVoc;
VOCNODE *pNode;
if( m_requestQueue_Voice.IsEmpty() ) return 0;
errcode = m_requestQueue_Voice.GetParamList(&pParamList);
if( !errcode )
{
channum = pParamList->iChannelNo;
//add by lj 2003/06/01
if(pParamList->iServiceNo != CMD_WTRING)
Ccs_sr_Stwtring(channum , 0);
//end add
switch( pParamList->iServiceNo )
{
case CMD_WTRING:
dxinfo[ channum ].service = pParamList->iServiceNo;
dxinfo[ channum ].reqid = pParamList->ISN;
dxinfo[ channum ].bIsIVR = pParamList->bIsIVR;
dxinfo[ channum ].nokeypressed = 0;
dxinfo[ channum ].warnType = 0;
strcpy( dxinfo[ channum ].msg_path ,"" );
dxinfo[ channum ].bIsInfotone = TRUE ;
//XYW add at 2000/12/15
Eralist( channum );
//XYW add end
if( frontend == CT_NTANALOG )
{
dxinfo[ channum ].state = ST_WTRING ;
set_hkstate( channum, DX_ONHOOK );
}
else
{
/*
if( stricmp( dxinfo[ channum ].protocol, "isdn" ) == 0 )
{
rc = gc_ResetLineDev( dxinfo[ channum ].g_dev, EV_ASYNC );
if (rc != GC_SUCCESS)
ShowError("gc_ResetLineDev()");
}
else
{
if( dxinfo[ channum ].g_crn > 0 )
{
rc = gc_DropCall( dxinfo[ channum ].g_crn, GC_NORMAL_CLEARING, EV_ASYNC );
if( rc != GC_SUCCESS )
ShowError("gc_DropCall()");
}
else
{
rc = gc_WaitCall( dxinfo[ channum ].g_dev, NULL, NULL, 0, EV_ASYNC);
if (rc != GC_SUCCESS)
ShowError("gc_WaitCall");
}
}
*/
//Add 2002-12-04 by XYW
if(dxinfo[ channum ].state >= ST_READY)
{
Ccs_sr_ReleaseCall( channum );
break;
}
//XYW add end
dxinfo[ channum ].state = ST_WTRING ;
//add by lj 2003/06/01 设为通道可用
Ccs_sr_Stwtring(channum , 1);
//end add
}
break;
case CMD_PLAY1:
case CMD_PLAY2:
case CMD_PLAY3:
case CMD_PLAY4:
case CMD_PLAY5:
//XYW add at 2000/12/14
if( dxinfo[ channum ].state < ST_READY ) break;
//XYW add end
if( dxinfo[ channum ].warnType == 2 && dxinfo[ channum ].stopTime < GetTickCount() )
{
dxinfo[ channum ].warnType = 0;
WriteReplyQueue( channum, TDX_ERROR );
break;
}
pVoc = (struct VoiceList *)(pParamList->pParam )->pParam;
pMeb = (struct VoiceListMember *)pVoc->pmember;
pNode = new VOCNODE;
pNode->service = pParamList->iServiceNo;
pNode->reqid = pParamList->ISN;
pNode->bIsIvr = pParamList->bIsIVR;
pNode->ac_count = pVoc->nCount;
pNode->bIsClear = 1 ;
pNode->pVocinfo = new VOCINFO[pVoc->nCount+1];
pTempVoc = pNode->pVocinfo ;
//Add at 2001/11/14 by xyw
if( dxinfo[ channum ].warnType == 1 && dxinfo[ channum ].warnTime < GetTickCount() )
{
dxinfo[ channum ].warnType = 2;
pTempVoc->Kind = '0';
strcpy(pTempVoc->Content,"msg_warning.vox" );
pTempVoc++;
}
//Add end
for( i=0; i<pNode->ac_count; i++ )
{
strcpy( pTempVoc->Content,(char *)(pMeb+i)->pVoice);
switch( (pMeb+i)->iType )
{
case 0://表示按文件播报;
pTempVoc->Kind = '0';
break;
case 1://表示按数值播报;
pTempVoc->Kind = '1';
if( dxinfo[ channum ].language == 2 )
{
strcpy( Condition, pTempVoc->Content );
//ldy change begin 2000/11/14
m_delete=Delete_0(Condition); //ldy add
//ldy change end 2000/11/14
NumberToSpeech ( Condition, pTempVoc->Content, 1 );
}
else
{
//ldy change begin 2000/12/08
m_delete=Delete_0( pTempVoc->Content ); //ldy add
//ldy change end 2000/12/08
ValueTrans( pTempVoc->Content );
}
break;
case 2://表示按数位播报;
pTempVoc->Kind = '1';
if( dxinfo[ channum ].language == 2 )
{
strcpy( Condition, pTempVoc->Content );
NumberToSpeech ( Condition, pTempVoc->Content, 0 );
}
break;
case 3://表示按时间播报;
pTempVoc->Kind = '1';
if( dxinfo[ channum ].language == 2 )
{
strcpy( Condition, pTempVoc->Content );
TimeToSpeech ( Condition, pTempVoc->Content, 1 );
}
else
{
TimeTrans( pTempVoc->Content );
}
break;
case 4://表示按日期播报;
pTempVoc->Kind = '1';
if( dxinfo[ channum ].language == 2 )
{
strcpy( Condition, pTempVoc->Content );
DateToSpeech ( Condition, pTempVoc->Content, 1 );
}
else
{
DateTrans( pTempVoc->Content );
}
break;
case 5://表示按资金播报;
pTempVoc->Kind = '1';
if( dxinfo[ channum ].language == 2 )
{
strcpy( Condition, pTempVoc->Content );
NumberToSpeech ( Condition, pTempVoc->Content, 1 );
strcat( pTempVoc->Content, "dollar" );
}
else
{
ValueTrans( pTempVoc->Content );
strcat( pTempVoc->Content, "$" );
}
break;
case 6://表示按百分数播报;
pTempVoc->Kind = '1';
if( dxinfo[ channum ].language == 2 )
{
strcpy( Condition, pTempVoc->Content );
NumberToSpeech ( Condition, pTempVoc->Content, 1 );
strcat( pTempVoc->Content, "percent" );
}
else
{
PercentTrans( pTempVoc->Content );
}
break;
default: //表示按文件播报;
pTempVoc->Kind = '0';
break;
}
pTempVoc++;
}
if( dxinfo[ channum ].service == CMD_PLAY5 )
{
Eralist( channum );
dx_stopch( dxinfo[ channum ].chdev, EV_ASYNC );
while ( ATDX_STATE( dxinfo[ channum ].chdev ) != CS_IDLE );
}
Putlist( channum, pNode );
if( (dxinfo[ channum ].ac_count == 0 && dxinfo[ channum ].ac_voice == NULL) || dxinfo[ channum ].state != ST_PLAY )
{
Getlist( channum );
errcode = PlayMsg( channum );
}
break;
case CMD_RECORD:
dxinfo[ channum ].service = pParamList->iServiceNo;
dxinfo[ channum ].reqid = pParamList->ISN;
dxinfo[ channum ].bIsIVR = pParamList->bIsIVR;
dxinfo[ channum ].state = ST_RECORD ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -