INCLUDE rtcu.inc
VAR_OUTPUT
connected : BOOL;
offhook : BOOL;
outputs : ARRAY[1..8] OF BOOL;
END_VAR;
VAR
no : INT;
command : INT;
state : SINT := 1;
incoming: gsmIncomingCall;
END_VAR;
PROGRAM SetOutput;
gsmPower(power:=ON);
BEGIN
incoming();
connected := gsmConnected();
CASE state OF
1:
IF incoming.status > 0 THEN
DebugMsg(message:="Incoming call, answering");
gsmAnswer();
state:=2;
END_IF;
2:
voiceTalk(message:="SelOutNo.wav");
no:=dtmfGetKey(timeout:=5000);
IF no>=1 AND no<=8 THEN
state:=3;
DebugFmt(message:="Output number \1 selected", v1:=no);
END_IF;
3:
voiceTalk(message:="SelOnOff.wav");
command:=dtmfGetKey(timeout:=5000);
IF command=0 OR command=1 THEN
outputs[no]:=BOOL(command);
DebugFmt(message:="Output number \1 set to \2", v1:=no, v2:=command);
state:=2;
ELSIF command=10 THEN
state:=2;
END_IF;
END_CASE;
offhook := gsmOffHook();
IF NOT offhook THEN
state:=1;
END_IF;
END;
END_PROGRAM;
|