|
@@ -5,9 +5,7 @@ import java.util.ArrayList;
|
|
|
public class HolonObject extends CpsObject {
|
|
|
|
|
|
/* Array of all consumers */
|
|
|
- private ArrayList<HolonElement> consumers;
|
|
|
- /* Array of all producers */
|
|
|
- private ArrayList<HolonElement> producers;
|
|
|
+ private ArrayList<HolonElement> elements;
|
|
|
/* Total of consumption */
|
|
|
private float currentEnergy;
|
|
|
/**
|
|
@@ -22,69 +20,75 @@ public class HolonObject extends CpsObject {
|
|
|
*/
|
|
|
public HolonObject(String ObjName) {
|
|
|
super(ObjName);
|
|
|
- consumers = new ArrayList<HolonElement>();
|
|
|
- producers = new ArrayList<HolonElement>();
|
|
|
+ elements = new ArrayList<HolonElement>();
|
|
|
}
|
|
|
|
|
|
public HolonObject(String ObjName, String obj) {
|
|
|
super(ObjName);
|
|
|
super.name = obj;
|
|
|
- consumers = new ArrayList<HolonElement>();
|
|
|
- producers = new ArrayList<HolonElement>();
|
|
|
+ elements = new ArrayList<HolonElement>();
|
|
|
}
|
|
|
|
|
|
public HolonObject(CpsObject obj) {
|
|
|
super(obj);
|
|
|
- consumers = new ArrayList<HolonElement>();
|
|
|
- producers = new ArrayList<HolonElement>();
|
|
|
- this.consumers = ((HolonObject)obj).getConsumers();
|
|
|
- this.producers = ((HolonObject)obj).getProducers();
|
|
|
- }
|
|
|
+ elements = new ArrayList<HolonElement>();
|
|
|
+ this.elements = ((HolonObject)obj).getElements();
|
|
|
|
|
|
- public void addConsumer(HolonElement consumer) {
|
|
|
- consumers.add(consumer);
|
|
|
}
|
|
|
|
|
|
- public void addProducer(HolonElement producer) {
|
|
|
- producers.add(producer);
|
|
|
- }
|
|
|
|
|
|
- public void deleteConsumer(int idx) {
|
|
|
- consumers.remove(idx);
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the elements
|
|
|
+ */
|
|
|
+ public ArrayList<HolonElement> getElements() {
|
|
|
+ return elements;
|
|
|
}
|
|
|
|
|
|
- public void deleteProducer(int idx) {
|
|
|
- producers.remove(idx);
|
|
|
+ /**
|
|
|
+ * @param elements the elements to set
|
|
|
+ */
|
|
|
+ public void setElements(ArrayList<HolonElement> elements) {
|
|
|
+ this.elements = elements;
|
|
|
}
|
|
|
|
|
|
- public float calculateCurrentEnergy() {
|
|
|
+ /**
|
|
|
+ * @return the currentEnergy
|
|
|
+ */
|
|
|
+ public float getCurrentEnergy() {
|
|
|
return currentEnergy;
|
|
|
}
|
|
|
|
|
|
- public ArrayList<HolonElement> getConsumers() {
|
|
|
- return consumers;
|
|
|
+ /**
|
|
|
+ * @param currentEnergy the currentEnergy to set
|
|
|
+ */
|
|
|
+ public void setCurrentEnergy(float currentEnergy) {
|
|
|
+ this.currentEnergy = currentEnergy;
|
|
|
}
|
|
|
|
|
|
- public void setConsumers(ArrayList<HolonElement> consumers) {
|
|
|
- this.consumers = consumers;
|
|
|
+ /**
|
|
|
+ * deletes Element
|
|
|
+ * @param idx
|
|
|
+ */
|
|
|
+ public void deleteElement(int idx) {
|
|
|
+ elements.remove(idx);
|
|
|
}
|
|
|
|
|
|
- public ArrayList<HolonElement> getProducers() {
|
|
|
- return producers;
|
|
|
+ public float calculateCurrentEnergy() {
|
|
|
+ return currentEnergy;
|
|
|
}
|
|
|
|
|
|
- public void setProducers(ArrayList<HolonElement> producers) {
|
|
|
- this.producers = producers;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* String of all consumers in this HolonObject
|
|
|
*
|
|
|
* @return all the names of this HolonObject separated by "," each object
|
|
|
*/
|
|
|
- public String toStringConsumers() {
|
|
|
+ public String toStringElements() {
|
|
|
String objString = "";
|
|
|
- for (HolonElement e : consumers) {
|
|
|
+ for (HolonElement e : elements) {
|
|
|
if (objString == "") {
|
|
|
objString = e.getEleName();
|
|
|
} else {
|
|
@@ -94,23 +98,4 @@ public class HolonObject extends CpsObject {
|
|
|
}
|
|
|
return objString;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * String of all producers in this HolonObject
|
|
|
- *
|
|
|
- * @return all the names of this HolonObject separated by "," each object
|
|
|
- */
|
|
|
- public String toStringProducers() {
|
|
|
- String objString = "";
|
|
|
- for (HolonElement e : producers) {
|
|
|
- if (objString == "") {
|
|
|
- objString = e.getEleName();
|
|
|
- } else {
|
|
|
- objString = objString + ", " + e.getEleName();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return objString;
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+}
|