VoiceSetup
The VoiceSetup instruction is used to control the hang up of the COM310/COM320 voice modem.
Syntax
VoiceSetup ( HangUpKey, ExitSubKey, ContinueKey, SecOnLine, UseTimeout, CallOut )

The following program shows an example of the datalogger calling out via a COM310/COM320 or receiving a call in from a user. If a user calls in, he has the choice of hearing measurement values, toggling a port, or toggling a Flag variable. The datalogger will initiate a call out if the temperature is greater than 85 degrees.
Public Value(3)
Alias Value(1) = BatteryV
Alias Value(2) = PTemp
Alias Value(3) = TCValue_F
Const KeyTimeout = 800 '8 second timeout waiting for key stroke before hangup
const SecOnLine = 360 '5 minutes On Line Timeout
const STAR = 42 'The * key
const POUND = 35 'The # key
const HangupIfKeyTimeout = TRUE 'We will hangup if timeout waiting for a key
public mykey as long
'<<< VOICE CODE that executes when the datalogger detects a RING from COM310/COM320 or when dialVoice() succeeds >>>
public CallingOut as Boolean 'Used to detect calling out or calling in
'STAR (*) key will be used to return from subroutines and to disconnect if not in a subroutine
VoiceSetup (STAR,STAR,0,SecOnLine,HangupIfKeyTimeout,CallingOut)
VoiceBeg
If CallingOut then 'calling out (triggered by DialVoice()
Call CallOutVoice
else
Call CallInVoice 'calling in
Endif
EndVoice
' ***** Subroutines *****
'Called when user is calling in
Sub CallInVoice
do
VoiceSpeak ("CURRENT STATION DATA 50MS 50MS", 0)
VoiceSpeak ("PRESS ONE TO HEAR THE BATTERY VOLTAGE 50MS", 0)
VoiceSpeak ("PRESS TWO TO HEAR THE DATALOGGER TEMPERATURE 50MS", 0)
VoiceSpeak ("PRESS THREE TO HEAR THE T C TEMPERATURE 50MS", 0)
VoiceSpeak ("PRESS STAR TO DISCONNECT", 0)
Select Case VoiceKey(keytimeout)
Case 1
VoiceSpeak ("THE BATTERY VOLTAGE IS" + Value(1) + "VOLTS", 1)
Case 2
VoiceSpeak ("THE REFERENCE IS" + Value(2) + "DEGREES", 1)
Case 3
VoiceSpeak ("THE AIR TEMPERATURE IS" + Value(3) + "DEGREES", 0)
EndSelect
loop 'until timeout or STAR
EndSub
' Calling Out
Public Alarm as Boolean, ArmAlarm as Boolean, ManualAlarm as Boolean
Sub CallOutVoice
'Dial # reset to reset alarm = 0
do
VoiceSpeak("50MS PRESS POUND TO RESET ALARM 50MS PRESS STAR TO DISCONNECT", 0)
mykey = VoiceKey(0)
loop until mykey = POUND
'they cleared the alarm, let them get it and do other things
Alarm = False
do 'until timeout
VoiceSpeak ("50MS C R ONE THOUSAND STATION 50MS 50MS", 0)
VoiceSpeak ("PRESS ONE TO HEAR A SENSOR VALUE 50MS 50MS", 0)
VoiceSpeak ("PRESS TWO TO HEAR OR TOGGLE PORT 50MS 50MS", 0)
VoiceSpeak ("PRESS STAR TO DISCONNECT 50MS 50MS", 0)
Select Case VoiceKey(KeyTimeout)
Case 1
Call SubKey1
Case 2
Call SubKey2
Case 3
Call SubKey3
EndSelect
loop 'until timeout
EndSub
'monitors a value
Sub SubKey1
Do
VoiceSpeak ("50MS PRESS SENSOR NUMBER 50MS PRESS STAR TO RETURN", 0)
mykey = VoiceKey (KeyTimeout)
If mykey = 1 then VoiceSpeak ("50MS THE BATTERY VOLTAGE IS" + Value(1) + "VOLTS", 1)
If (mykey = 2) then VoiceSpeak ("50MS THE REFERENCE IS" + Value(2) + "DEGREES", 1)
IF (mykey = 3) then VoiceSpeak ("50MS THE T C IS" + Value(3) + "DEGREES", 1)
Loop ' Sensor value loop
EndSub
' Read a port and possibly toggle
Sub SubKey2
Do 'until * or timeout
dim keybit, port as long, state
VoiceSpeak("50MS PRESS PORT NUMBER 50MS PRESS STAR TO RETURN", 0)
port = VoiceKey(keyTimeout)
if (port > 0) and (port <= 8) then
keybit = 2^(port-1) 'bit 0..7 is set in keybit
do
ReadIO(state, &b1111111111111111)
VoiceSpeak("50MS C" + port + "IS",0)
if state and keybit then
VoiceSpeak("ON",0)
else
VoiceSpeak("OFF",0)
Endif
VoiceSpeak("50MS PRESS POUND TO TOGGLE 50MS PRESS STAR to return", 0)
if VoiceKey(KeyTimeout) = POUND then
ReadIO (state,&b11111111)
if state and keybit then
state = state and (not keybit)
else
state = state or keybit
endif
WriteIO(&b1111111111111111,state) ' toggle control port
endif
Loop
endif
Loop
EndSub
Sub SubKey3
Const NUMBERFLAGS = 4
Public Flags(NUMBERFLAGS)
Do 'until * or timeout
VoiceSpeak("50MS PRESS FLAG NUMBER 50MS PRESS STAR TO RETURN", 0)
mykey = VoiceKey(keyTimeout)
if (mykey > 0) and (mykey <= NUMBERFLAGS) then
do
VoiceSpeak("50MS C" + mykey + "IS",0)
if Flags(mykey) then
VoiceSpeak("ON",0)
else
VoiceSpeak("OFF",0)
Endif
VoiceSpeak("50MS PRESS POUND TO TOGGLE 50MS PRESS STAR to return", 0)
if VoiceKey(KeyTimeout) = POUND then
flags(mykey) = NOT flags(mykey)
else
exitdo
endif
Loop
EndIf
Loop ' Port loop
EndSub
DataTable (Test,1,-1)
DataInterval (0,0,Sec,10)
Minimum (1,BatteryV,FP2,0,False)
Sample (1,PTemp,FP2
Sample (1,TCvalue_F,FP2)
EndTable
' <<<<<<<<<<<<<<<<<< MEASUREMENT PROGRAM >>>>>>>>>>>>>>>>>>
BeginProg
Scan (1,Sec,3,0)
Battery (BatteryV)
PanelTemp (PTemp,15000)
TCDiff (TCvalue_F,1,mv200,U7,TypeT,PTemp,True,0,15000,1.8,32)
' Add measurement code here *******************
CallTable Test
NextScan
' <<< VOICE CALLBACK CODE that executes when alarm conditions are met >>>
SlowSequence
' Slow Sequence do loop forever possibly doing alarm call out
Const NUMPHONES = 3 '3 phone numbers to try
Const PHONE1 = "603"
Const PHONE2 = "603"
Const PHONE3 = "603"
dim i,Phones(NUMPHONES) as String
phones(1) = PHONE1
phones(2) = PHONE2
phones(3) = PHONE3
Alarm = FALSE
ArmAlarm = TRUE
do 'forever
delay(1,1,sec)
if (TCvalue_F < 85) then
ArmAlarm = TRUE
elseif (TCvalue_F > 85 And ArmAlarm) or ManualAlarm = TRUE then
ManualAlarm = False
Alarm = TRUE
do
for i = 1 to NUMPHONES
'call these numbers until the alarm is cleared
if Alarm then dialVoice(phones(i)) 'calls only if alarm is set
next i
if Alarm then Delay(1,1,min)
loop until Alarm = FALSE
ArmAlarm = False
Endif
loop
EndProg
Parameters
HangUpKey
The key that, when pressed, will disconnect the COM310/COM320.
Type: Variable
ExitSubKey
The key that, when pressed, will exit a subroutine if the datalogger is running one.
Type: Variable
ContinueKey
The key that, when pressed, will begin announcing the next VoiceSpeak phrase.
Type: Variable
SecOnLine
The maximum number of seconds that the COM310 will be on a call before it is hung up by the datalogger.
Type: Variable
UseTimeOut
Boolean variable that determines whether or not the datalogger will hang up the COM310 after the timeout in the VoiceKey instruction expires. If this parameter is set to True, the timeout will be used. If this parameter is set to False, the timeout will not be used.
Type: Variable
CallOut
Boolean variable that indicates the mode that the COM310 is in. If the value returned in this parameter is True, the datalogger has called out. If the value is False, the datalogger has received an incoming call.
Type: Variable
If the same character is used for HangUpKey and ExitSubKey, the datalogger will exit a subroutine if it is in one, otherwise, it will hang up the COM310/COM320. If the ContinueKey is pressed, the COM310/COM320 will skip the current VoiceSpeak string and move to the next VoiceSpeak string. If any other key is pressed, the COM310/COM320 will skip to the next group of VoiceSpeak instructions.