moved to 3 dt switch ObservableValues

This commit is contained in:
hneemann 2018-11-07 07:52:02 +01:00
parent eb703e05e6
commit 181803bc78
4 changed files with 20 additions and 26 deletions

View File

@ -9,7 +9,6 @@ import de.neemann.digital.core.Model;
import de.neemann.digital.core.NodeException;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.ObservableValues;
import de.neemann.digital.core.element.PinDescription;
import de.neemann.digital.lang.Lang;
/**
@ -18,19 +17,17 @@ import de.neemann.digital.lang.Lang;
public final class PlainSwitchDT {
private final PlainSwitch s1;
private final PlainSwitch s2;
private final ObservableValue outputAB;
private final ObservableValue outputAC;
private final ObservableValue outputA;
private final ObservableValue outputB;
private final ObservableValue outputC;
PlainSwitchDT(int bits, int num) {
outputAB = new ObservableValue("A" + num, bits).setBidirectional().setToHighZ().setDescription(Lang.get("elem_Switch_pin")).setSwitchPin(true);
outputAC = new ObservableValue("AC" + num, bits).setBidirectional().setToHighZ().setDescription(PinDescription.IGNORE).setSwitchPin(true);
outputA = new ObservableValue("A" + num, bits).setBidirectional().setToHighZ().setDescription(Lang.get("elem_Switch_pin")).setSwitchPin(true);
outputB = new ObservableValue("B" + num, bits).setBidirectional().setToHighZ().setDescription(Lang.get("elem_Switch_pin")).setSwitchPin(true);
outputC = new ObservableValue("C" + num, bits).setBidirectional().setToHighZ().setDescription(Lang.get("elem_Switch_pin")).setSwitchPin(true);
s1 = new PlainSwitch(outputAB, outputB, false);
s2 = new PlainSwitch(outputAC, outputC, true);
s1 = new PlainSwitch(outputA, outputB, false);
s2 = new PlainSwitch(outputA, outputC, true);
}
/**
@ -39,21 +36,20 @@ public final class PlainSwitchDT {
* @param ov the builder to use
*/
public void addOutputs(ObservableValues.Builder ov) {
ov.add(outputAB, outputAC, outputB, outputC);
ov.add(outputA, outputB, outputC);
}
/**
* Sets the inputs of this switch
*
* @param inAB first input of pin A
* @param inAC second input of pin A
* @param inB pin B
* @param inC Pin C
* @param inA first input, the DT switch anchor
* @param inB pin B
* @param inC Pin C
* @throws NodeException NodeException
*/
public void setInputs(ObservableValue inAB, ObservableValue inAC, ObservableValue inB, ObservableValue inC) throws NodeException {
s1.setInputs(inAB, inB);
s2.setInputs(inAC, inC);
public void setInputs(ObservableValue inA, ObservableValue inB, ObservableValue inC) throws NodeException {
s1.setInputs(inA, inB);
s2.setInputs(inA, inC);
}
/**
@ -90,6 +86,6 @@ public final class PlainSwitchDT {
* @param ov the builder
*/
public void addOutputsTo(ObservableValues.Builder ov) {
ov.add(outputAB, outputAC, outputB, outputC);
ov.add(outputA, outputB, outputC);
}
}

View File

@ -53,8 +53,8 @@ public class SwitchDT implements Element, NodeInterface {
public void setInputs(ObservableValues inputs) throws NodeException {
int i = 0;
for (PlainSwitchDT p : poles) {
p.setInputs(inputs.get(i), inputs.get(i + 1), inputs.get(i + 2), inputs.get(i + 3));
i += 4;
p.setInputs(inputs.get(i), inputs.get(i + 1), inputs.get(i + 2));
i += 3;
}
}

View File

@ -54,10 +54,9 @@ public class RelayDTShape implements Shape {
for (int p = 0; p < poles; p++)
pins
.add(new Pin(new Vector(0, p * SIZE * 2), outputs.get(p * 4)))
.add(new Pin(new Vector(0, p * SIZE * 2), outputs.get(p * 4 + 1)))
.add(new Pin(new Vector(SIZE * 2, p * SIZE * 2), outputs.get(p * 4 + 2)))
.add(new Pin(new Vector(SIZE * 2, p * SIZE * 2 + SIZE), outputs.get(p * 4 + 3)));
.add(new Pin(new Vector(0, p * SIZE * 2), outputs.get(p * 3)))
.add(new Pin(new Vector(SIZE * 2, p * SIZE * 2), outputs.get(p * 3 + 1)))
.add(new Pin(new Vector(SIZE * 2, p * SIZE * 2 + SIZE), outputs.get(p * 3 + 2)));
}
return pins;

View File

@ -56,10 +56,9 @@ public class SwitchDTShape implements Shape {
Pins pins = new Pins();
for (int p = 0; p < poles; p++) {
pins
.add(new Pin(new Vector(0, SIZE * 2 * p), outputs.get(p * 4)))
.add(new Pin(new Vector(0, SIZE * 2 * p), outputs.get(p * 4 + 1)))
.add(new Pin(new Vector(SIZE * 2, SIZE * 2 * p), outputs.get(p * 4 + 2)))
.add(new Pin(new Vector(SIZE * 2, SIZE + SIZE * 2 * p), outputs.get(p * 4 + 3)));
.add(new Pin(new Vector(0, SIZE * 2 * p), outputs.get(p * 3)))
.add(new Pin(new Vector(SIZE * 2, SIZE * 2 * p), outputs.get(p * 3 + 1)))
.add(new Pin(new Vector(SIZE * 2, SIZE + SIZE * 2 * p), outputs.get(p * 3 + 2)));
}
return pins;
}