|
@@ -11,6 +11,8 @@ import ui.view.MyCanvas;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
+import com.sun.xml.internal.ws.util.xml.XMLReaderComposite.State;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Controller for Simulation.
|
|
* Controller for Simulation.
|
|
*
|
|
*
|
|
@@ -77,7 +79,26 @@ public class SimulationManager {
|
|
// surplus of energy is computed by sum, since consumption is a
|
|
// surplus of energy is computed by sum, since consumption is a
|
|
// negative value
|
|
// negative value
|
|
float energySurplus = production + consumption;
|
|
float energySurplus = production + consumption;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ //-->TODO: OutSourcing later in method and just use whats needed
|
|
|
|
+ float getMaxInPut = 0;
|
|
|
|
+ float getMaxOutPut = 0;
|
|
|
|
+ for(HolonBattery hB : singleSubNet.getBatteries())
|
|
|
|
+ {
|
|
|
|
+ getMaxInPut += hB.getIN();
|
|
|
|
+ getMaxOutPut += hB.getOUT();
|
|
|
|
+ if(energySurplus < 0)
|
|
|
|
+ hB.setState(HolonBattery.State.EMIT);
|
|
|
|
+ else if (energySurplus > 0)
|
|
|
|
+ hB.setState(HolonBattery.State.COLLECT);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if(energySurplus < 0)
|
|
|
|
+ energySurplus += getMaxOutPut;
|
|
|
|
+ else if (energySurplus > 0)
|
|
|
|
+ energySurplus -= getMaxInPut;
|
|
|
|
+ System.out.println(energySurplus);
|
|
|
|
+ //<--
|
|
//float minConsumption = calculateMinimumEnergy(singleSubNet, timeStep);
|
|
//float minConsumption = calculateMinimumEnergy(singleSubNet, timeStep);
|
|
|
|
|
|
// --------------- use flexible devices ---------------
|
|
// --------------- use flexible devices ---------------
|
|
@@ -567,7 +588,7 @@ public class SimulationManager {
|
|
}
|
|
}
|
|
if (type.equals("cons")) {
|
|
if (type.equals("cons")) {
|
|
if (currentEnergyWithoutFlexibles < 0) {
|
|
if (currentEnergyWithoutFlexibles < 0) {
|
|
- energy = energy + currentEnergyWithoutFlexibles;
|
|
|
|
|
|
+ energy += currentEnergyWithoutFlexibles;
|
|
hl.setState(HolonObject.NOT_SUPPLIED);
|
|
hl.setState(HolonObject.NOT_SUPPLIED);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -666,7 +687,7 @@ public class SimulationManager {
|
|
while (!end) {
|
|
while (!end) {
|
|
cps = objectsToHandle.get(i);
|
|
cps = objectsToHandle.get(i);
|
|
SubNet singleSubNet = new SubNet(new ArrayList<>(),
|
|
SubNet singleSubNet = new SubNet(new ArrayList<>(),
|
|
- new ArrayList<>(), new ArrayList<>());
|
|
|
|
|
|
+ new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
|
singleSubNet = buildSubNet(cps, new ArrayList<>(), singleSubNet);
|
|
singleSubNet = buildSubNet(cps, new ArrayList<>(), singleSubNet);
|
|
if (singleSubNet.getObjects().size() != 0) {
|
|
if (singleSubNet.getObjects().size() != 0) {
|
|
subNets.add(singleSubNet);
|
|
subNets.add(singleSubNet);
|
|
@@ -699,6 +720,9 @@ public class SimulationManager {
|
|
if (cps instanceof HolonSwitch) {
|
|
if (cps instanceof HolonSwitch) {
|
|
sN.getSwitches().add((HolonSwitch) cps);
|
|
sN.getSwitches().add((HolonSwitch) cps);
|
|
}
|
|
}
|
|
|
|
+ if (cps instanceof HolonBattery) {
|
|
|
|
+ sN.getBatteries().add((HolonBattery) cps);
|
|
|
|
+ }
|
|
removeFromToHandle(cps.getId());
|
|
removeFromToHandle(cps.getId());
|
|
AbstractCpsObject a;
|
|
AbstractCpsObject a;
|
|
AbstractCpsObject b;
|
|
AbstractCpsObject b;
|