|
@@ -28,6 +28,7 @@ public class SimulationManager {
|
|
|
private int timeStep;
|
|
|
private boolean simMode;
|
|
|
private HashMap<Integer, Float> tagTable = new HashMap<Integer, Float>();
|
|
|
+ private boolean recalculate;
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -40,6 +41,7 @@ public class SimulationManager {
|
|
|
model = m;
|
|
|
subNets = new ArrayList<SubNet>();
|
|
|
simMode = model.getIsSimulation();
|
|
|
+ recalculate = false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -90,7 +92,12 @@ public class SimulationManager {
|
|
|
}
|
|
|
}
|
|
|
canvas.repaint();
|
|
|
- printNet();
|
|
|
+ System.out.println(recalculate);
|
|
|
+ if(recalculate){
|
|
|
+ recalculate = false;
|
|
|
+ calculateStateForTimeStep(x);
|
|
|
+ }
|
|
|
+ //printNet();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -154,6 +161,9 @@ public class SimulationManager {
|
|
|
}
|
|
|
edge.setFlow(edge.getFlow() + energy);
|
|
|
edge.calculateState(true);
|
|
|
+ if(!edge.getState()){
|
|
|
+ recalculate = true;
|
|
|
+ }
|
|
|
edge.addTag(hl.getID());
|
|
|
if (edge.getState() && !producers.contains(tmp)) {
|
|
|
if(tmp instanceof HolonSwitch){
|
|
@@ -210,6 +220,9 @@ public class SimulationManager {
|
|
|
}
|
|
|
}
|
|
|
edge.calculateState(true);
|
|
|
+ if(!edge.getState()){
|
|
|
+ recalculate = true;
|
|
|
+ }
|
|
|
if(edge.getState() && !(tmp instanceof CpsUpperNode)){
|
|
|
tmp.addAllPseudoTags(cps.getTag());
|
|
|
if(!newNodes.contains(tmp)){
|