mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-11 13:57:11 -04:00
Removes a superfluous model event; closes #551
This commit is contained in:
parent
4d688b9fb9
commit
8d42d7838d
@ -170,10 +170,8 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
* Needs to be called after all nodes are added.
|
* Needs to be called after all nodes are added.
|
||||||
* Resets and initializes the model.
|
* Resets and initializes the model.
|
||||||
* Calls <code>init(true);</code>
|
* Calls <code>init(true);</code>
|
||||||
*
|
|
||||||
* @throws NodeException NodeException
|
|
||||||
*/
|
*/
|
||||||
public void init() throws NodeException {
|
public void init() {
|
||||||
init(true);
|
init(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,9 +180,8 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
* Resets and initializes the model.
|
* Resets and initializes the model.
|
||||||
*
|
*
|
||||||
* @param noise setup with or without noise
|
* @param noise setup with or without noise
|
||||||
* @throws NodeException NodeException
|
|
||||||
*/
|
*/
|
||||||
public void init(boolean noise) throws NodeException {
|
public void init(boolean noise) {
|
||||||
nodesToUpdateNext.addAll(nodes);
|
nodesToUpdateNext.addAll(nodes);
|
||||||
state = State.INITIALIZING;
|
state = State.INITIALIZING;
|
||||||
doStep(noise);
|
doStep(noise);
|
||||||
@ -277,24 +274,21 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
|
|
||||||
synchronized private void stepWithCondition(boolean noise, StepCondition cond) {
|
synchronized private void stepWithCondition(boolean noise, StepCondition cond) {
|
||||||
try {
|
try {
|
||||||
if (cond.doNextMicroStep()) {
|
int counter = 0;
|
||||||
int counter = 0;
|
while (cond.doNextMicroStep() && state != State.CLOSED) {
|
||||||
while (cond.doNextMicroStep() && state != State.CLOSED) {
|
if (counter++ > MAX_LOOP_COUNTER) {
|
||||||
if (counter++ > MAX_LOOP_COUNTER) {
|
if (oscillatingNodes == null)
|
||||||
if (oscillatingNodes == null)
|
oscillatingNodes = new HashSet<>();
|
||||||
oscillatingNodes = new HashSet<>();
|
if (counter > COLLECTING_LOOP_COUNTER) {
|
||||||
if (counter > COLLECTING_LOOP_COUNTER) {
|
NodeException seemsToOscillate = new NodeException(Lang.get("err_seemsToOscillate")).addNodes(oscillatingNodes);
|
||||||
NodeException seemsToOscillate = new NodeException(Lang.get("err_seemsToOscillate")).addNodes(oscillatingNodes);
|
oscillatingNodes = null;
|
||||||
oscillatingNodes = null;
|
throw seemsToOscillate;
|
||||||
throw seemsToOscillate;
|
} else {
|
||||||
} else {
|
oscillatingNodes.addAll(nodesToUpdateNext);
|
||||||
oscillatingNodes.addAll(nodesToUpdateNext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
doMicroStep(noise);
|
|
||||||
}
|
}
|
||||||
} else
|
doMicroStep(noise);
|
||||||
fireEvent(ModelEvent.STEP);
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorOccurred(e);
|
errorOccurred(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user