DIRECTORY BluejaySmarts USING [ handle ], BluejayUtils, BluejayUtilsRpcControl USING [ ExportInterface, InterfaceName, UnexportInterface ], Commander USING [ CommandProc, Register ], Jukebox USING [ CloseTune, CreateTune, DeleteTune, Error, FirstNoisyIntervalIn, Info, OpenTune, Tune, TuneSize ], LupineRuntime USING [ BindingError ], Names USING [ CurrentPasskey ], Log USING [ Report ], Thrush USING [ IntervalSpec, IntervalSpecBody, IntervalSpecs, nullTune, Tune, VoiceInterval, VoiceTime ], ThVersions USING [ JayVR ], UserProfile USING [ Token ] ; BluejayUtilsImpl: CEDAR PROGRAM IMPORTS BluejaySmarts, BluejayUtilsRpcControl, Commander, Jukebox, LupineRuntime, Names, Log, ThVersions, UserProfile EXPORTS BluejayUtils = { myName: BluejayUtilsRpcControl.InterfaceName; utilsExported: BOOL_FALSE; Tune: TYPE = Thrush.Tune; DescribeTune: PUBLIC PROC[tune: Tune] RETURNS [exists: BOOL_TRUE, size: INT] = TRUSTED { t: Jukebox.Tune = Jukebox.OpenTune[self: BluejaySmarts.handle, tuneId: tune, write: FALSE! Jukebox.Error=>GOTO NoTune]; size _ Jukebox.TuneSize[t]; Jukebox.CloseTune[BluejaySmarts.handle, t]; EXITS NoTune => exists_FALSE; }; DescribeInterval: PUBLIC PROC[targetTune: Thrush.Tune, targetInterval: Thrush.VoiceInterval, minSilence: Thrush.VoiceTime _ 1] RETURNS [exists: BOOL_TRUE, intervals: Thrush.IntervalSpecs_NIL] = TRUSTED { t: Jukebox.Tune = Jukebox.OpenTune[self: BluejaySmarts.handle, tuneId: targetTune, write: FALSE! Jukebox.Error=>GOTO NoTune]; lastInterval: Thrush.IntervalSpecs_NIL; start, length, end, nextStart: INT_0; start _ targetInterval.start; end _ IF targetInterval.length>=0 THEN start + targetInterval.length ELSE LAST[INT]; WHILE start exists_FALSE; }; DeleteTune: PUBLIC PROC[tune: Tune] RETURNS [existed: BOOL_TRUE] = TRUSTED { Jukebox.DeleteTune[BluejaySmarts.handle, tune!Jukebox.Error => GOTO NoTune]; EXITS NoTune => existed_FALSE; }; NewTune: PUBLIC PROC RETURNS [tune: Tune_Thrush.nullTune] = TRUSTED { t: Jukebox.Tune = Jukebox.CreateTune[self: BluejaySmarts.handle, tuneId: -1!Jukebox.Error=>GOTO NoTune]; tune _ t.tuneId; Jukebox.CloseTune[BluejaySmarts.handle, t!Jukebox.Error=>GOTO NoTune]; EXITS NoTune => NULL; }; TunesInJukebox: PUBLIC PROC RETURNS [nTunes: INT_0] = TRUSTED { nTunes _ Jukebox.Info[BluejaySmarts.handle!Jukebox.Error=>GOTO Problem].nTunes; EXITS Problem => NULL; }; InitializeJukebox: PUBLIC PROC = TRUSTED { nTunes: NAT = TunesInJukebox[]; FOR i: NAT IN [0..nTunes) DO Jukebox.DeleteTune[BluejaySmarts.handle, i!Jukebox.Error=>CONTINUE]; ENDLOOP; }; Initialize: PUBLIC PROC = { Uninitialize[]; myName _ [ type: "BluejayUtils.Lark", instance: UserProfile.Token[key: "BluejayServerInstance", default: "Lampson.Lark"], version: ThVersions.JayVR ]; BluejayUtilsRpcControl.ExportInterface[ interfaceName: myName, user: myName.instance, password: Names.CurrentPasskey[UserProfile.Token[ key: "BluejayServerPassword", default: "MFLFLX"]]]; Log.Report["Bluejay Utility interface Initialized and Exported", $Bluejay]; utilsExported _ TRUE; }; Uninitialize: PUBLIC PROC = { IF utilsExported THEN { BluejayUtilsRpcControl.UnexportInterface[!LupineRuntime.BindingError=>CONTINUE]; Log.Report["Bluejay Utility interface Unexported", $Bluejay]; }; utilsExported _ FALSE; }; InitCmd: Commander.CommandProc = TRUSTED { Initialize[]; }; UninitCmd: Commander.CommandProc = TRUSTED { Uninitialize[]; }; Commander.Register["JayUtils", InitCmd, "Start Bluejay Utilities (won't work if Ja)"]; Commander.Register["UnJayUtils", UninitCmd, "Terminate Bluejay Utilities (won't work if Ja)"]; }. \BluejayUtilsImpl.mesa Last Edited by: Swinehart, September 28, 1984 5:30:47 pm PDT Êá˜J™J™