# Switching application example

This topic describes how to use the Natural Access Switching service to develop a call center application. The following information is provided:

- Scenario of the example

- Hardware used

- Sample program

## Scenario

There are 24 incoming lines with 24 analog operator stations, as shown in the following illustration:

Note: A real application would have more incoming lines than operators.

####

This program:

1. Accepts a call on an incoming T1 line.

2. Plays a please hold message, and sends silence to the caller.

Note: A real application may do some preparatory work, such as database look-up, before transferring a call to an operator.

3. Plays a you have a call.... message to the operator (assuming that the operator is already listening).

4. Connects the voice paths of the incoming line and an operator station.

5. Monitors the incoming line for hang-up.

6. Breaks down both ends of the call when either end hangs up.

7. Returns to step 1.

## Hardware

For purposes of this example, the hardware is:

- One AG 4000 T board with as many as 96 digital line interfaces and 96 DSP ports, one for each incoming line.

- One CX 2000 board with up to 48 analog operator station interfaces.

Note: A real call center application may use different hardware configurations.

## Sample program

The following illustration shows the initial state of the switch blocks
in the system when there are no connections. Stream connections and only timeslot
0 are shown.

* Only trunk 1 is shown.

####

1. Open the switching device and access the switch handle
   for the AG 4000 board and the CX 2000 board. This example assumes that the switches are open in MVIP-95 mode, and that their states are restored on exit.

void myInitialize(CTAHD ctahd, SWIHD *t1hd, SWIHD *cxhd)
{
SWI_TERMINUS inputs[24], outputs[24];
unsigned count;
/* Open a switch handle to the AG 4000 board */
swiOpenSwitch(ctahd, "AGSW", 0, SWI_ENABLE_RESTORE, t1hd);
/* Open a switch handle to the CX 2000 board */
swiOpenSwitch(ctahd, "CXSW", 0, SWI_ENABLE_RESTORE, cxhd);
/* Connect the DSPs to the line interfaces on the AG 4000: */
/* Connect the voice streams: */
/* Connect network XMIT to DSP RCV */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_LOCAL_BUS;
inputs[count].stream = 0;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_LOCAL_BUS;
outputs[count].stream = 17;
outputs[count].timeslot = (DWORD)count;
}
/* Make output address(es) read from input address(es) */
swiMakeConnection(*t1hd, inputs, outputs, count);
/* Connect DSP XMIT to network RCV */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_LOCAL_BUS;
inputs[count].stream = 16;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_LOCAL_BUS;
outputs[count].stream = 1;
outputs[count].timeslot = (DWORD)count;
}
swiMakeConnection(*t1hd, inputs, outputs, count);
/* Connect the signaling streams: */
/* Connect network XMIT to DSP RCV */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_LOCAL_BUS;
inputs[count].stream = 2;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_LOCAL_BUS;
outputs[count].stream = 19;
outputs[count].timeslot = (DWORD)count;
}
swiMakeConnection(*t1hd, inputs, outputs, count);
/* Connect DSP XMIT to network RCV */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_LOCAL_BUS;
inputs[count].stream = 18;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_LOCAL_BUS;
outputs[count].stream = 3;
outputs[count].timeslot = (DWORD)count;
}
swiMakeConnection(*t1hd, inputs, outputs, count);
}
/* Connect the DSPs to the line interfaces on the CX 2000 (signaling only)*/
/* Connect the signaling streams: */
/* Connect network XMIT to DSP RCV */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_LOCAL_BUS;
inputs[count].stream = 2;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_LOCAL_BUS;
outputs[count].stream = 7;
outputs[count].timeslot = (DWORD)count;
}
swiMakeConnection(*t1hd, inputs, outputs, count);
/* Connect DSP XMIT to network RCV */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_LOCAL_BUS;
inputs[count].stream = 6;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_LOCAL_BUS;
outputs[count].stream = 3;
outputs[count].timeslot = (DWORD)count;
}

2. Using switching, nail up the CX 2000 lines to the MVIP bus on streams 0 and 1.

/* Nails up CX 2000 lines to the MVIP bus */
void myConnectAgCx(SWIHD cxhd)
{
SWI_TERMINUS outputs[24], inputs[24];
unsigned count;
/* Connect Voice lines: */
/* Connect CX2000 local:0:0..23 to mvip:1:0..23 */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_LOCAL_BUS;
inputs[count].stream = 0;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_MVIP_BUS;
outputs[count].stream = 1;
outputs[count].timeslot = (DWORD)count;
}
swiMakeConnection(cxhd, inputs, outputs, count);
/* Connect CX2000 mvip:0:0..23 to local:1:0..23 */
for (count = 0; count < 24; count++)
{
inputs[count].bus = MVIP95_MVIP_BUS;
inputs[count].stream = 0;
inputs[count].timeslot = (DWORD)count;
outputs[count].bus = MVIP95_LOCAL_BUS;
outputs[count].stream = 1;
outputs[count].timeslot = (DWORD)count;
}
swiMakeConnection(cxhd, inputs, outputs, count);
}

