8.7 State-Machine Program
(Page 8 of 12 in this chapter)
Name:
adistate
Purpose:
Demonstrates:
Single-thread multiple port program
Multiple I/O drivers (line control simulated with keyboard)
AG Access used strictly for voice (inband path)
Usage
:
adistate [options]
where the options are:
Option
Description
-b board
Specifies the AG board number <n>. Default 0.
-s stream
Specifies the MVIP stream.
-p count
Specifies the number of ports.
-z bytes
Specifies the play/record buffer size.
-q
Specifies quiet mode.
Highlights
:
adiOpenPort
- Multiple concurrent opens.
adiCollectDigits
adiRecordAsync
- Asynchronous buffer submission.
adiSubmitRecordBuffer
adiPlayAsync
- Asynchronous buffer submission.
adiSubmitPlayBuffer
Description:
The
adistate
demo is an implementation of a simple IVR application, and includes a main menu and a record demo sub-menu.
The demo is structured such that each port is an independent asynchronous state- machine. When an AG Access function is initiated, the demo assigns a call-out table to handle the "done event" for the function.
Each port's context is maintained in a
DEMO_PORT_STRUCT
. Correlating events to
DEMO_PORT_STRUCTs
when AG Access events are received is achieved by employing the
userid
variable (refer to
adiOpenPort
) as an index into a table of pointers to these structures.
After the demo's port structure is dereferenced, the application determines exactly which event occurred (e.g.,
RECORD_DONE
because of
TIMEOUT
). The event is used to index into the call-out table for the application state for the port. The call- out is invoked to advance to the next step in the demo.
Procedure:
After configuring your MVIP bus and starting
agmon
, execute the
adistate
demo. You can specify the number of ports to open with the
-p
option.
Once the ports are open, use the keyboard to type commands simulating call- control. Type "
answer [port]
" to begin the demo on the given port or "
hang up [port]
" to terminate the demo. For example, type "
answer 0
" to begin the demo on port 0. You must ensure that the port number specified is indeed MVIP configured so that data is routed to your handset.
(Page 8 of 12 in this chapter)