⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datafunc.cpp

📁 170话费催交系统
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		TRACE("%s: SIGA_4: %s -- Network Congestion",dxinfo[channel].chdevname,teleinfo[channel].num);
		return yin_fwaon(channel);
		break;

	case SIGA_5: // Invalid number, hangup then
		TRACE("%s: SIGA_5: %s -- Invalid Number",dxinfo[channel].chdevname,teleinfo[channel].num);
		return yin_fwaon(channel);
		break;

	default: //hangup then
		// will not arrive here
		return yin_fwaon(channel);
		break;
	}

	TRACE("%s: State %2d, In yin_mfc(), ---- fwsig=%d",
		dxinfo[channel].chdevname,dxinfo[channel].chdevzt,fwsig);
	if(yin_r2_playfsig(channel,fwsig) == -1){
		TRACE("yin_r2_playfsig error");
		return(-1);
	}

	return 0;
}

/*************************************************************************
 *	FUNCTION NAME: int yin_r2_playfsig(int channel, int forwardsig)
 *	DESCRIPTION: to play a forward signal
 *	INPUT: voice device handle, forwardsig, and play mode
 *  RETURN: if in EV_SYNC mode the return the terminate backward ToneID
 *************************************************************************/
int yin_r2_playfsig(int channel, int forwardsig)
{
	int mode=EV_ASYNC;
	int i;
		
	i=forwardsig - SIGI_1;

	if(dx_playtone(dxinfo[channel].chdev,&tngen[i],r2_tpt,mode) == -1){
		TRACE("dx_playtone error");
		return(-1);
	}
	return(0);
}

/***************************************************************************
 *	FUNCTION NAME: playtone_init()
 *	DESCRIPTION: to initialize tonegen and r2_tpt
 *  RETURN: 
 **************************************************************************/
int playtone_init(void)
{
	int i;

	memset(tngen,0,sizeof(tngen));
	for(i=0;i<15;i++)
		dx_bldtngen(&tngen[i],fsig[i][0],fsig[i][1],R2_DEFAMPL,R2_DEFAMPL,200);

	memset(r2_tpt,0,sizeof(r2_tpt));

	r2_tpt[0].tp_type=IO_CONT;
	r2_tpt[0].tp_termno=DX_TONE;
	r2_tpt[0].tp_length=SIGA_1;
	r2_tpt[0].tp_flags=TF_TONE;
	r2_tpt[0].tp_data=DX_TONEON;

	r2_tpt[1].tp_type=IO_CONT;
	r2_tpt[1].tp_termno=DX_TONE;
	r2_tpt[1].tp_length=SIGA_6;
	r2_tpt[1].tp_flags=TF_TONE;
	r2_tpt[1].tp_data=DX_TONEON;

	r2_tpt[2].tp_type=IO_CONT;
	r2_tpt[2].tp_termno=DX_TONE;
	r2_tpt[2].tp_length=SIGA_3;
	r2_tpt[2].tp_flags=TF_TONE;
	r2_tpt[2].tp_data=DX_TONEON;

	r2_tpt[3].tp_type=IO_CONT;
	r2_tpt[3].tp_termno=DX_TONE;
	r2_tpt[3].tp_length=SIGB_1;
	r2_tpt[3].tp_flags=TF_TONE;
	r2_tpt[3].tp_data=DX_TONEON;

	r2_tpt[4].tp_type=IO_EOT;
	r2_tpt[4].tp_termno=DX_MAXTIME;
	r2_tpt[4].tp_length=300;
	r2_tpt[4].tp_flags=TF_10MS;

	return 0;
}

/*************************************************************************
*			Fuction    : int yin_bwboff(int channel)
*			Description: Backword hangup during MFC
**************************************************************************/
int yin_bwboff(int channel)
{
	int retval;

	dx_stopch(dxinfo[channel].chdev,EV_ASYNC);
	//backword signal hangs up first
	//BW:11-->10
	if((retval=dt_settssig(dxinfo[channel].dtdev,DTB_ABIT,DTA_ADDMSK))!=0){
		TRACE("%s: dt_settssig() in yin_bwboff() error",dxinfo[channel].dtdevname);
		return -1;
	}

	return chan_init(channel);
}

