(FILECREATED " 4-NOV-83 14:52:13" {PHYLUM}<BLUEBONNET>DMRUSSELL>PLANNER.;2 47495  

      changes to:  (FNS CreateKernelEntry CreatePlanStep CreateUserInstruction Plan1To1 PlanPanel 
			PlanThankYou)

      previous date: "20-SEP-83 21:57:17" {PHYLUM}<BLUEBONNET>DMRUSSELL>PLANNER.;1)


(PRETTYCOMPRINT PLANNERCOMS)

(RPAQQ PLANNERCOMS [(FNS * PLANNERFNS)
		    (RECORDS * PLANNERRECORDS)
		    (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 ← [AND assumption (COND
				((type? Paragraph assumption)
				  assumption)
				(T (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 ← [COND
			   (instructions (for inst in (COND
							([AND (LISTP instructions)
							      (NOT (ATOM (CAR instructions]
							  instructions)
							(T (LIST instructions)))
					    collect (COND
						      ((type? Paragraph inst)
							inst)
						      (T (create Paragraph
								 text ← inst]
			 goal ← goal
			 keywords ← keywordList
			 help ← (COND
			   (help (for h in (COND
					     ([AND (LISTP help)
						   (NOT (ATOM (CAR help]
					       help)
					     (T (LIST help)))
				    collect (COND
					      ((type? Paragraph h)
						h)
					      (T (create Paragraph
							 text ← h]
          (replace step of (fetch kernel of step) with step)
          [replace assertions of step
	     with (COND
		    (assertions (for assert in (OR (LISTP assertions)
						   (LIST assertions))
				   collect (COND
					     ((type? KernelEntry assert)
					       (replace producer of assert with step)
					       assert)
					     (T (create KernelEntry
							wff ← assert
							producer ← step]
          [replace entries of (fetch kernel of step)
	     with (COND
		    (kernelEntries (for ke in (OR (LISTP kernelEntries)
						  (LIST kernelEntries))
				      join (COND
					     ((type? KernelEntry ke)
					       (LIST ke))
					     (T (APPEND (fetch assertions of ke]
          (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.)


    (APPEND [COND
	      (instruction (LIST (create Paragraph
					 text ← instruction
					 lookY ← lookY]
	    (COND
	      (goal (LIST (create Paragraph
				  leftMargin ← 5
				  text ← (CONS (PACK* '%( (CAR goal))
					       (APPEND (for x on (CDR goal) while (CDR x)
							  collect (CAR x))
						       (LIST (PACK* (CAR (LAST goal))
								    '%)])

(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")
          (SETQ makeReady (PlanMakeReady job))               (* Step S1b-g: "Do Select panel features")
          (SETQ setPanel (PlanPanel (fetch Collate of job)
				    (fetch CopyBrightness of job)
				    (fetch CopiesOnStandardPaper of job)
				    (fetch NumberOfCopies of job)
				    (fetch (CopyJob Reduction) of job)
				    (fetch Staple of job)))
          [COND
	    ((EQ (fetch CopiesOnStandardPaper of job)
		 'No)                                        (* Step S1g.1: "TellUser Load paper tray.")
	      (SETQ loadTopPaperTray (PlanLoadTopPaperTray]
                                                             (* Step S1h: "TellUser Load RDH.")
          (SETQ loadRDH (PlanLoadRDH))                       (* Step S2: "TellUser Press Start.")
          [SETQ pushStart (PlanPushStart (fetch NumberOfCopies of job)
					 (CONS setPanel (APPEND (COND
								  ((EQ (fetch CopiesOnStandardPaper
									  of job)
								       'No)
								    (LIST loadTopPaperTray)))
								(LIST loadRDH makeReady]
                                                             (* Step S3: "Do CompletePrinting")
          [SETQ completePrinting
	    (CreatePlanStep [CreateComment
			      (BQUOTE (Your ,@ [COND
					      ((EQ (fetch NumberOfCopies of job)
						   1)
						'(copy is))
					      (T '(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)
						      '(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)
									    'Yes)
									 '(stapled and]
								     put into the output tray. Each 
								     copy is made in the same manner.]
			    '(CompletePrintingStep)
			    (CreateKernelEntry 'CopiesMade '(The copies have been made.))
			    pushStart
			    '(Copying the originals,)
			    '(OutputTray]
          (COND
	    ((EQ (fetch CopiesOnStandardPaper of job)
		 'No)                                        (* Step S4: "TellUser Remove paper.")
	      (SETQ unloadTopPaperTray (PlanUnloadTopPaperTray))
                                                             (* Step S5: "Do Select BottomPaperTray")
	      (SETQ selectBottomTray (PlanPaperTray 'Yes (LIST unloadTopPaperTray)))
	      (push steps loadTopPaperTray unloadTopPaperTray selectBottomTray)))
                                                             (* Step S6a: "Tell User Unload RDH")
          (SETQ unloadRdh (PlanUnloadRdh))                   (* Step S6b: "Tell User Unload output")
          (SETQ unloadOutputTray (PlanUnloadOutputTray))     (* Step S7: "Tell User Thank You")
          [SETQ thankUser (PlanThankYou (CONS completePrinting
					      (APPEND (COND
							((EQ (fetch CopiesOnStandardPaper
								of job)
							     'No)
							  (LIST selectBottomTray)))
						      (LIST 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)
						   'copy.)
						 (T 'copies.]
			  initialState ← '(CopiesMade])

(Plan1To2
  [LAMBDA (job originalsReversedFlg)                         (* edited: "15-MAR-83 17:45")

          (* 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 even numbered pages of your 
									 original are being copied. 
									 Each page 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 odd numbered pages of your 
									 original are being copied. 
									 Each page 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: "14-MAR-83 12:51")
                                                             (* 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 Bound Document Aid.))
					(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))
	      (QUOTE (The copier is waiting for the document cover to be closed. If you think you 
			  have followed the current instructions, check to see if the cover is 
			  latched. If you cannot find the document cover, you may have pulled the 
			  "Document Glass"
			  latch rather than the "Bound Document Aid" latch when you opened the RDH. 
			  Try closing the RDH and reopening it, making sure you are pulling the latch 
			  labelled "Bound Document Aid"]     (* 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 
							    Bound Document Aid %(BDA%) to make your ,
							    (COND
							      ((EQ (fetch NumberOfCopies
								      of job)
								   1)
								(QUOTE copy.))
							      (T (QUOTE copies.]
			  initialState ←(QUOTE (FirstPageCopied CopiesMade])

(PlanBdaWithMaster
  [LAMBDA (job)                                              (* edited: " 8-MAR-83 16:08")
                                                             (* 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 use the Bound Document Aid %(BDA%) to 
						    make an unbound copy of your original. That copy 
						    can then be put in the Recirculating Document 
						    Handler %(RDH%) to make your ,@
						    [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 (COND
			    [(EQ Collate 'Yes)
			      (COND
				((EQ Staple 'Yes)
				  'CollatedStapled)
				(T 'CollatedUnstapled]
			    ((EQ Staple 'Yes)
			      (SHOULDNT))
			    (T 'Uncollated]
	   [brightness (COND
			 ((EQ CopyBrightness 'normal)
			   'Normal)
			 ((STREQUAL CopyBrightness "darker than normal")
			   'Darker)
			 (T 'Lighter]
	   [paperTray (COND
			((EQ CopiesOnStandardPaper 'Yes)
			  'Bottom)
			(T 'Top]
	   (reduce (COND
		     ((OR (EQ Reduction 'No)
			  (NOT Reduction)
			  (EQ Reduction 'FullSize))
		       'FullSize)
		     ((STREQUAL Reduction "35%% smaller")
		       65)
		     ((STREQUAL Reduction "26%% smaller")
		       74)
		     (T 98)))
	   (sidedness (COND
			[(EQ TwoSidedCopies 'Yes)
			  (COND
			    ((EQ TwoSidedOriginals 'Yes)
			      'TwoSidedOriginalsAndCopies)
			    (T 'TwoSidedCopies]
			((EQ TwoSidedOriginals 'Yes)
			  (SHOULDNT))
			(T 'OneSidedCopies]
          (RETURN (CreatePlanStep '(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)))
				  [LIST [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
				  '(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)                                    (* JG " 4-NOV-83 14:33")
                                                             (* Create a plan step informing the user that the task 
							     is completed.)
    (CreatePlanStep '(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 'Kernel '(POINTER POINTER))
(/DECLAREDATATYPE 'KernelEntry '(POINTER POINTER POINTER))
(/DECLAREDATATYPE 'Plan '(POINTER POINTER POINTER POINTER POINTER))
(/DECLAREDATATYPE 'PlanStep '(POINTER POINTER POINTER POINTER POINTER POINTER POINTER))
(DECLARE: EVAL@COMPILE 
(LOADCOMP? 'LOADBLUEBONNET)
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (941 46016 (CreateComment 951 . 1340) (CreateKernelEntry 1342 . 1847) (CreatePlanStep 
1849 . 4445) (CreateUserInstruction 4447 . 5197) (Plan1To1 5199 . 9589) (Plan1To2 9591 . 17053) (
Plan2To1NoMaster 17055 . 18311) (Plan2To1WithMaster 18313 . 18920) (Plan2To2 18922 . 20156) (
PlanBdaNoMaster 20158 . 28529) (PlanBdaWithMaster 28531 . 31621) (PlanClearA10 31623 . 33826) (
PlanClearA12 33828 . 34813) (PlanCopyJob 34815 . 35283) (PlanLoadRDH 35285 . 36232) (
PlanLoadTopPaperTray 36234 . 36902) (PlanMakeReady 36904 . 37341) (PlanPanel 37343 . 39402) (
PlanPaperTray 39404 . 40082) (PlanPushStart 40084 . 40958) (PlanSidedness 40960 . 41791) (
PlanStatusCodeMessage 41793 . 42572) (PlanThankYou 42574 . 42973) (PlanTooThick 42975 . 43889) (
PlanUnloadOutputTray 43891 . 44514) (PlanUnloadRdh 44516 . 44983) (PlanUnloadTopPaperTray 44985 . 
45518) (PrintPlan 45520 . 46014)))))
STOP