|
@@ -10,7 +10,7 @@ public class HolonObject extends CpsObject {
|
|
|
|
|
|
/* Array of all consumers */
|
|
|
private ArrayList<HolonElement> elements;
|
|
|
- /* Array of all Indices of Elements*/
|
|
|
+ /* Array of all Indices of Elements */
|
|
|
private HashMap<String, Integer> EleIdx;
|
|
|
/* Total of consumption */
|
|
|
private float currentEnergy;
|
|
@@ -27,7 +27,7 @@ public class HolonObject extends CpsObject {
|
|
|
public HolonObject(String ObjName) {
|
|
|
super(ObjName);
|
|
|
setElements(new ArrayList<HolonElement>());
|
|
|
- setEleIdx(new HashMap<String,Integer>());
|
|
|
+ setEleIdx(new HashMap<String, Integer>());
|
|
|
setState();
|
|
|
}
|
|
|
|
|
@@ -35,26 +35,26 @@ public class HolonObject extends CpsObject {
|
|
|
super(ObjName);
|
|
|
super.setName(obj);
|
|
|
setElements(new ArrayList<HolonElement>());
|
|
|
- setEleIdx(new HashMap<String,Integer>());
|
|
|
+ setEleIdx(new HashMap<String, Integer>());
|
|
|
setState();
|
|
|
}
|
|
|
|
|
|
public HolonObject(CpsObject obj) {
|
|
|
super(obj);
|
|
|
setEleIdx(MultiPurposeController.copyHashMap(((HolonObject) obj).getEleIdx()));
|
|
|
- setElements(copyElements(((HolonObject)obj).getElements()));
|
|
|
+ setElements(copyElements(((HolonObject) obj).getElements()));
|
|
|
setState();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * sets the State, wether object is a producer, zero Energy, supplied or not supplied
|
|
|
+ * sets the State, wether object is a producer, zero Energy, supplied or not
|
|
|
+ * supplied
|
|
|
*/
|
|
|
- public void setState(){
|
|
|
- if(getCurrentEnergy() > 0){
|
|
|
+ public void setState() {
|
|
|
+ if (getCurrentEnergy() > 0) {
|
|
|
setState(3);
|
|
|
- }
|
|
|
- else{
|
|
|
- if(getCurrentEnergy() == 0){
|
|
|
+ } else {
|
|
|
+ if (getCurrentEnergy() == 0) {
|
|
|
setState(0);
|
|
|
}
|
|
|
}
|
|
@@ -92,7 +92,7 @@ public class HolonObject extends CpsObject {
|
|
|
currentEnergy = temp;
|
|
|
return currentEnergy;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public float getCurrentEnergyAtTimeStep(int x) {
|
|
|
float temp = 0;
|
|
|
for (HolonElement e : getElements()) {
|
|
@@ -103,7 +103,6 @@ public class HolonObject extends CpsObject {
|
|
|
currentEnergy = temp;
|
|
|
return currentEnergy;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* @param currentEnergy
|
|
@@ -138,8 +137,6 @@ public class HolonObject extends CpsObject {
|
|
|
}
|
|
|
return objString;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* @return the eleIdx
|
|
@@ -149,13 +146,16 @@ public class HolonObject extends CpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param eleIdx the eleIdx to set
|
|
|
+ * @param eleIdx
|
|
|
+ * the eleIdx to set
|
|
|
*/
|
|
|
public void setEleIdx(HashMap<String, Integer> eleIdx) {
|
|
|
EleIdx = eleIdx;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Copy all Elements into a New Array
|
|
|
+ *
|
|
|
* @param arr
|
|
|
* @return
|
|
|
*/
|
|
@@ -181,4 +181,14 @@ public class HolonObject extends CpsObject {
|
|
|
public void setState(int st) {
|
|
|
this.state = st;
|
|
|
}
|
|
|
+
|
|
|
+ public HolonElement searchElement(String name) {
|
|
|
+ HolonElement ele = null;
|
|
|
+ for (HolonElement e : getElements()) {
|
|
|
+ if (e.getEleName().equals(name)) {
|
|
|
+ ele = e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ele;
|
|
|
+ }
|
|
|
}
|