From 29d7e87b338243b6d0f29d84d2b90a619fe7dd0c Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 16:24:18 +0200 Subject: [PATCH 1/5] msgs: remove gate from DS prepare message Mark the slot id and name as reserved so they won't be re-used on accident. --- src/msgs/MachineInstructions.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/msgs/MachineInstructions.proto b/src/msgs/MachineInstructions.proto index a7000fbd7..45a936e51 100644 --- a/src/msgs/MachineInstructions.proto +++ b/src/msgs/MachineInstructions.proto @@ -61,7 +61,8 @@ message PrepareInstructionBS { } message PrepareInstructionDS { - required uint32 gate = 1; + reserved "gate"; + reserved 1; required uint32 order_id = 2; } From a5f77005a2dc7729b5620b8332f3511822387e43 Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 16:26:42 +0200 Subject: [PATCH 2/5] rcll-prepare-machine: remove gate from DS prepare message We no longer require (or allow) a gate slot in the DS prepare message. --- src/tools/rcll-prepare-machine.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/tools/rcll-prepare-machine.cpp b/src/tools/rcll-prepare-machine.cpp index a0cea26da..f274f4d45 100644 --- a/src/tools/rcll-prepare-machine.cpp +++ b/src/tools/rcll-prepare-machine.cpp @@ -57,7 +57,6 @@ std::string machine_name_; std::string machine_type_; llsf_msgs::MachineSide bs_side_; llsf_msgs::BaseColor bs_color_; -int ds_gate_; int ds_order_id_; llsf_msgs::SSOp ss_op_; int ss_slot_x_; @@ -171,7 +170,6 @@ handle_message(boost::asio::ip::udp::endpoint &sender, llsf_msgs::BaseColor_Name(bs_color_).c_str()); } else if (machine_type_ == "DS") { llsf_msgs::PrepareInstructionDS *prep_ds = prep.mutable_instruction_ds(); - prep_ds->set_gate(ds_gate_); prep_ds->set_order_id(ds_order_id_); } else if (machine_type_ == "SS") { llsf_msgs::PrepareInstructionSS *prep_ss = prep.mutable_instruction_ss(); @@ -202,7 +200,7 @@ usage(const char *progname) "\n" "instructions are specific for the machine type:\n" "BS: (INPUT|OUTPUT) (BASE_RED|BASE_BLACK|BASE_SILVER)\n" - "DS: \n" + "DS: \n" "SS: (RETRIEVE|STORE) \n" "RS: (RING_BLUE|RING_GREEN|RING_ORANGE|RING_YELLOW)\n" "CS: (RETRIEVE_CAP|MOUNT_CAP)\n", @@ -237,13 +235,12 @@ main(int argc, char **argv) printf("Invalid base color\n"); exit(-2); } } else if (machine_type_ == "DS") { - if (argp.num_items() != 4) { - printf("Wrong number of arguments. Expected 4, got %zu\n", argp.num_items()); + if (argp.num_items() != 3) { + printf("Wrong number of arguments. Expected 3, got %zu\n", argp.num_items()); usage(argv[0]); exit(-1); } ds_order_id_ = argp.parse_item_int(2); - ds_gate_ = argp.parse_item_int(3); } else if (machine_type_ == "SS") { if (argp.num_items() < 6) { printf("SS machine requires operation and x, y, z arguments %zu\n", argp.num_items()); From b3c45a68fb4d915c5eceaf4dd4a08b04daeaedc5 Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 16:32:03 +0200 Subject: [PATCH 3/5] shell: show order ID instead of delivery gate for prepared DS --- src/shell/machine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shell/machine.cpp b/src/shell/machine.cpp index 6b1b3dcc4..022219601 100644 --- a/src/shell/machine.cpp +++ b/src/shell/machine.cpp @@ -321,7 +321,7 @@ LLSFRefBoxShellMachine::refresh() if (minfo_ && minfo_->has_instruction_ds()) { attron(' '|COLOR_PAIR(COLOR_BLACK_ON_BACK)); addstr(0, 26, (boost::str(boost::format("%u") - % minfo_->instruction_ds().gate())).c_str()); + % minfo_->instruction_ds().order_id())).c_str()); } else { attron(' '|COLOR_PAIR(COLOR_BLACK_ON_BACK)); addstr(0, 26, " "); From 49624a7d6b2893870ee4c66858f4f18aa0e8add2 Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Tue, 16 Apr 2019 16:53:00 +0200 Subject: [PATCH 4/5] rcll: only expect order ID in DS prep, break machine on invalid order ID We no longer receive the gate as part of the DS prepare message. Get the gate from the respective order fact instead. If the order does not exist, directly set the machine to BROKEN. --- src/games/rcll/production.clp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/games/rcll/production.clp b/src/games/rcll/production.clp index f95a89671..d4bb921ca 100644 --- a/src/games/rcll/production.clp +++ b/src/games/rcll/production.clp @@ -101,12 +101,16 @@ (if (pb-has-field ?p "instruction_ds") then (bind ?prepmsg (pb-field-value ?p "instruction_ds")) - (bind ?gate (pb-field-value ?prepmsg "gate")) - (bind ?order (pb-field-value ?prepmsg "order_id")) - (printout t "Prepared " ?mname " (gate: " ?gate ", order: " ?order ")" crlf) - (modify ?m (state PREPARED) (ds-gate ?gate) (ds-order ?order) + (bind ?order-id (pb-field-value ?prepmsg "order_id")) + (if (any-factp ((?order order)) (eq ?order:id ?order-id)) + then + (printout t "Prepared " ?mname " (order: " ?order-id ")" crlf) + (modify ?m (state PREPARED) (ds-order ?order-id) (mps-state AVAILABLE) (wait-for-product-since ?gt)) - ;(wait-for-product-since ?gt)) + else + (modify ?m (state BROKEN) (prev-state ?m:state) + (broken-reason (str-cat "Prepare received for " ?mname " with invalid order ID"))) + ) else (modify ?m (state BROKEN) (prev-state ?m:state) (broken-reason (str-cat "Prepare received for " ?mname " without data"))) @@ -298,13 +302,13 @@ "BS must be instructed to dispense base for processing" (declare (salience ?*PRIORITY_HIGHER*)) (gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt)) - ?m <- (machine (name ?n) (mtype DS) (state PREPARED) (proc-state ~PREPARED) - (ds-gate ?gate)) + (order (id ?order) (delivery-gate ?gate)) + ?m <- (machine (name ?n) (mtype DS) (state PREPARED) (proc-state ~PREPARED)) => (printout t "Machine " ?n " of type DS switching to PREPARED state" crlf) (modify ?m (proc-state PREPARED) (desired-lights GREEN-BLINK) (prep-blink-start ?gt)) - (printout t "Machine " ?n " processing to gate " ?gate crlf) + (printout t "Machine " ?n " processing to gate " ?gate " for order " ?order crlf) (mps-ds-process (str-cat ?n) ?gate) ) From d7b8845ce903c973b19a471abe891150014fab17 Mon Sep 17 00:00:00 2001 From: Till Hofmann Date: Wed, 17 Apr 2019 15:43:54 +0200 Subject: [PATCH 5/5] rcll: fix rule documentation for processing rule for the DS --- src/games/rcll/production.clp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/games/rcll/production.clp b/src/games/rcll/production.clp index d4bb921ca..a7962223d 100644 --- a/src/games/rcll/production.clp +++ b/src/games/rcll/production.clp @@ -299,7 +299,7 @@ ) (defrule prod-proc-state-processing-ds-start - "BS must be instructed to dispense base for processing" + "Instruct DS to start processing" (declare (salience ?*PRIORITY_HIGHER*)) (gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt)) (order (id ?order) (delivery-gate ?gate))