|
@@ -26,7 +26,6 @@ public class SimulationManager {
|
|
|
private ArrayList<SubNet> subNets;
|
|
|
private MyCanvas canvas;
|
|
|
private int timeStep;
|
|
|
- private boolean simMode;
|
|
|
private HashMap<Integer, Float> tagTable = new HashMap<Integer, Float>();
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -38,7 +37,6 @@ public class SimulationManager {
|
|
|
canvas = null;
|
|
|
model = m;
|
|
|
subNets = new ArrayList<SubNet>();
|
|
|
- simMode = model.getIsSimulation();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -48,7 +46,6 @@ public class SimulationManager {
|
|
|
* current Iteration
|
|
|
*/
|
|
|
public void calculateStateForTimeStep(int x) {
|
|
|
- simMode = model.getIsSimulation();
|
|
|
timeStep = x;
|
|
|
searchForSubNets();
|
|
|
for (SubNet singleSubNet : subNets) {
|
|
@@ -58,7 +55,7 @@ public class SimulationManager {
|
|
|
float production = calculateEnergy("prod", singleSubNet, timeStep);
|
|
|
float consumption = calculateEnergy("cons", singleSubNet, timeStep);
|
|
|
float minConsumption = calculateMinimumEnergy(singleSubNet, timeStep);
|
|
|
- setFlow(singleSubNet, simMode);
|
|
|
+ setFlowSimulation(singleSubNet);
|
|
|
for (HolonObject hl : singleSubNet.getObjects()) {
|
|
|
if (!(hl.getState() == 0) && !(hl.getState() == 3)) {
|
|
|
for (int i = 0; i < hl.getConnections().size(); i++) {
|
|
@@ -92,40 +89,6 @@ public class SimulationManager {
|
|
|
//printNet();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Sets the Flow.
|
|
|
- *
|
|
|
- * @param sN
|
|
|
- * Subnet
|
|
|
- * @param simulation
|
|
|
- * boolean if Simulation is on
|
|
|
- */
|
|
|
- public void setFlow(SubNet sN, boolean simulation) {
|
|
|
- if (simulation) {
|
|
|
- setFlowSimulation(sN);
|
|
|
- } else {
|
|
|
- setFlowModelation(sN);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * set the Flow Modelation.
|
|
|
- *
|
|
|
- * @param sN
|
|
|
- * Subnet
|
|
|
- */
|
|
|
- public void setFlowModelation(SubNet sN) {
|
|
|
- for (HolonObject hl : sN.getObjects()) {
|
|
|
- float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
|
|
|
- if (energy > 0) {
|
|
|
- for (CpsEdge e : sN.getEdges()) {
|
|
|
- e.setFlow(e.getFlow() + energy);
|
|
|
- e.calculateState(simMode);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Set Flow Simulation.
|
|
|
*
|
|
@@ -152,7 +115,7 @@ public class SimulationManager {
|
|
|
tmp = edge.getA();
|
|
|
}
|
|
|
edge.setFlow(edge.getFlow() + energy);
|
|
|
- edge.calculateState(true);
|
|
|
+ edge.calculateState();
|
|
|
edge.addTag(hl.getId());
|
|
|
if (edge.getState() && !producers.contains(tmp)) {
|
|
|
if(tmp instanceof HolonSwitch){
|
|
@@ -208,7 +171,7 @@ public class SimulationManager {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- edge.calculateState(true);
|
|
|
+ edge.calculateState();
|
|
|
if(edge.getState() && !(tmp instanceof CpsUpperNode)){
|
|
|
tmp.addAllPseudoTags(cps.getTag());
|
|
|
if(!newNodes.contains(tmp)){
|
|
@@ -310,7 +273,7 @@ public class SimulationManager {
|
|
|
for (CpsEdge e : cps.getConnections()) {
|
|
|
if (!(visitedEdges.contains(e))) {
|
|
|
e.setFlow(0);
|
|
|
- e.calculateState(simMode);
|
|
|
+ e.calculateState();
|
|
|
e.setTags(new ArrayList<Integer>());
|
|
|
visitedEdges.add(e);
|
|
|
if (!(visitedObj.contains(e.getA().getId()))) {
|
|
@@ -433,7 +396,7 @@ public class SimulationManager {
|
|
|
AbstractCpsObject a;
|
|
|
AbstractCpsObject b;
|
|
|
for (CpsEdge edge : cps.getConnections()) {
|
|
|
- if(!(simMode && !edge.getState())){
|
|
|
+ if(edge.getState()){
|
|
|
a = edge.getA();
|
|
|
b = edge.getB();
|
|
|
if (!(cps instanceof HolonSwitch)) {
|