|
109 | 109 | (if (pb-has-field ?p "instruction_ss") |
110 | 110 | then |
111 | 111 | (bind ?prepmsg (pb-field-value ?p "instruction_ss")) |
112 | | - (bind ?task (pb-field-value ?prepmsg "task")) |
113 | | - (bind ?operation (sym-cat (pb-field-value ?task "operation"))) |
114 | | - (bind ?slot (pb-field-value ?task "shelf")) |
115 | | - (bind ?slot-x (pb-field-value ?slot "x")) |
116 | | - (bind ?slot-y (pb-field-value ?slot "y")) |
117 | | - (bind ?slot-z (pb-field-value ?slot "z")) |
118 | | - |
| 112 | + (bind ?operation (sym-cat (pb-field-value ?prepmsg "operation"))) |
119 | 113 | (if (eq ?operation RETRIEVE) |
120 | 114 | then |
121 | | - ; check if slot is filled |
122 | | - (if (any-factp ((?ss-slot machine-ss-filled)) (and (eq ?ss-slot:name ?mname) |
123 | | - (and (eq (nth$ 1 ?ss-slot:slot) ?slot-x) |
124 | | - (and (eq (nth$ 2 ?ss-slot:slot) ?slot-y) |
125 | | - (eq (nth$ 3 ?ss-slot:slot) ?slot-z) |
126 | | - ) |
127 | | - ) |
128 | | - ) |
129 | | - ) |
| 115 | + (if ?m:ss-holding |
130 | 116 | then |
131 | | - (printout t "Prepared " ?mname " (RETRIVE: (" ?slot-x ", " ?slot-y ", " ?slot-z ") )" crlf) |
132 | | - (modify ?m (state PREPARED) (ss-operation ?operation) (ss-slot ?slot-x ?slot-y ?slot-z) (wait-for-product-since ?gt)) |
| 117 | + (printout t "Prepared " ?mname crlf) |
| 118 | + (modify ?m (state PREPARED) (ss-operation ?operation) (wait-for-product-since ?gt)) |
133 | 119 | else |
134 | | - (modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with RETRIVE (" ?slot-x ", " ?slot-y ", " ?slot-z ") but this is empty"))) |
| 120 | + (modify ?m (state BROKEN) |
| 121 | + (broken-reason |
| 122 | + (str-cat "Prepare received for " ?mname ", but station is empty"))) |
135 | 123 | ) |
136 | 124 | else |
137 | 125 | (if (eq ?operation STORE) |
138 | 126 | then |
139 | | - (modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with STORE-operation"))) |
| 127 | + (modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with STORE operation"))) |
140 | 128 | else |
141 | | - (modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with unknown operation"))) |
| 129 | + (modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with unknown operation " ?operation))) |
142 | 130 | ) |
143 | 131 | ) |
144 | 132 | else |
|
450 | 438 | (mps-move-conveyor (str-cat ?n) "OUTPUT" "FORWARD") |
451 | 439 | ) |
452 | 440 |
|
453 | | -(defrule production-bs-cs-rs-ready-at-output |
| 441 | +(defrule production-bs-cs-rs-ss-ready-at-output |
454 | 442 | "Workpiece is in output, switch to READY-AT-OUTPUT" |
455 | 443 | (gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt)) |
456 | | - ?m <- (machine (name ?n) (mtype BS|CS|RS) (state PROCESSED) (task MOVE-OUT) |
| 444 | + ?m <- (machine (name ?n) (mtype BS|CS|RS|SS) (state PROCESSED) (task MOVE-OUT) |
457 | 445 | (mps-busy FALSE) (mps-ready TRUE)) |
458 | 446 | => |
459 | 447 | (modify ?m (state READY-AT-OUTPUT) (task nil)) |
|
504 | 492 | (modify ?m (state WAIT-IDLE) (idle-since ?gt)) |
505 | 493 | ) |
506 | 494 |
|
| 495 | +(defrule production-ss-start-retrieval |
| 496 | + "SS is prepared, move the workpiece to the output." |
| 497 | + (gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt)) |
| 498 | + ?m <- (machine (name ?n) (mtype SS) (state PREPARED) |
| 499 | + (ss-operation RETRIEVE) (task nil)) |
| 500 | + => |
| 501 | + (modify ?m (state PROCESSING) (proc-start ?gt)) |
| 502 | +) |
| 503 | + |
| 504 | +(defrule production-ss-processed-retrieval |
| 505 | + "The conveyor started moving, go to processed." |
| 506 | + (gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt)) |
| 507 | + ?m <- (machine (name ?n) (mtype SS) (team ?team) (state PROCESSING) (ss-operation RETRIEVE) |
| 508 | + (proc-start ?t&:(timeout-sec ?gt ?t ?*PROCESS-TIME-SS*))) |
| 509 | + => |
| 510 | + (assert (points (game-time ?gt) (team ?team) (phase PRODUCTION) |
| 511 | + (points ?*PRODUCTION-POINTS-SS-RETRIEVAL*) |
| 512 | + (reason (str-cat "Retrieved product from " ?n)))) |
| 513 | + (mps-move-conveyor (str-cat ?n) "OUTPUT" "FORWARD") |
| 514 | + (modify ?m (state PROCESSED) (task MOVE-OUT) (mps-busy WAIT) (ss-holding FALSE)) |
| 515 | +) |
| 516 | + |
507 | 517 | (defrule production-mps-idle |
508 | 518 | "The machine has been in WAIT-IDLE for the specified time, switch to IDLE." |
509 | 519 | (gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt)) |
|
0 commit comments