Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cnrg.itx.gtwy
Class Gateway

    java.lang.Object
      |
      +--cnrg.itx.gtwy.Gateway

public class Gateway
extends java.lang.Object

This class contains the main Gateway control. It also creates instances of other classes needed for controlling individual Gateway channels, data flow, and the interface with signaling.

Inner Class Summary
`private class` | `Gateway.ThreadWait` Inner private class that waits for keyboard input.

Field Summary
`protected static int` | `BUFFERSIZE` Size of voice packets transferred from phone to Gateway.
`private static int` | `CHANNELCOUNT` Number of channels on the Gateway.
`private java.lang.Object[]` | `DTMFMutex` Object used for mutex in stopping and restarting the thread responsible for playout on a phone.
`private Line[]` | `gateLine` Array of Line objects.
`private ListenChannel[]` | `gateListen` Thread that listens for incoming phone calls.
`private java.lang.Thread[]` | `gatePlay` Thread for playing out voice packets to a phone.
`private java.lang.Thread[]` | `gateRecord` Thread that sends voice packets from a phone to a computer.
`private SignalInterface` | `gateSignal` Instance of SignalInterface.
`private static int` | `LINECOUNT` Number of lines on the Gateway.
`private java.lang.Thread` | `myThreadWait` Thread that waits for user input.
`private static java.lang.String[]` | `PHONENUMBER` Extension numbers used to call each line.
`protected static int` | `PXFERFACTOR` Factor `BUFFERSIZE` is multiplied by to determine the size of voice packets transferred from Gateway to phone.

Constructor Summary
`private` | `Gateway(boolean usePBX)`

