FinchTTYImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Last Edited by: Swinehart, July 19, 1987 5:39:17 pm PDT
DIRECTORY
Atom USING [ GetPropFromList, PutPropOnList ],
FinchTTY,
FinchSmarts USING [ ConvDesc, ObtainServiceInterface, RegisterForReports, ReportConversationStateProc, ReportRequestStateProc, ServiceConnect ],
IO USING [ char ],
RefID USING [ ID, nullID ],
Rope USING [ ROPE ],
RPC USING [ CallFailed, ImportFailed ],
Thrush USING [ ConversationID, InterfaceSpec, NB, nullConvID, nullID, SHHH ],
LarkTTYRpcControl USING [
ImportNewInterface, InterfaceRecord, PutRope ],
VoiceUtils USING [ReportFR]
;
FinchTTYImpl: CEDAR MONITOR
Confusion about locks here and in FinchSmartsImpl; careful!
IMPORTS IO, LarkTTYRpcControl, Atom, FinchSmarts, RPC, VoiceUtils
EXPORTS FinchTTY = {
Declarations
ConvDesc: TYPE = FinchSmarts.ConvDesc;
ConversationID: TYPE = Thrush.ConversationID;
NB: TYPE = Thrush.NB;
nullID: RefID.ID = Thrush.nullID;
SHHH: TYPE = Thrush.SHHH;
larkTTY: LarkTTYRpcControl.InterfaceRecord ← NIL;
shhh: SHHH;
LTDesc: TYPE = REF LTDescBody;
LTDescBody: TYPE = RECORD [ serviceID: RefID.ID ← RefID.nullID ];
Supervision
ConvStateReport: ENTRY FinchSmarts.ReportConversationStateProc = {
[nb: NB, cDesc: ConvDesc, remark: ROPE]
No action is considered very useful, at present.
};
ReportReport: ENTRY FinchSmarts.ReportRequestStateProc = {
[cDesc: ConvDesc, actionReport: Thrush.ActionReport, actionRequest: REF]
RETURNS[betterActionRequest: REF]
This one should get the reports first. Then the client that requested action reports can get them too.
ENABLE UNWIND => NULL;
i: CARDINAL;
c: CHAR;
betterActionRequest ← actionRequest;
SELECT actionReport.actionClass FROM
$larktty =>
SELECT actionReport.actionType FROM
$getchar => NULL;
ENDCASE => RETURN;
ENDCASE=>RETURN;
i ← actionReport.actionID;
c ← LOOPHOLE[i];
VoiceUtils.ReportFR["TTY Char: %g", NIL, NIL, IO.char[c]];
};
Client Functions
PutRope: PUBLIC PROC
-- TAKES -- [
convID: Thrush.ConversationID←Thrush.nullConvID,
rope: Rope.ROPE
]
RETURNS [
nb: Thrush.NB←$success,
newConvID: Thrush.ConversationID
] = {
cDesc: ConvDesc;
ltDesc: LTDesc;
ScheduleRope: ENTRY PROC = {
ENABLE {
UNWIND=>NULL;
RPC.CallFailed => {
IF larkTTY=NIL THEN CONTINUE;
larkTTY ← NIL;
RETRY; -- Will attempt reconnection via main Finch connection—once
};
};
nb ← larkTTY.PutRope[shhh, cDesc.situation.self, ltDesc.serviceID, rope];
};
[nb,cDesc, ltDesc]←LarkTTYConnect[convID];
IF nb#$success THEN RETURN; -- Complain?
newConvID ← cDesc.situation.self.convID;
ScheduleRope[];
};
LarkTTYConnect: PROC[convID: Thrush.ConversationID]
RETURNS [nb: NB, cDesc: ConvDesc, ltDesc: LTDesc] = {
[nb, cDesc] ← FinchSmarts.ServiceConnect[NIL, convID]; -- Make an empty conv. if necc.
IF nb#$success THEN RETURN;
ltDesc ← NARROW[Atom.GetPropFromList[cDesc.props, $LarkTTYDesc]];
IF ltDesc#NIL THEN RETURN;
ltDesc ← NEW[LTDescBody ← []];
cDesc.props ← Atom.PutPropOnList[cDesc.props, $LarkTTYDesc, ltDesc];
nb ← LarkTTYInterface[cDesc, ltDesc];
};
LarkTTYInterface: PROC[cDesc: ConvDesc, ltDesc: LTDesc]
RETURNS [nb: NB←$success] = {
interfaceSpec: Thrush.InterfaceSpec;
IF larkTTY#NIL AND (ltDesc=NIL OR ltDesc.serviceID#nullID) THEN RETURN;
[nb, shhh, interfaceSpec] ← FinchSmarts.ObtainServiceInterface[NIL, "LarkTTY", NIL];
Service from own party, or poachee
IF nb#$success THEN RETURN;
larkTTY ← LarkTTYRpcControl.ImportNewInterface[
interfaceName: interfaceSpec.interfaceName,
hostHint: interfaceSpec.hostHint!RPC.ImportFailed => CONTINUE
];
IF larkTTY=NIL THEN RETURN[$noLarkTTYInterface];
IF ltDesc#NIL THEN ltDesc.serviceID ← interfaceSpec.serviceID;
};
Initialization
InitializeLarkTTY: PUBLIC PROC = {
FinchSmarts.RegisterForReports[s: NIL, c: ConvStateReport, r: ReportReport, before: TRUE];
Ask Finch to inform us of changes in conversation state, and action reports.
};
}.
Swinehart, May 11, 1987 1:33:22 pm PDT
Extracted from old FinchSynthesizerImpl