|
@@ -26,6 +26,10 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
private HashMap<String, Integer> eleIdx;
|
|
|
/* Total of consumption */
|
|
|
private float currentEnergy;
|
|
|
+ /* Array for tracking Production */
|
|
|
+ private float[] trackingProd;
|
|
|
+ /* Array for tracking Consumption */
|
|
|
+ private float[] trackingCons;
|
|
|
|
|
|
/*
|
|
|
* 0 = no energy, 1 = not supplied, 2 = supplied, 3 producer
|
|
@@ -44,6 +48,8 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
setElements(new ArrayList<HolonElement>());
|
|
|
setEleIdx(new HashMap<String, Integer>());
|
|
|
setState();
|
|
|
+ setTrackingProd(new float[100]);
|
|
|
+ setTrackingCons(new float[100]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -57,6 +63,8 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
setEleIdx(MultiPurposeController.copyHashMap(((HolonObject) obj).getEleIdx()));
|
|
|
setElements(copyElements(((HolonObject) obj).getElements()));
|
|
|
setState();
|
|
|
+ setTrackingProd(new float[100]);
|
|
|
+ setTrackingCons(new float[100]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -331,4 +339,59 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
public Color getColor() {
|
|
|
return stateColor;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set the Array Production
|
|
|
+ */
|
|
|
+ public void setTrackingProd(float[] arr) {
|
|
|
+ this.trackingProd = arr;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the Array Production
|
|
|
+ */
|
|
|
+ public float[] getTrackingProd() {
|
|
|
+ return this.trackingProd;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set the Array Consumption
|
|
|
+ */
|
|
|
+ public void setTrackingCons(float[] arr) {
|
|
|
+ this.trackingCons = arr;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the Array Consumption
|
|
|
+ */
|
|
|
+ public float[] getTrackingCons() {
|
|
|
+ return this.trackingCons;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * If the user track any HolonObject the tracking information will be
|
|
|
+ * updated. (If the HolonObject enters into the untracked state, the array
|
|
|
+ * will be reseted)
|
|
|
+ */
|
|
|
+
|
|
|
+ public void updateTrackingInfo() {
|
|
|
+ float[] tempProd = new float[100];
|
|
|
+ float[] tempCons = new float[100];
|
|
|
+ for (int i = 0; i < 100; i++) {
|
|
|
+ float valueProd = 0;
|
|
|
+ float valueCons = 0;
|
|
|
+ for (HolonElement e : getElements()) {
|
|
|
+ if (e.getActive() && e.getSign() == '+') {
|
|
|
+ valueProd = valueProd + e.getTotalEnergyAtTimeStep(i);
|
|
|
+ }
|
|
|
+ if (e.getActive() && e.getSign() == '-') {
|
|
|
+ valueCons = valueCons + e.getTotalEnergyAtTimeStep(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tempProd[i] = valueProd;
|
|
|
+ tempCons[i] = valueCons;
|
|
|
+ }
|
|
|
+ this.trackingProd = tempProd;
|
|
|
+ this.trackingCons = tempCons;
|
|
|
+ }
|
|
|
}
|