mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 15:03:21 -04:00
Better error message if pull up and pull down are connected to the same net.
This commit is contained in:
parent
d9c9118e2e
commit
c6130a0a12
@ -1,7 +1,5 @@
|
||||
package de.neemann.digital.core;
|
||||
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -14,9 +12,12 @@ public class BurnException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param message the message
|
||||
* @param values the values connected to the net
|
||||
*/
|
||||
public BurnException(List<ObservableValue> values) {
|
||||
super(Lang.get("err_burnError"));
|
||||
public BurnException(String message, List<ObservableValue> values) {
|
||||
super(message);
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package de.neemann.digital.core.wiring.bus;
|
||||
import de.neemann.digital.core.BurnException;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.element.PinDescription;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -15,7 +16,9 @@ import java.util.List;
|
||||
public abstract class AbstractBusHandler {
|
||||
|
||||
private final BusModelStateObserver obs;
|
||||
private boolean burn;
|
||||
|
||||
private enum State {ok, burn, both}
|
||||
private State burn;
|
||||
private int addedVersion = -1;
|
||||
|
||||
/**
|
||||
@ -53,9 +56,9 @@ public abstract class AbstractBusHandler {
|
||||
*/
|
||||
public void recalculate() {
|
||||
long value = 0;
|
||||
burn = false;
|
||||
burn = State.ok;
|
||||
if (getResistor().equals(PinDescription.PullResistor.both)) {
|
||||
burn = true;
|
||||
burn = State.both;
|
||||
set(0, true);
|
||||
} else {
|
||||
boolean highz = true;
|
||||
@ -66,7 +69,7 @@ public abstract class AbstractBusHandler {
|
||||
value = input.getValue();
|
||||
} else {
|
||||
if (value != input.getValue())
|
||||
burn = true;
|
||||
burn = State.burn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,7 +89,7 @@ public abstract class AbstractBusHandler {
|
||||
}
|
||||
|
||||
// if burn condition and not yet added for post step check add for post step check
|
||||
if (burn && (obs.getVersion() != addedVersion)) {
|
||||
if (burn != State.ok && (obs.getVersion() != addedVersion)) {
|
||||
addedVersion = obs.getVersion();
|
||||
obs.addCheck(this);
|
||||
}
|
||||
@ -99,8 +102,12 @@ public abstract class AbstractBusHandler {
|
||||
* an exception is thrown.
|
||||
*/
|
||||
public void checkBurn() {
|
||||
if (burn)
|
||||
throw new BurnException(getInputs());
|
||||
switch (burn) {
|
||||
case burn:
|
||||
throw new BurnException(Lang.get("err_burnError"), getInputs());
|
||||
case both:
|
||||
throw new BurnException(Lang.get("err_pullUpAndDown"), getInputs());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -379,7 +379,8 @@ Die gesammte Speichergröße beträgt damit damit dx*dy*2 Speicherworte.</string
|
||||
<string name="err_breakTimeOut">Nach {0} Zyklen ist kein Break aufgetreten</string>
|
||||
<string name="err_builder_exprNotSupported">Ausdruck {0} wird nicht unterstützt.</string>
|
||||
<string name="err_builder_operationNotSupported">Operation {0} wird nicht unterstützt.</string>
|
||||
<string name="err_burnError">Es sind mehrere zusammengeschaltete Ausgänge gleichzeitig aktiv</string>
|
||||
<string name="err_burnError">Es sind mehrere zusammengeschaltete Ausgänge gleichzeitig aktiv und haben einen Kurzschluss erzeugt.</string>
|
||||
<string name="err_pullUpAndDown">Ein Pull-Up- und Pull-Down-Widerstand in einem Netz ist nicht erlaubt.</string>
|
||||
<string name="err_cannotAnalyse_N">Element {0} kann nicht analysiert werden.</string>
|
||||
<string name="err_containsVarAndNotVar">Enthält [var] und [nicht var]</string>
|
||||
<string name="err_duplicatePinLabel">Pin {0} in Element {1} exitiert mehrfach</string>
|
||||
|
@ -366,7 +366,8 @@
|
||||
<string name="err_breakTimeOut">Break timeout after {0} cycles</string>
|
||||
<string name="err_builder_exprNotSupported">Expression {0} not supported</string>
|
||||
<string name="err_builder_operationNotSupported">Operation {0} not supported</string>
|
||||
<string name="err_burnError">More then one output is active on a wire</string>
|
||||
<string name="err_burnError">More then one output is active on a wire, causing a short circuit.</string>
|
||||
<string name="err_pullUpAndDown">It is not allowed to connect a pull-up and pull-down resistor to the same net.</string>
|
||||
<string name="err_cannotAnalyse_N">Cannot analyse Node {0}</string>
|
||||
<string name="err_containsVarAndNotVar">Contains [var] and [not var]</string>
|
||||
<string name="err_duplicatePinLabel">Pin {0} in component {1} exists twice</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user