to:枫之叶
好久没做dialogic系统。我把前年做过的Dialogic系统程序的几个函数帖上来给你看看
参考一下:
/*****************************************************
BOOL hk_detectsignal(DX_CST* cstp,UINT sigs,int sigcount);
测信号音
cstp CST事件
sigs 信号音(可以是多种信号音)
sigcount 信号音个数
返回 TRUE //测到
*****************************************************/
BOOL CChannel::hk_detectsignal(DX_CST* cstp,UINT sigs,int sigcount)
{
int tonetype,tonecount;
char linemsg[256];
if (cstp->cst_event!= DE_TONEON) return (FALSE);
tonetype=cstp->cst_data;
switch (tonetype)
{
case TID_DIAL_LCL:
fsigcount[0]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[0].str,fsigcount[0]);
break;
case TID_DIAL_INTL:
fsigcount[1]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[1].str,fsigcount[1]);
break;
case TID_DIAL_XTRA:
fsigcount[2]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[2].str,fsigcount[2]);
break;
case TID_BUSY1:
fsigcount[3]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[3].str,fsigcount[3]);
break;
case TID_BUSY2:
fsigcount[4]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[4].str,fsigcount[4]);
break;
case TID_RNGBK1:
fsigcount[5]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[5].str,fsigcount[5]);
break;
case TID_RNGBK2:
fsigcount[6]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[6].str,fsigcount[6]);
break;
case TID_FAX1:
fsigcount[7]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[7].str,fsigcount[7]);
break;
case TID_FAX2:
fsigcount[8]++;
sprintf(linemsg,"通道%02d %s %d次",m_channelno,Dxxxboard.DefaultTones[8].str,fsigcount[8]);
break;
}
Dxxxboard.hk_listmsg(linemsg);
tonecount=0;
if ((sigs&Dxxxconst.DIAL_LCL)==Dxxxconst.DIAL_LCL)
{
tonecount=tonecount+fsigcount[0];
}
if ((sigs&Dxxxconst.DIAL_INTL)==Dxxxconst.DIAL_INTL)
{
tonecount=tonecount+fsigcount[1];
}
if ((sigs&Dxxxconst.DIAL_XTRA)==Dxxxconst.DIAL_XTRA)
{
tonecount=tonecount+fsigcount[2];
}
if ((sigs&Dxxxconst.BUSY1)==Dxxxconst.BUSY1)
{
tonecount=tonecount+fsigcount[3];
}
if ((sigs&Dxxxconst.BUSY2)==Dxxxconst.BUSY2)
{
tonecount=tonecount+fsigcount[4];
}
if ((sigs&Dxxxconst.RNGBK1)==Dxxxconst.RNGBK1)
{
tonecount=tonecount+fsigcount[5];
}
if ((sigs&Dxxxconst.RNGBK2)==Dxxxconst.RNGBK2)
{
tonecount=tonecount+fsigcount[6];
}
if ((sigs&Dxxxconst.FAX1)==Dxxxconst.FAX1)
{
tonecount=tonecount+fsigcount[7];
}
if ((sigs&Dxxxconst.FAX2)==Dxxxconst.FAX2)
{
tonecount=tonecount+fsigcount[8];
}
if (tonecount>=sigcount)
{
return(TRUE);
}
return (FALSE);
}
/*****************************************************
int hk_setsignal();
设置信号音
返回 >0 设置成功
*****************************************************/
int CChannel::hk_setsignal()
{
if (dx_deltones(m_voxdev) == -1)
{
return(-1);
}
for (int index (0);
index < MAX_TONES;
index++)
{
if (dx_blddtcad(Tone_T[index].tid,
Tone_T[index].freq1,
Tone_T[index].deviation1,
Tone_T[index].freq2,
Tone_T[index].deviation2,
Tone_T[index].ontime,
Tone_T[index].ondeviation,
Tone_T[index].offtime,
Tone_T[index].offdeviation,
Tone_T[index].repcnt)== -1)
{
return(-1);
}
if (dx_addtone(m_voxdev,(unsigned char)NULL,0) == -1)
{
return(-1);
}
if (dx_distone(m_voxdev,Tone_T[index].tid,DM_TONEOFF) == -1)
{
return(-1);
}
}
return(1);
}