if (port.startsWith("mux") && (!box_in1.dataReadyForShip() || !box_in2.dataReadyForShip())) return;
if (port.startsWith("deMux") && (!box_in1.dataReadyForShip())) return;
- long val = box_in.removeDataForShip();
+ long val = selector.value;
boolean condition = false;
if (port.endsWith("IfZero")) condition = val==0;
if (port.endsWith("IfNonZero")) condition = val!=0;
if (condition) {
box_out1.addDataFromShip(box_in2.removeDataForShip());
box_out2.addDataFromShip(box_in1.removeDataForShip());
+ selector = null;
} else {
box_out1.addDataFromShip(box_in1.removeDataForShip());
box_out2.addDataFromShip(box_in2.removeDataForShip());
+ selector = null;
}
} else if (port.startsWith("mux")) {
box_out1.addDataFromShip(condition ? box_in2.removeDataForShip() : box_in1.removeDataForShip());
+ selector = null;
} else if (port.startsWith("deMux")) {
(condition ? box_out2 : box_out1).addDataFromShip(box_in1.removeDataForShip());
+ selector = null;
}
}