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

📄 ivoice.c

📁 170话费催交系统
💻 C
📖 第 1 页 / 共 2 页
字号:


 /**************************************************************************
 *                                                                         *
 *          IIIIII   VV   VV   OOOOO   IIIIII    CCCCC   EEEEEEE           *
 *            II     VV   VV  OO   OO    II     CC   CC  EE                *
 *            II     VV   VV  OO   OO    II     CC       EE                *
 *            II      V   V   OO   OO    II     CC       EEEEE             *
 *            II      VV VV   OO   OO    II     CC       EE                *
 *            II      VV VV   OO   OO    II     CC   CC  EE                *
 *          IIIIII     VVV     OOOOO   IIIIII    CCCCC   EEEEEEE           *
 *                                                                         *
 ***************************************************************************
 *            C Source Code IVOICE                                         *
 ***************************************************************************
 *********** Rev 1.00 Alpha 1.00 ***** 3/18/96 *****************************
 *  1. Initial Release                                                     *
 ***************************************************************************
 *                                                                         *
 *  Here is the sample code that is detecting r2-MF tone on a D300SCE1 in  *
 *  PEB mode. It works fine on my test system and detects forward tone 1   *
 *  and plays the corresponding backward tone which terminates on          *
 *  DE_TONEOFF event and it go back to initial state to wait for another   *
 *  call.   It can detect any forward tone but it is playing only first    *
 *  backward tone.  You can change it to any other backward tone by        *
 *  changing second and third paramters of r2_playbsig() function.         *
 *                                                                         *
 *  I am following the same signalling protocol that was included in your  *
 *  code that you send to us.  In case if you IDLE or SEIZER patterns are  *
 *  different, you can change then in sysinit() function.                  *
 *                                                                         *
 **************************************************************************/
/*
 * System Include Files
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <windows.h>

/*
 * Dialogic Include Files
 */
#include <srllib.h>
#include <dxxxlib.h>
#include <dtilib.h>
#include <msilib.h>

#include "ivoice.h"

/*
 * Public Variables
 */
DX_INFO dxinfo[MAXCHANS +1];

/* voice file handles */
int promptfh;

DX_IOTT iott;

TABLE table[TABLE_SIZE]=
   { /* current_state    event             next_stat    function */
   { ST_WTFORCALL,     DTEV_MTFCNCPT, ST_GETMFDIG,     nochange    },
   { ST_GETMFDIG,      DE_TONEON,     ST_WTFORONHK,    playtone    },
   { ST_GETMFDIG,      DE_TONEOFF,    ST_WTFORONHK,    nochange    },
   { ST_WTFORONHK,     DX_ONHOOK,     ST_WTFORCALL,    setonhook   }  };

/***************************************************************************
 *        NAME: void sysinit()
 * DESCRIPTION: Start D/4x System, Enable CST events, put line ON-Hook
 *              and open VOX files.
 *       INPUT: None.
 *      OUTPUT: None.
 *     RETURNS: None.
 *    CAUTIONS: None.
 ***************************************************************************/
