mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 15:26:52 -04:00
simplified DT switches, see #255
This commit is contained in:
parent
12adf74a2b
commit
714043ce03
@ -67,7 +67,7 @@ public final class PlainSwitch implements NodeInterface {
|
|||||||
input2.addObserverToValue(this).checkBits(bits, null);
|
input2.addObserverToValue(this).checkBits(bits, null);
|
||||||
switch (unidirectional) {
|
switch (unidirectional) {
|
||||||
case NO:
|
case NO:
|
||||||
switchModel = createSwitchModel(input1, input2, output1, output2, true, true);
|
switchModel = createSwitchModel(input1, input2, output1, output2, false);
|
||||||
break;
|
break;
|
||||||
case FROM1TO2:
|
case FROM1TO2:
|
||||||
switchModel = new UniDirectionalSwitch(input1, output2);
|
switchModel = new UniDirectionalSwitch(input1, output2);
|
||||||
@ -82,13 +82,13 @@ public final class PlainSwitch implements NodeInterface {
|
|||||||
static SwitchModel createSwitchModel(
|
static SwitchModel createSwitchModel(
|
||||||
ObservableValue input1, ObservableValue input2,
|
ObservableValue input1, ObservableValue input2,
|
||||||
ObservableValue output1, ObservableValue output2,
|
ObservableValue output1, ObservableValue output2,
|
||||||
boolean setOpenContactToHighZ, boolean optimizeConstants) throws NodeException {
|
boolean isDoubleThrow) throws NodeException {
|
||||||
|
|
||||||
if (input1 instanceof CommonBusValue) {
|
if (input1 instanceof CommonBusValue) {
|
||||||
if (input2 instanceof CommonBusValue) {
|
if (input2 instanceof CommonBusValue) {
|
||||||
final CommonBusValue in1 = (CommonBusValue) input1;
|
final CommonBusValue in1 = (CommonBusValue) input1;
|
||||||
final CommonBusValue in2 = (CommonBusValue) input2;
|
final CommonBusValue in2 = (CommonBusValue) input2;
|
||||||
if (optimizeConstants) {
|
if (!isDoubleThrow) {
|
||||||
ObservableValue constant = in1.searchConstant();
|
ObservableValue constant = in1.searchConstant();
|
||||||
if (constant != null)
|
if (constant != null)
|
||||||
return new UniDirectionalSwitch(constant, output2);
|
return new UniDirectionalSwitch(constant, output2);
|
||||||
@ -105,7 +105,7 @@ public final class PlainSwitch implements NodeInterface {
|
|||||||
return new UniDirectionalSwitch(input1, output2);
|
return new UniDirectionalSwitch(input1, output2);
|
||||||
} else {
|
} else {
|
||||||
if (input2 instanceof CommonBusValue) {
|
if (input2 instanceof CommonBusValue) {
|
||||||
return new UniDirectionalSwitch(input2, output1, setOpenContactToHighZ);
|
return new UniDirectionalSwitch(input2, output1, !isDoubleThrow);
|
||||||
} else {
|
} else {
|
||||||
throw new NodeException(Lang.get("err_switchHasNoNet"), output1, output2);
|
throw new NodeException(Lang.get("err_switchHasNoNet"), output1, output2);
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,11 @@ public final class PlainSwitchDT implements NodeInterface {
|
|||||||
|
|
||||||
if (inA != null && inB != null) {
|
if (inA != null && inB != null) {
|
||||||
inB.addObserverToValue(this).checkBits(bits, null);
|
inB.addObserverToValue(this).checkBits(bits, null);
|
||||||
s1 = PlainSwitch.createSwitchModel(inA, inB, outputA, outputB, inC == null, false);
|
s1 = PlainSwitch.createSwitchModel(inA, inB, outputA, outputB, inC != null);
|
||||||
}
|
}
|
||||||
if (inA != null && inC != null) {
|
if (inA != null && inC != null) {
|
||||||
inC.addObserverToValue(this).checkBits(bits, null);
|
inC.addObserverToValue(this).checkBits(bits, null);
|
||||||
s2 = PlainSwitch.createSwitchModel(inA, inC, outputA, outputC, inB == null, false);
|
s2 = PlainSwitch.createSwitchModel(inA, inC, outputA, outputC, inB != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user