|
@@ -15,20 +15,21 @@ import javafx.util.converter.PercentageStringConverter;
|
|
|
* @author Gruppe14
|
|
|
*/
|
|
|
public class HolonObject extends AbstractCpsObject {
|
|
|
- /*
|
|
|
- * the constants showing a HolonObject's current state
|
|
|
- * (whether it needs no energy, whether it is not supplied, fully supplied,
|
|
|
- * a producer, partially supplied or over-supplied)
|
|
|
- */
|
|
|
- //TODO: enum
|
|
|
+ @Deprecated
|
|
|
enum State{
|
|
|
NO_ENERGY, NOT_SUPPLIED, SUPPLIED, PRODUCER, PARTIALLY_SUPPLIED, OVER_SUPPLIED
|
|
|
}
|
|
|
+ @Deprecated
|
|
|
public final static int NO_ENERGY = 0;
|
|
|
+ @Deprecated
|
|
|
public final static int NOT_SUPPLIED = 1;
|
|
|
+ @Deprecated
|
|
|
public final static int SUPPLIED = 2;
|
|
|
+ @Deprecated
|
|
|
public final static int PRODUCER = 3;
|
|
|
+ @Deprecated
|
|
|
public final static int PARTIALLY_SUPPLIED = 4;
|
|
|
+ @Deprecated
|
|
|
public final static int OVER_SUPPLIED = 5;
|
|
|
|
|
|
/*
|
|
@@ -48,7 +49,8 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
private float[] trackingCons;
|
|
|
/* Total Flexibility */
|
|
|
private float totalFlex;
|
|
|
- @Expose
|
|
|
+ @Deprecated
|
|
|
+ @Expose
|
|
|
private int state = 0;
|
|
|
/**
|
|
|
* Energy level that was supplied by other HolonObjects in the current Calculation
|
|
@@ -68,7 +70,6 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
public HolonObject(String objName) {
|
|
|
super(objName);
|
|
|
setElements(new ArrayList<>());
|
|
|
- setState();
|
|
|
setTrackingProd(new float[100]);
|
|
|
setTrackingCons(new float[100]);
|
|
|
}
|
|
@@ -81,33 +82,11 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
public HolonObject(AbstractCpsObject obj) {
|
|
|
super(obj);
|
|
|
setElements(copyElements(((HolonObject) obj).getElements()));
|
|
|
- setState();
|
|
|
setTrackingProd(new float[100]);
|
|
|
setTrackingCons(new float[100]);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * sets the State, whether object is a producer, zero Energy, supplied,
|
|
|
- * partially or over-supplied
|
|
|
- */
|
|
|
- public void setState() {
|
|
|
- if (getMaxActiveEnergy() > 0) {
|
|
|
- setState(PRODUCER);
|
|
|
- stateColor = Color.lightGray;
|
|
|
- } else {
|
|
|
- if (getMaxActiveEnergy() == 0) {
|
|
|
- setState(NO_ENERGY);
|
|
|
- stateColor = Color.WHITE;
|
|
|
- } else {
|
|
|
- if (checkIfPartiallySupplied(0)) {
|
|
|
- stateColor = Color.yellow;
|
|
|
- } else {
|
|
|
- stateColor = new Color(230, 120, 100);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Getter for all Elements in the HolonObject.
|
|
@@ -163,30 +142,6 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * Getter for the current energy at a given timestep.
|
|
|
- *
|
|
|
- * @param x timestep
|
|
|
- * @return corresponding energy
|
|
|
- */
|
|
|
- public float getCurrentEnergyAtTimeStep(int x) {
|
|
|
- float cons = 0;
|
|
|
- float prod = currentSupply;
|
|
|
- float t;
|
|
|
- for (HolonElement e : getElements()) {
|
|
|
- if (e.isActive()) {
|
|
|
- t = e.getOverallEnergyAtTimeStep(x);
|
|
|
- if(t<0){
|
|
|
- cons+=t;
|
|
|
- }else{
|
|
|
- prod+=t;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- currentEnergy = prod + cons;
|
|
|
- suppliedPercentage = prod / -cons;
|
|
|
- return currentEnergy;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* Getter for the current energy at a given timestep.
|
|
@@ -194,6 +149,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
* @param x timestep
|
|
|
* @return corresponding energy
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
public float getCurrentEnergyAtTimeStepWithoutFlexiblesAndResetFlexibles(int x) {
|
|
|
float temp = 0;
|
|
|
for (HolonElement e : getElements()) {
|
|
@@ -245,6 +201,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
*
|
|
|
* @return state the State of the Element
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
public int getState() {
|
|
|
return this.state;
|
|
|
}
|
|
@@ -254,6 +211,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
*
|
|
|
* @param state boolean if the Object is fully supplied
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
public void setState(int state) {
|
|
|
this.state = state;
|
|
|
switch (state) {
|
|
@@ -319,84 +277,6 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
return ele;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Check if Partially Supplied.
|
|
|
- *
|
|
|
- * @param x current Iteration
|
|
|
- * @return boolean is partially supplied
|
|
|
- */
|
|
|
- public boolean checkIfPartiallySupplied(int x) {
|
|
|
-
|
|
|
- if (getElements().size() == 0) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- float minConsum = 0;
|
|
|
- // Search for a activ element
|
|
|
- for (HolonElement e : getElements()) {
|
|
|
- if (e.isActive()) {
|
|
|
- float overallEnergy = e.getOverallEnergyAtTimeStep(x);
|
|
|
- if (overallEnergy < 0) {
|
|
|
- // Is a consumer
|
|
|
- minConsum = overallEnergy;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- float prod = 0;
|
|
|
- float cons = 0;
|
|
|
- for (HolonElement e : getElements()) {
|
|
|
- if (e.isActive()) {
|
|
|
- float overallEnergy = e.getOverallEnergyAtTimeStep(x);
|
|
|
- if (overallEnergy > 0) {
|
|
|
- prod += overallEnergy;
|
|
|
- }else{
|
|
|
- cons += overallEnergy;
|
|
|
- }
|
|
|
- if (minConsum < 0 && (overallEnergy > minConsum && overallEnergy < 0)) {
|
|
|
- minConsum = overallEnergy;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- suppliedPercentage = -(prod + currentSupply)/cons;
|
|
|
- // System.out.println("minCons: " + minConsum + " prod: " + prod);
|
|
|
- if (minConsum < 0 && prod >= -minConsum) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param x
|
|
|
- * @return
|
|
|
- */
|
|
|
- public float getSelfMadeEnergy(int x)
|
|
|
- {
|
|
|
- return getElements().stream()
|
|
|
- .map(e ->(e.isActive() && e.getOverallEnergyAtTimeStep(x) > 0) ? e.getOverallEnergyAtTimeStep(x) : 0.0f)
|
|
|
- .reduce(0.0f, (a , b) -> a + b );
|
|
|
- }
|
|
|
- /**
|
|
|
- * Calculates the minimumEnergy Needed to turn on atleast on device
|
|
|
- * of this HolonObject
|
|
|
- * @param timestep Timestep of the calculation
|
|
|
- * @return minEnergy, -inf if no Devices are consuming power
|
|
|
- */
|
|
|
- public float getMinEnergy(int timestep) {
|
|
|
- if (getElements().size() == 0) {
|
|
|
- return Float.NEGATIVE_INFINITY;
|
|
|
- }
|
|
|
- float minConsum = Float.NEGATIVE_INFINITY;
|
|
|
- for (HolonElement e : getElements()) {
|
|
|
- if (e.isActive()) {
|
|
|
- float overallEnergy = e.getOverallEnergyAtTimeStep(timestep);
|
|
|
- if (minConsum < 0 && (overallEnergy > minConsum && overallEnergy < 0)) {
|
|
|
- minConsum = overallEnergy;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return minConsum;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|