allows unconnected wires; closes #546

This commit is contained in:
hneemann 2020-11-05 11:51:28 +01:00
parent afd3e737d9
commit 6c891f9978
2 changed files with 11 additions and 4 deletions

View File

@ -46,9 +46,12 @@ public class ObservableValue extends Observable implements PinDescription {
/**
* Makes this value a constant value
*
* @return this for chained calls
*/
public void setConstant() {
public ObservableValue setConstant() {
isConstant = true;
return this;
}
/**

View File

@ -27,6 +27,7 @@ import java.util.HashSet;
* After creation all the ObservableValues belonging to the outputs are set.
*/
public class Net {
private static final ObservableValue UNCONNECTED_WIRE = new ObservableValue("unconnected wire", 1).setToHighZ().setConstant();
private final HashSet<Vector> points;
private final ArrayList<Pin> pins;
@ -172,14 +173,17 @@ public class Net {
outputs.add(p);
}
if (outputs.size() == 0)
if (outputs.size() == 0 && inputs.size() > 0)
throw new PinException(Lang.get("err_noOutConnectedToWire", this.toString()), this);
ObservableValue value = null;
ObservableValue value;
if (outputs.size() == 1 && outputs.get(0).getPullResistor() == PinDescription.PullResistor.none) {
value = outputs.get(0).getValue();
} else {
value = new DataBus(this, m, outputs).getReadableOutput();
if (inputs.size() == 0 && outputs.size() == 0) // unconnected wire
value = UNCONNECTED_WIRE;
else
value = new DataBus(this, m, outputs).getReadableOutput();
}
if (value == null)