The following illustration shows the state of the switches in the system:

The program returns to this state after each call.

3. Wait for incoming calls on the incoming lines using the Natural Call Control service.

4. When a call comes in, use the Natural Call Control service to perform call control. Once the T1 call is connected, play Please hold using the Voice Message service and send a silence pattern to the incoming line using the Switching service.

/* Send Silence to incoming T1 call */
void mySendSilence(SWIHD t1hd, DWORD timeslot)
{
SWI_TERMINUS output;
BYTE pattern = 0x7F; /* Silence pattern for MU-law */
/* Send silence pattern to incoming call via local:1:timeslot */
output.bus = MVIP95_LOCAL_BUS;
output.stream = 1;
output.timeslot = timeslot;
swiSendPattern(t1hd, &pattern, &output, 1);
}

5. Connect the DSP
   port assigned to the incoming call to the CX 2000 operator station. (This step assumes the battery and the bit detector are enabled on the CX 2000 ports.) Notify the operator of the incoming call using the Voice Message service.

/* Connect T1 DSP to CX 2000 station, DUPLEX connection via the CT bus,
* in preparation for playing the "here comes a call" message.
*/
void myConnect4KCx(SWIHD t1hd, DWORD timeslot)
{
SWI_TERMINUS output, input;
/* Connect AG4000 T1 local:16:timeslot to mvip:0:timeslot */
input.bus = MVIP95_LOCAL_BUS;
input.stream = 16;
input.timeslot = timeslot;
output.bus = MVIP95_MVIP_BUS;
output.stream = 0;
output.timeslot = timeslot;
swiMakeConnection(t1hd, &input, &output, 1);
/* Connect AG4000 T1 mvip:1:timeslot to local:17:timeslot */
input.bus = MVIP95_MVIP_BUS;
input.stream = 1;
input.timeslot = timeslot;
output.bus = MVIP95_LOCAL_BUS;
output.stream = 17;
output.timeslot = timeslot;
swiMakeConnection(t1hd, &input, &output, 1);
}

The following illustration shows the state of the switches in the system:

6. Connect the voice paths of the AG 4000 T1 line and the CX 2000 operator station so that the caller and the operator can carry on a conversation. To accomplish this task, connect the AG 4000 board's voice streams to the CX 2000 board's operator voice streams.

/* Connect Voice paths of CX 2000 station and
* the incoming call, DUPLEX connection.
*/
void myConnectVoice(SWIHD t1hd, DWORD timeslot)
{
SWI_TERMINUS output, input;
/* Connect AG 4000 T1 local:0:timeslot to mvip:0:timeslot */
input.bus = MVIP95_LOCAL_BUS;
input.stream = 0;
input.timeslot = timeslot;
output.bus = MVIP95_MVIP_BUS;
output.stream = 0;
output.timeslot = timeslot;
swiMakeConnection(t1hd, &input, &output, 1);
/* Connect AG 4000 T1 mvip:1:timeslot to local:1:timeslot */
input.bus = MVIP95_MVIP_BUS;
input.stream = 1;
input.timeslot = timeslot;
output.bus = MVIP95_LOCAL_BUS;
output.stream = 1;
output.timeslot = timeslot;
swiMakeConnection(t1hd, &input, &output, 1);
}

The following illustration shows the state of the switches in the system:

7. If either end hangs up, disconnect the call using the Natural Call Control service. Reconnect the AG 4000 board's DSP streams to the AG 4000 board's line interface streams.

/* Reset paths to get ready for next incoming call.
*/
void myResetT1Line(SWIHD t1hd, DWORD timeslot)
{
SWI_TERMINUS output, input;
/* Disable outputs of switch to mvip:0:timeslot */
output.bus = MVIP95_MVIP_BUS;
output.stream = 0;
output.timeslot = timeslot;
swiDisableOutput(t1hd, &output, 1);
/* Disable outputs of switch to local:1:timeslot */
output.bus = MVIP95_LOCAL_BUS;
output.stream = 1;
output.timeslot = timeslot;
swiDisableOutput(t1hd, &output, 1);
/* Reconnect voice streams */
input.bus = MVIP95_LOCAL_BUS;
input.stream = 0;
input.timeslot = timeslot;
output.bus = MVIP95_LOCAL_BUS;
output.stream = 17;
output.timeslot = timeslot;
swiMakeConnection(t1hd, &input, &output, 1);
input.bus = MVIP95_LOCAL_BUS;
input.stream = 16;
input.timeslot = timeslot;
output.bus = MVIP95_LOCAL_BUS;
output.stream = 1;
output.timeslot = timeslot;
swiMakeConnection(t1hd, &input, &output, 1);

The application returns to the initial state, as shown in the following illustration:

8. At the end of the program, call swiCloseSwitch to close all the switches and restore the state of the switch blocks.

/* Close open switches */
void myShutdown(SWIHD t1hd, SWIHD cxhd)
{
swiCloseSwitch(t1hd);
swiCloseSwitch(cxhd);
}