/*************************************************************************
*
*			Fuction    : yin_getbksig()
*			Description: Get backward signal
**************************************************************************/
int yin_getbksig(int channel,unsigned long evt_handle)
{
	DX_CST* cstp;

	cstp=(DX_CST*)sr_getevtdatap(evt_handle);
	dxinfo[channel].bksig=cstp->cst_data;

	if(dxinfo[channel].Sending==END_R2MF)
		switch (dxinfo[channel].bksig){
		case SIGB_1://The Called Party is Idle, free
		case SIGB_6://The Called Party is Idle, free
			dxinfo[channel].chdevzt=CHDEVZT_D;
			ChnPrintf(channel+1,"_START","振铃");
			break;
		case SIGB_2://Local Call Busy
		case SIGB_3://Long Distance Call Busy
		case SIGB_4://Congestion
			TRACE("%s: %s -- Line is Busy",dxinfo[channel].chdevname,teleinfo[channel].num);
			ChnPrintf(channel+1,"_START","线路忙");
			Writeappdata(channel);
			yin_fwaon(channel);//hangup at this state
			break;
		case SIGB_5://There is no this number
			TRACE("%s: %s -- Invalid Telephone Number",dxinfo[channel].chdevname,teleinfo[channel].num);
			ChnPrintf(channel+1,"_START","无此号码");
			yin_fwaon(channel);
			break;
		};
	return 0;
}

/*************************************************************************
*			Fuction    : yin_fwaon()
*			Description: Forward hangup after end of play
**************************************************************************/
int  yin_fwaon(int channel)
{
	if(dt_settssig(dxinfo[channel].dtdev,DTB_ABIT,DTA_ADDMSK)!=0){
		TRACE("%s: dt_settssig() error",dxinfo[channel].dtdevname);
		return -1;
	}
	chan_init(channel);
	return 0;
}

/*************************************************************************
*
*			Fuction    : yin_playf()
*			Description: Set up IOTT and TPT's and Play-Back sample.vox
**************************************************************************/
int yin_playf(int channel)
{
	//play sample.vox file
	dx_clrdigbuf(dxinfo[channel].chdev);

	//add the counter
	telecount.success_count++;
	
    //索引语音串
	Index_sz(channel);
	/* Play VOX File on D/30PCI-E1 Channel, Normal Play Back */
	if (dx_playiottdata(dxinfo[channel].chdev,dxinfo[channel].iott_cjvalue,tptplay,&xpbVox,EV_ASYNC)==-1 ){
		TRACE("%s: %s in dx_playiottdata() error",dxinfo[channel].chdevname,ATDV_ERRMSGP(dxinfo[channel].chdev));
		return -1;
	}
	dxinfo[channel].playflag=1;
	TRACE("%s: %2d, %s -- Playing...",dxinfo[channel].chdevname,channel,teleinfo[channel].num);
	return 0;
}

/************************************************************************
*     名称:int clr_output(int channel)
*     功能:清除某通道屏显的函数
************************************************************************/
int clr_output(int channel)
{
	//清除某通道的屏显
	ChnPrintf(channel+1,"_USER","");
	ChnPrintf(channel+1,"_STATE","");
	ChnPrintf(channel+1,"_TELE","");
	ChnPrintf(channel+1,"_BEGIN","");
	ChnPrintf(channel+1,"_END","");
	return(0);
}

