mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 15:58:41 -04:00
allows to set the oscillationDetectionCounter in the circuit specific settings; closes #837
This commit is contained in:
parent
e743c60d42
commit
b47c2dfc2f
@ -52,9 +52,9 @@ public class Model implements Iterable<Node>, SyncAccess {
|
||||
/**
|
||||
* Maximal number of calculation loops before oscillating behaviour is detected
|
||||
*/
|
||||
private static final int MAX_LOOP_COUNTER = 1000;
|
||||
private static final int COLLECTING_LOOP_COUNTER = MAX_LOOP_COUNTER + 100;
|
||||
private static final int COLLECTING_LOOP_COUNTER_OFFS = 100;
|
||||
private ArrayList<BreakDetector> brVal;
|
||||
private int oscillationDetectionCounter = 1000;
|
||||
|
||||
private enum State {BUILDING, INITIALIZING, RUNNING, CLOSED}
|
||||
|
||||
@ -104,6 +104,17 @@ public class Model implements Iterable<Node>, SyncAccess {
|
||||
this.observers = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of gate delays at which an oscillation is detected.
|
||||
*
|
||||
* @param oscillationDetectionCounter number of steps
|
||||
* @return this for chained calls
|
||||
*/
|
||||
public Model setOscillationDetectionCounter(int oscillationDetectionCounter) {
|
||||
this.oscillationDetectionCounter = oscillationDetectionCounter;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this model to async mode.
|
||||
* Async mode means that the circuit is not able to reach a stable state once the reset gates are released.
|
||||
@ -283,10 +294,10 @@ public class Model implements Iterable<Node>, SyncAccess {
|
||||
if (cond.doNextMicroStep()) {
|
||||
int counter = 0;
|
||||
while (cond.doNextMicroStep() && state != State.CLOSED) {
|
||||
if (counter++ > MAX_LOOP_COUNTER) {
|
||||
if (counter++ > oscillationDetectionCounter) {
|
||||
if (oscillatingNodes == null)
|
||||
oscillatingNodes = new HashSet<>();
|
||||
if (counter > COLLECTING_LOOP_COUNTER) {
|
||||
if (counter > oscillationDetectionCounter + COLLECTING_LOOP_COUNTER_OFFS) {
|
||||
NodeException seemsToOscillate = new NodeException(Lang.get("err_seemsToOscillate")).addNodes(oscillatingNodes);
|
||||
oscillatingNodes = null;
|
||||
throw seemsToOscillate;
|
||||
|
@ -530,6 +530,15 @@ public final class Keys {
|
||||
public static final Key<Boolean> SETTINGS_SHOW_TUNNEL_RENAME_DIALOG
|
||||
= new Key<>("tunnelRenameDialog", true).setSecondary();
|
||||
|
||||
/**
|
||||
* Counter used to detect oscillations
|
||||
*/
|
||||
public static final Key<Integer> OSCILLATION_DETECTION_COUNTER =
|
||||
new Key.KeyInteger("oscillationDetectionCounter", 1000)
|
||||
.setComboBoxValues(1000, 5000, 10000)
|
||||
.setMin(1000)
|
||||
.setMax(100000);
|
||||
|
||||
/**
|
||||
* output format for numbers
|
||||
*/
|
||||
|
@ -291,7 +291,8 @@ public class ModelCreator implements Iterable<ModelEntry> {
|
||||
public Model createModel(boolean attachWires) throws PinException, NodeException {
|
||||
Model m = new Model()
|
||||
.setRootPath(circuit.getOrigin())
|
||||
.setAllowGlobalValues(attachWires);
|
||||
.setAllowGlobalValues(attachWires)
|
||||
.setOscillationDetectionCounter(circuit.getAttributes().get(Keys.OSCILLATION_DETECTION_COUNTER));
|
||||
|
||||
for (Net n : netList)
|
||||
n.interconnect(m, attachWires);
|
||||
|
@ -77,6 +77,7 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
ATTR_LIST.add(Keys.PINCOUNT);
|
||||
ATTR_LIST.add(Keys.BACKGROUND_COLOR);
|
||||
ATTR_LIST.add(Keys.DESCRIPTION);
|
||||
ATTR_LIST.add(Keys.OSCILLATION_DETECTION_COUNTER);
|
||||
ATTR_LIST.add(Keys.LOCKED_MODE);
|
||||
ATTR_LIST.add(Keys.ROMMANAGER);
|
||||
ATTR_LIST.add(Keys.SHOW_DATA_TABLE);
|
||||
|
@ -1681,6 +1681,10 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_persistTime">Nachleuchten</string>
|
||||
<string name="key_persistTime_tt">Gibt die Dauer des Nachleuchtens an. Je größer der Wert, je länger die Nachleuchtdauer.</string>
|
||||
|
||||
<string name="key_oscillationDetectionCounter">Oszillationserkennung</string>
|
||||
<string name="key_oscillationDetectionCounter_tt">Anzahl der Gatterlaufzeiten, bei der eine Oszillation erkannt
|
||||
wird, wenn sich die Schaltung bis dahin noch nicht stabilisiert hat.</string>
|
||||
|
||||
<string name="key_telnetEscape">Telnet-Modus</string>
|
||||
<string name="key_telnetEscape_tt">Wenn gesetzt, werden die Telnet Steuerkommandos ausgewertet.
|
||||
Zusätzlich werden vom Server die Kommandos SGA und ECHO gesendet.
|
||||
|
@ -1664,6 +1664,10 @@
|
||||
<string name="key_persistTime">Persistence Of Vision</string>
|
||||
<string name="key_persistTime_tt">Specifies the duration of the afterglow. The larger the value, the longer the afterglow duration.</string>
|
||||
|
||||
<string name="key_oscillationDetectionCounter">Oscillation detection</string>
|
||||
<string name="key_oscillationDetectionCounter_tt">Number of gate propagation times at which a oscillation is
|
||||
detected if the circuit has not stabilized by then.</string>
|
||||
|
||||
<string name="key_telnetEscape">Telnet mode</string>
|
||||
<string name="key_telnetEscape_tt">If set, the Telnet control commands are evaluated.
|
||||
In addition, the server sends the SGA and ECHO commands. If this option is disabled,
|
||||
|
Loading…
x
Reference in New Issue
Block a user