--File PressNetDefs.mesa
--Last edited November 23, 1981 10:59 AM By Glen Williams
--added imageCode
DIRECTORY;

PressNetDefs: DEFINITIONS =

BEGIN

--Types and Variables

Printer: TYPE = {Stinger};
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,--scanlines/inch
resolutionS(2: 0..15):CARDINAL,--bits/inch in scan line
scanLengthInches(3: 0..15):CARDINAL--length of scan in inches (paper size) * 10
];

PageAttributes: TYPE = MACHINE DEPENDENT RECORD
[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).
];
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,
errorEftpOK,--looks like an error but isn’t
errorEftpExternalReceiverAbort,
errorEftpReceiverBusyAbort,
errorEftpOutOfSyncAbort,
errorEftpRejected,
errorNotSending,

errorTimedOut --this occurs when data is being transmitted to rhe listener: when 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 successfully, you have a connection.
--Later may return reason for no connection (i.e., printer down, not listening etc)

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 goAhead returns FALSE, there was trouble with the parameters and the connection is closed.

SendLine: PROCEDURE[p: POINTER];
--Sends a scan-line of bits to the printer. The # of words sent is taken from PageAttributes.bitWc.

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