/*************************************************************************
*
*			Fuction    : void time_process(void)
*			Description: Set up IOTT and TPT's and Play-Back sample.vox
**************************************************************************/
void time_process(void)
{
	int channel;

	if(datajy_counts>=DATAJY_COUNTS) {
		 datajy_counts=0;
		 datacon.chdevno=-1;
		 //校验数据库连接的线程事件
		 JiaoYan.SetEvent();
	}

	for(channel=0;channel<cjdevcounts/2;channel++) {
		init_count[channel]++;
		if(init_count[channel]>=INIT_COUNT) {
			init_count[channel]=0;
			clr_output(channel);
		}

		if(dxinfo[channel].playflag==0) {
			dxinfo[channel].chtime++;
		}
		switch(dxinfo[channel].chdevzt){
		case CHDEVZT_A:
			dxinfo[channel].chtime=0;
			break;
		case CHDEVZT_B:
			if(dxinfo[channel].chtime>5){
				dxinfo[channel].chtime=0;
				chan_init(channel);
			}
			break;
		case CHDEVZT_C:
			if(dxinfo[channel].chtime>10){
				dxinfo[channel].chtime=0;
				Writeappdata(channel);
				chan_init(channel);
			}
			break;
		case CHDEVZT_D:
			if(dxinfo[channel].chtime>cjarg.ringtime){ //响铃超过最大秒数
				dxinfo[channel].chtime=0;
				Writeappdata(channel);
				chan_init(channel);
			}
			break;
		case CHDEVZT_E:
			if(dxinfo[channel].chtime>5){
				dxinfo[channel].chtime=0;
				yin_bwboff(channel);
			}
			break;
		case CHDEVZT_F:
			if(dxinfo[channel].chtime>WRITEDATATIME){
				dxinfo[channel].chtime=0;
				chan_init(channel);
			}
			break;
		case CHDEVZT_G:
		case CHDEVZT_H:
			if(dxinfo[channel].chtime>5){
				dxinfo[channel].chtime=0;
				chan_init(channel);
			}
			break;
		}
	}
}

/************************************************************************
*     名称:int Readdata(int channel)
*     功能:从缓冲区读一条数据
************************************************************************/
int Readdata(int channel)
{
	//清空原数据
	teleinfo[channel].hth[0]='\0';
	teleinfo[channel].num[0]='\0';
	teleinfo[channel].cuijiao[0]='\0';
	teleinfo[channel].qfmonth[0]='\0';
	teleinfo[channel].cjcount=0;
	teleinfo[channel].cjmonth[0]='\0';
	teleinfo[channel].cjyin_flag=1;
	teleinfo[channel].append_count=0;
	//写入新数据
	if(appendcounts > 0){
		strcpy(teleinfo[channel].hth,appendcjdata[readappend].hth);
		strcpy(teleinfo[channel].num,appendcjdata[readappend].num);
		strcpy(teleinfo[channel].cuijiao,appendcjdata[readappend].cuijiao);
		strcpy(teleinfo[channel].qfmonth,appendcjdata[readappend].qfmonth);
		teleinfo[channel].cjcount=appendcjdata[readappend].cjcount;
		strcpy(teleinfo[channel].cjmonth,appendcjdata[readappend].cjmonth);
		teleinfo[channel].cjyin_flag=appendcjdata[readappend].cjyin_flag;
		teleinfo[channel].append_count=appendcjdata[readappend].append_count;	//进辅缓冲区的次数
		
		appendcounts--;
		if(readappend>=APPENDDATA_COUNTS-1)
			readappend=0;
		else
			readappend++;

		return(0);
	}

	if(maincounts > 0){
		strcpy(teleinfo[channel].hth,maincjdata[readmain].hth);
		strcpy(teleinfo[channel].num,maincjdata[readmain].num);
		strcpy(teleinfo[channel].cuijiao,maincjdata[readmain].cuijiao);
		strcpy(teleinfo[channel].qfmonth,maincjdata[readmain].qfmonth);
		teleinfo[channel].cjcount=maincjdata[readmain].cjcount;
		strcpy(teleinfo[channel].cjmonth,maincjdata[readmain].cjmonth);
		teleinfo[channel].cjyin_flag=maincjdata[readmain].cjyin_flag;
		teleinfo[channel].append_count=0;				//进辅缓冲区的次数
		
		maincounts--;
		if(readmain>=MAINDATA_LENGTH-1)
			readmain=0;
		else
			readmain++;

		return(0);
	}
	return(-1);
}

