mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
moved to 3 dt switch ObservableValues
This commit is contained in:
parent
eb703e05e6
commit
181803bc78
@ -9,7 +9,6 @@ import de.neemann.digital.core.Model;
|
|||||||
import de.neemann.digital.core.NodeException;
|
import de.neemann.digital.core.NodeException;
|
||||||
import de.neemann.digital.core.ObservableValue;
|
import de.neemann.digital.core.ObservableValue;
|
||||||
import de.neemann.digital.core.ObservableValues;
|
import de.neemann.digital.core.ObservableValues;
|
||||||
import de.neemann.digital.core.element.PinDescription;
|
|
||||||
import de.neemann.digital.lang.Lang;
|
import de.neemann.digital.lang.Lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,19 +17,17 @@ import de.neemann.digital.lang.Lang;
|
|||||||
public final class PlainSwitchDT {
|
public final class PlainSwitchDT {
|
||||||
private final PlainSwitch s1;
|
private final PlainSwitch s1;
|
||||||
private final PlainSwitch s2;
|
private final PlainSwitch s2;
|
||||||
private final ObservableValue outputAB;
|
private final ObservableValue outputA;
|
||||||
private final ObservableValue outputAC;
|
|
||||||
private final ObservableValue outputB;
|
private final ObservableValue outputB;
|
||||||
private final ObservableValue outputC;
|
private final ObservableValue outputC;
|
||||||
|
|
||||||
|
|
||||||
PlainSwitchDT(int bits, int num) {
|
PlainSwitchDT(int bits, int num) {
|
||||||
outputAB = new ObservableValue("A" + num, bits).setBidirectional().setToHighZ().setDescription(Lang.get("elem_Switch_pin")).setSwitchPin(true);
|
outputA = 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);
|
|
||||||
outputB = new ObservableValue("B" + 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);
|
outputC = new ObservableValue("C" + num, bits).setBidirectional().setToHighZ().setDescription(Lang.get("elem_Switch_pin")).setSwitchPin(true);
|
||||||
s1 = new PlainSwitch(outputAB, outputB, false);
|
s1 = new PlainSwitch(outputA, outputB, false);
|
||||||
s2 = new PlainSwitch(outputAC, outputC, true);
|
s2 = new PlainSwitch(outputA, outputC, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,21 +36,20 @@ public final class PlainSwitchDT {
|
|||||||
* @param ov the builder to use
|
* @param ov the builder to use
|
||||||
*/
|
*/
|
||||||
public void addOutputs(ObservableValues.Builder ov) {
|
public void addOutputs(ObservableValues.Builder ov) {
|
||||||
ov.add(outputAB, outputAC, outputB, outputC);
|
ov.add(outputA, outputB, outputC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the inputs of this switch
|
* Sets the inputs of this switch
|
||||||
*
|
*
|
||||||
* @param inAB first input of pin A
|
* @param inA first input, the DT switch anchor
|
||||||
* @param inAC second input of pin A
|
|
||||||
* @param inB pin B
|
* @param inB pin B
|
||||||
* @param inC Pin C
|
* @param inC Pin C
|
||||||
* @throws NodeException NodeException
|
* @throws NodeException NodeException
|
||||||
*/
|
*/
|
||||||
public void setInputs(ObservableValue inAB, ObservableValue inAC, ObservableValue inB, ObservableValue inC) throws NodeException {
|
public void setInputs(ObservableValue inA, ObservableValue inB, ObservableValue inC) throws NodeException {
|
||||||
s1.setInputs(inAB, inB);
|
s1.setInputs(inA, inB);
|
||||||
s2.setInputs(inAC, inC);
|
s2.setInputs(inA, inC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,6 +86,6 @@ public final class PlainSwitchDT {
|
|||||||
* @param ov the builder
|
* @param ov the builder
|
||||||
*/
|
*/
|
||||||
public void addOutputsTo(ObservableValues.Builder ov) {
|
public void addOutputsTo(ObservableValues.Builder ov) {
|
||||||
ov.add(outputAB, outputAC, outputB, outputC);
|
ov.add(outputA, outputB, outputC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ public class SwitchDT implements Element, NodeInterface {
|
|||||||
public void setInputs(ObservableValues inputs) throws NodeException {
|
public void setInputs(ObservableValues inputs) throws NodeException {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (PlainSwitchDT p : poles) {
|
for (PlainSwitchDT p : poles) {
|
||||||
p.setInputs(inputs.get(i), inputs.get(i + 1), inputs.get(i + 2), inputs.get(i + 3));
|
p.setInputs(inputs.get(i), inputs.get(i + 1), inputs.get(i + 2));
|
||||||
i += 4;
|
i += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,9 @@ public class RelayDTShape implements Shape {
|
|||||||
|
|
||||||
for (int p = 0; p < poles; p++)
|
for (int p = 0; p < poles; p++)
|
||||||
pins
|
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 * 3)))
|
||||||
.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 * 3 + 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 * 3 + 2)));
|
||||||
.add(new Pin(new Vector(SIZE * 2, p * SIZE * 2 + SIZE), outputs.get(p * 4 + 3)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return pins;
|
return pins;
|
||||||
|
@ -56,10 +56,9 @@ public class SwitchDTShape implements Shape {
|
|||||||
Pins pins = new Pins();
|
Pins pins = new Pins();
|
||||||
for (int p = 0; p < poles; p++) {
|
for (int p = 0; p < poles; p++) {
|
||||||
pins
|
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 * 3)))
|
||||||
.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 * 3 + 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 * 3 + 2)));
|
||||||
.add(new Pin(new Vector(SIZE * 2, SIZE + SIZE * 2 * p), outputs.get(p * 4 + 3)));
|
|
||||||
}
|
}
|
||||||
return pins;
|
return pins;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user