<> <> <> DIRECTORY Basics USING [bitsPerWord, DoubleShiftRight, LongMult], CountedVM USING [Handle, SimpleAllocate], <> Imager USING [Context, metersPerInch, RotateT, ScaleT, TranslateT], ImagerBitmapContext USING [Create], ImagerDevice USING [FontTuner], ImagerSample USING [Clear, GetSize, MapFromVM, RasterSampleMap], Loader USING [MakeProcedureResident, MakeGlobalFrameResident], LSEPFace, Process USING [Pause, MsecToTicks], PrincOps USING [wordsPerPage, BBTableSpace, BBptr, PageCount], PrincOpsUtils USING [AllocateNakedCondition, AlignedBBTable], RavenCodes, RavenDriver, Rope USING [ROPE], VM USING [Allocate, Interval, PageCount, PagesForWords, Pin ]; RavenDriverImpl: MONITOR IMPORTS Basics, CountedVM, -- FontTune, -- Imager, ImagerBitmapContext, ImagerSample, Loader, -- LSEPFace, -- Process, PrincOpsUtils, VM EXPORTS RavenDriver ~ BEGIN OPEN RavenDriver; myPixelMap: ImagerSample.RasterSampleMap _ NIL; secondPixelMap: ImagerSample.RasterSampleMap _ NIL; GetPrinterPixelMap: PUBLIC PROC RETURNS [pixelMap: ImagerSample.RasterSampleMap] = {RETURN[myPixelMap]}; MakePrinterPixelMap: PROC RETURNS [pixelMap: ImagerSample.RasterSampleMap] = BEGIN numBands: NAT = ((8*300+300/2)+15)/16; numLines: CARDINAL = numBands * sizeEachBand; wordsPerLine: NAT ~ activeLength; words: LONG CARDINAL ~ Basics.LongMult[wordsPerLine, numLines]; pages: CARDINAL = VM.PagesForWords[words]; vm: CountedVM.Handle _ CountedVM.SimpleAllocate[words]; interval: VM.Interval ~ vm.interval; pixelMap _ ImagerSample.MapFromVM[ vm: vm, box: [min: [0, 0], max: [(8*300+300/2), (11*300)]], bitsPerSample: 1, bitsPerLine: 11*300]; FOR i: INT _ 0, i+400 UNTIL i >= interval.count DO -- only pin about 100K each time VM.Pin[[page: interval.page+i, count: MIN[interval.count-i, 400]]]; Process.Pause[Process.MsecToTicks[500]]; -- wait a half second for Laundry process ENDLOOP; ImagerSample.Clear[pixelMap]; END; ContextFromPixelMap: PUBLIC PROC [pixelMap: ImagerSample.RasterSampleMap, fontTunerParms: Rope.ROPE _ NIL] RETURNS [context: Imager.Context] = BEGIN fontTuner: ImagerDevice.FontTuner _ NIL; <> context _ ImagerBitmapContext.Create[deviceSpaceSize: ImagerSample.GetSize[pixelMap], scanMode: [slow: left, fast: up], surfaceUnitsPerInch: [300, 300], pixelUnits: FALSE, fontCacheName: $Bitmap, fontTuner: NIL]; Imager.RotateT[context, -90.0]; Imager.TranslateT[context, [-(8*300+300/2), 0]]; Imager.ScaleT[context, RavenCodes.resolution[fast]/Imager.metersPerInch]; END; lastPaperFeed: RavenCodes.PrinterCommand _ feed; SetRegistration: PUBLIC PROCEDURE [registration: RavenRegistration] = TRUSTED BEGIN DivideUp: PROCEDURE [divident, divisor: CARDINAL] RETURNS [quotient: CARDINAL] = TRUSTED INLINE BEGIN RETURN[quotient: (divident + divisor - 1) / divisor]; END; <> <> <> <> END; -- SetRegistration bandBufferSize: PrincOps.PageCount = 16; -- From BandBLT ScanLine: TYPE = [0..bandBufferSize); -- scan line index into a band bbTableSpace: PrincOps.BBTableSpace; bb: PrincOps.BBptr ~ PrincOpsUtils.AlignedBBTable[@bbTableSpace]; dstBpl: INTEGER ~ PrincOps.wordsPerPage*Basics.bitsPerWord; dataOnPulses: ARRAY [0 .. 256) OF CARD _ ALL[0]; PrintFromSampleMap: PUBLIC PROC [sampleMap: ImagerSample.RasterSampleMap, copies: CARDINAL _ 1, paperFeed: RavenDriver.PaperFeed _ alternating] RETURNS [endingStatus: PrinterStatus, type: StatusType] = BEGIN RETURN [ropeStatus[noStatus], normal]; END; currStatus: RavenCodes.PrinterStatus _ noStatus; mySP: REF StatusProc _ NIL; printing: BOOL _ FALSE; SetScanLineLength: PUBLIC SAFE PROCEDURE [scanLineLength: (0..PrincOps.wordsPerPage]] = TRUSTED BEGIN END; MonitorRavenStatus: PROC [] = BEGIN END; Message: TYPE = {traysUnlatched, preRegistrationFault, postRegistrationJam, preExitJam, postExitJam, doorOpen, outputTrayFull, tonerLow, aboutToDozeOff, fuserUnderTemperature, imageFault, commandStatusFault, offLine, ok}; RegisterStatusProc: PUBLIC ENTRY PROC [sp: StatusProc] = {mySP _ NEW[StatusProc _ sp]}; UnRegisterStatusProc: PUBLIC ENTRY PROC [sp: StatusProc] = {mySP _ NIL}; WakeUp: PUBLIC PROCEDURE[] = BEGIN <> END; bandBufferCount: LSEPFace.BandBufferCount _ 3; wordsPerBand: CARDINAL = sizeEachBand * PrincOps.wordsPerPage; sizeEachBand: CARDINAL = 16; pagesNeedForBands: VM.PageCount = LSEPFace.MaxBands * sizeEachBand + 20; vm: VM.Interval; activeLength: (0..PrincOps.wordsPerPage] _ ((11*300)+15)/16; statusCondition: LONG POINTER TO CONDITION _ NIL; statusMask: WORD _ 0; dataCondition: LONG POINTER TO CONDITION _ NIL; dataMask: WORD _ 0; Init: PROC [] = BEGIN vm _ VM.Allocate[pagesNeedForBands]; <> <> SetScanLineLength[activeLength]; myPixelMap _ MakePrinterPixelMap[]; <> Loader.MakeProcedureResident[PrintFromSampleMap]; Loader.MakeGlobalFrameResident[PrintFromSampleMap]; [statusCondition, statusMask] _ PrincOpsUtils.AllocateNakedCondition[]; [dataCondition, dataMask] _ PrincOpsUtils.AllocateNakedCondition[]; <> <> <> <> END; ropeStatus: ARRAY RavenCodes.PrinterStatus OF PrinterStatus _ ALL[NIL]; ropeStatus[noStatus] _ "No status"; ropeStatus[key0] _ "key0"; ropeStatus[key1] _ "key1"; ropeStatus[key2] _ "key2"; ropeStatus[key3] _ "key3"; ropeStatus[key4] _ "key4"; ropeStatus[key5] _ "key5"; ropeStatus[key6] _ "key6"; ropeStatus[key7] _ "key7"; ropeStatus[key8] _ "key8"; ropeStatus[key9] _ "key9"; ropeStatus[keyClear] _ "keyClear"; ropeStatus[keyTest] _ "keyTest"; ropeStatus[keyOnLine] _ "keyOnLine"; ropeStatus[keyOffLine] _ "keyOffLine"; ropeStatus[warming] _ "Warming"; ropeStatus[standBy] _ "Ready"; ropeStatus[feederFault] _ "Feeder Fault"; ropeStatus[registrationJam] _ "Registration Jam"; ropeStatus[fuserJam] _ "Fuser Jam"; ropeStatus[noExit] _ "No Exit"; ropeStatus[interlockOpen] _ "Interlock Open"; ropeStatus[fuserCold] _ "Fuser Cold"; ropeStatus[feeding] _ "Feeding"; ropeStatus[readyToFeed] _ "Ready To Feed"; ropeStatus[displayAcknowledge] _ "displayAcknowledge"; ropeStatus[parityError] _ "parityError"; ropeStatus[unrecognizedCommand] _ "illegalCharacter"; ropeStatus[illegalSequence] _ "illegalSequence"; ropeStatus[feedTraysNotEngaged] _ "Paper Tray Open or Out of Paper"; ropeStatus[pageSync] _ "pageSync"; ropeStatus[pageAtOutputTray] _ "pageAtOutputTray"; ropeStatus[tonerLow] _ "Toner Low"; ropeStatus[goingOffLine] _ "goingOffLine"; ropeStatus[offLine] _ "offLine"; ropeStatus[outputTrayFull] _ "outputTrayFull"; ropeStatus[aboutToDozeOff] _ "Low Power Mode"; ropeStatus[statusError] _ "statusError"; ropeStatus[statusOverRun] _ "statusOverRun"; Init[]; END.