|
@@ -1,13 +1,11 @@
|
|
package holeg.model;
|
|
package holeg.model;
|
|
|
|
|
|
-
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The class HolonObject represents any Object on the system which capability of
|
|
* The class HolonObject represents any Object on the system which capability of
|
|
* injecting or consuming energy on the network, for instance a house or a power
|
|
* injecting or consuming energy on the network, for instance a house or a power
|
|
@@ -15,245 +13,304 @@ import java.util.stream.Stream;
|
|
*
|
|
*
|
|
* @author Gruppe14
|
|
* @author Gruppe14
|
|
*/
|
|
*/
|
|
-public class HolonObject extends AbstractCanvasObject {
|
|
|
|
- /* Array of all consumers */
|
|
|
|
- private List<HolonElement> elements = new ArrayList<HolonElement>();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Constructor Set by default the name of the object equals to the category
|
|
|
|
- * name, until the user changes it.
|
|
|
|
- *
|
|
|
|
- * @param objName name of the Object
|
|
|
|
- */
|
|
|
|
- public HolonObject(String objName) {
|
|
|
|
- super(objName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Contructor of a copy of an Object.
|
|
|
|
- *
|
|
|
|
- * @param obj object to be copied
|
|
|
|
- */
|
|
|
|
- public HolonObject(HolonObject obj) {
|
|
|
|
- super(obj);
|
|
|
|
- for(HolonElement ele : obj.elements) {
|
|
|
|
- this.add(new HolonElement(ele));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void initForReflection() {
|
|
|
|
- elements = new ArrayList<HolonElement>();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Getter for all Elements in the HolonObject.
|
|
|
|
- *
|
|
|
|
- * @return the elements ArrayList
|
|
|
|
- */
|
|
|
|
- public Stream<HolonElement> getElements() {
|
|
|
|
- return elements.stream();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void clearElements() {
|
|
|
|
- elements.clear();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * adds an Element to the Object.
|
|
|
|
- *
|
|
|
|
- * @param element the Element to add
|
|
|
|
- */
|
|
|
|
- public void add(HolonElement element) {
|
|
|
|
- elements.add(element);
|
|
|
|
- element.parentObject = this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * adds an Element to the Object.
|
|
|
|
- *
|
|
|
|
- * @param element the Element to add
|
|
|
|
- */
|
|
|
|
- public void add(Collection<HolonElement> elements) {
|
|
|
|
- for(HolonElement hE : elements) {
|
|
|
|
- hE.parentObject = this;
|
|
|
|
- }
|
|
|
|
- this.elements.addAll(elements);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * remove an Element to the Object.
|
|
|
|
- *
|
|
|
|
- * @param element the Element to add
|
|
|
|
- */
|
|
|
|
- public void remove(HolonElement element) {
|
|
|
|
- elements.remove(element);
|
|
|
|
- element.parentObject = null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void removeElement(int index) {
|
|
|
|
- HolonElement ele = elements.remove(index);
|
|
|
|
- ele.parentObject = null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * This Method returns the smallest consuming HolonElement that is ACTIVE.
|
|
|
|
- * If the HolonObject has no Consumer its return null.
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The smallest consuming HolonElement or null.
|
|
|
|
- */
|
|
|
|
- public HolonElement getMinimumConsumingElement(){
|
|
|
|
- return elements.stream().filter(element -> element.getActualEnergy() < 0).max((lhs,rhs) -> Float.compare(lhs.getActualEnergy(), rhs.getActualEnergy())).orElse(null);
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * This Method returns the smallest consuming HolonElement'Energy that is ACTIVE.
|
|
|
|
- * If the HolonObject has no Consumer its return 0.
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The smallest consuming HolonElement or 0.
|
|
|
|
- */
|
|
|
|
- public float getMinimumConsumingElementEnergy(){
|
|
|
|
- return elements.stream().filter(element -> element.getActualEnergy() < 0 ).map(element -> -element.getActualEnergy()).min((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * This Method returns the biggest consuming HolonElement'Energy that is ACTIVE.
|
|
|
|
- * If the HolonObject has no Consumer its return 0.
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The biggest consuming HolonElement or 0.
|
|
|
|
- */
|
|
|
|
- public float getMaximumConsumingElementEnergy(){
|
|
|
|
- return elements.stream().filter(element -> element.getActualEnergy() < 0 ).map(element -> -element.getActualEnergy()).max((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public float getMaximumProductionPossible() {
|
|
|
|
- return elements.stream().filter(element -> element.getEnergy() > 0).map(element -> element.getEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
- }
|
|
|
|
- public float getMaximumConsumptionPossible() {
|
|
|
|
- return elements.stream().filter(element -> element.getEnergy() < 0).map(element -> -element.getEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * This Method returns the Energy that all HolonElements from the HolonObject produce by itself. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Producer.
|
|
|
|
- * If the HolonObject have no HolonElement its return 0;
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The Energy of the producing HolonElements.
|
|
|
|
- */
|
|
|
|
- public float getEnergySelfProducingFromProducingElements() {
|
|
|
|
- return elements.stream().filter(element -> element.getActualEnergy() > 0).map(element -> element.getActualEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * This Method returns the Energy of all HolonElements from the HolonObject that are consuming. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Consumer.
|
|
|
|
- * If the HolonObject have no HolonElement its return 0;
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The Energy of the consuming HolonElements.
|
|
|
|
- */
|
|
|
|
- public float getEnergyNeededFromConsumingElements() {
|
|
|
|
- return elements.stream().filter(element -> element.getActualEnergy() < 0).map(element -> -element.getActualEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * This Method calculate the amount of HolonElements that are consuming Energy and are ACTIVE.
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The amount of HolonElements that are consuming Energy.
|
|
|
|
- */
|
|
|
|
- public int countConsumingElements() {
|
|
|
|
- return (int) elements.stream().filter(element -> element.getActualEnergy() < 0).count();
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * This Method calculate the amount of HolonElements that are producing Energy and are ACTIVE.
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The amount of HolonElements that are producing Energy.
|
|
|
|
- */
|
|
|
|
- public int countProducingElements() {
|
|
|
|
- return (int) elements.stream().filter(element -> element.getActualEnergy() > 0).count();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public int getNumberOfActiveElements() {
|
|
|
|
- return (int) elements.stream().filter(ele -> ele.active).count();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public int getNumberOfInActiveElements() {
|
|
|
|
- return (int) elements.stream().filter(ele -> !ele.active).count();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public int getNumberOfElements() {
|
|
|
|
- return elements.size();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * STATE
|
|
|
|
- */
|
|
|
|
- private float actualEnergy;
|
|
|
|
- private HolonObjectState state;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * This Method returns the Energy of a HolonObject. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE.
|
|
|
|
- * If the HolonObject have no HolonElement its return 0;
|
|
|
|
- * Is the returned Energy negative then the HolonObject need Energy because its consuming HolonElements need more Energy then the producing HolonElements.
|
|
|
|
- * Is the returned Energy positive its reversed.
|
|
|
|
- * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
- * @return The Energy of the HolonObject.
|
|
|
|
- */
|
|
|
|
- public void calculateEnergy(int timestep)
|
|
|
|
- {
|
|
|
|
- elements.forEach(ele -> ele.calculateState(timestep));
|
|
|
|
- actualEnergy = elements.stream().map(element -> element.getActualEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public float getActualEnergy()
|
|
|
|
- {
|
|
|
|
- return actualEnergy;
|
|
|
|
- }
|
|
|
|
|
|
+public class HolonObject extends AbstractCanvasObject {
|
|
|
|
+ /* Array of all consumers */
|
|
|
|
+ private List<HolonElement> elements = new ArrayList<HolonElement>();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Constructor Set by default the name of the object equals to the category
|
|
|
|
+ * name, until the user changes it.
|
|
|
|
+ *
|
|
|
|
+ * @param objName name of the Object
|
|
|
|
+ */
|
|
|
|
+ public HolonObject(String objName) {
|
|
|
|
+ super(objName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Contructor of a copy of an Object.
|
|
|
|
+ *
|
|
|
|
+ * @param obj object to be copied
|
|
|
|
+ */
|
|
|
|
+ public HolonObject(HolonObject obj) {
|
|
|
|
+ super(obj);
|
|
|
|
+ for (HolonElement ele : obj.elements) {
|
|
|
|
+ this.add(new HolonElement(ele));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void initForReflection() {
|
|
|
|
+ elements = new ArrayList<HolonElement>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Getter for all Elements in the HolonObject.
|
|
|
|
+ *
|
|
|
|
+ * @return the elements ArrayList
|
|
|
|
+ */
|
|
|
|
+ public Stream<HolonElement> getElements() {
|
|
|
|
+ return elements.stream();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void clearElements() {
|
|
|
|
+ elements.clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * adds an Element to the Object.
|
|
|
|
+ *
|
|
|
|
+ * @param element the Element to add
|
|
|
|
+ */
|
|
|
|
+ public void add(HolonElement element) {
|
|
|
|
+ elements.add(element);
|
|
|
|
+ element.parentObject = this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * adds an Element to the Object.
|
|
|
|
+ *
|
|
|
|
+ * @param element the Element to add
|
|
|
|
+ */
|
|
|
|
+ public void add(Collection<HolonElement> elements) {
|
|
|
|
+ for (HolonElement hE : elements) {
|
|
|
|
+ hE.parentObject = this;
|
|
|
|
+ }
|
|
|
|
+ this.elements.addAll(elements);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * remove an Element to the Object.
|
|
|
|
+ *
|
|
|
|
+ * @param element the Element to add
|
|
|
|
+ */
|
|
|
|
+ public void remove(HolonElement element) {
|
|
|
|
+ elements.remove(element);
|
|
|
|
+ element.parentObject = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void removeElement(int index) {
|
|
|
|
+ HolonElement ele = elements.remove(index);
|
|
|
|
+ ele.parentObject = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method returns the smallest consuming HolonElement that is ACTIVE. If
|
|
|
|
+ * the HolonObject has no Consumer its return null.
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The smallest consuming HolonElement or null.
|
|
|
|
+ */
|
|
|
|
+ public HolonElement getMinimumConsumingElement() {
|
|
|
|
+ return elements.stream().filter(element -> element.getActualEnergy() < 0)
|
|
|
|
+ .max((lhs, rhs) -> Float.compare(lhs.getActualEnergy(), rhs.getActualEnergy())).orElse(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method returns the smallest consuming HolonElement'Energy that is
|
|
|
|
+ * ACTIVE. If the HolonObject has no Consumer its return 0.
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The smallest consuming HolonElement or 0.
|
|
|
|
+ */
|
|
|
|
+ public float getMinimumConsumingElementEnergy() {
|
|
|
|
+ return elements.stream().filter(element -> element.getActualEnergy() < 0)
|
|
|
|
+ .map(element -> -element.getActualEnergy()).min((lhs, rhs) -> Float.compare(lhs, rhs)).orElse(0.0f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method returns the biggest consuming HolonElement'Energy that is ACTIVE.
|
|
|
|
+ * If the HolonObject has no Consumer its return 0.
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The biggest consuming HolonElement or 0.
|
|
|
|
+ */
|
|
|
|
+ public float getMaximumConsumingElementEnergy() {
|
|
|
|
+ return elements.stream().filter(element -> element.getActualEnergy() < 0)
|
|
|
|
+ .map(element -> -element.getActualEnergy()).max((lhs, rhs) -> Float.compare(lhs, rhs)).orElse(0.0f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public float getMaximumProductionPossible() {
|
|
|
|
+ return elements.stream().filter(element -> element.getEnergy() > 0).map(element -> element.getEnergy())
|
|
|
|
+ .reduce(0.0f, Float::sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public float getMaximumConsumptionPossible() {
|
|
|
|
+ return elements.stream().filter(element -> element.getEnergy() < 0).map(element -> -element.getEnergy())
|
|
|
|
+ .reduce(0.0f, Float::sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method returns the Energy that all HolonElements from the HolonObject
|
|
|
|
+ * produce by itself. Its sums all Energies from the HolonElements of the
|
|
|
|
+ * HolonObject that are ACTIVE and are Producer. If the HolonObject have no
|
|
|
|
+ * HolonElement its return 0;
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The Energy of the producing HolonElements.
|
|
|
|
+ */
|
|
|
|
+ public float getEnergySelfProducingFromProducingElements() {
|
|
|
|
+ return elements.stream().filter(element -> element.getActualEnergy() > 0)
|
|
|
|
+ .map(element -> element.getActualEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method returns the Energy of all HolonElements from the HolonObject that
|
|
|
|
+ * are consuming. Its sums all Energies from the HolonElements of the
|
|
|
|
+ * HolonObject that are ACTIVE and are Consumer. If the HolonObject have no
|
|
|
|
+ * HolonElement its return 0;
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The Energy of the consuming HolonElements.
|
|
|
|
+ */
|
|
|
|
+ public float getEnergyNeededFromConsumingElements() {
|
|
|
|
+ return elements.stream().filter(element -> element.getActualEnergy() < 0)
|
|
|
|
+ .map(element -> -element.getActualEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method calculate the amount of HolonElements that are consuming Energy
|
|
|
|
+ * and are ACTIVE.
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The amount of HolonElements that are consuming Energy.
|
|
|
|
+ */
|
|
|
|
+ public int countConsumingElements() {
|
|
|
|
+ return (int) elements.stream().filter(element -> element.getActualEnergy() < 0).count();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method calculate the amount of HolonElements that are producing Energy
|
|
|
|
+ * and are ACTIVE.
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The amount of HolonElements that are producing Energy.
|
|
|
|
+ */
|
|
|
|
+ public int countProducingElements() {
|
|
|
|
+ return (int) elements.stream().filter(element -> element.getActualEnergy() > 0).count();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getNumberOfActiveElements() {
|
|
|
|
+ return (int) elements.stream().filter(ele -> ele.active).count();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getNumberOfInActiveElements() {
|
|
|
|
+ return (int) elements.stream().filter(ele -> !ele.active).count();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public int getNumberOfElements() {
|
|
|
|
+ return elements.size();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * STATE
|
|
|
|
+ */
|
|
|
|
+ private float actualEnergy;
|
|
|
|
+ private HolonObjectState state;
|
|
|
|
+ private float energyFromNetwork;
|
|
|
|
+ private float minimumConsumingElementEnergy;
|
|
|
|
+ private float energyNeededFromNetwork;
|
|
|
|
+ private float energyFromConsumingElemnets;
|
|
|
|
+ private float energySelfSupplied;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This Method returns the Energy of a HolonObject. Its sums all Energies from
|
|
|
|
+ * the HolonElements of the HolonObject that are ACTIVE. If the HolonObject have
|
|
|
|
+ * no HolonElement its return 0; Is the returned Energy negative then the
|
|
|
|
+ * HolonObject need Energy because its consuming HolonElements need more Energy
|
|
|
|
+ * then the producing HolonElements. Is the returned Energy positive its
|
|
|
|
+ * reversed.
|
|
|
|
+ *
|
|
|
|
+ * @param timestep is the TimeStep to compare the HolonElements.
|
|
|
|
+ * @return The Energy of the HolonObject.
|
|
|
|
+ */
|
|
|
|
+ public void calculateEnergy(int timestep) {
|
|
|
|
+ elements.forEach(ele -> ele.calculateState(timestep));
|
|
|
|
+ actualEnergy = elements.stream().map(element -> element.getActualEnergy()).reduce(0.0f, Float::sum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public float getActualEnergy() {
|
|
|
|
+ return actualEnergy;
|
|
|
|
+ }
|
|
|
|
|
|
public enum HolonObjectState {
|
|
public enum HolonObjectState {
|
|
NO_ENERGY, NOT_SUPPLIED, SUPPLIED, PRODUCER, PARTIALLY_SUPPLIED, OVER_SUPPLIED
|
|
NO_ENERGY, NOT_SUPPLIED, SUPPLIED, PRODUCER, PARTIALLY_SUPPLIED, OVER_SUPPLIED
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public HolonObjectState getState() {
|
|
public HolonObjectState getState() {
|
|
return state;
|
|
return state;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void setState(HolonObjectState state) {
|
|
public void setState(HolonObjectState state) {
|
|
this.state = state;
|
|
this.state = state;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
+ public float getEnergyFromNetwork() {
|
|
|
|
+ return energyFromNetwork;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // TODO(Tom2021-01-11): Should not exist hidden or package visibility
|
|
|
|
+ public void setEnergyFromNetwork(float energyFromNetwork) {
|
|
|
|
+ this.energyFromNetwork = energyFromNetwork;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ public float getMinimumConsumingElementEnergyState() {
|
|
|
|
+ return minimumConsumingElementEnergy;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // TODO(Tom2021-01-11): Should not exist hidden or package visibility
|
|
|
|
+ public void setMinimumConsumingElementEnergy(float minimumConsumingElementEnergy) {
|
|
|
|
+ this.minimumConsumingElementEnergy = minimumConsumingElementEnergy;
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
|
|
+ public float getEnergyNeededFromNetwork() {
|
|
|
|
+ return energyNeededFromNetwork;
|
|
|
|
+ }
|
|
|
|
|
|
- public String toString() {
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
+ // TODO(Tom2021-01-11): Should not exist hidden or package visibility
|
|
|
|
+ public void setEnergyNeededFromNetwork(float energyNeededFromNetwork) {
|
|
|
|
+ this.energyNeededFromNetwork = energyNeededFromNetwork;
|
|
|
|
+ }
|
|
|
|
|
|
- sb.append("[HolonObject: ");
|
|
|
|
- sb.append("id=").append(getId())
|
|
|
|
- .append(", name=").append(name)
|
|
|
|
- .append(", state=");
|
|
|
|
- sb.append(", elements=[");
|
|
|
|
- for (int i = 0; i < elements.size(); i++) {
|
|
|
|
- HolonElement el = elements.get(i);
|
|
|
|
- if (i != 0) {
|
|
|
|
- sb.append(", ");
|
|
|
|
- }
|
|
|
|
- sb.append(el.getName());
|
|
|
|
- }
|
|
|
|
- sb.append("]]");
|
|
|
|
|
|
+ public float getEnergyFromConsumingElemnets() {
|
|
|
|
+ return energyFromConsumingElemnets;
|
|
|
|
+ }
|
|
|
|
|
|
- return sb.toString();
|
|
|
|
- }
|
|
|
|
|
|
+ // TODO(Tom2021-01-11): Should not exist hidden or package visibility
|
|
|
|
+ public void setEnergyFromConsumingElemnets(float energyFromConsumingElemnets) {
|
|
|
|
+ this.energyFromConsumingElemnets = energyFromConsumingElemnets;
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
|
|
+ public float getEnergySelfSupplied() {
|
|
|
|
+ return energySelfSupplied;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // TODO(Tom2021-01-11): Should not exist hidden or package visibility
|
|
|
|
+ public void setEnergySelfSupplied(float energySelfSupplied) {
|
|
|
|
+ this.energySelfSupplied = energySelfSupplied;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ float getCurrentEnergy() {
|
|
|
|
+ return energyFromNetwork-energyNeededFromNetwork;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
+ public float getSupplyBarPercentage() {
|
|
|
|
+ return (getEnergyFromConsumingElemnets() > 0.001)
|
|
|
|
+ ? (getEnergyFromNetwork() + this.getEnergySelfSupplied()) / getEnergyFromConsumingElemnets()
|
|
|
|
+ : 1.0f;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String toString() {
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ sb.append("[HolonObject: ").append("id=").append(getId()).append(", name=").append(name).append(", state=")
|
|
|
|
+ .append(state).append(", elements=[")
|
|
|
|
+ .append(getElements().map(HolonElement::getName).collect(Collectors.joining(", "))).append("]]");
|
|
|
|
+ return sb.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|