Method Summary
`(package private) static void` | `()`
`private void` | `channelOffHook(int chDev)` Sets the channel off hook to allow for passing voice data through.
`private void` | `channelOnHook(int chDev)` Sets the channel on hook.
`private int` | `channelSetUp(int channelNum, int xferFactor)` Used for channel initialization.
`protected cnrg.itx.datax.Connection` | `dialComputer(Line lineInfo, java.lang.String ext)` Dials an computer application extension from ListenChannel.
`protected void` | `dialPhone(java.lang.String digits, Line lineInfo)` Dials a phone.
`private void` | `endPlayConnection(int lineNumber)` Stops audio playout from computer to phone
`private void` | `endRecordConnection(int lineNumber)` Terminates the data flow from phone to computer.
`protected void` | `freeLine(Line lineInfo)` Resets and unreserves a line for a future connection.
`protected Line` | `getAvailableLine()` Finds a line that can be used for a connection between a computer and a phone.
`protected void` | `hangup(Line lineInfo)` Called by a RecordChannel.
`private void` | `initialize(int numLines, int bufferSize, int pXferFactor)` Initializes parameters in the .cpp file.
`static void` | `main(java.lang.String[] args)` The main entry point for the Gateway.
`protected void` | `playDTMF(java.lang.String digits, Line lineInfo, cnrg.itx.datax.Connection c)` Used by SignalInterface to play DTMF tones onto the connected phone.
`private void` | `playTones(java.lang.String digits, int chDev)` Plays DTMF tones to the telephone connected to the line.
`private void` | `reroute(int chDev, int secDev)` Reroutes the second channel's playout to the primary channel's playout.
`private void` | `resetPlaySequence(int lineNumber, boolean isStartCall)` Resets handlers for a playout on a phone.
`private void` | `resetRecordSequence(int lineNumber, boolean isStartCall)` Resets handlers for sending data from phone to computer.
`protected void` | `resetSequence(Line lineInfo)` Reinitializes a line for data flow.
`protected void` | `sendDTMF(java.lang.String digits, Line lineInfo)` RecordChannel calls this to send any DTMF digits it received while sending voice data from a phone to a computer.
`protected void` | `setUpConnection(Line lineInfo, cnrg.itx.datax.Connection c)` Sets up a data connection between phone and computer.
`private void` | `shutDown(int[] chDevArray)` Closes all Gateway channels and cleans up memory.
`private void` | `startListen(int index)` Starts a thread for a Gateway channel.
`private void` | `startThreadWait()` Starts the ThreadWait instance.
`protected void` | `tearDownConnection(Line lineInfo)` Used by `SignalInterface` to take down a data connection between computer and phone.
`protected void` | `tearDownPlayConnection(Line lineInfo)` Used by `RecordChannel` after a hangup to stop playout on a phone.
`private void` | `unroute(int chDev)` "Releases" the second channel from playing out on the primary channel.
`protected boolean` | `useLine(Line lineInfo)` Checks if the specified line can be used for a connection between a phone and computer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait`

Field Detail

### BUFFERSIZE

    protected static final int BUFFERSIZE

  Size of voice packets transferred from phone to Gateway.

### PXFERFACTOR

    protected static final int PXFERFACTOR

  Factor `BUFFERSIZE` is multiplied by to determine the size of voice packets transferred from Gateway to phone.

### LINECOUNT

    private static final int LINECOUNT

  Number of lines on the Gateway.

### CHANNELCOUNT

    private static final int CHANNELCOUNT

  Number of channels on the Gateway. NOTE: A line could contain more than one channel.

### PHONENUMBER

    private static final java.lang.String[] PHONENUMBER

  Extension numbers used to call each line. PBX uses these to make a connection between a line and a phone when Gateway calls a telephone.

### DTMFMutex

    private java.lang.Object[] DTMFMutex

  Object used for mutex in stopping and restarting the thread responsible for playout on a phone.

### gateListen

    private ListenChannel[] gateListen

  Thread that listens for incoming phone calls.

### gateRecord

    private java.lang.Thread[] gateRecord

  Thread that sends voice packets from a phone to a computer.

### gatePlay

    private java.lang.Thread[] gatePlay

  Thread for playing out voice packets to a phone.

### gateSignal

    private SignalInterface gateSignal

  Instance of SignalInterface. For interfacing with the signaling component.

### gateLine

    private Line[] gateLine

  Array of Line objects. Each Line object holds information concerning a Gateway line.

### myThreadWait

    private java.lang.Thread myThreadWait

  Thread that waits for user input. Terminates Gateway on Enter key event.

Constructor Detail

### Gateway

    private Gateway(boolean usePBX)
             throws GatewayException

  Parameters:
    `usePBX` - true if the gateway uses the PBX; false otherwise.
  Throws:
    GatewayException - If a channel could not be opened.

Method Detail

###

    static void ()

### startThreadWait

    private void startThreadWait()

  Starts the ThreadWait instance. Waits for Enter key to be pressed.
  See Also:
    `Gateway.ThreadWait`

### startListen

    private void startListen(int index)

  Starts a thread for a Gateway channel. This channel then listens for incoming calls from a phone.
  Parameters:
    `index` - corresponds with each channel number. index 0 is for channel 1.
  See Also:
    `ListenChannel.run()`

### getAvailableLine

    protected Line getAvailableLine()

  Finds a line that can be used for a connection between a computer and a phone. Initializes and reserves that line.
  Returns:
    the `Line` instance of the available line. Contains information concerning that line.
  See Also:
    `Line`

### useLine

    protected boolean useLine(Line lineInfo)

  Checks if the specified line can be used for a connection between a phone and computer. If so, then the line is set offhook and reserved.
  Parameters:
    `lineInfo` - the `Line` instance of the specific line being reserved. Contains information concerning that line.
  Returns:
    true if the channel has been reserved; false otherwise.

### freeLine

    protected void freeLine(Line lineInfo)

  Resets and unreserves a line for a future connection.
  Parameters:
    `lineInfo` - the `Line` instance of the line being freed. Contains information concerning that line.

### resetSequence

    protected void resetSequence(Line lineInfo)

  Reinitializes a line for data flow.
  Parameters:
    `lineInfo` - the `Line` instance of the line being reinitialized. Contains information concerning that line.

### setUpConnection

    protected void setUpConnection(Line lineInfo,
                                   cnrg.itx.datax.Connection c)

  Sets up a data connection between phone and computer. The connection is always through a Gateway line.
  Parameters:
    `lineInfo` - the `Line` instance of the line where the connection is set up. Contains information concerning that line.
    `c` - the `Connection` instance associated with the connection. Provides the means to transfer voice data.
  See Also:
    `Connection`

### tearDownConnection

    protected void tearDownConnection(Line lineInfo)

  Used by `SignalInterface` to take down a data connection between computer and phone. The connection is always through a line.
  Parameters:
    `lineInfo` - the `Line` instance of the line where the connection currently exists. Contains information concerning the line.

### tearDownPlayConnection

    protected void tearDownPlayConnection(Line lineInfo)

  Used by `RecordChannel` after a hangup to stop playout on a phone. The connection on the line is terminated.
  Parameters:
    `lineInfo` - the `Line` instance of the line where the connection currently exists. Contains information concerning that line.

### dialComputer

    protected cnrg.itx.datax.Connection dialComputer(Line lineInfo,
                                                     java.lang.String ext)
                                              throws GatewayException

  Dials an computer application extension from ListenChannel. Returns when call is either accepted or rejected. If the call is accepted, a connection is then set up.
  Parameters:
    `lineInfo` - The `Line` instance of the line from which the phone dial is being made. Contains information concerning that line.
    `ext` - extension number to dial.
  Returns:
    the `Connection` instance used to service data flow on a line. Provides the means necessary for voice data transfer.
  Throws:
    GatewayException - If extension is invalid or call has been rejected.

### hangup

    protected void hangup(Line lineInfo)
                   throws GatewayException

  Called by a RecordChannel. It informs the Gateway that the connected phone has hung up. The Gateway then informs SignalInterface.
  Parameters:
    `lineInfo` - the `Line` instance of the line that is disconnected. Contains information concerning that line.
  Throws:
    GatewayException - If the hangup fails.

### sendDTMF

    protected void sendDTMF(java.lang.String digits,
                            Line lineInfo)
                     throws GatewayException

  RecordChannel calls this to send any DTMF digits it received while sending voice data from a phone to a computer.
  Parameters:
    `digits` - the DTMF digits that were detected from the phone.
    `lineInfo` - the `Line` instance of the line on which the DTMF tones were detected.
  Throws:
    GatewayException - If something goes wrong in sending digits.

### playDTMF

    protected void playDTMF(java.lang.String digits,
                            Line lineInfo,
                            cnrg.itx.datax.Connection c)

  Used by SignalInterface to play DTMF tones onto the connected phone.
  Parameters:
    `digits` - the DTMF tones being played.
    `lineInfo` - the `Line` instance of the line where the DTMF tones are being played. Contains information concerning the line.
    `c` - the `Connection` instance associated with the connection the line is on.

### main

    public static void main(java.lang.String[] args)

  The main entry point for the Gateway.
  Parameters:
    `args` - Array of parameters passed to the application via the command line.

### initialize

    private void initialize(int numLines,
                            int bufferSize,
                            int pXferFactor)

  Initializes parameters in the .cpp file. Called when Gateway starts.
  Parameters:
    `numLines` - the number of lines in the gateway.
    `bufferSize` - the packet transfer rate between the gateway and phone.
    `pXferFactor` - factor bufferSize is multiplied by to define size of packets played to phone.

### shutDown

    private void shutDown(int[] chDevArray)

  Closes all Gateway channels and cleans up memory. Called at termination of the Gateway.
  Parameters:
    `chDevArray` - array of all channel device handlers.

### channelSetUp

    private int channelSetUp(int channelNum,
                             int xferFactor)

  Used for channel initialization. Called during the initialization of the Gateway.
  Parameters:
    `channelNum` - the channel's designated number.
    `xferFactor` - to be multiplied with the packet transfer rate. Meant to increase transfer rate if desired.
  Returns:
    the channel's device handler.

### reroute

    private void reroute(int chDev,
                         int secDev)

  Reroutes the second channel's playout to the primary channel's playout. Necessary for a full duplex connection.
  Parameters:
    `chDev` - the primary channel's device handler.
    `secDev` - the second channel's device handler. This channel is responsible for playout.

### unroute

    private void unroute(int chDev)

  "Releases" the second channel from playing out on the primary channel.
  Parameters:
    `chDev` - the primary channel's device handler.

### channelOnHook

    private void channelOnHook(int chDev)

  Sets the channel on hook. Channel is available to receive incoming calls from a phone.
  Parameters:
    `chDev` - the channel's device handler.

### channelOffHook

    private void channelOffHook(int chDev)

  Sets the channel off hook to allow for passing voice data through.
  Parameters:
    `chDev` - the channel's device handler.

### dialPhone

    protected void dialPhone(java.lang.String digits,
                             Line lineInfo)
                      throws GatewayException

  Dials a phone. Returns as soon as the phone starts ringing or something goes wrong.
  Parameters:
    `digits` - the phone number being dialed.
    `lineInfo` - the `Line` instance of the line where the connection is to be made.
  Throws:
    GatewayException - If the call to a phone fails or a busy signal is received.

### playTones

    private void playTones(java.lang.String digits,
                           int chDev)

  Plays DTMF tones to the telephone connected to the line.
  Parameters:
    `digits` - the DTMF digits being played.
    `chDev` - the channel's device handler.

### resetRecordSequence

    private void resetRecordSequence(int lineNumber,
                                     boolean isStartCall)

  Resets handlers for sending data from phone to computer. Handlers are set to designate that the connection is still alive.
  Parameters:
    `lineNumber` - the channel's corresponding line number.
    `isStartCall` - true if this is the beginning of a connection session; false otherwise.

### resetPlaySequence

    private void resetPlaySequence(int lineNumber,
                                   boolean isStartCall)

  Resets handlers for a playout on a phone. Handlers are set to designate that playout is still active.
  Parameters:
    `lineNumber` - the channel's corresponding line number.
    `isStartCall` - true if this is the beginning of a connection session; false otherwise.

### endRecordConnection

    private void endRecordConnection(int lineNumber)

  Terminates the data flow from phone to computer.
  Parameters:
    `lineNumber` - the channel's corresponding line number.

### endPlayConnection

    private void endPlayConnection(int lineNumber)

  Stops audio playout from computer to phone
  Parameters:
    `lineNumber` - the channel's corresponding line number.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD