(FILECREATED "27-JUL-83 16:13:55" {PHYLUM}<FIKES>LISP>PLANNER.;33 46920  

      changes to:  (FNS Plan1To2 PlanBdaNoMaster PlanBdaWithMaster)

      previous date: "15-MAR-83 18:09:17" {PHYLUM}<FIKES>LISP>PLANNER.;32)


(PRETTYCOMPRINT PLANNERCOMS)

(RPAQQ PLANNERCOMS [(FNS * PLANNERFNS)
		    (RECORDS * PLANNERRECORDS)
		    (ADVISE * PLANNERADVICE)
		    (DECLARE: EVAL@COMPILE (P (LOADCOMP? 'LOADBLUEBONNET])

(RPAQQ PLANNERFNS (CreateComment CreateKernelEntry CreatePlanStep CreateUserInstruction Plan1To1 
				 Plan1To2 Plan2To1NoMaster Plan2To1WithMaster Plan2To2 
				 PlanBdaNoMaster PlanBdaWithMaster PlanClearA10 PlanClearA12 
				 PlanCopyJob PlanLoadRDH PlanLoadTopPaperTray PlanMakeReady PlanPanel 
				 PlanPaperTray PlanPushStart PlanSidedness PlanStatusCodeMessage 
				 PlanThankYou PlanTooThick PlanUnloadOutputTray PlanUnloadRdh 
				 PlanUnloadTopPaperTray PrintPlan))
(DEFINEQ

(CreateComment
  [LAMBDA (text)                                             (* ref: " 7-JAN-83 13:55")

          (* Return a list of paragraphs that can be used as the instructions in a plan step to make text a comment to the 
	  user.)


    (DECLARE (USEDFREE CommentHeader))
    <CommentHeader (create Paragraph
			   leftMargin ← 5
			   text ← text)
      >])

(CreateKernelEntry
  [LAMBDA (wff assumption producer)                          (* edited: " 6-FEB-83 21:10")
                                                             (* Create a kernel entry. assumption can be either a 
							     list of atoms or a paragragh.)
    (create KernelEntry
	    wff ← wff
	    assumption ←(assumption and (if (type? Paragraph assumption)
					    then assumption
					  else (create Paragraph
						       text ← assumption)))
	    producer ← producer])

(CreatePlanStep
  [LAMBDA (instructions action assertions kernelEntries goal keywordList help)
                                                             (* edited: "11-MAR-83 14:35")

          (* Create a plan step with the given instructions, action, assertions, a kernel that has the given kernel entries 
	  with the created step as its step, the given goal, keyword list, and help. instructions is either text for a 
	  paragraph, represented as a list of atoms, a paragraph, or a list of paragraphs and texts.
	  assertions is either a kernel entry, a wff, or a list each of whose elements is a kernel entry or a wff.
	  In the case of a wff, a kernel entry is created for the wff with the created step as its producer.
	  kernelEntries is either a kernel entry, plan step, or a list each of whose elements is a kernel entry or plan 
	  step. In the case of a plan step, all of the step's assertions are taken as kernel entries.
	  goal is text for a paragraph.)


    (PROG [(step (create PlanStep
			 action ← action
			 kernel ←(create Kernel)
			 instructions ←[if instructions
					   then (for inst in (if (LISTP instructions)
								   and ~(ATOM instructions:1)
								 then instructions
							       else <instructions>)
						   collect (if (type? Paragraph inst)
							       then inst
							     else (create Paragraph
									  text ← inst]
			 goal ← goal
			 keywords ← keywordList
			 help ←(if help
				   then (for h in (if (LISTP help) and ~(ATOM help:1)
						      then help
						    else <help>)
					   collect (if (type? Paragraph h)
						       then h
						     else (create Paragraph
								  text ← h]
          (step:kernel:step←step)
          [step:assertions←(if assertions
			       then (for assert in (LISTP assertions) or <assertions>
				       collect (if (type? KernelEntry assert)
						   then assert:producer←step
							assert
						 else (create KernelEntry
							      wff ← assert
							      producer ← step]
          [step:kernel:entries←(if kernelEntries
				   then (for ke in (LISTP kernelEntries) or <kernelEntries>
					   join (if (type? KernelEntry ke)
						    then <ke>
						  else < ! ke:assertions>]
          (RETURN step])

(CreateUserInstruction
  [LAMBDA (instruction goal lookY)                           (* ref: "31-AUG-82 11:45")

          (* Return a list containing two paragraphs, the first containing text instruction and the second containing text 
	  goal. The first is given lookY. The second has a left margin of 5 and has parens inserted around the text.)


    < !(if instruction
	   then <(create Paragraph
			 text ← instruction
			 lookY ← lookY)
		  >)
     !(if goal
	  then <(create Paragraph
			leftMargin ← 5
			text ←(<(PACK* '%( goal:1) !(for x on goal::1 while x::1 collect x:1)
			  (PACK* goal:-1 '%))
			  >))
		 >)
    >])

(Plan1To1
  [LAMBDA (job)                                              (* edited: " 8-MAR-83 17:02")
                                                             (* Create a plan for making one-sided copies from 
							     one-sided RDHable originals.)
    (PROG (steps makeReady setPanel loadTopPaperTray loadRDH pushStart completePrinting 
		 selectBottomTray unloadTopPaperTray unloadRdh unloadOutputTray thankUser)
                                                             (* Step S1a: "Do MakeReady")
          (makeReady←(PlanMakeReady job))                    (* Step S1b-g: "Do Select panel features")
          (setPanel←(PlanPanel job:Collate job:CopyBrightness job:CopiesOnStandardPaper 
			       job:NumberOfCopies job:CopyJob.Reduction job:Staple))
          (if job:CopiesOnStandardPaper=(QUOTE No)
	      then                                           (* Step S1g.1: "TellUser Load paper tray.")
		   loadTopPaperTray←(PlanLoadTopPaperTray))
                                                             (* Step S1h: "TellUser Load RDH.")
          (loadRDH←(PlanLoadRDH))                            (* Step S2: "TellUser Press Start.")
          (pushStart←(PlanPushStart job:NumberOfCopies <setPanel !(if job:CopiesOnStandardPaper=(
									QUOTE No)
								      then <loadTopPaperTray>)
							 loadRDH makeReady>))
                                                             (* Step S3: "Do CompletePrinting")
          [completePrinting←(CreatePlanStep
	      [CreateComment (BQUOTE (Your ,@ [COND
					     ((EQ (fetch NumberOfCopies of job)
						  1)
					       (QUOTE (copy is)))
					     (T (QUOTE (copies are]
					   being made. Each sheet of the original is being taken into 
					   the copier by the RDH, copied once, and returned. ,@
					   (COND
					     ((EQ (fetch NumberOfCopies of job)
						  1)
					       (QUOTE (When all sheets have been returned, the copy 
							    will be put into the output tray.)))
					     (T (BQUOTE (When all sheets have been returned, a copy 
							      will be ,@
							      [COND
								((EQ (fetch Staple of job)
								     (QUOTE Yes))
								  (QUOTE (stapled and]
							      put into the output tray. Each copy is 
							      made in the same manner.]
	      (QUOTE (CompletePrintingStep))
	      (CreateKernelEntry (QUOTE CopiesMade)
				 (QUOTE (The copies have been made.)))
	      pushStart
	      (QUOTE (Copying the originals,))
	      (QUOTE (OutputTray]
          (if job:CopiesOnStandardPaper=(QUOTE No)
	      then                                           (* Step S4: "TellUser Remove paper.")
		   unloadTopPaperTray←(PlanUnloadTopPaperTray) 
                                                             (* Step S5: "Do Select BottomPaperTray")
		   selectBottomTray←(PlanPaperTray (QUOTE Yes)
						   <unloadTopPaperTray>)
		   (push steps loadTopPaperTray unloadTopPaperTray selectBottomTray))
                                                             (* Step S6a: "Tell User Unload RDH")
          (unloadRdh←(PlanUnloadRdh))                        (* Step S6b: "Tell User Unload output")
          (unloadOutputTray←(PlanUnloadOutputTray))          (* Step S7: "Tell User Thank You")
          (thankUser←(PlanThankYou <completePrinting !(if job:CopiesOnStandardPaper=(QUOTE No)
							  then <selectBottomTray>)
				     unloadRdh unloadOutputTray makeReady>))
          (push steps makeReady setPanel loadRDH pushStart completePrinting unloadRdh 
		unloadOutputTray thankUser)
          (RETURN (create Plan
			  steps ← steps
			  goal ← thankUser:kernel
			  summary ←[create Paragraph
					   text ←(BQUOTE (You can use the Recirculating Document 
							      Handler %(RDH%) to make your ,
							      (COND
								((EQ (fetch NumberOfCopies
									of job)
								     1)
								  (QUOTE copy.))
								(T (QUOTE copies.]
			  initialState ←(QUOTE (CopiesMade])

(Plan1To2
  [LAMBDA (job originalsReversedFlg)                         (* edited: "27-JUL-83 15:40")

          (* Create a plan for making two-sided copies from one-sided RDHable originals. If originalsReversedFlg is set, 
	  then the originals are assumed to be reversed at the beginning of the plan.)


    (PROG (steps makeReady setPanel loadTopPaperTray1 loadRdh1 unloadTopPaperTray pushStart1 
		 completePrinting1 unloadOutputTray1 loadTopPaperTray2 unloadRdh1 loadRdh2 pushStart2 
		 completePrinting2 unloadRdh2 unloadOutputTray2 thankUser pass1DoneKernelEntry)
          (makeReady←(PlanMakeReady))
          (setPanel←(PlanPanel job:Collate job:CopyBrightness job:CopiesOnStandardPaper 
			       job:NumberOfCopies job:CopyJob.Reduction job:Staple job:TwoSidedCopies)
	    )
          (if job:CopiesOnStandardPaper=(QUOTE No)
	      then loadTopPaperTray1←(PlanLoadTopPaperTray))
          [loadRdh1←(CreatePlanStep
	      <
		!(if ~originalsReversedFlg
		     then
		      <(QUOTE (Reverse the order of the pages in the original so that the first page 
				       is on the bottom and the last page is on top.))
			>)
		!(CreateUserInstruction (QUOTE (Place the original in the RDH face up, with the pages 
						      in reverse order, last page on top.))
					(QUOTE (so that the RDH can automatically feed each sheet 
						   into the copier))
					1)
		>
	      (QUOTE (replace OriginalsReversed of JobState with T))
	      (CreateKernelEntry (CreateWff (QUOTE (AND DocumentInRDH OriginalsReversed)))
				 (QUOTE (The document to be copied is in the RDH, face up, last page 
					     on top.)))
	      NIL NIL (QUOTE (RDH]
          (pushStart1←(PlanPushStart job:NumberOfCopies <setPanel !(if job:CopiesOnStandardPaper=(
									 QUOTE No)
								       then <loadTopPaperTray1>)
							  loadRdh1 makeReady>))
          [pass1DoneKernelEntry←(CreateKernelEntry (QUOTE Pass1Done)
						   (QUOTE (The back sides of the copies have been 
							       made.]
          [completePrinting1←(CreatePlanStep [CreateComment (BQUOTE (The back sides of the copies are 
									 being made. Each page of the 
									 original is taken into the 
									 copier by the RDH
									   and returned. A copy is 
									 then put into the output 
									 tray. ,@(COND
									   ((NEQ (fetch 
										   NumberOfCopies
										    of job)
										 1)
									     (QUOTE (This process is 
											 repeated for 
											  each copy.]
					     [QUOTE (PROGN (DisplayStopButton)
							   (COND
							     ((MakeReady)
							       (replace Pass1Done of JobState
								  with T]
					     <pass1DoneKernelEntry
					       !(if job:CopiesOnStandardPaper=(QUOTE No)
						    then <[CreateWff (QUOTE (= UnloadTopPaperTray
									       (QUOTE on]
							   >
						  else <[CreateWff (QUOTE (= UnloadOutputTray
									     (QUOTE on]
							 [CreateWff (QUOTE (= LCITTLight
									      (QUOTE on]
							 >)
					       >
					     pushStart1 NIL (QUOTE (OutputTray]
          (if job:CopiesOnStandardPaper=(QUOTE No)
	      then unloadTopPaperTray←(CreatePlanStep (QUOTE (Remove your paper from the top paper 
								     tray.))
						      NIL <[CreateWff (QUOTE (= UnloadOutputTray
										(QUOTE on]
							    [CreateWff (QUOTE (= LCITTLight
										 (QUOTE on]
							    >)
		   (push steps loadTopPaperTray1 unloadTopPaperTray)
		   (QUOTE (TopPaperTray)))
          [unloadOutputTray1←(CreatePlanStep (BQUOTE (Remove the , (COND
							       ((EQ (fetch NumberOfCopies
								       of job)
								    1)
								 (QUOTE copy))
							       (T (QUOTE copies)))
							     from the output tray.))
					     NIL
					     [CreateWff (QUOTE (= UnloadOutputTray (QUOTE off]
					     (if job:CopiesOnStandardPaper=(QUOTE No)
						 then unloadTopPaperTray)
					     NIL
					     (QUOTE (OutputTray]
          [loadTopPaperTray2←(CreatePlanStep (BQUOTE (Place the , (COND
							      ((EQ (fetch NumberOfCopies
								      of job)
								   1)
								(QUOTE copy))
							      (T (QUOTE copies)))
							    in the top paper tray.))
					     NIL
					     (CreateKernelEntry
					       [CreateWff (QUOTE (AND (= OriginalsFaceUp
									 (QUOTE on))
								      (= LastPageBottomFirstPageTop
									 (QUOTE on]
					       (QUOTE (The copies from the first pass are in the top 
							   paper tray.)))
					     unloadOutputTray1 NIL (QUOTE (TopPaperTray]
          (unloadRdh1←(PlanUnloadRdh))
          (loadRdh2←(CreatePlanStep
	      <(BQUOTE (Restore the order of the pages in the original ,@[COND
				  ((NOT originalsReversedFlg)
				    (QUOTE (again]
				so that the first page is on top and the last page is on the bottom.))
		!(CreateUserInstruction (QUOTE (Place the originals in the RDH face up.))
					(QUOTE (so that the RDH can again feed each sheet into the 
						   copier))
					1)
		>
	      (QUOTE (replace OriginalsReversed of JobState with NIL))
	      (CreateKernelEntry [CreateWff (QUOTE (AND DocumentInRDH (~ OriginalReversed]
				 (QUOTE (The document being copied is in the RDH, face up, first page 
					     on top.)))
	      unloadRdh1))
          (pushStart2←(PlanPushStart job:NumberOfCopies <loadTopPaperTray2 loadRdh2>))
          (completePrinting2←(CreatePlanStep [CreateComment (BQUOTE (The front sides of the copies 
									 are being made. Each page of 
									 the original is taken into 
									 the copier by the RDH
									   and returned. A finished 
									       copy is then put into 
									 the output tray. ,@(COND
									   ((NEQ (fetch 
										   NumberOfCopies
										    of job)
										 1)
									     (QUOTE (This process is 
											 repeated for 
											  each copy.]
					     (QUOTE (CompletePrintingStep))
					     (CreateKernelEntry (QUOTE CopiesMade)
								(QUOTE (The front sides of the copies 
									    have been made.)))
					     pushStart2))
          (unloadRdh2←(PlanUnloadRdh))
          (unloadOutputTray2←(PlanUnloadOutputTray))
          (thankUser←(PlanThankYou <pass1DoneKernelEntry completePrinting2 unloadRdh2 
				     unloadOutputTray2 makeReady>))
          (push steps makeReady setPanel loadRdh1 pushStart1 completePrinting1 unloadOutputTray1 
		loadTopPaperTray2 unloadRdh1 loadRdh2 pushStart2 completePrinting2 unloadRdh2 
		unloadOutputTray2 thankUser)
          (RETURN (create Plan
			  steps ← steps
			  goal ← thankUser:kernel
			  summary ←(create Paragraph
					   text ←(BQUOTE (I will give you instructions for using the 
							    Recirculating Document Handler %(RDH%) to 
							    make your ,
							    (COND
							      ((EQ (fetch NumberOfCopies
								      of job)
								   1)
								(QUOTE copy))
							      (T (QUOTE copies)))
							    in two %"passes%". During the first pass, 
							    the back sides of the copies will be 
							    made. Then I will ask you to prepare the 
							    copier for the second pass, during which 
							    the front sides of the copies will be 
							    made.)))
			  initialState ←(QUOTE (Pass1Done CopiesMade (OriginalsReversed 
									     originalsReversedFlg])

(Plan2To1NoMaster
  [LAMBDA (CopyBrightness CopiesOnStandardPaper NumberOfCopies Reduction)
                                                             (* ref: " 5-MAY-82 16:29")
                                                             (* Create a plan for making either 1 or multiple 
							     uncollated one-sided copies from two-sided RDHable 
							     originals.)
    <(PlanSidedness)
    (PlanCollateStaple)
    (PlanCopyBrightness CopyBrightness)
    (PlanPaperTray CopiesOnStandardPaper)
    (PlanReduction Reduction)
    (PlanNumberOfCopies NumberOfCopies) !(if ~CopiesOnStandardPaper
					     then <
"User Step:  Place special paper in top paper tray." >)
    "User Step:  Place originals in RDH face down." "User Step:  Press Start button." 
    "User Step:  Remove copies of fronts of originals from output tray."
    "User Step:  Place originals in RDH face up." "User Step:  Press Start button." 
    "User Step:  Remove copies of backs of originals from output tray."
    "User Step:  Merge first set of copies with second set." "User Step:  Remove originals from RDH."
     !(if ~CopiesOnStandardPaper
	  then <"User Step:  Remove paper from top paper tray." >)
    >])

(Plan2To1WithMaster
  [LAMBDA (CopyBrightness CopiesOnStandardPaper NumberOfCopies Reduction Staple)
                                                             (* ref: " 5-MAY-82 16:28")
                                                             (* Create a plan for making multiple collated one-sided 
							     copies from two-sided RDHable originals.)
    < !(Plan2To1NoMaster CopyBrightness T 1 Reduction)
    "Note:  Use the complete copy just made as the original in the following steps."
     !(Plan1To1 T 'Normal CopiesOnStandardPaper NumberOfCopies NIL Staple)
    >])

(Plan2To2
  [LAMBDA (CopyBrightness CopiesOnStandardPaper NumberOfCopies Reduction Staple)
                                                             (* ref: " 5-MAY-82 15:19")
                                                             (* Create a plan for making two sided copies from 
							     two-sided RDHable originals.)
    <(PlanSidedness T T)
    (PlanCollateStaple T Staple)
    (PlanCopyBrightness CopyBrightness)
    (PlanPaperTray CopiesOnStandardPaper)
    (PlanReduction Reduction)
    (PlanNumberOfCopies NumberOfCopies) !(if ~CopiesOnStandardPaper
					     then <
"User Step:  Load special paper into bottom paper tray." >)
    "User Step:  Place originals in RDH face down, top toward back." 
    "User Step:  Press Start button."
    "User Step:  Remove copies from output tray." 
    "User Step:  Place copies face up in the top paper tray."
    "User Step:  Place originals in RDH face up, top toward back." "User Step:  Press Start button." 
    "User Step:  Remove copies from output tray."
    "User Step:  Remove originals from RDH." !(if ~CopiesOnStandardPaper
						  then <
"User Step:  Remove special paper from bottom paper tray." >)
    >])

(PlanBdaNoMaster
  [LAMBDA (job)                                              (* edited: "27-JUL-83 15:48")
                                                             (* Create a plan for making either 1 or multiple 
							     uncollated one-sided copies using the BDA.)
    (PROG [steps makeReady setPanel loadTopPaperTray unloadTopPaperTray openRdh placeFirstPage 
		 pushStartFirstTime completeFirstPrinting pushStart completePrinting openShade 
		 placeNextPage unloadOutputTray thankUser RdhClosed
		 (beingCopiedMsg (CreateComment (BQUOTE (The original on the glass is being copied. 
							     The ,@[COND
							       ((EQ (fetch NumberOfCopies
								       of job)
								    1)
								 (QUOTE (copy is)))
							       (T (QUOTE (copies are]
							     being put into the output tray.]
                                                             (* Step S1a: "Do MakeReady")
          (makeReady←(PlanMakeReady job))                    (* Step S1b-g: "Do Select CollateStaple")
          (setPanel←(PlanPanel (if job:NumberOfCopies=1
				   then (QUOTE Yes)
				 else (QUOTE No))
			       job:CopyBrightness job:CopiesOnStandardPaper job:NumberOfCopies 
			       job:CopyJob.Reduction))
          (if job:CopiesOnStandardPaper=(QUOTE No)
	      then                                           (* Step S1g.1: "TellUser Load paper tray.")
		   loadTopPaperTray←(PlanLoadTopPaperTray) 
                                                             (* Step S10a1: "TellUser Remove paper.")
		   unloadTopPaperTray←(PlanUnloadTopPaperTray) 
                                                             (* Step S10a2: "Do Select BottomPaperTray")
		   selectBottomTray←(PlanPaperTray (QUOTE Yes)
						   <unloadTopPaperTray>)
		   (push steps loadTopPaperTray unloadTopPaperTray selectBottomTray))
                                                             (* Step S1a.1: "TellUser Pull BDA latch.")
          [openRdh←(CreatePlanStep
	      < !(CreateUserInstruction (QUOTE (Pull the latch labelled LIFT.))
					(QUOTE (to release the RDH)))
		!(CreateUserInstruction (QUOTE (Raise the RDH.))
					(QUOTE (to enable placement of the bound document on the 
						   glass))
					1)
		>
	      NIL
	      (QUOTE RDHOpen)
	      NIL
	      (QUOTE (Opening the RDH,))
	      (QUOTE (AccessBDA]                             (* Step S1a.2: "TellUser Place first page on glass.")
          [placeFirstPage←(CreatePlanStep
	      <
		!(CreateUserInstruction (QUOTE (Place your original face down on the glass, centered 
						      over the registration guide.))
					(QUOTE (to position it for the copier lens)))
		!(CreateUserInstruction (QUOTE (Slide the document cover left over your original 
						      until it latches.))
					(QUOTE (to provide an eye shield from the copier lights))
					1)
		>
	      NIL
	      (CreateKernelEntry (CreateWff (QUOTE (~ ShadeOpen)))
				 (QUOTE (The first page to be copied is on the glass.)))
	      <openRdh>
	      (QUOTE (Positioning the first page,))
	      (QUOTE (CloseDocumentCover]                    (* Step S2: "TellUser Press Start.")
          (pushStartFirstTime←(PlanPushStart job:NumberOfCopies <setPanel !(if 
								       job:CopiesOnStandardPaper=(
										 QUOTE No)
									       then 
									       <loadTopPaperTray>)
								  placeFirstPage makeReady>))
                                                             (* Step S3: "Do CompletePrinting")
          [completeFirstPrinting←(CreatePlanStep beingCopiedMsg
						 [BQUOTE (COND
							   ((CompletePrintingStep)
							     (replace FirstPageCopied of JobState
								with T)
							     (replace CopiesMade of JobState
								with T]
						 (QUOTE FirstPageCopied)
						 pushStartFirstTime
						 (QUOTE (Copying the first page.))
						 (QUOTE (OutputTray]
                                                             (* Step S5: "Tell User press Start")
          (pushStart←(PlanPushStart job:NumberOfCopies <setPanel !(if job:CopiesOnStandardPaper=(
									QUOTE No)
								      then <loadTopPaperTray>)
							 makeReady>))
                                                             (* Step S6: "Complete printing")
          [completePrinting←(CreatePlanStep beingCopiedMsg (QUOTE (CompletePrintingStep))
					    (CreateKernelEntry (QUOTE CopiesMade)
							       (BQUOTE (The ,
									    (COND
									      ((EQ (fetch 
										   NumberOfCopies
										      of job)
										   1)
										(QUOTE copy))
									      (T (QUOTE copies)))
									    of the original on the 
									    glass ,
									    (COND
									      ((EQ (fetch 
										   NumberOfCopies
										      of job)
										   1)
										(QUOTE has))
									      (T (QUOTE have)))
									    been made.)))
					    pushStart
					    (QUOTE (Copying the original on the glass.]
                                                             (* Step S7: "Tell User open shade")
          [openShade←(CreatePlanStep (CreateUserInstruction (QUOTE (Slide the document cover right.))
							    (QUOTE (to remove the original)))
				     NIL
				     (QUOTE ShadeOpen)
				     completePrinting
				     (QUOTE (Opening the document cover,))
				     (QUOTE (OpenDocumentCover]
                                                             (* Step S8: "Tell User remove original")
          [RdhClosed←(CreateKernelEntry (CreateWff (QUOTE (~ RDHOpen)))
					(QUOTE (Copies of all the originals have been made.]
          [placeNextPage←(CreatePlanStep
	      <(QUOTE (Remove the original from the glass.))
		(create Paragraph
			text ←(QUOTE (If more pages are to be copied, then:))
			lookY ← 1)
		(create Paragraph
			text ←(QUOTE (Place the next page face down on the glass.))
			leftMargin ← 5
			lookY ← 1)
		(create Paragraph
			text ←(QUOTE (Slide the document cover left until it latches.))
			leftMargin ← 5
			lookY ← 1)
		(create Paragraph
			text ←(QUOTE (Otherwise, lower the RDH until it latches.))
			lookY ← 1)
		>
	      (QUOTE JobState:CopiesMade←NIL)
	      RdhClosed openShade (QUOTE (Removing the original that was just copied,]
                                                             (* Step S10b: "Tell User Unload output")
          [unloadOutputTray←(CreatePlanStep [BQUOTE (Remove the ,@(COND
							      ((EQ (fetch NumberOfCopies
								      of job)
								   1)
								(QUOTE (copy from the output tray.)))
							      (T (QUOTE (copies from the output tray.]
					    NIL
					    (CreateWff (QUOTE (~ OffsettingCatchTray)))
					    NIL
					    (QUOTE (Unloading the output tray,))
					    (QUOTE (OutputTray]
                                                             (* Step S11: "Tell User Thank You")
          (thankUser←(PlanThankYou <completeFirstPrinting RdhClosed !(if job:CopiesOnStandardPaper=(
									   QUOTE No)
									 then <selectBottomTray>)
				     unloadOutputTray makeReady>))
          (push steps makeReady setPanel openRdh placeFirstPage pushStartFirstTime 
		completeFirstPrinting pushStart completePrinting openShade placeNextPage 
		unloadOutputTray thankUser)
          (RETURN (create Plan
			  steps ← steps
			  goal ← thankUser:kernel
			  summary ←[create Paragraph
					   text ←(BQUOTE (I will give you instructions for using the 
							    glass to make your ,
							    (COND
							      ((EQ (fetch NumberOfCopies
								      of job)
								   1)
								(QUOTE copy.))
							      (T (QUOTE copies.]
			  initialState ←(QUOTE (FirstPageCopied CopiesMade])

(PlanBdaWithMaster
  [LAMBDA (job)                                              (* edited: "27-JUL-83 15:50")
                                                             (* Create a plan for making either multiple or two-sided
							     copies from a bound document.)
    (PROG (plan1 plan2 connectStep (subjob1 (CopyCopyJob job))
		 (subjob2 (CopyCopyJob job)))
          (subjob1:CopiesOnStandardPaper←(QUOTE Yes))
          (subjob1:NumberOfCopies←1)
          (subjob1:TwoSidedCopies←(QUOTE No))
          (subjob1:Staple←(QUOTE No))
          (plan1←(PlanBdaNoMaster subjob1))
          (subjob2:CopyBrightness←(QUOTE normal))
          (subjob2:InputProcessor←(QUOTE RDH))
          (subjob2:NumberOfCopies←(if job:CopiesOnStandardPaper=(QUOTE Yes) and job:Staple=(QUOTE
										  No)
					and job:TwoSidedCopies=(QUOTE No)
				      then job:NumberOfCopies-1
				    else job:NumberOfCopies))
          (subjob2:OriginalsBound←(QUOTE No))
          (subjob2:OriginalsOnStandardPaper←(QUOTE Yes))
          (subjob2:OriginalsStandardSize←(QUOTE Yes))
          (subjob2:CopyJob.Reduction←(QUOTE FullSize))
          (subjob2:TwoSidedOriginals←(QUOTE No))
          (plan2←(PlanCopyJob subjob2 T))
          [connectStep←(CreatePlanStep (QUOTE (Use the copy just made as the original in the 
						   following steps.))
				       (QUOTE (PROGN (replace CopiesMade of JobState
							with (replace FirstPageCopied of JobState
								with (replace Pass1Done of JobState
									with NIL)))
						     (replace MasterMade of JobState with T)
						     (DISMISS 5000)))
				       NIL NIL (QUOTE (Completing the making of the unbound copy.]
          (connectStep:kernel←plan1:Plan.goal)
          (plan1:Plan.goal:step←connectStep)
          (push plan2:Plan.goal:entries
		(CreateKernelEntry (QUOTE MasterMade)
				   (QUOTE (A copy of your document is being used as the original to 
					     make the final copies.))
				   connectStep))
          (plan2:steps← < ! plan1:steps connectStep ! plan2:steps>)
          [plan2:summary←(create Paragraph
				 text ←(BQUOTE (You need to first make 1 unbound copy of your 
						    original. That copy can then be used to make your 
						    , (fetch NumberOfCopies of job)
						    ,@[COND
						      ((EQ (fetch Staple of job)
							   (QUOTE Yes))
							(QUOTE (stapled]
						    ,@[COND
						      ((AND (EQ (fetch Collate of job)
								(QUOTE Yes))
							    (IGREATERP (fetch NumberOfCopies
									  of job)
								       1))
							(QUOTE (collated]
						    ,@[COND
						      ((EQ (fetch TwoSidedCopies of job)
							   (QUOTE Yes))
							(QUOTE (two-sided]
						    ,
						    (COND
						      ((EQ (fetch NumberOfCopies of job)
							   1)
							(QUOTE copy.))
						      (T (QUOTE copies.]
          (plan2:initialState←plan1:initialState)
          (RETURN plan2])

(PlanClearA10
  [LAMBDA (job)                                              (* edited: " 3-MAR-83 15:35")
                                                             (* Planner for clearing an A12 status code.)
    (PROG (closeLeftCover closeRightCover goalStep)
          (openLeftCover←(CreatePlanStep (QUOTE (Open the left cover of the RDH.))
					 NIL
					 (QUOTE RDHLeftCover)))
          (closeLeftCover←(CreatePlanStep (QUOTE (Remove any originals and close the cover.))
					  (QUOTE (replace LeftChecked of JobState with T))
					  <(CreateWff (QUOTE (~ RDHLeftCover)))
					    LeftChecked >
					  openLeftCover))
          (openRightCover←(CreatePlanStep (QUOTE (Open the right cover of the RDH.))
					  NIL
					  (QUOTE RDHRightCover)))
          (closeRightCover←(CreatePlanStep (QUOTE (Squeeze the yellow latch to open the area. Remove 
							   any originals, then close the latch and 
							   the cover.))
					   (QUOTE (replace RightChecked of JobState with T))
					   <(CreateWff (QUOTE (~ RDHRightCover)))
					     RightChecked >
					   openRightCover))
          (unloadRdh←(PlanUnloadRdh))
          (openRdh←(CreatePlanStep < !(CreateUserInstruction '(Pull the BDA latch forward.)
							     '(to release the RDH))
				     '(Raise the RDH.) >
				   NIL
				   (QUOTE RDHOpen)
				   unloadRdh))
          (clearGlass←(CreatePlanStep < '(Remove any originals.) '(Squeeze the hellow tabs to open 
									   the baffle.)
					'(Close the baffle firmly to reseat the pin ends.) '(Close
					  the RDH.)
					>
				      (QUOTE (replace GlassChecked of JobState with T))
				      <(CreateWff (QUOTE (~ RDHOpen)))
					GlassChecked >
				      openRdh))
          (goalStep←(CreatePlanStep NIL NIL NIL closeRightCover))
          (RETURN (create Plan
			  steps ←(<closeLeftCover closeRightCover goalStep>)
			  goal ← goalStep:kernel
			  summary ←(create Paragraph
					   text ←(QUOTE (Your job has stopped because of a misfeed in 
							      the RDH. I will give you instructions 
							      for returning to the Ready state.)))
			  initialState ← '(LeftChecked RightChecked GlassChecked])

(PlanClearA12
  [LAMBDA (job)                                              (* edited: " 6-FEB-83 22:04")
                                                             (* Planner for clearing an A12 status code.)
    (PROG (closeLeftCover closeRightCover goalStep)
          [closeLeftCover←(CreatePlanStep (QUOTE (Close the left RDH cover.))
					  NIL
					  (CreateWff (QUOTE (~ RDHLeftCover]
          (closeRightCover←(CreatePlanStep (QUOTE (Close the right RDH cover.))
					   NIL
					   [CreateWff (QUOTE (= State (QUOTE Ready]
					   closeLeftCover))
          (goalStep←(CreatePlanStep NIL NIL NIL closeRightCover))
          (RETURN (create Plan
			  steps ←(<closeLeftCover closeRightCover goalStep>)
			  goal ← goalStep:kernel
			  summary ←(create Paragraph
					   text ←(QUOTE (Your job has stopped because the RDH covers 
							      are open. I will give you instructions 
							      for returning to the Ready state.])

(PlanCopyJob
  [LAMBDA (job originalsReversedFlg)                         (* edited: " 8-MAR-83 16:11")

          (* Produce a plan to do the given copy job. If originalsReversedFlg is set, then assume the pages of the original 
	  are reversed at the beginning of the plan. NIL)


    (PROG ((gen (SelectPlanGenerator (DeriveValuesForGenerators job):1)))
          (RETURN (if gen
		      then (APPLY* gen:generator job originalsReversedFlg])

(PlanLoadRDH
  [LAMBDA (faceDownFlg lastPageOnTopFlg)                     (* edited: "13-MAR-83 23:00")

          (* Create a plan step that tells the user to load his originals into the RDH. The step asserts DocumentInRDH.
	  The flags affect the wording of the instruction indicating the desired orientation of the original.)


    (CreatePlanStep (CreateUserInstruction (BQUOTE (Place all of your originals in the RDH, face ,
							  (COND
							    (faceDownFlg (QUOTE down,))
							    (T (QUOTE up,)))
							  ,
							  (COND
							    (lastPageOnTopFlg (QUOTE last))
							    (T (QUOTE first)))
							  page on top.))
					   (QUOTE (so that the RDH can automatically feed each sheet 
						      into the copier)))
		    NIL
		    (CreateKernelEntry (QUOTE DocumentInRDH)
				       (QUOTE (The document to be copied is in the RDH.)))
		    NIL
		    (QUOTE (Loading the RDH,))
		    (QUOTE (RDH])

(PlanLoadTopPaperTray
  [LAMBDA (kernelEntries)                                    (* edited: " 4-MAR-83 14:47")

          (* Create a plan step that tells the user to load his paper into the top paper tray. The step asserts that 
	  AddPaper is off.)


    (CreatePlanStep (QUOTE (Place the paper on which the copies are to be made in the top paper tray.)
			   )
		    NIL
		    (CreateKernelEntry [CreateWff (QUOTE (= AddPaper (QUOTE off]
				       (QUOTE (The paper on which the copies are to be made is in the 
						   top paper tray.)))
		    kernelEntries
		    (QUOTE (Loading the top paper tray,))
		    '(TopPaperTray])

(PlanMakeReady
  [LAMBDA (job)                                              (* edited: " 6-FEB-83 21:21")
                                                             (* Create a plan step that calls MakeReady and asserts 
							     the ready state.)
    (CreatePlanStep NIL <(QUOTE MakeReady)
			  (KWOTE job) > <[CreateWff (QUOTE (= State (QUOTE Ready] > NIL
		    (QUOTE (Returning the 8200 to the Ready State,])

(PlanPanel
  [LAMBDA (Collate CopyBrightness CopiesOnStandardPaper NumberOfCopies Reduction Staple 
		   TwoSidedCopies TwoSidedOriginals)         (* edited: "11-MAR-83 14:24")
                                                             (* Create a plan step to select the panel features 
							     corresponding to the given parameters.)
    (PROG [(collateStaple (if Collate=(QUOTE Yes)
			      then (if Staple=(QUOTE Yes)
				       then (QUOTE CollatedStapled)
				     else (QUOTE CollatedUnstapled))
			    elseif Staple=(QUOTE Yes)
			      then (SHOULDNT)
			    else (QUOTE Uncollated)))
	   (brightness (if CopyBrightness=(QUOTE normal)
			   then (QUOTE Normal)
			 elseif (STREQUAL CopyBrightness "darker than normal")
			   then (QUOTE Darker)
			 else (QUOTE Lighter)))
	   (paperTray (if CopiesOnStandardPaper=(QUOTE Yes)
			  then (QUOTE Bottom)
			else (QUOTE Top)))
	   (reduce (if Reduction=(QUOTE No) or ~Reduction or Reduction=(QUOTE FullSize)
		       then (QUOTE FullSize)
		     elseif (STREQUAL Reduction "35%% smaller")
		       then 65
		     elseif (STREQUAL Reduction "26%% smaller")
		       then 74
		     else 98))
	   (sidedness (if TwoSidedCopies=(QUOTE Yes)
			  then (if TwoSidedOriginals=(QUOTE Yes)
				   then (QUOTE TwoSidedOriginalsAndCopies)
				 else (QUOTE TwoSidedCopies))
			elseif TwoSidedOriginals=(QUOTE Yes)
			  then (SHOULDNT)
			else (QUOTE OneSidedCopies]
          (RETURN (CreatePlanStep (QUOTE (Please wait while the 8200 control panel is set.))
				  (BQUOTE (PROGN ,@ [for f in (LIST collateStaple brightness 
								    paperTray reduce sidedness)
						       collect (BQUOTE (Select8200Feature
									 ,
									 (KWOTE f]
						 (DoSelectNumberOfCopiesStep , NumberOfCopies)))
				  <[CreateWff (BQUOTE (= Output , (KWOTE collateStaple]
				    [CreateWff (BQUOTE (= Copy , (KWOTE brightness]
				    [CreateWff (BQUOTE (= PaperTray , (KWOTE paperTray]
				    (CreateWff (BQUOTE (= numberOfCopiesSelected , NumberOfCopies)))
				    [CreateWff (BQUOTE (= Reduction , (KWOTE reduce]
				    [CreateWff (BQUOTE (= CopyMode , (KWOTE sidedness] >
				  NIL
				  (QUOTE (Setting the 8200 control panel,])

(PlanPaperTray
  [LAMBDA (CopiesOnStandardPaper kernelEntries)              (* ref: "11-JAN-83 09:42")
                                                             (* Create a plan step to select a paper tray setting.)
    (PROG [(paperTray (if CopiesOnStandardPaper=(QUOTE Yes)
			  then (QUOTE Bottom)
			else (QUOTE Top]
          (RETURN (CreatePlanStep (CreateComment (QUOTE (The standard %(bottom%) paper tray is being 
							     reselected.)))
				  <(QUOTE Select8200Feature)
				    (KWOTE paperTray) >
				  [CreateWff (BQUOTE (= PaperTray , (KWOTE paperTray]
				  kernelEntries
				  (QUOTE (Reselecting the bottom paper tray.])

(PlanPushStart
  [LAMBDA (NumberOfCopies kernelEntries)                     (* edited: "15-MAR-83 17:42")

          (* Create a plan step with the given kernel entries to tell the user to push the start button.
	  Assert the printing state. Each item on kernelEntries is either a kernel entry or a plan step, in which case all 
	  of the plan step's assertions are used.)


    (CreatePlanStep (CreateUserInstruction (QUOTE (Press the Start button.))
					   (BQUOTE (to produce ,@ [COND
							 ((EQ NumberOfCopies 1)
							   (QUOTE (a copy)))
							 (T (LIST NumberOfCopies (QUOTE copies]
						       in the output tray)))
		    (QUOTE (PROGN (WINDOWPROP StatusWindow (QUOTE PlanSummary)
					      NIL)
				  (DisplayStartButton)))
		    [CreateWff (QUOTE (= State (QUOTE Printing]
		    kernelEntries
		    (QUOTE (Starting the copier,])

(PlanSidedness
  [LAMBDA (TwoSidedCopies TwoSidedOriginals)                 (* ref: "22-SEP-82 15:44")
                                                             (* Create a plan step to select a sidedness for the 
							     originals and copies.)
    (PROG (step (sidedness (if TwoSidedCopies='Yes
			       then (if TwoSidedOriginals='Yes
					then 'TwoSidedOriginalsAndCopies
				      else 'TwoSidedCopies)
			     elseif TwoSidedOriginals='Yes
			       then (SHOULDNT)
			     else 'OneSidedCopies)))
          (step←(CreatePlanStep <'Select8200Feature (KWOTE sidedness)
				  >))
          (step:assertions← <(create KernelEntry
				     wff ←(CreateWff <'= 'CopyMode (KWOTE sidedness)
						       >)
				     producer ← step)
			      >)
          (RETURN step])

(PlanStatusCodeMessage
  [LAMBDA (code)                                             (* edited: "13-MAR-83 22:48")
                                                             (* Create a one step plan that asks the user to clear 
							     the status code.)
    (PROG [instructionStep goalStep (msg (OR (GETP JobState:OpStatusCode (QUOTE Message))
					     (BQUOTE (of an , code error.]
          [instructionStep←(CreatePlanStep (CreateUserInstruction (BQUOTE (Your job has stopped 
										because ,@ msg)))
					   NIL
					   (CreateWff (QUOTE (= State (QUOTE Ready]
          (goalStep←(CreatePlanStep NIL NIL NIL instructionStep))
          (RETURN (create Plan
			  steps ←(<instructionStep goalStep>)
			  goal ← goalStep:kernel])

(PlanThankYou
  [LAMBDA (kernelEntries)                                    (* ref: " 6-JAN-83 11:35")
                                                             (* Create a plan step informing the user that the task 
							     is completed.)
    (CreatePlanStep (QUOTE (Thank you. Your job is completed.))
		    ('(DISMISS 5000))
		    NIL kernelEntries ('(Completing the copy job.])

(PlanTooThick
  [LAMBDA (Collate CopyBrightness CopiesOnStandardPaper NumberOfCopies Reduction Staple 
		   TwoSidedCopies TwoSidedOriginals)         (* ref: " 5-MAY-82 15:03")
                                                             (* Create a plan for making copies from originals too 
							     thick for the RDH, but otherwise RDHAble.)
    <(CONCAT "User Step:  Divide the original into sections, where each section "
	     (if TwoSidedCopies and ~TwoSidedOriginals
		 then "has an even number of pages not more than 50."
	       else "has not more than 50 pages."))
    <"For each section:" < !(PlanCopyJob Collate CopyBrightness CopiesOnStandardPaper 'RDH 
					 NumberOfCopies NIL Reduction NIL TwoSidedCopies 
					 TwoSidedOriginals)
			   

"User Step:  Remove the copies from the output tray and append them to the copies of the earlier sections."
			   >>>])

(PlanUnloadOutputTray
  [LAMBDA (NumberOfCopies kernelEntries)                     (* edited: " 4-MAR-83 14:51")
                                                             (* Crete a plan step telling the user to unload the 
							     output tray. The step asserts ~OffsettingCatchTray.)
    (CreatePlanStep (BQUOTE (Remove the , (COND
				      ((EQ NumberOfCopies 1)
					(QUOTE copy))
				      (T (QUOTE copies)))
				    from the output tray.))
		    NIL
		    (CreateWff (QUOTE (~ OffsettingCatchTray)))
		    kernelEntries
		    (QUOTE (Unloading the output tray.))
		    (QUOTE (OutputTray])

(PlanUnloadRdh
  [LAMBDA (kernelEntries)                                    (* edited: "13-MAR-83 22:48")
                                                             (* Crete a plan step that tells the user to unload the 
							     RDH. The step asserts ~DocumentInRDH.)
    (CreatePlanStep (QUOTE (Remove the originals from the RDH.))
		    NIL
		    (CreateWff (QUOTE (~ DocumentInRDH)))
		    kernelEntries
		    (QUOTE (Unloading the RDH.])

(PlanUnloadTopPaperTray
  [LAMBDA (kernelEntries)                                    (* edited: "13-MAR-83 22:48")
                                                             (* Create a plan step that tells the user to unload his 
							     paper from the top paper tray.
							     The step asserts AddPaper on.)
    (CreatePlanStep (QUOTE (Remove your paper from the top paper tray.))
		    NIL
		    [CreateWff (QUOTE (= AddPaper (QUOTE on]
		    kernelEntries
		    ('(Unloading the top paper tray,])

(PrintPlan
  [LAMBDA (plan)                                             (* ref: "27-JUL-82 14:42")
                                                             (* Print a plan, one step per line.)
    (for step in plan do (if (LISTP step)
			     then (PrintPlanStep step:1)
				  (TERPRI)
				  (for substep in step:2 do (SPACES 5)
							    (PrintPlanStep substep)
							    (TERPRI))
			   else (PrintPlanStep step)
				(TERPRI])
)

(RPAQQ PLANNERRECORDS (Kernel KernelEntry Plan PlanStep))
[DECLARE: EVAL@COMPILE 

(DATATYPE Kernel (entries step))

(DATATYPE KernelEntry (wff producer assumption))

(DATATYPE Plan (steps kernels goal summary                   (* A paragraph or text list giving the user a summary of
							     the plan.)
		      initialState                           (* A list in the form of the second element of a PROG 
							     indicating JobState field names and initial values for 
							     those fields.)
		      ))

(DATATYPE PlanStep (action                                   (* An s-expression to be evaled.)
			   instructions                      (* A list of paragraphs to be printed in the instruction
							     window.)
			   kernel assertions goal            (* A list of atoms representing text for a paragraph.)
			   help                              (* A list of paragraphs or text lists to respond to the 
							     user's request for help about this step.)
			   keywords                          (* Keywords that index into the help graph.)
			   ))
]
(/DECLAREDATATYPE (QUOTE Kernel)
		  (QUOTE (POINTER POINTER)))
(/DECLAREDATATYPE (QUOTE KernelEntry)
		  (QUOTE (POINTER POINTER POINTER)))
(/DECLAREDATATYPE (QUOTE Plan)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER)))
(/DECLAREDATATYPE (QUOTE PlanStep)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER)))

(RPAQQ PLANNERADVICE (EXPANDBQUOTE))

(PUTPROPS EXPANDBQUOTE READVICE (NIL (AROUND NIL (DWIMIFY * T))))
(READVISE EXPANDBQUOTE)
(DECLARE: EVAL@COMPILE 
(LOADCOMP? 'LOADBLUEBONNET)
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (904 45233 (CreateComment 914 . 1303) (CreateKernelEntry 1305 . 1833) (CreatePlanStep 
1835 . 4285) (CreateUserInstruction 4287 . 4972) (Plan1To1 4974 . 9098) (Plan1To2 9100 . 16568) (
Plan2To1NoMaster 16570 . 17826) (Plan2To1WithMaster 17828 . 18435) (Plan2To2 18437 . 19671) (
PlanBdaNoMaster 19673 . 27525) (PlanBdaWithMaster 27527 . 30545) (PlanClearA10 30547 . 32750) (
PlanClearA12 32752 . 33737) (PlanCopyJob 33739 . 34207) (PlanLoadRDH 34209 . 35156) (
PlanLoadTopPaperTray 35158 . 35826) (PlanMakeReady 35828 . 36265) (PlanPanel 36267 . 38607) (
PlanPaperTray 38609 . 39287) (PlanPushStart 39289 . 40163) (PlanSidedness 40165 . 40996) (
PlanStatusCodeMessage 40998 . 41777) (PlanThankYou 41779 . 42190) (PlanTooThick 42192 . 43106) (
PlanUnloadOutputTray 43108 . 43731) (PlanUnloadRdh 43733 . 44200) (PlanUnloadTopPaperTray 44202 . 
44735) (PrintPlan 44737 . 45231)))))
STOP