📄 stove.clp
字号:
"the elements and plug the stove back in. Turn the element" crlf
"to high. Does the bad element appear to be working while" crlf
"the good element is not? y or n ")
(retract ?x)
(assert (switch bad =(read))))
;****************************
;rule28
; rule to handle if a bad switch exists
;****************************
(defrule bad-switch
?x <- (switch bad y)
=>
(printout t crlf crlf
"Replace the switch of the nonworking element and hook the" crlf
"wires back to there original places. Afterward retest the" crlf
"element. If there is still a problem rerun this program." crlf)
(retract ?x)
(assert (stop)))
;*****************************
;rule29:
; rule to handle if the switch is not bad
;*****************************
(defrule good-switch
?x <- (switch bad n)
=>
(printout t crlf crlf
"You have a bad wire somewhere between the switch and the " crlf
"nonworking element. You must trace the wire to the problem" crlf
"and replace the bad area. Afterward recheck the burner. If" crlf
"there is still a problem rerun this program." crlf)
(retract ?x)
(assert (stop)))
;****************************
;rule30
; gives first step to perform if there is a electric
; oven problem
;****************************
(defrule oven-ck
(oven type 1)
(oven problem y) =>
(printout t crlf crlf
"Turn on the oven to 400 degrees and determine which of the oven" crlf
"elements are not working. Turn off the stove and let cool." crlf
"Unplug the stove and remove the stove holding the nonworking" crlf
"element in place. Pull the element toward you. The element" crlf
"will be held by power wires with connectors or screws." crlf
"Remove the wires and remove the element. Test the element" crlf
"with a ohmmeter by placing a probe on each terminal." crlf
"Does the meter register 0 resistance? y or n ")
(assert (bad oven element =(read))))
;****************************
;rule31:
; handles if a bad oven element exists
;****************************
(defrule bad-oven-element
?x <- (bad oven element y) =>
(printout t crlf crlf
"The oven element is bad and must be replaced. Replace the" crlf
"element and retry the oven. If there is still a problem" crlf
"rerun this program." crlf)
(retract ?x)
(assert (stop)))
;****************************
;rule32
; handles if the oven element is good
;****************************
(defrule good-oven-element
(declare (salience 100))
(bad oven element n) =>
(printout t crlf crlf
"Look for a wiring diagram for the oven selector switch pasted" crlf
"on the inner side of the back panel or in the owners manual." crlf
"If there is no wiring diagram use the one in the manual for" crlf
"this program. Using the chart, test the switch with a " crlf
"ohmmeter. Unplug the oven. Open the control panel to reach the" crlf
"contacts of the switch. Label the wires and disconnect the wires" crlf
"from the switch. Label the wires and disconnect the wires from "crlf
"the switch."crlf
"Hold leads to terminals L1 and BK." crlf
"Is there 0 resistance? y or n ")
(assert (switch failed =(read))))
;****************************
;rule33:
; rule to check the oven switch
;****************************
(defrule ck-switch1
(bad oven element n)
(switch failed ~y)
=>
(printout t crlf crlf
"Hold leads to terminals PL and N." crlf
"Is there 0 resistance? y or n ")
(assert (switch failed =(read))))
;****************************
;rule34:
; rule to check the oven switch
;****************************
(defrule ck-switch2
(declare (salience -10))
(bad oven element n)
(switch failed ~y)
=>
(printout t crlf crlf
"Hold leads to terminals PL and BR." crlf
"Is there 0 resistance? y or n ")
(assert (switch failed =(read))))
;***************************
;rule35:
; rule to check the oven broiler switch
;***************************
(defrule ck-switch3
(declare (salience -100))
(bad oven element n)
(switch failed ~y)
=>
(printout t crlf crlf
"To test the broiler:" crlf
"Hold leads to terminals L1 and BR." crlf
"Is there 0 resistance? y or n ")
(assert (switch failed =(read))))
;*****************************
;rule36:
; rule to check the oven broiler switch
;*****************************
(defrule ck-switch4
(declare (salience -150))
(bad oven element n)
(switch failed ~y)
=>
(printout t crlf crlf
"Hold leads to L1 and PL." crlf
"Is there 0 resistance? y or n ")
(assert (switch failed =(read))))
;****************************
;rule37:
; rule for if there is a bad oven switch
;****************************
(defrule switch-failed
(declare (salience 10))
?x <- (switch failed y)
=>
(printout t crlf crlf
"You must replace the switch. Afterward, hook the wires back" crlf
"to the original state and retest the oven. If there is " crlf
"still a problem rerun this program." crlf)
(retract ?x)
(assert (stop)))
;****************************
;rule38:
; rule to see if the clock is set
;****************************
(defrule test-clock
(declare (salience 200))
(bad oven element n) =>
(printout t crlf crlf
"Check the clock timer. Is it set to AUTOMATIC? y or n ")
(assert (clock on =(read))))
;*****************************
;rule39:
; rule if clock is set
;*****************************
(defrule clock-set
(declare (salience 200))
?x <- (clock on y)
=>
(printout t crlf crlf
"The oven won't work until the time set on the clock is" crlf
"reached. Set the switch to manual and retest the oven." crlf
"If there is still a problem, rerun this program." crlf)
(retract ?x)
(assert (stop)))
;****************************
;rule40:
; rule to test the temperature control switch
;****************************
(defrule temp-control
(declare (salience -100))
(oven type 1)
(oven problem y) =>
(printout t crlf crlf
"Now we will chwck the oven temperature control switch. See" crlf
"if there is a wiring diagram pasted on the oven or in the" crlf
"owners manual for the temperature control switch. If not,"crlf
"use the one in the manual for this program. Unplug the stove."crlf
"remove the screws and open the control panel. Label the wires" crlf
"Turn the switch to 300 degrees. Using a ohmmeter, place the " crlf
"leads on contacts 1 and 2 and turn the switch to broil." crlf
"Is there 0 resistance? y or n ")
(assert (temp switch good =(read))))
;****************************
;rule41:
; rule to test temperature control switch
;****************************
(defrule temp-control2
(temp switch good ~n) =>
(printout t crlf crlf
"Hold leads to terminals 1 and 3 and turn the control switch" crlf
"to bake." crlf
"Is there 0 resistance? y or n ")
(assert (temp switch good =(read))))
;****************************
;rule42:
; rule to test temperature control switch
;****************************
(defrule tenp-control3
?x <- (temp switch good n) =>
(printout t crlf crlf
"You will have to replace the switch. Afterward, hook the wires" crlf
"back up to the original state plug it back in and test the oven." crlf
"If there is still a problem, rerun this program.")
(retract ?x)
(assert (stop)))
;*********************************
;* gas stove rules start here ****
;*********************************
;****************************
;rule43:
; first rule if there is a gas stove
;****************************
(defrule gas-stove
(declare (salience 100))
(oven type 2)
(burner problem y) =>
(printout t crlf crlf
"Do you have " crlf
" 1) gas fed igniters" crlf
" 2) spark igniters" crlf crlf
"Choose 1 or 2 ")
(assert (igniter type =(read))))
;****************************
;rule44:
; rule to handle if the igniter is gas fed
;****************************
(defrule gas-fed
(declare (salience 100))
?x <- (igniter type 1) =>
(printout t crlf crlf
"Turn off the gas while replacing any part" crlf)
(retract ?x))
;***************************
;rule45:
; rule to handle if the igniter is electric
;***************************
(defrule igniter-type
(declare (salience 100))
?x <- (igniter type 2) =>
(printout t crlf crlf
"Unplug the stove while replacing any part" crlf)
(retract ?x))
;***************************
;rule46:
; checks the gas burners
;***************************
(defrule gas-burners
(oven type 2)
(burner problem y) =>
(printout t crlf crlf
"Each pair of burners uses a common igniter. Is one burner" crlf
"out while the other burner that uses the same igniter, still" crlf
"working? y or n ")
(assert (gas switch bad =(read))))
;****************************
;rule47:
; rule to handle if a bad igniter
;****************************
(defrule bad-igniter
?x <- (gas switch bad y)
?y <- (burner problem ?)
=>
(printout t crlf crlf
"Replace the control switch of the nonworking burner as" crlf
"water has probably dripped into it causing a short." crlf
"Replace and recheck the burner. If there is still a problem" crlf
"then rerun this program.")
(retract ?x ?y)
(assert (stop)))
;****************************
;rule48:
; rule to check the igniter
;****************************
(defrule ck-igniter
(declare (salience -100))
(oven type 2)
?x <- (burner problem y)
=>
(printout t crlf crlf
"If both burners, sharing the same igniter are not working then" crlf
"unplug the stove. At the module, disconnect and reverse the" crlf
"wires to the 2 electrodes. Restore electricity and retry all" crlf
"burners. If the problem was the right side burners and now" crlf
"the left side do not work, or visa versa, the replace the " crlf
"electrode on the problem side. Before pulling the electrode/" crlf
"wiring assembly out of the range, cut off the old electrode" crlf
"tape the ends of the new wires to the old wires and fish the" crlf
"old wires out of the range while fishing the new wires in." crlf
"If there is still a problem, rerun this program." crlf)
(retract ?x)
(assert (stop)))
;****************************
;rule49:
; rule to check the oven igniter
;****************************
(defrule gas-oven
(oven type 2)
(oven problem y) =>
(printout t crlf crlf
"Turn on the oven and look inside." crlf
"Does the carbordium igniter glow? y or n ")
(assert (oven igniter good =(read))))
;*****************************
;rule50:
; rule for if there is a bad oven igniter
;*****************************
(defrule bad-oven-igniter
?x <- (oven igniter good n) =>
(printout t crlf crlf
"Replace the oven igniter coil." crlf crlf
"** CAUTION - do not touch the coil during installation as" crlf
" oil from your fingers will ruin it ***" crlf crlf
"Afterward, if there is still a problem rerun this program. " crlf)
(retract ?x)
(assert (stop)))
;****************************
;rule51:
; rule for if the oven igniter is good
;****************************
(defrule good-oven-igniter
(oven igniter good y) =>
(printout t crlf crlf
"Do you have a gas fed pilot igniter? y or n ")
(assert (gas fed igniter =(read))))
;****************************
;rule52:
; rule for if there is a gas fed igniter
;****************************
(defrule gas-fed-igniter
?x <- (gas fed igniter y) =>
(printout t crlf crlf
"A spill over might have clogged the orfice. Unscrew the jet" crlf
"and clean it and replace it. Spread a detergent soap and water" crlf
"solution around the base of the jet and turn the gas back on." crlf
"If bubbles begin to form at the base, retighten the jet and " crlf
"recheck. If bubbles persist, turn off the gas, remove the jet," crlf
"and spread a pipe-joint compound around the threads and " crlf
"reinstall the jet. Check for a leak again." crlf
"Do bubbles continue to form? y or n ")
(retract ?x )
(assert (bubbles =(read))))
;****************************
;rule53:
; rule for checking for gas leaks during cleaning of
; the orffice
;****************************
(defrule bubbles
?x <- (bubbles y)
?y <- (need professional ?) =>
(retract ?x ?y)
(assert (need professional y)))
;****************************
;rule54:
; rule for if there are no bubbles (leak check)
;****************************
(defrule no-bubbles
?x <- (bubbles n) =>
(printout t crlf crlf
"Recheck the oven. If there is still a problem rerun this program." crlf)
(retract ?x)
(assert (stop)))
;****************************
;rule55:
; handles if the problem is best suited for a
; professional
;****************************
(defrule no-gas-fed-pilot
(gas fed igniter n)
?x <- (need professional ?) =>
(printout t crlf crlf
"The problem would best be left to a professional as there is" crlf
"a danger working with the remaining gas parts.")
(retract ?x)
(assert (need professional y)))
;****************************
;rule56:
; this rule handles if the user wants to exit the
; program
;****************************
(defrule quit
(declare (salience 9700))
(oven type 3)
=>
(printout t crlf crlf crlf crlf
"Exiting the program " crlf crlf)
(assert (stop))
(assert (quit)))
;****************************
;rule57:
; rule to handle when user quits system
;****************************
(defrule finished
(declare (salience 9990))
?w <- (quit)
=>
(retract ?w)
(halt))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -