--File PressNetDefs.mesa
--Last February 8, 1982 2:13 PM By Glen Williams
--Added DLP to printer type, and its attributes.
DIRECTORY;

PressNetDefs: DEFINITIONS =

BEGIN

--Types and Variables

Printer: TYPE = {Stinger, DLP1};
ScanDirection: TYPE = {portrait, landscape};
--the direction the scanner writes bits:
-- landscape=bits go up the length of
-- the page

attributesCode: CARDINAL = 134267B;
--semi-random code to make sure attributes block
-- is recognized
imageCode: CARDINAL = 134367B;
--another semi-random code. Means this buffer
-- holds image data

PrinterAttributes: TYPE = MACHINE DEPENDENT RECORD
--these are the values a user needs.
[printer(0: 0..9): Printer,
nPrinterColors(0: 10..12):[0..7B],
scanDirection(0: 13..15):ScanDirection,
resolutionB(1: 0..15):CARDINAL,--bits/inch in scan line
resolutionS(2: 0..15):CARDINAL,--scanlines/inch
scanLengthInches(3: 0..15):CARDINAL--length of scan in inches (paper size) * 10
];

PageAttributes: TYPE = MACHINE DEPENDENT RECORD
[scanDirection: ScanDirection,
filler:[0..77777B],
firstScan:CARDINAL,--the first scan line of information on the page. I.e., the
-- count of scan lines to skip before your
-- first line of data. On a landscape machine, first scan
-- determines the left margin. On a portrait
-- machine, the top margin. Begin enumeration at zero.
lastScan:CARDINAL,--the last scan line of data on the page. I.e., the image is
-- composed of scanlines starting @ firstScan and ending
-- @lastScan, interpreted as addresses on the printed page.
margin: CARDINAL,--# of bits into page to position the beginning of the scan.
-- On a landscape machine, this determines the bottom margin.
bitWc:CARDINAL--# of bits in scan line/word size. (Usually bits/16).
];

DLP1Attributes: PrinterAttributes =
[printer: DLP1, nPrinterColors: 1, scanDirection: portrait, resolutionB: 880, resolutionS: 880, scanLengthInches: 85];

StingerAttributes: PrinterAttributes =
[printer: Stinger, nPrinterColors: 1, scanDirection: landscape, resolutionB: 384, resolutionS: 384, scanLengthInches: 110];

PressSendError: ERROR [err: PressNetErr, s: STRING];
--if s # NIL then it contains info passed from the specific error-generator

PressNetErr: TYPE =
{noError,--for initialization

--These are renamed from Eftp-generated errors
errorNoRoute,
errorNoResponse,
errorFromServer, --the lookup server, not the print server
errorEftpOK,--looks like an error but isn’t
errorEftpExternalReceiverAbort,
errorEftpReceiverBusyAbort,
errorEftpOutOfSyncAbort,
errorEftpRejected,
errorNotSending,

errorTimedOut --this occurs when data is being transmitted to the listener
--or on trying to connect to the printer: SetRetries’s count is exhausted
};

--Procedures

--for sender
--Currently the sender is allowed to send one page only.
--The steps in sending a page to the printer are the following.
-- Call GetPrinterAttributes to determine scan-line direction of desired printer.
-- Call PrinterReady to see if the printer is available.
-- Call SendPageAttributes to let the printer set up its parameters.
-- Call SendLine lastScan-firstScan+1 times to transmit the scan lines.
-- Call CloseConnection.

GetPrinterAttributes: PROCEDURE[printer: Printer] RETURNS [pa: PrinterAttributes];
--for now returns a compiled-in set of attributes

PrinterReady: PROCEDURE [printer: Printer, retries: CARDINAL ← 1] RETURNS [goAhead: BOOLEAN ← FALSE];
--If returns TRUE, you have a connection; FALSE if the printer doesn’t answer in time.
-- It will raise PressSendError if any error occurs, and the exact error can be discriminated.
-- possible elements of the Type are errorNoRoute,errorNoResponse, errorFromServer, errorEftpRejected,
-- errorEftpOK, errorEftpExternalReceiverAbort, errorEftpReceiverBusyAbort, errorEftpOutOfSyncAbort

SetRetries: PROC[n: CARDINAL];
--sets the retry count for all the transfers after the connection is established.

SendPageAttributes: PROCEDURE[attrPt: POINTER TO PageAttributes];
--This routine sends the page attributes to the printer.
--If PressSendError is raised, there was trouble with the parameters and the connection is closed.

SendLine: PROCEDURE[p: LONG POINTER];
--Sends a scan-line of bits to the printer. The # of words sent is taken from PageAttributes.bitWc.
--Can raise PressSendError with any of the following conditions: errorNoRoute, errorNoResponse,
-- errorFromServer, errorEftpOK, errorEftpExternalReceiverAbort, errorEftpReceiverBusyAbort,
-- errorEftpOutOfSyncAbort, errorEftpRejected, errorTimedOut.

CloseConnection: PROCEDURE[];
--A connection will be kept open until this routine is called. Don’t forget to call it!


--for Printer

GetAJob: PROCEDURE[];--listens for a job request and gets attributes. If attributes are
-- ok, it stores them as first page of Press.bits and returns

GetBits: PROCEDURE[] RETURNS[okToProceed: BOOLEAN ← FALSE];
--This differs from Send Bits in that this routine gets all the bits of the page before
--exiting. It also responds to CloseConnection from the user. When this exits, we’re ready to print.

SendPrinterAttributes: PROCEDURE[printer: Printer];
--This routine answers the GetPrinterAttributes query from remote users. Not
-- implemented in first round of implementations.

END. --of PressNetDefs
Last edited September 21, 1981 4:21 PM By Glen Williams
--created
--Last edited November 17, 1981 11:45 AM By Glen Williams
--changed PrinterAttributes and SendBits to Sendline
--Last edited November 23, 1981 10:59 AM By Glen Williams
--added imageCode
--Last edited 22-Dec-81 15:47:54 By Glen Williams
--SendLine now takes a Long Pointer