FinchSmarts.mesa
Copyright Ó 1985, 1986, 1987 by Xerox Corporation. All rights reserved.
Last Edited by: Swinehart, July 24, 1987 2:19:53 pm PDT
Doug Terry, September 5, 1986 3:44:36 pm PDT
Polle Zellweger (PTZ) July 27, 1987 8:39:58 pm PDT
DIRECTORY
Atom USING [ PropList ],
BasicTime USING [ GMT ],
GVBasics USING [ Password ],
LarkFeepRpcControl USING [ InterfaceRecord ],
MBQueue USING [ Queue ],
RefID USING [ ID ],
Rope USING [ ROPE ],
RPC USING [ EncryptionKey, InterfaceName, TimeoutEnable ],
ThParty USING [ PartyInfo ],
Thrush
USING
[ ActionReport, ConversationID, ConvEventBody, InterfaceSpec, NB, nullConvID, nullID, PartyID, Reason, ROPE, SHHH, SmartsID, StateInConv ],
ThSmartsRpcControl
;
FinchSmarts:
CEDAR DEFINITIONS = {
Types
ConversationID:
TYPE = Thrush.ConversationID;
nullConvID: ConversationID = Thrush.nullConvID;
NB: TYPE = Thrush.NB;
nullID: RefID.ID = Thrush.nullID;
WhoOriginated: TYPE = INT; -- the index of the originating party
unknown: WhoOriginated = -1;
us: WhoOriginated = 0;
them: WhoOriginated > 0;
PartyID: TYPE = Thrush.PartyID;
Reason: TYPE = Thrush.Reason;
ROPE: TYPE = Thrush.ROPE;
SHHH: TYPE = Thrush.SHHH;
PD:
TYPE =
RECORD [
-- Global values for all Finch instances
doReports: BOOL←FALSE,
doNice: BOOL←FALSE,
doPollingTimeouts: BOOL←TRUE,
pollDefault: INT ← 300, -- 5 minutes minimum between probes when disconnected
timeoutEnable: RPC.TimeoutEnable ← always,
maxTransmissions: CARDINAL ← 6,
timeoutInitiating: NAT ← 11,
timeoutNoAction: INTEGER ← 30,
timeoutJayConnect: INTEGER ← 1,
jayTimeout: NAT ← 1,
encryptionRequested: BOOLEAN←TRUE,
smartsIsExported: BOOLEAN←FALSE,
waitsForConnect: NAT𡤅,
queueIt: BOOL←FALSE,
maxProseLength: INT,
requests: MBQueue.Queue, -- requests to report; must be serialized across all instances
interfaceName: RPC.InterfaceName ← [],
enabled: BOOL←FALSE, -- client has required Finch connection
connected: BOOL ← FALSE -- connection is established
];
pd: REF PD;
FinchInfo: TYPE = REF FinchInfoBody;
FinchInfoBody:
TYPE =
MONITORED
RECORD [
-- Per Finch instance: one, for now
smartsID: Thrush.SmartsID←nullID,
partyID: PartyID ← nullID,
shh: SHHH←NIL,
conversations: LIST OF ConvDesc -- of ConvDescs --,
stateChange: CONDITION,
myName: ThSmartsRpcControl.InterfaceName ← [],
myRName: ROPE ← NIL,
myPassword: RPC.EncryptionKey ← NULL,
prevThrushInstance: ROPE ← NIL,
pollCondition: CONDITION,
nextScheduledCheck: INT𡤀,
Call backs
systemStateSubscribers: LIST OF ReportSystemStateProc,
convStateSubscribers: LIST OF ReportConversationStateProc,
requestStateSubscribers: LIST OF ReportRequestStateProc
];
ConvDesc: TYPE = REF ConvDescBody;
ConvDescBody:
TYPE =
RECORD [
Switching data
situation: Thrush.ConvEventBody, -- amalgam of useful info from last-reported event
Data of use to clients, maintained by FinchSmarts
whoOriginated: WhoOriginated ← unknown,
ultimateState: Thrush.StateInConv ← idle,
-- last state reached (except for idle)
Maintained by SmartsImpl:
For calls that were completed, this will be active
For attempted outgoing calls, this is perhaps maybe
For incoming calls that were not answered, this is perhaps ringing
startTime: BasicTime.GMT←NULL,
subject: ROPE←NIL,
numParties: NAT𡤀,
numActive: NAT𡤀,
numIdle: NAT𡤀,
partyInfo: ThParty.PartyInfo←NIL, -- Complete description as of some recent time
feepInterfaceSpec: Thrush.InterfaceSpec,
feepInterface: LarkFeepRpcControl.InterfaceRecord,
Client-maintained data
clientData:
REF ←
NIL,
ReportConversationState implementation can store client-dependent pointers here; but this field is cleared once the ConvDesc leaves the FinchInfo.conversations Queue.
props: Atom.PropList ←
NIL,
Client-specific values, such as information used by synthesizer code and such. Placed here as a convenience for such services.
originatorRecorded: BOOL←FALSE,
reportComplete: BOOL←FALSE
];
Initialization
InitFinchSmarts:
PROC [thrushInstance: Thrush.
ROPE←
NIL, s: ReportSystemStateProc ←
NIL, c: ReportConversationStateProc ←
NIL, r: ReportRequestStateProc ←
NIL, before:
BOOL ←
TRUE];
Initialize, then register the specified procedures via RegisterForReports. Solves a mutual dependency: the completion of InitFinchSmarts wants to call ReportSystemState via the registry, but the registry is maintained by a data structure that this procedure creates.
FinchIsRunning:
PROC
RETURNS [finchIsEnabled:
BOOL, finchIsRunning:
BOOL];
finchIsEnabled means InitFinchSmarts has been called more frequently than UninitFinchSmarts; finchIsRunning means Finch and the server are in contact; if false, the next call will attempt to reestablish, but it might fail.
Poke:
PROC;
If enabled but not connected, tries to get connected, best way.
UninitFinchSmarts: PROC;
Call Management
PlaceCall:
PROC [
convID: Thrush.ConversationID ← nullConvID,
rName: ROPE←NIL,
number: ROPE←NIL,
useNumber: BOOL←FALSE];
Uses specified conversation, creates a new one or uses one that's in a sufficiently idle state.
Interpretation of rName and number -- evaluate until action can be taken:
rName exists in switching system (has an Etherphone, usually) and ~use#: call that party.
number#NIL: rName is simply a description; call by number
rName=NIL or use#: invalid parameters
rName exists in obsolete directory and ~use#: use the resulting number
all tests fail: no such party.
AnswerCall:
PROC[convID: ConversationID];
DisconnectCall:
PROC[
convID: ConversationID,
reason: Thrush.Reason←$terminating,
comment: ROPE←NIL,
newState: Thrush.StateInConv ← $idle -- Can also be $failed, to terminate with fast-busy and such.
];
If the other party is willing to do it (trunk parties only, at present), generate touchtones corresponding to the characters in feepString. For talking to feep-controlled services.
Alphabetic characters in feepString are translated to their corresponding digits, based ont he mapping found on most telephone touchpads and dials.
Feep: PROC[convID: ConversationID, feepString: ROPE];
ObtainNumbersForRName:
PROC[rName:
ROPE]
RETURNS [fullRName: ROPE, number: ROPE, homeNumber: ROPE];
Management of services
ServiceConnect:
PROC [
serviceName: ROPE,
convID: Thrush.ConversationID ← nullConvID,
createOK: BOOL←TRUE
] RETURNS [
nb: NB←$success,
cDesc: ConvDesc←NIL
];
Establishes an active conversation with the named voice service, e.g. "recording". Uses specified conversation, creates a new one, or uses one that's in a sufficiently idle state.
If serviceName is NIL, this is a request to establish as innocuous a one-party conversation as possible—preferably in the state $inactive—so that we can talk with our poachee.
ObtainServiceInterface:
PROC [
serviceName: ROPE,
interfaceName: ROPE,
cDesc: ConvDesc←NIL
] RETURNS [
nb: NB←$success,
shhh: Thrush.SHHH,
interfaceSpec: Thrush.InterfaceSpec
];
Looks up the interface for the named voice service, e.g. the "VoiceRopeServer" interface for the "recording" service. Clients can then import this interface directly.
If serviceName is NIL, this is a request to obtain the service from our own party, or (more likely, since that's the whole idea) that of its poachee.
IF cDesc#NIL, this is a request to obtain the service from the "other party" in the present conversation; a bit flakey since there could be more than one, in which case it makes an arbitrary choice.
Visiting
IdentifyVisitor:
PROC[visitor, password: Rope.
ROPE, complain:
BOOL ←
TRUE]
RETURNS [nb: NB←$success];
Will complain about invalid passwords iff complain=TRUE.
ReleaseVisitor: PROC[visitor, password: Rope.ROPE];
Problem:
PROC[remark:
ROPE←
NIL, nb:
NB←
NIL];
These are merely linkages from FinchSmartsImpl to ThPartyClientImpl. There remains some confusion about Finch-to-ThParty connection time, and about registration of a particular Finch instance; at present, only one per machine makes sense anyway, though.
FinchRegister:
PROC[info: FinchInfo, interfaceName:
RPC.InterfaceName]
RETURNS[nb: NB];
FinchDeregister: PROC[info: FinchInfo, disable: BOOL←TRUE] RETURNS [nb: NB];
QUit:
PROC[proposedNB:
NB, problem:
ROPE←
NIL]
RETURNS [nb:
NB];
Records that Finch is disconnected, logs the remark if given, reports new system state to registered clients, returns its NB argument. See FinchSmartsImpl, ThPartyClientImpl.
Reporting
Clients of Finch can register callback procedures to receive reports concerning the state of conversations, actions taken by the recording service, etc. These will be executed serially, in the order that they are issued.
ReportSystemStateProc:
TYPE =
PROC[ enabled:
BOOL, connected:
BOOL ];
enabled is made true through calls to InitFinchSmarts; connected is true only when a server connection has been established.
ReportConversationStateProc:
TYPE =
PROC[ nb:
NB, cDesc: ConvDesc, remark:
ROPE←
NIL ];
Client-relevant changes in conversation state are reported in gory detail; FinchSmarts is allowed to invent parts of it (e.g., reason and remark fields)
ReportRequestStateProc:
TYPE =
PROC[ cDesc: ConvDesc, actionReport: Thrush.ActionReport, actionRequest:
REF ]
RETURNS [betterActionRequest:
REF];
ThSmarts.ReportAction was called; we are willing to pass the report on to this routine. FinchSmarts implementation will locate the relevant action request (e.g., an IntervalSpec) and pass it on with the action report.
N.B.!!! Each registered ReportRequestStateProc must either return actionReport, or return a better value for it. The intended use is for an upstream registered proc. to compute the request value as a function of actionReport and some local state. Downstream procedures get the augmented report. Care must be taken to register these procedures (with the help of the before hint (see RegisterForReports), so that the right thing happens.
RegisterForReports:
PROC [s: ReportSystemStateProc ←
NIL, c: ReportConversationStateProc ←
NIL, r: ReportRequestStateProc ←
NIL, before:
BOOL ←
TRUE];
If before is true, procs go at front of list, else they go at end of list.
UnRegisterForReports:
PROC [s: ReportSystemStateProc ←
NIL, c: ReportConversationStateProc ←
NIL, r: ReportRequestStateProc ←
NIL];
Remove procs from the list of report subscribers.
ReportConversationState:
PROC [nb:
NB, cDesc: ConvDesc, remark: Rope.
ROPE];
Distributes a report to all subscribers.
}.
Swinehart, July 18, 1985 3:31:34 pm PDT
Created FinchSmarts.Register and friends -- easier for WalnutVoice to deal with Finch.
changes to: InitFinchSmarts, RecordTuneProc, RecordTune, StopTuneProc, StopTune, PlaybackTuneProc, PlaybackTune, PlayNoiseProc, PlayNoise, Feep, FinchState, Procs, CurrentFinchState, Procs, Register, FinchIsRunning, UninitFinchSmarts, GetProcs
Polle Zellweger (PTZ) July 13, 1985 5:20:26 pm PDT
adding Text-to-Speech server
Changes to: DIRECTORY, FinchInfoBody, ConvDescBody
Added: TextToSpeech, StopSpeech
Swinehart, August 6, 1985 4:19:33 pm PDT
Merge PTZ Prose changes
changes to: DIRECTORY, FinchInfoBody, ConvDescBody, PlayNoise, TextToSpeech, StopSpeechProc, StopSpeech, ProcsRecord
Polle Zellweger (PTZ) August 29, 1985 5:06:29 pm PDT
changes to: TextToSpeechProc, ProseTranslateProc, TextToSpeech, StopSpeechProc, StopSpeech, ResetProse, ProcsRecord
Polle Zellweger (PTZ) September 3, 1985 6:17:21 pm PDT
Allow registration of proseTranslateProc.
changes to: ProseTranslateProc, TextToSpeech, RegisterTranslateProcType, RegisterTranslateProc, ProcsRecord
Polle Zellweger (PTZ) October 24, 1985 4:56:25 pm PDT
Move bluejayConnection and proseConnection from FinchInfo to ConvDesc.
changes to: FinchInfoBody, ConvDescBody
Doug Terry, August 28, 1986 4:22:57 pm PDT
Created FinchSmarts.RegisterForReports; removed all routines dealing with record or playback of tunes and removed record/play stuff from FinchInfo and ConvDesc; retired FinchSmarts.Register and friends.
changes to: ReportSystemStateProc, ReportConversationStateProc, ReportRequestStateProc, RegisterForReports, DIRECTORY, FinchInfoBody, ConvDescBody, InitFinchSmarts, UnRegisterForReports
Doug Terry, August 29, 1986 12:06:10 pm PDT
New interface procedures for FinchSmarts clients to get at voice services: VoiceConnect and LookupServiceInterface.
changes to: VoiceConnect, LookupServiceInterface
Swinehart, September 25, 1986 11:12:43 am PDT
Add props field to ConvDesc, in order to allow per-conversation application-specific data.
changes to: ConvDescBody
Polle Zellweger (PTZ) February 19, 1987 10:31:24 pm PST
changes to: FinchInfoBody, VisitorInfo, VisitorInfoBody, ConvDesc, DIRECTORY, IdentifyVisitor, ReleaseVisitor
Polle Zellweger (PTZ) February 23, 1987 2:15:25 pm PST
changes to: FinchInfoBody
Polle Zellweger (PTZ) February 27, 1987 4:23:24 pm PST
changes to: IdentifyVisitor, ReleaseVisitor, FinchInfoBody
Swinehart, July 14, 1987 4:19:10 pm PDT
Numerous changes in support of improved error and connection management.
Swinehart, July 19, 1987 4:45:25 pm PDT
VoiceConnect => ServiceConnect
changes to: ServiceConnect
Polle Zellweger (PTZ) July 27, 1987 8:35:23 pm PDT
Allow for better party reports in FinchTool (>2 parties in conversation)
changes to: WhoOriginated, unknown, us