void sysinit(void)
{
   int  channum;
   char d4xname[ 32 ];
   int mode;
   int dtibh;
   int parmvalue;
   int arecv, brecv, crecv, drecv;
   long tsbit;


   /* Clear the dxinfo structure */

    memset( dxinfo, 0, (sizeof( DX_INFO ) * (MAXCHANS+1)) );

    /* Set the Device to Polled Mode */

    mode = SR_POLLMODE;
    if ( sr_setparm( SRL_DEVICE, SR_MODEID, &mode ) == -1 ) {
       exit(1);
    }


    for ( channum = 1; channum <= MAXCHANS; channum++ ) {

       sprintf( d4xname, "dxxxB%dC%d",
           (channum % 4) ? (channum / 4) + 1 :
           1 + (channum / 4) - 1,
           (channum % 4) ? (channum % 4) : 4 );

       /* open voice channels */
       if ( ( dxinfo[ channum ].devhandle = dx_open( d4xname, 0 ) ) == -1 )   {
          printf("error opening %s",d4xname);
          exit(2);
       }
       printf("opened %s\n",d4xname);
       
       /* Delete all other GTD tone templets */ 
       if (dx_deltones(dxinfo[channum].devhandle)==-1){
          printf("error building tones\n");
          exit(1);
       }

       /* Create GTD templets for detecting R2-MF tones */     
       if (r2_creatfsig(dxinfo[channum].devhandle,R2_ALLFSIG)==-1){
          printf("error r2_createfsig\n");
          exit(1);
       }

       /* Enable the detection of MF tones */
       if (dx_setdigtyp(dxinfo[channum].devhandle,DM_MF)==-1){
          printf("error dx_setdigtyp");
          exit(1);
       }

   }


   /* Open dti board device */
   if ((dtibh = dt_open("dtiB1",0))==-1){
      printf("error opening dtiB1 %d",errno);
      exit(0);
   }
   printf("dtiB1 board device is opened\n");
   parmvalue = 0x0909;

   /* Set receive idle patteren & transmit idle pattern */
   if (dt_setparm(dtibh,DTG_RXTXIDLE,(void *) &parmvalue)==-1){
      printf("error dt_setparm %s %d",errno);
      exit(1);
   }
   printf("DTG_RXTXIDLE is set\n");

   parmvalue = 0x080B;
   if(dt_setparm(dtibh,DTG_SEIZESIG,(void *) &parmvalue) == -1){
      printf("error dt_setparm DTG_RXTXIDLE");
      exit(1);
   }

   /* Set the line seizer pattern */
   printf("DTG_SEIZESIG is set\n");

   /* Close board device handle */
   if (dt_close(dtibh)==-1){
      printf("error closing dtiB1");
      exit(0);
   }


   for (channum = 1; channum <= MAXCHANS; channum++){
      sprintf(d4xname,"dtiB1T%d",channum);
      
      /* Open dti time slot */ 
      if ( (dxinfo[ channum ].dtihandle = dt_open(d4xname,0) ) == -1) {
         printf("error opening %s\n",d4xname);
         exit(1);
      }

      /* set to signal insertion mode */
      printf("opened %s\n",d4xname);
      if (dt_setsigmod(dxinfo[channum].dtihandle,DTM_SIGINS)==-1){
         printf("error dt_setsigmod");
         exit(1);
      }

      /* check receive idle patttern */
      if ((tsbit = ATDT_TSSGBIT(dxinfo[channum].dtihandle)) == AT_FAILURE){
         printf(" error ATDT_TSSGBIT() ");
         exit(1);
      }

      arecv = ( tsbit & DTSG_RCVA ) ? 1 : 0;
      brecv = ( tsbit & DTSG_RCVB ) ? 1 : 0;
      crecv = ( tsbit & DTSG_RCVC ) ? 1 : 0;
      drecv = ( tsbit & DTSG_RCVD ) ? 1 : 0;

      printf("tslot %d A = %d,  B = %d,  C = %d,  D = %d\n",channum,
                              arecv,brecv,crecv, drecv);

      /* set outbound idle pattern on the line */
      if (dt_settssig(dxinfo[channum].dtihandle,DTB_ABIT|
                                           DTB_DBIT,DTA_SETMSK)==-1){
         printf("error dt_setigmod %s",ATDV_ERRMSGP(dxinfo[channum].dtihandle));
         exit(1);
      }

      /* Call multitasking function */
      if (dt_mtfcn(dxinfo[channum].dtihandle,DEMT_WTCALL,0) == -1){
         printf("error dt_mtfcn %s",ATDV_ERRMSGP(dxinfo[channum].dtihandle));
         exit(1);
      }

      /* set initial state of the channel */
      dxinfo[channum].state = ST_WTFORCALL;
   }


}
/***************************************************************************
 *        NAME: void intr_hdlr()
 * DESCRIPTION: Exiting the application and aboarting dt_mtfcn before exiting
 *       INPUT: None.
 *      OUTPUT: None.
 *     RETURNS: None.
 *    CAUTIONS: None.
 ***************************************************************************/
void intr_hdlr()
{  int i;

   /* Aborting multitasking function */   
   printf("exiting application\n");
   for ( i=1; i<=MAXCHANS; i++){
     if (dt_mtfcn(dxinfo[i].dtihandle,DEMT_ABORT,0) == -1){
        printf("error dt_mtfcn abort");
        exit(1);
     }
   }
   exit(1);
}
/***************************************************************************
 *        NAME: void setonhook(int channel)
 * DESCRIPTION: put a channel onhook
 *       INPUT: channel = a channel number
 *      OUTPUT: None.

⌨️ 快捷键说明

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