/************************************************************************
*     名称:int Writeappdata(int channel)
*     功能:往辅缓冲区写数据
************************************************************************/
int Writeappdata(int channel)
{
	if(teleinfo[channel].append_count>=cjarg.cb_count) {
		return(-1);
	}
	teleinfo[channel].append_count++;
	if(appendcounts < APPENDDATA_COUNTS){
		//先清空缓冲区上一次的数据
		appendcjdata[writeappend].hth[0]='\0';
		appendcjdata[writeappend].num[0]='\0';
		appendcjdata[writeappend].cuijiao[0]='\0';
		appendcjdata[writeappend].qfmonth[0]='\0';
		appendcjdata[writeappend].cjcount=0;
		appendcjdata[writeappend].cjmonth[0]='\0';
		appendcjdata[writeappend].cjyin_flag=1;
		appendcjdata[writeappend].append_count=0;
		//写入新数据
		strcpy(appendcjdata[writeappend].hth,teleinfo[channel].hth);
		strcpy(appendcjdata[writeappend].num,teleinfo[channel].num);
		strcpy(appendcjdata[writeappend].cuijiao,teleinfo[channel].cuijiao);
		strcpy(appendcjdata[writeappend].qfmonth,teleinfo[channel].qfmonth);
		appendcjdata[writeappend].cjcount=teleinfo[channel].cjcount;
		strcpy(appendcjdata[writeappend].cjmonth,teleinfo[channel].cjmonth);
		appendcjdata[writeappend].cjyin_flag=teleinfo[channel].cjyin_flag;
		appendcjdata[writeappend].append_count=teleinfo[channel].append_count;	//进辅缓冲区的次数

		appendcounts++;
		if(writeappend>=APPENDDATA_COUNTS-1)
			writeappend=0;
		else
			writeappend++;
	}
	return(0);
}

/*********************************************
*     名称:int Index_sz(int channel)
*     功能:索引语音数组
*********************************************/
int Index_sz(int channel)
{
	int count;
	int countn;
	DX_IOTT *iott_qs;

	count=0;
	switch(teleinfo[channel].cjyin_flag) {
	case 1:
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 2: 
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOB_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOB_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[2].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 3:
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOC_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOC_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[3].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	default:
		dxinfo[channel].iott_cjvalue[count].io_offset = HELLOA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = HELLOA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_LINK;
		dxinfo[channel].iott_cjvalue[count].io_nextp = &dxinfo[channel].iott_cjvalue[count+1];
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	}
	count++;

	iott_qs=dxinfo[channel].iott_cjvalue+count;
	countn=Index_value( teleinfo[channel].cuijiao, iott_qs, 0, channel);
	count=count+countn;
	dxinfo[channel].iott_cjvalue[count-1].io_nextp = &dxinfo[channel].iott_cjvalue[count];
	dxinfo[channel].iott_cjvalue[count-1].io_type = IO_DEV|IO_LINK;

	switch(teleinfo[channel].cjyin_flag) {
	case 1:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 2:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERB_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERB_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[2].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	case 3:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERC_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERC_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[3].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	default:
		dxinfo[channel].iott_cjvalue[count].io_offset = OTHERA_OFFSET;
		dxinfo[channel].iott_cjvalue[count].io_length = OTHERA_LENGTH;
		dxinfo[channel].iott_cjvalue[count].io_type = IO_DEV|IO_EOT;
		dxinfo[channel].iott_cjvalue[count].io_nextp = NULL;
		dxinfo[channel].iott_cjvalue[count].io_fhandle=szfile[1].filehandle;
		dxinfo[channel].iott_cjvalue[count].io_bufp = 0;
		break;
	}
	return(0);
}

/**************************************************************************************
*		int Index_time(char *sz_time, DX_IOTT *iott_time,int filenum,int channum)
*	函数说明: 索引时间字串,并将索引后的语音内容填入 *iott_time,返回语音串的长度

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -