PSExecCImpl.mesa
Copyright (C) Xerox Corporation 1984, 1985. All rights reserved.
Last edited by Jacks 13-Dec-85 16:44:42
Ruseli Binsol: December 11, 1986 10:25:50 am PST
Implements several commands: Set Parameters, Set Target Print Service, Put Print Display, Get Printer Display and Set Trace.
DIRECTORY
Auth USING [IdentityHandle],
CHNameP2V0 USING [Name, maxObjectLength, maxDomainLength, maxOrganizationLength],
NSAddressTranslation USING [Error, StringToNetworkAddress],
NSExec USING [Error, ExecProc, GetTTY, Handle, OutputHandle, ServerName],
NSString USING [AppendDecimal, AppendLongDecimal, FreeString, nullString, MakeString, String],
PaperHandling USING [BannerMode, D1Registration, D1RegLong, D1RegShort, Fax495BannerMode, FX3500Registration, FX3500RegLong, FX3500RegShort, PaperFeed, PaperStacking, PrintOrder, RavenRegistration, RavenRegLong, RavenRegShort, TwoPaperSizes],
PaperTypes USING [PaperSize],
PSCommand USING [Error, GetPrinterDisplay, GetPrintServiceStatus, PutPrinterDisplay, SetBanner, SetMultipleCopies, SetPaperFeed, SetPaperSupply, SetRegistration, SetPaperStacking, SetPrintOrder, SetTargetPrintService, SetTrace, TraceParameters, SetTransmissionRetries],
PSExecInternal USING [ChoiceList, ExpandKeyAndPrint, GetList, KeyList, KeyListRep, printServiceName],
PSExecMessages USING [Key],
PSKMessages USING [GetHandle],
PSState USING [StateHandle, TraceLevel],
TextInput USING [ChoiceIndex, GetChoice, GetDecimal, GetLongDecimal, GetText],
TTY USING [Handle],
XFormat USING [Blanks, Handle, NSLine, NSString],
XMessage USING [Get, Handle, Compose, StringArray],
XNS USING [Address, unknownAddress];
PSExecCImpl: CEDAR PROGRAM
IMPORTS NSExec, NSString, PSCommand, PSExecInternal, PSKMessages, TextInput, XFormat, XMessage
EXPORTS PSExecInternal
SHARES NSString = BEGIN
OPEN CHName: CHNameP2V0;
nsNil: NSString.String = NIL;
tab0: CARDINAL = 2;
tab1: CARDINAL = 4;
tab2: CARDINAL = 8;
Message domain handle:
execMsgs: XMessage.Handle ← PSKMessages.GetHandle[exec];
*******************************
COMMAND PROCESSORS:
*******************************
SetParameters: PUBLIC NSExec.ExecProc = TRUSTED BEGIN
ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit;
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
nsPrompt: NSString.String ← nsNil;
nsPrompt2: NSString.String ← M[mSelect];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
WITH s: state SELECT FROM
bansheeDl => --Banshee has only one operation parameter
so we don't display a menu, as with the other printing options.
BansheeBannerMode[exec, s.banner];
d1 => BEGIN
d1Choices: CARDINAL = 4;
d1MsgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[d1Choices]];
d1ChoiceStrings: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[d1Choices]];
PSExecInternal.GetList[d1Choices, d1MsgKeys, d1ChoiceStrings];
DO -- until EXIT
SELECT TextInput.GetChoice[tty: tty, prompt: nsPrompt, choices: d1ChoiceStrings, default: 0] FROM
0 => EXIT;
1 => D1BannerMode[exec, s.banner];
2 => PrintOrderMode[exec, s.printOrder];
3 => D1RegistrationMode[exec, s.registration];
ENDCASE => outputHandle.NSLine[M[mInvalidChoice]];
nsPrompt ← nsPrompt2;
ENDLOOP;
END;
fax495 => BEGIN
faxChoices: CARDINAL = 4;
faxMsgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[faxChoices]];
faxChoiceStrings: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[faxChoices]];
PSExecInternal.GetList[faxChoices, faxMsgKeys, faxChoiceStrings];
DO -- until EXIT
SELECT TextInput.GetChoice[tty: tty, prompt: nsPrompt,
choices: faxChoiceStrings, default: 0] FROM
0 => EXIT;
1 => FaxRetryMode[exec, s.retries[noConnection].count,
s.retries[noConnection].delayInSecs,
s.retries[transmitError].count,
s.retries[transmitError].delayInSecs];
2 => Fax495BannerMode[exec, s.banner];
3 => FaxMultCopiesMode[exec, s.multLocalCopiesAllowed, s.multRemoteCopiesAllowed];
ENDCASE => outputHandle.NSLine[M[mInvalidChoice]];
nsPrompt ← nsPrompt2;
ENDLOOP;
END;
fx3500 => BEGIN
fx3500Choices: CARDINAL = 5;
fx3500MsgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[fx3500Choices]];
fx3500ChoiceStrings: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[fx3500Choices]];
PSExecInternal.GetList[fx3500Choices, fx3500MsgKeys, fx3500ChoiceStrings];
DO -- until EXIT
SELECT TextInput.GetChoice[tty: tty, prompt: nsPrompt,
choices: fx3500ChoiceStrings, default: 0] FROM
0 => EXIT;
1 => FX3500PaperFeedMode[exec: exec, current: s.paperFeed,
sameSizeBothTrays: s.paperSupply.size1 = s.paperSupply.size2];
2 => FX3500BannerMode[exec, s.banner];
3 => PrintOrderMode[exec, s.printOrder];
4 => FX3500RegistrationMode[exec, s.registration];
ENDCASE => outputHandle.NSLine[M[mInvalidChoice]];
nsPrompt ← nsPrompt2;
ENDLOOP;
END;
raven => BEGIN
IF s.engineBuild < b2 THEN BEGIN --Can't set stacking on a b0 and b1 ravens.
b1Choices: CARDINAL = 5;
b1MsgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[b1Choices]];
b1ChoiceStrings: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[b1Choices]];
PSExecInternal.GetList[b1Choices, b1MsgKeys, b1ChoiceStrings];
DO -- until EXIT
SELECT TextInput.GetChoice[tty: tty, prompt: nsPrompt,
choices: b1ChoiceStrings, default: 0] FROM
0 => EXIT;
1 => RavenPaperSupplyMode[exec, s.paperSupply];
2 => RavenPaperFeedMode[exec: exec, current: s.paperFeed,
sameSizeBothTrays: s.paperSupply.size1 = s.paperSupply.size2];
3 => RavenBannerMode[exec, s.banner];
4 => RavenRegistrationMode[exec, s.registration];
ENDCASE => outputHandle.NSLine[M[mInvalidChoice]];
nsPrompt ← nsPrompt2;
ENDLOOP;
END
ELSE BEGIN --b2 and later engines may set stacking.
b2Choices: CARDINAL = 6;
b2MsgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[b2Choices]];
b2ChoiceStrings: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[b2Choices]];
PSExecInternal.GetList[b2Choices, b2MsgKeys, b2ChoiceStrings];
DO -- until EXIT
SELECT TextInput.GetChoice[tty: tty, prompt: nsPrompt,
choices: b2ChoiceStrings, default: 0] FROM
0 => EXIT;
1 => RavenPaperSupplyMode[exec, s.paperSupply];
2 => RavenPaperFeedMode[exec: exec, current: s.paperFeed,
sameSizeBothTrays: s.paperSupply.size1 = s.paperSupply.size2];
3 => RavenBannerMode[exec, s.banner];
4 => RavenStackingMode[exec, s.paperStacking];
5 => RavenRegistrationMode[exec, s.registration];
ENDCASE => outputHandle.NSLine[M[mInvalidChoice]];
nsPrompt ← nsPrompt2;
ENDLOOP;
END;
END;
ENDCASE;
EXITS Exit => NULL;
END; --SetParameters
PutPrinterDisplay: PUBLIC NSExec.ExecProc =
BEGIN --Display chars input at TTY on printer console.
ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit;
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
charString: NSString.String ← NSString.MakeString[2];
leftChar, rightChar: CHARACTER;
BEGIN ENABLE UNWIND => NSString.FreeString[charString];
charString ← TextInput.GetText[tty: tty,
prompt: M[mDisplayChars], text: charString,
minLength: 2, maxLength: 2];
leftChar ← LOOPHOLE[charString[0]];
rightChar ← LOOPHOLE[charString[1]];
PSCommand.PutPrinterDisplay[leftChar, rightChar];
NSString.FreeString[charString];
END; --Enable clause and code
EXITS Exit => NULL;
END; --PutPrinterDisplay
GetPrinterDisplay: PUBLIC NSExec.ExecProc = BEGIN
ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit;
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
leftChar, rightChar: CHARACTER;
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
TRUSTED BEGIN ENABLE UNWIND => NULL;
stringArray[0] ← NSString.MakeString[2];
[leftChar, rightChar] ← PSCommand.GetPrinterDisplay[];
stringArray[0].bytes[0] ← LOOPHOLE[leftChar];
stringArray.data[0][0] ← LOOPHOLE[leftChar];
stringArray[0].bytes[1] ← LOOPHOLE[rightChar];
stringArray.data[0][1] ← LOOPHOLE[rightChar];
stringArray[0].length ← 2;
stringArray.data[0].length ← 2;
PSExecInternal.ExpandKeyAndPrint[exec, mPrinterDisplay, stringArray];
NSString.FreeString[stringArray[0]];
END; --Enable clause and code
EXITS Exit => NULL;
END; --GetPrinterDisplay
SetTargetPrintService: PUBLIC NSExec.ExecProc = TRUSTED BEGIN
ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit;
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
identity: Auth.IdentityHandle ← NSExec.ServerIdentity[];
maxTargetStringSize: CARDINAL = CHName.maxObjectLength +
CHName.maxDomainLength + CHName.maxOrganizationLength + 5;
Added 5 for separator chars and leeway.
target: NSString.String ← NSString.MakeString[bytes: maxTargetStringSize];
address: XNS.Address ← XNS.unknownAddress;
name: NSString.String ← NSString.nullString;
oldTargetName: CHName.Name ← [NIL, NIL, NIL];
defaultDomainOrg: CHName.Name ← IF PSExecInternal.printServiceName = [NIL, NIL, NIL]
THEN NSExec.ServerName[] ELSE PSExecInternal.printServiceName;
chUsed: BOOLEANFALSE;
errorString: NSString.String;
chRetries: CARDINAL ← 0;
BEGIN ENABLE UNWIND => NSString.FreeString[target];
Get old target print service name to prompt with:
WITH s: state SELECT FROM
feps9700 => TRUSTED BEGIN
oldTargetName ← LOOPHOLE[@s.targetPSName.record];
IF oldTargetName.local.length # 0 THEN --check that old name is known
target ← NSString.AppendToMesaString[s: target, name: oldTargetName];
END;
ENDCASE => ERROR;
DO
Prompt the user to enter target PS name or address:
target ← TextInput.GetText[tty: tty, prompt: M[mEnterNameOrAddr], text: target,
maxLength: maxTargetStringSize, default: target];
This proc turns the name or address string into a XNS.Address.
Other return parms indicate if the clearinghouse was used and what
type of property was associated with the network address found.
[address, chUsed] ← NSAddressTranslation.StringToNetworkAddress[
s: target, id: identity, defaultDomainOrg: defaultDomainOrg,
distingName: name
! NSAddressTranslation.Error =>
WITH e: errorRecord SELECT FROM
scanError, badSyntax => {
outputHandle.Blanks[tab2];
outputHandle.NSLine[M[mCantReadData]];
LOOP};
chLookupProblem => SELECT e.rc.code FROM
rejectedTooBusy => {
outputHandle.Blanks[tab2];
[errorString,] ← MsgOps.Error[e.rc];
outputHandle.NSLine[errorString];
IF NSExec.CheckForAbort[exec] THEN GOTO Exit;
IF chRetries < 3 THEN {
outputHandle.NSString[M[mRetry]];
chRetries ← chRetries + 1;
RETRY}
ELSE {outputHandle.NSLine[M[mTryAgainLater]]; GOTO Exit}};
allDown, wasUpNowDown => {
outputHandle.Blanks[tab2];
[errorString,] ← MsgOps.Error[e.rc];
outputHandle.NSLine[errorString];
outputHandle.Blanks[tab2];
outputHandle.NSLine[M[mTryAgainLater]];
GOTO Exit};
badProtocol, credentialsInvalid, credentialsTooWeak,
notAllowed, overflowOfDataBase => {
outputHandle.Blanks[tab2];
[errorString,] ← MsgOps.Error[e.rc];
outputHandle.NSLine[errorString];
GOTO Exit};
ENDCASE => {
outputHandle.Blanks[tab2];
[errorString,] ← MsgOps.Error[e.rc];
outputHandle.NSLine[errorString];
LOOP};
otherCHProblem => SELECT e.reason FROM
authentication, invalidName, invalidPassword => {
outputHandle.Blanks[tab2];
outputHandle.NSLine[M[mCHAuthProblem]];
GOTO Exit};
ambiguousSeparators, tooManySeparators => {
outputHandle.Blanks[tab2];
outputHandle.NSLine[M[mCantReadData]];
LOOP};
ENDCASE => {
outputHandle.Blanks[tab2];
outputHandle.NSLine[M[mCHLookupProblem]];
LOOP};
ENDCASE
];
EXIT; --lookup successful!
ENDLOOP;
PSCommand.SetTargetPrintService[address, name ! PSCommand.Error => BEGIN
WITH problem SELECT FROM
targetPS => BEGIN
Target PS was set, but could not be reached to get status and properties.
Display warning messages to user...
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[1]];
outputHandle.NSLine[M[mSetTargetWarning]];
outputHandle.NSLine[M[mTargetAttrDefaulted]];
stringArray[0] ← M[mQueryTargetPS];
PSExecInternal.ExpandKeyAndPrint[exec, mUseCommand, stringArray];
END;
ENDCASE;
CONTINUE;
END;
];
outputHandle.Blanks[tab2];
outputHandle.NSLine[M[mDone]];
NSString.FreeString[target];
END; -- of code and enable clause
EXITS Exit => NULL;
END; --SetTargetPrintService
SetTrace: PUBLIC NSExec.ExecProc = BEGIN --This is NOT an officially supported command.
ENABLE NSExec.Error => IF type = invalidExec THEN GOTO Exit;
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
traceChoices: REF XMessage.StringArray ← NEW [XMessage.StringArray[4]];
levelChoices: REF XMessage.StringArray ← NEW [XMessage.StringArray[3]];
traceParams: PSCommand.TraceParameters;
GetTraceLevel: PROCEDURE RETURNS [level: PSState.TraceLevel] = BEGIN
choice: TextInput.ChoiceIndex ← TextInput.GetChoice[tty: tty, prompt: nsNil,
choices: levelChoices, default: 0];
RETURN [SELECT choice FROM 0 => none, 1 => mini, ENDCASE => verbose];
END; -- GetTraceLevel
GetActivityTrace: PROCEDURE RETURNS [traceParms: PSCommand.TraceParameters] = BEGIN
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
traceParms ← [spooler: state.spoolerTrace, decomposer: state.formatterTrace, marker: state.markerTrace];
END; --GetActivityTrace
traceParams ← GetActivityTrace[];
SELECT TextInput.GetChoice[tty: tty, prompt: nsNil, choices: traceChoices, default: 0] FROM
0 => traceParams.spooler ← traceParams.decomposer ← traceParams.marker ←
GetTraceLevel[];
1 => traceParams.spooler ← GetTraceLevel[];
2 => traceParams.decomposer ← GetTraceLevel[];
3 => traceParams.marker ← GetTraceLevel[];
ENDCASE => {outputHandle.NSLine[M[mInvalidChoice]]; GOTO Exit; };
PSCommand.SetTrace[traceParams];
EXITS Exit => NULL;
END; --SetTrace
***************************************************
INTERNAL PROCS CALLED BY SETPARAMETERS:
***************************************************
***Banner Mode:
Fax495BannerMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.Fax495BannerMode] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
faxBanner: PaperHandling.Fax495BannerMode;
faxBanner.local ← GetBannerChoice[exec: exec,
prompt: M[mSelLocalBanner], default: current.local];
faxBanner.remote ← GetBannerChoice[exec: exec,
prompt: M[mSelRemoteBanner], default: current.remote];
PSCommand.SetBanner[[fax495[faxBanner]]];
WITH s: state SELECT FROM
fax495 => BEGIN
stringArray[0] ← M[
SELECT s.banner.local FROM
oncePerDocument => mPerCopy,
oncePerJob => mPerSetOfCopies,
ENDCASE => mSuppressed];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mLocalBanner, stringArray];
stringArray[0] ← M[
SELECT s.banner.remote FROM
oncePerDocument => mPerCopy,
oncePerJob => mPerSetOfCopies,
ENDCASE => mSuppressed];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mRemoteBanner, stringArray];
END;
ENDCASE => ERROR;
END; --Fax495BannerMode
BansheeBannerMode: PROCEDURE [exec: NSExec.Handle, current:
PaperHandling.BannerMode] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
PSCommand.SetBanner[[bansheeDl[
GetBannerChoice[exec: exec, prompt: M[mSelBanner], default: current]]]];
Check and display current value:
WITH s: state SELECT FROM
bansheeDl => stringArray[0] ← M[
SELECT s.banner FROM
oncePerDocument => mPerCopy,
oncePerJob => mPerSetOfCopies,
ENDCASE => mSuppressed];
ENDCASE => ERROR;
outputHandle.Blanks[tab0];
PSExecInternal.ExpandKeyAndPrint[exec, mBanner2, stringArray];
END; -- BansheeBannerMode
D1BannerMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.BannerMode] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
PSCommand.SetBanner[[d1[
GetBannerChoice[exec: exec, prompt: M[mSelBanner], default: current]]]];
Check and display current value:
WITH s: state SELECT FROM
d1 => stringArray[0] ← M[
SELECT s.banner FROM
oncePerDocument => mPerCopy,
oncePerJob => mPerSetOfCopies,
ENDCASE => mSuppressed];
ENDCASE => ERROR;
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mBanner2, stringArray];
END; -- D1BannerMode
FX3500BannerMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.BannerMode] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
PSCommand.SetBanner[[fx3500[
GetBannerChoice[exec: exec, prompt: M[mSelBanner], default: current]]]];
Check and display current value:
WITH s: state SELECT FROM
fx3500 => stringArray[0] ← M[
SELECT s.banner FROM
oncePerDocument => mPerCopy,
oncePerJob => mPerSetOfCopies,
ENDCASE => mSuppressed];
ENDCASE => ERROR;
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mBanner2, stringArray];
END; -- FX3500BannerMode
RavenBannerMode: PROCEDURE [exec: NSExec.Handle, current:
PaperHandling.BannerMode] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
PSCommand.SetBanner[[raven[
GetBannerChoice[exec: exec, prompt: M[mSelBanner], default: current]]]];
Check and display current value:
WITH s: state SELECT FROM
raven => stringArray[0] ← M[
SELECT s.banner FROM
oncePerDocument => mPerCopy,
oncePerJob => mPerSetOfCopies,
ENDCASE => mSuppressed];
ENDCASE => ERROR;
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mBanner2, stringArray];
END; -- RavenBannerMode
GetBannerChoice: PROCEDURE [exec: NSExec.Handle, prompt: NSString.String, default: PaperHandling.BannerMode]
RETURNS [PaperHandling.BannerMode] = BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
choices: CARDINAL = 3;
msgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[choices]];
bannerChoices: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[choices]];
choice: TextInput.ChoiceIndex;
defaultChoice: CARDINAL
SELECT default FROM oncePerDocument => 0, oncePerJob => 1, ENDCASE => 2;
PSExecInternal.GetList[choices, msgKeys, bannerChoices];
choice ← TextInput.GetChoice[tty: tty, prompt: prompt,
choices: bannerChoices, default: defaultChoice];
RETURN [
SELECT choice FROM
0 => oncePerDocument,
1 => oncePerJob,
ENDCASE => suppressed];
END; --GetBannerChoice
***Fax Retries:
FaxRetryMode: PROCEDURE [exec: NSExec.Handle, currentNoConnectionCount: CARDINAL,
currentNoConnectionDelayInSecs: LONG CARDINAL,
currentXMitErrorCount: CARDINAL, currentXMitErrorDelayInSecs: LONG CARDINAL] =
TRUSTED BEGIN --NOTE: Should fix interface to provide another menu for each retry reason.
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
WITH s: state SELECT FROM
fax495 => TRUSTED BEGIN
count: CARDINAL;
delayInMinutes: LONG CARDINAL;
freeThisString: NSString.String;
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[2]];
***Prompt for # of retries for no connection:
stringArray[0] ← M[mNoConnection];
freeThisString ← XMessage.Compose[M[mRetries2], stringArray];
count ← TextInput.GetDecimal[tty: tty,
prompt: freeThisString, min: 0, max: 100,
default: currentNoConnectionCount];
NSString.FreeString[freeThisString];
IF count > 0 THEN
delayInMinutes ← TextInput.GetLongDecimal[tty: tty,
prompt: M[mRetryInterval], min: 0, max: 100,
default: currentNoConnectionDelayInSecs/60]
ELSE delayInMinutes ← 0;
PSCommand.SetTransmissionRetries[
retries: count, delayInSeconds: delayInMinutes*60, reason: noConnectionMade];
***Prompt of # of retires for transmission failure:
stringArray[0] ← M[mTransmitFailure];
freeThisString ← XMessage.Compose[M[mRetries2], stringArray];
count ← TextInput.GetDecimal[tty: tty,
prompt: freeThisString, min: 0, max: 100,
default: currentXMitErrorCount];
NSString.FreeString[freeThisString];
IF count > 0 THEN
delayInMinutes ← TextInput.GetLongDecimal[tty: tty,
prompt: M[mRetryInterval], min: 0, max: 100,
default: currentXMitErrorDelayInSecs/60]
ELSE delayInMinutes ← 0;
PSCommand.SetTransmissionRetries[
retries: count, delayInSeconds: delayInMinutes*60, reason: transmitError];
END;
ENDCASE => ERROR;
Display current setting:
WITH s: state SELECT FROM
fax495 => TRUSTED BEGIN
DisplayCurrentFaxRetries[exec: exec,
currentCount: s.retries[noConnection].count,
currentDelay: s.retries[noConnection].delayInSecs/60,
reasonKey: mNoConnection];
DisplayCurrentFaxRetries[exec: exec,
currentCount: s.retries[transmitError].count,
currentDelay: s.retries[transmitError].delayInSecs/60,
reasonKey: mTransmitFailure];
END;
ENDCASE => ERROR;
END; --FaxRetryMode
DisplayCurrentFaxRetries: PROCEDURE [exec: NSExec.Handle, currentCount: CARDINAL,
currentDelay: LONG CARDINAL, reasonKey: PSExecMessages.Key] = BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
sCount1: NSString.String ← NEW[TEXT[20]];
sCount2: NSString.String ← NEW[TEXT[20]];
freeThisString: NSString.String;
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[2]];
XFormat.NSString[outputHandle, NSString.AppendDecimal[sCount1, currentCount]];
IF currentCount > 0 THEN BEGIN
stringArray[0] ← NEW[TEXT[20]];
XFormat.NSString[outputHandle, NSString.AppendLongDecimal[sCount2, currentDelay]];
stringArray[1] ← NEW[TEXT[20]];
freeThisString ← XMessage.Compose[M[mRetryDelay], stringArray];
stringArray[1] ← freeThisString;
END
ELSE stringArray[1] ← NEW[TEXT[20]];
stringArray[0] ← M[reasonKey];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mTransmissionRetries, stringArray];
IF currentCount > 0 THEN NSString.FreeString[freeThisString];
END; --DisplayCurrentFaxRetries
***Fax Multiple Copies:
FaxMultCopiesMode: PROCEDURE [exec: NSExec.Handle, currentLocal, currentRemote: BOOLEAN] = BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
choices: CARDINAL = 2;
msgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[choices]];
copyChoices: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[choices]];
multLocalCopiesAllowed, multRemoteCopiesAllowed: BOOLEANFALSE;
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[2]];
PSExecInternal.GetList[choices, msgKeys, copyChoices];
multLocalCopiesAllowed ← TextInput.GetChoice[tty: tty, prompt: M[mSelLocalDuplicate], choices: copyChoices,
default: IF currentLocal THEN 0 ELSE 1] = 0;
multRemoteCopiesAllowed ← TextInput.GetChoice[tty: tty, prompt: M[mSelRemoteDuplicate], choices: copyChoices,
default: IF currentRemote THEN 0 ELSE 1] = 0;
PSCommand.SetMultipleCopies[multLocalCopiesAllowed, multRemoteCopiesAllowed];
stringArray[0] ← M[
IF multLocalCopiesAllowed THEN mAllowed
ELSE mSuppressed];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mLocalCopies, stringArray];
stringArray[0] ← M[
IF multRemoteCopiesAllowed THEN mAllowed
ELSE mSuppressed];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mRemoteCopies, stringArray];
END; --FaxMultCopiesMode
***Paper Feed:
RavenPaperFeedMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.PaperFeed,
sameSizeBothTrays: BOOLEAN] = BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[2]];
choice: TextInput.ChoiceIndex;
defaultChoice: CARDINAL ← 0;
IF sameSizeBothTrays THEN TRUSTED BEGIN
choices: CARDINAL = 2;
msgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[choices]];
feedChoices: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[choices]];
defaultChoice ←
SELECT current FROM fromBottomBannerFromTop => 0, ENDCASE => 1;
PSExecInternal.GetList[choices, msgKeys, feedChoices];
choice ← TextInput.GetChoice[
tty: tty, prompt: M[mSpecifyFeedTray],
choices: feedChoices, default: defaultChoice];
PSCommand.SetPaperFeed[
SELECT choice FROM
0 => fromBottomBannerFromTop,
ENDCASE => fromBottomOrTop];
END;
WITH s: state SELECT FROM
raven => BEGIN
stringArray[0] ←
IF NOT sameSizeBothTrays THEN M[mAsAppropriate]
ELSE M[
SELECT s.paperFeed FROM
fromBottomBannerFromTop => mFromBottomBannerfromTopTray,
ENDCASE => mFromBottomorTopTray];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mPaperFeed, stringArray];
END;
ENDCASE;
END; -- RavenPaperFeedMode
FX3500PaperFeedMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.PaperFeed,
sameSizeBothTrays: BOOLEAN] = BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[2]];
choice: TextInput.ChoiceIndex;
defaultChoice: CARDINAL ← 0;
IF sameSizeBothTrays THEN TRUSTED BEGIN
choices: CARDINAL = 5;
msgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[choices]];
feedChoices: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[choices]];
defaultChoice ← SELECT current FROM
fromBottom => 0,
fromBottomBannerFromTop => 1,
fromBottomOrTop => 2,
alternateBottomAndTop => 3,
ENDCASE => 4;
PSExecInternal.GetList[choices, msgKeys, feedChoices];
choice ← TextInput.GetChoice[
tty: tty, prompt: M[mSpecifyFeedTray],
choices: feedChoices, default: defaultChoice];
PSCommand.SetPaperFeed[
SELECT choice FROM
0 => fromBottom,
1 => fromBottomBannerFromTop,
2 => fromBottomOrTop,
3 => alternateBottomAndTop,
ENDCASE => fromTop];
END;
WITH s: state SELECT FROM
fx3500 => BEGIN
stringArray[0] ←
IF NOT sameSizeBothTrays THEN M[mAsAppropriate]
ELSE M[
SELECT s.paperFeed FROM
fromBottom => mFromBottom,
fromBottomBannerFromTop => mFromBottomBannerfromTopTray,
fromBottomOrTop => mFromBottomorTopTray,
alternateBottomAndTop => mAlternateBottomAndTop,
ENDCASE => mFromTop];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mPaperFeed, stringArray];
END;
ENDCASE;
END; -- FX3500PaperFeedMode
***Paper Supply:
RavenPaperSupplyMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.TwoPaperSizes ← [letter, letter]] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
choices: CARDINAL = 3;
msgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[choices]];
paperChoices: REF XMessage.StringArray ← NEW [XMessage.StringArray[choices]];
choice: TextInput.ChoiceIndex;
defaultTopChoice: CARDINAL
SELECT current.size2 FROM letter => 0, legal => 1, ENDCASE => 2;
defaultBottomChoice: CARDINAL
SELECT current.size1 FROM letter => 0, legal => 1, ENDCASE => 2;
paper: PaperHandling.TwoPaperSizes;
PSExecInternal.GetList[choices, msgKeys, paperChoices];
choice ← TextInput.GetChoice[
tty: tty, prompt: M[mSelTopPaper],
choices: paperChoices, default: defaultTopChoice];
paper.size2 ←
SELECT choice FROM 0 => letter, 1 => legal, ENDCASE => a4;
choice ← TextInput.GetChoice[
tty: tty, prompt: M[mSelBottomPaper],
choices: paperChoices, default: defaultBottomChoice];
paper.size1 ←
SELECT choice FROM 0 => letter, 1 => legal, ENDCASE => a4;
PSCommand.SetPaperSupply[[raven[paper]]];
WITH s: state SELECT FROM
raven => BEGIN
stringArray[0] ← M[
IF s.paperSupply.size2 = s.paperSupply.size1
THEN mBothTrays ELSE mTopTray];
stringArray[1] ← M[
SELECT s.paperSupply.size2 FROM
a4 => mA4,
legal => mLegal,
letter => mLetter,
ENDCASE => mQuestion];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mPaperSize2, stringArray];
IF s.paperSupply.size2 # s.paperSupply.size1 THEN BEGIN
stringArray[0] ← M[mBottomTray];
stringArray[1] ← M[
SELECT s.paperSupply.size1 FROM
a4 => mA4,
legal => mLegal,
letter => mLetter,
ENDCASE => mQuestion];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mPaperSize2, stringArray];
END;
END;
ENDCASE;
END; --RavenPaperSupplyMode
***Print Order:
PrintOrderMode: PROCEDURE [exec: NSExec.Handle, current:
PaperHandling.PrintOrder] = BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray;
choices: CARDINAL = 2;
msgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[choices]];
printOrderChoices: REF XMessage.StringArray ← NEW [XMessage.StringArray[choices]];
choice: TextInput.ChoiceIndex;
defaultChoice: CARDINAL
SELECT current FROM firstPageOutFirst => 0, ENDCASE => 1;
PSExecInternal.GetList[choices, msgKeys, printOrderChoices];
choice ← TextInput.GetChoice[tty: tty,
prompt: M[mSpecifyOutputPrintOrder],
choices: printOrderChoices, default: defaultChoice];
PSCommand.SetPrintOrder[
SELECT choice FROM 0 => firstPageOutFirst, ENDCASE => lastPageOutFirst];
Display current value:
stringArray[0] ← M[
SELECT state.printOrder FROM
firstPageOutFirst => mFirstPagePrintedFirst,
ENDCASE => mLastPagePrintedFirst];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mPrintOrder2, stringArray];
END; -- PrintOrderMode
***Registration:
D1RegistrationMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.D1Registration] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
reg: PaperHandling.D1Registration;
reg.long ← TextInput.GetDecimal[tty: tty,
prompt: M[mSetLongAxisRegistration],
min: FIRST[PaperHandling.D1RegLong],
max: LAST[PaperHandling.D1RegLong], default: current.long];
reg.short ← TextInput.GetDecimal[tty: tty,
prompt: M[mSetShortAxisRegistration],
min: FIRST[PaperHandling.D1RegShort],
max: LAST[PaperHandling.D1RegShort], default: current.short];
PSCommand.SetRegistration[[d1[reg]]];
Display current values:
WITH s: state SELECT FROM
d1 => BEGIN
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
stringArray[0] ← NEW[TEXT[10]];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mLongAxisRegistration, stringArray];
XFormat.NSString[outputHandle, NSString.AppendDecimal[NIL, s.registration.short]];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mShortAxisRegistration, stringArray];
END;
ENDCASE;
END; --D1RegistrationMode
FX3500RegistrationMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.FX3500Registration] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
reg: PaperHandling.FX3500Registration;
reg.long ← TextInput.GetDecimal[tty: tty,
prompt: M[mSetLongAxisRegistration],
min: FIRST[PaperHandling.FX3500RegLong],
max: LAST[PaperHandling.FX3500RegLong], default: current.long];
reg.short ← TextInput.GetDecimal[tty: tty,
prompt: M[mSetShortAxisRegistration],
min: FIRST[PaperHandling.FX3500RegShort],
max: LAST[PaperHandling.FX3500RegShort], default: current.short];
PSCommand.SetRegistration[[fx3500[reg]]];
Display current values:
WITH s: state SELECT FROM
fx3500 => TRUSTED BEGIN
stringArray: REF XMessage.StringArray ← NEW [XMessage.StringArray[2]];
XFormat.NSString[outputHandle, NSString.AppendDecimal[s.registration.long]];
stringArray[0] ← NEW[TEXT[10]];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mLongAxisRegistration, stringArray];
sValue.length ← 0;
XFormat.NSString[outputHandle, NSString.AppendDecimal[NIL, s.registration.short]];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mShortAxisRegistration, stringArray];
END;
ENDCASE;
END; --FX3500RegistrationMode
RavenRegistrationMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.RavenRegistration] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
reg: PaperHandling.RavenRegistration;
reg.long ← TextInput.GetDecimal[tty: tty,
prompt: M[mSetLongAxisRegistration],
min: FIRST[PaperHandling.RavenRegLong],
max: LAST[PaperHandling.RavenRegLong], default: current.long];
reg.short ← TextInput.GetDecimal[tty: tty,
prompt: M[mSetShortAxisRegistration],
min: FIRST[PaperHandling.RavenRegShort],
max: LAST[PaperHandling.RavenRegShort], default: current.short];
PSCommand.SetRegistration[[raven[reg]]];
Display current values:
WITH s: state SELECT FROM
raven => BEGIN
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[2]];
XFormat.NSString[outputHandle, NSString.AppendDecimal[NIL, s.registration.long]];
stringArray[0] ← NEW[TEXT[10]];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mLongAxisRegistration, stringArray];
sValue.length ← 0;
XFormat.NSString[outputHandle, NSString.AppendDecimal[s.registration.short]];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mShortAxisRegistration, stringArray];
END;
ENDCASE;
END; --RavenRegistrationMode
***Stacking:
RavenStackingMode: PROCEDURE [exec: NSExec.Handle, current: PaperHandling.PaperStacking] = TRUSTED BEGIN
tty: TTY.Handle ← NSExec.GetTTY[exec];
outputHandle: XFormat.Handle ← NSExec.OutputHandle[exec];
state: PSState.StateHandle ← PSCommand.GetPrintServiceStatus[];
stringArray: REF XMessage.StringArray ← NEW[XMessage.StringArray[2]];
choices: CARDINAL = 3;
msgKeys: PSExecInternal.KeyList ← NEW[PSExecInternal.KeyListRep[choices]];
stackingChoices: PSExecInternal.ChoiceList ← NEW[XMessage.StringArray[choices]];
choice: TextInput.ChoiceIndex;
defaultChoice: CARDINAL
SELECT current FROM aligned => 0, documentOffset => 1, ENDCASE => 2;
WITH s: state SELECT FROM
raven => IF s.engineBuild < b2 THEN ERROR; --Pre b2 ravens don't have stackers
ENDCASE => ERROR;
PSExecInternal.GetList[choices, msgKeys, stackingChoices];
choice ← TextInput.GetChoice[
tty: tty, prompt: M[mSpecifyOutputStackingMode],
choices: stackingChoices, default: defaultChoice];
PSCommand.SetPaperStacking[
SELECT choice FROM 0 => aligned, 1 => documentOffset, ENDCASE => jobOffset];
WITH s: state SELECT FROM
raven => BEGIN
stringArray[0] ← M[
SELECT s.paperStacking FROM
aligned => mAligned,
documentOffset => mCopyOffset,
ENDCASE --jobOffset-- => mSetOfCopiesOffset];
outputHandle.Blanks[tab1];
PSExecInternal.ExpandKeyAndPrint[exec, mOutputStacking, stringArray];
END;
ENDCASE => ERROR;
END; -- RavenStackingMode
==== ==== ==== ====
SUPPORT ROUTINES:
==== ==== ==== ====
Proc for getting NSString from XMessage key
M: PROCEDURE [key: PSExecMessages.Key] RETURNS [string: NSString.String] = {
RETURN[XMessage.Get[execMsgs, ORD[key]]]};
END. --PSExecCImpl
LOG when/who/what
9-Jan-84 18:06:24 - Jacks - Split off from PSTTYExecAImpl, which was too large.
11-Jan-84 10:28:40 - Jacks - Changed call to PSCommand.SetFaxRetries to reflect delay in seconds instead of minutes.
22-Jan-84 11:34:45 - Jacks - Converted to 8.0 SCS.
9-Feb-84 13:11:59 - Jacks - Added fx3500 SetParameters functionality.
14-Feb-84 11:35:44 - Jacks - Changed to use current printOrder value for SetPrintOrder.
19-Feb-84 13:31:57 - Jacks - Removed all procedure calls from WITH stmt headers.
23-Feb-84 21:09:48 - Jacks - Added PutPrinterDisplay and GetPrinterDisplay; converted to private heap.
19-Mar-84 15:51:54 - Jacks - Fixed up FaxRetryMode for no connection vs. transmit failure and not displaying interval if number of retries is 0.
2-Apr-84 11:00:31 - Jacks - Removed NewControlMessages.
3-Apr-84 19:14:35 - Jacks - Added support for multiple execs.
15-Sep-84 12:50:02 - Jacks - Converted to new 9.0 PS interfaces: PSState, PSCommand.
27-Sep-84 13:09:10 - Jacks - Renamed from PSTTYExecCImpl to PSExecCImpl.
19-Oct-84 10:58:19 - Jacks - Added SetTargetPrintService; renamed ttyHeap to execHeap.
1-Nov-84 17:38:10 - Jacks - Removed redundant calls to GetPrintServiceStatus in many procs.
14-Nov-84 14:12:11 - Jacks - Updated to new PSState interface; removed TTY.Rubout catch phrases.
19-Nov-84 13:34:21 - Jacks - Added BansheeBannerMode.
13-Dec-84 11:03:22 - Jacks - Added catch phrase to PSCommand.SetTargetPrintService.
16-Jan-85 15:38:39 - Jacks - Removed ERRORs in catch phrase for NSAddressTranslation.StringToNetworkAddress in SetTargetPrintService; added "ps" prefix to all new msg keys for 9.0.
28-Feb-85 15:29:52 - Jacks - Added comment.
8-May-85 13:15:56 - Jacks - Updated to Pilot/Mesa 12.0 (changes in NSAddressTranslation).
19-Jun-85 11:56:51 - Jacks - Added copyright notice; updated to PS Euclid interfaces; turned off public error catching by SCS in all exec procs.
28-Jun-85 15:08:45 - Jacks - Added d1 code (including D1BannerMode and D1RegistrationMode); removed SetCatching calls.
18-Jul-85 14:40:02 - Jacks - Converted to XMessage.
2-Aug-85 9:11:57 - Jacks - Made use of MsgOps for getting CHS error msgs in SetTargetPrintService.
6-Nov-85 13:12:33 - Jacks - Call PSKMessages for msg handle.
13-Dec-85 16:44:19 - Jacks - ExecMessages renamed to PSExecMessages.