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

📄 tpt.java

📁 著名的dialogic电话语音卡的java驱动程序,已经验证可用。
💻 JAVA
字号:
// TPT: Model Termination Parameters Table
// $Id: TPT.java,v 1.3 2003/11/13 11:55:18 cgm8 Exp $
/* 
 * Copyright (c) 1999 Carlos G Mendioroz.
 *
 *  This file is part of D4J.
 *
 *  D4J is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *  
 *  D4J is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *  
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *  Boston, MA  02111-1307, USA.
 *
 * Report problems and direct all questions to:
 *
 *	tron@acm.org
 */
package local.dialogic;

public class TPT extends java.lang.Object
{
    
// This is what we model:
//     typedef struct dx_tpt {
//       unsigned short   tp_type;             /* Flags describing this entry */
//       unsigned short   tp_termno;           /* Termination Parameter number */
//       unsigned short   tp_length;           /* Length of terminator */
//       unsigned short   tp_flags;            /* Parameter attribute flag */
//       unsigned short   tp_data;             /* Optional additional data */
//       unsigned short   rfu;                 /* Reserved                 */
//       DV_TPT           *tp_nextp;           /* Pointer to next termination
//                                             * parameter if IO_LINK set  */
//      }DX_TPT

// tp_type := {IO_LINK, IO_CONT, IO_EOT}      ' we use IO_CONT/IO_EOT only
// tp_termno := {DX_MAXDTMF,DX_MAXSIL,DX_MAXNOSIL,DX_LCOFF,DX_IDDTIME,
//               DX_MAXTIME,DX_DIGMASK,DX_PMOFF,DX_PMON,DX_TONE}
// tp_length := time in 10/100 ms units 
//           or # of digits  ( DX_MAXDTMF )
//           or digit type desc ( DX_DIGTYPE )
//           or bit mask ( DX_DIGMASK )
//           or # patterns ( DX_PMOFF )
// tp_flags := EDGE/LEVEL, CLREND, CLRBEG, USE, 10MS, SETINIT, FIRST
// Low level interface reconstructs this based on our variables:

    protected int size;
    protected int termno[];
    protected int length[];
    protected int flags[];
    protected int data[];
    
    public static final int MAXDTMF = 1;
    public static final int MAXSIL = 2;
    public static final int MAXNOSIL = 3;
    public static final int LCOFF = 4;
    public static final int MAXIDDTIME = 5;
    public static final int MAXTIME = 6;
    public static final int DIGMASK = 7;
    public static final int PMOFF = 8;
    public static final int PMON = 9;
    public static final int DIGTYPE = 11;
    public static final int TONE = 12;
    
    public static final int EDGE = 0;
    public static final int LEVEL = 1;
    public static final int CLREND = 2;
    public static final int CLRBEG = 4;
    public static final int USE = 8;
    public static final int SETINIT = 16;
    public static final int TENMS = 32;
    
/*
 * Masked DTMF termination/initiation equates
 */
    public static final int DM_D = 0x0001; /* Mask for DTMF d. */
    public static final int DM_1 = 0x0002; /* Mask for DTMF 1. */
    public static final int DM_2 = 0x0004; /* Mask for DTMF 2. */
    public static final int DM_3 = 0x0008; /* Mask for DTMF 3. */
    public static final int DM_4 = 0x0010; /* Mask for DTMF 4. */
    public static final int DM_5 = 0x0020; /* Mask for DTMF 5. */
    public static final int DM_6 = 0x0040; /* Mask for DTMF 6. */
    public static final int DM_7 = 0x0080; /* Mask for DTMF 7. */
    public static final int DM_8 = 0x0100; /* Mask for DTMF 8. */
    public static final int DM_9 = 0x0200; /* Mask for DTMF 9. */
    public static final int DM_0 = 0x0400; /* Mask for DTMF 0. */
    public static final int DM_S = 0x0800; /* Mask for DTMF *. */
    public static final int DM_P = 0x1000; /* Mask for DTMF #. */
    public static final int DM_A = 0x2000; /* Mask for DTMF a. */
    public static final int DM_B = 0x4000; /* Mask for DTMF b. */
    public static final int DM_C = 0x8000; /* Mask for DTMF c. */
    
    
    public static final int TONEOFF = 0;
    public static final int TONEON = 1;
    
    public TPT()
    {
        termno = new int[10];
        length = new int[10];
        flags = new int[10];
        data = new int[10];
        
        size = 0;
    }
 
    public TPT(int term, int len, int flgs, int dta)
    {
        if (term < 0 || term > 12)
            throw new RuntimeException("Invalid termination event");
 
        termno = new int[10];
        length = new int[10];
        flags = new int[10];
        data = new int[10];
        
        termno[0] = term;
        length[0] = len;
        flags[0] = flgs;
        data[0] = dta;
        size = 1;
    }
    
    public TPT add(int term, int len, int flgs, int dta)
    {
        if (term < 0 || term > 12)
            throw new RuntimeException("Invalid termination event");
 
        if (size == termno.length) {
            int i, p[];
            p = termno;
            termno = new int[size+10];
            for(i = 0; i < size; i++) termno[i] = p[i];
            p = length;
            length = new int[size+10];
            for(i = 0; i < size; i++) length[i] = p[i];
            p = flags;
            flags = new int[size+10];
            for(i = 0; i < size; i++) flags[i] = p[i];
            p = data;
            data = new int[size+10];
            for(i = 0; i < size; i++) data[i] = p[i];
            p = null;
        }
        
        termno[size] = term;
        length[size] = len;
        flags[size] = flgs;
        data[size] = dta;
        size ++;
        return this;
    }
        
}

⌨️ 快捷键说明

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