|
@@ -109,6 +109,9 @@ public class StatisticGraph extends JPanel {
|
|
case TrackedDataSet.ACTIVATED_ELEMENTS:
|
|
case TrackedDataSet.ACTIVATED_ELEMENTS:
|
|
case TrackedDataSet.TOTAL_PRODUCTION:
|
|
case TrackedDataSet.TOTAL_PRODUCTION:
|
|
case TrackedDataSet.TOTAL_CONSUMPTION:
|
|
case TrackedDataSet.TOTAL_CONSUMPTION:
|
|
|
|
+ case TrackedDataSet.AMOUNT_SUBNETS:
|
|
|
|
+ case TrackedDataSet.GROUP_CONSUMPTION:
|
|
|
|
+ case TrackedDataSet.GROUP_PRODUCTION:
|
|
createPathFloats(set);
|
|
createPathFloats(set);
|
|
break;
|
|
break;
|
|
case TrackedDataSet.ON_OFF:
|
|
case TrackedDataSet.ON_OFF:
|
|
@@ -124,7 +127,6 @@ public class StatisticGraph extends JPanel {
|
|
}
|
|
}
|
|
g2.setColor(set.getColor());
|
|
g2.setColor(set.getColor());
|
|
g2.draw(path);
|
|
g2.draw(path);
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -199,7 +201,6 @@ public class StatisticGraph extends JPanel {
|
|
val += h.getEnergy() * h.getAmount();
|
|
val += h.getEnergy() * h.getAmount();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
break;
|
|
break;
|
|
case TrackedDataSet.ACTIVATED_ELEMENTS:
|
|
case TrackedDataSet.ACTIVATED_ELEMENTS:
|
|
for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
|
|
for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
|
|
@@ -221,7 +222,23 @@ public class StatisticGraph extends JPanel {
|
|
case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
|
|
case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
|
|
val = 1;
|
|
val = 1;
|
|
break;
|
|
break;
|
|
|
|
+ case TrackedDataSet.GROUP_PRODUCTION:
|
|
|
|
+ val = getMaxTotalProduction(((CpsUpperNode) set.getCpsObject()).getNodes());
|
|
|
|
+ break;
|
|
|
|
+ case TrackedDataSet.GROUP_CONSUMPTION:
|
|
|
|
+ val = getMaxTotalConsumption(((CpsUpperNode) set.getCpsObject()).getNodes());
|
|
|
|
+ val *= -1;
|
|
|
|
+ break;
|
|
|
|
+ case TrackedDataSet.AMOUNT_SUBNETS:
|
|
|
|
+ val = controller.getSimManager().getSubNets().size();
|
|
|
|
+ for (int i = 0; i < model.getCurIteration(); i++) {
|
|
|
|
+ if (val < set.getValues()[i]) {
|
|
|
|
+ val = set.getValues()[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
|
|
+ maximum = 0;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
if (val > maximum) {
|
|
if (val > maximum) {
|
|
@@ -236,7 +253,7 @@ public class StatisticGraph extends JPanel {
|
|
*/
|
|
*/
|
|
private void addValues() {
|
|
private void addValues() {
|
|
for (TrackedDataSet set : objects) {
|
|
for (TrackedDataSet set : objects) {
|
|
- int val = 0;
|
|
|
|
|
|
+ float val = 0;
|
|
switch (set.getProperty()) {
|
|
switch (set.getProperty()) {
|
|
case TrackedDataSet.CONSUMPTION:
|
|
case TrackedDataSet.CONSUMPTION:
|
|
for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
|
|
for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
|
|
@@ -279,20 +296,37 @@ public class StatisticGraph extends JPanel {
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case TrackedDataSet.TOTAL_PRODUCTION:
|
|
case TrackedDataSet.TOTAL_PRODUCTION:
|
|
- set.setValAt(getTotalProductionAt(model.getObjectsOnCanvas(), model.getCurIteration()), model.getCurIteration());
|
|
|
|
|
|
+ set.setValAt(getTotalProductionAt(model.getObjectsOnCanvas(), model.getCurIteration()),
|
|
|
|
+ model.getCurIteration());
|
|
break;
|
|
break;
|
|
case TrackedDataSet.TOTAL_CONSUMPTION:
|
|
case TrackedDataSet.TOTAL_CONSUMPTION:
|
|
- set.setValAt(-getTotalConsumptionAt(model.getObjectsOnCanvas(), model.getCurIteration()), model.getCurIteration());
|
|
|
|
|
|
+ set.setValAt(-getTotalConsumptionAt(model.getObjectsOnCanvas(), model.getCurIteration()),
|
|
|
|
+ model.getCurIteration());
|
|
break;
|
|
break;
|
|
case TrackedDataSet.PERCENT_SUPPLIED:
|
|
case TrackedDataSet.PERCENT_SUPPLIED:
|
|
- set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.SUPPLIED), model.getCurIteration());
|
|
|
|
|
|
+ set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.SUPPLIED),
|
|
|
|
+ model.getCurIteration());
|
|
break;
|
|
break;
|
|
case TrackedDataSet.PERCENT_NOT_SUPPLIED:
|
|
case TrackedDataSet.PERCENT_NOT_SUPPLIED:
|
|
- set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.NOT_SUPPLIED), model.getCurIteration());
|
|
|
|
|
|
+ set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.NOT_SUPPLIED),
|
|
|
|
+ model.getCurIteration());
|
|
break;
|
|
break;
|
|
case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
|
|
case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
|
|
- set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.PARTIALLY_SUPPLIED), model.getCurIteration());
|
|
|
|
|
|
+ set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.PARTIALLY_SUPPLIED),
|
|
|
|
+ model.getCurIteration());
|
|
|
|
+ break;
|
|
|
|
+ case TrackedDataSet.GROUP_PRODUCTION:
|
|
|
|
+ val = getTotalProductionAt(((CpsUpperNode) set.getCpsObject()).getNodes(),model.getCurIteration());
|
|
|
|
+ break;
|
|
|
|
+ case TrackedDataSet.GROUP_CONSUMPTION:
|
|
|
|
+ val = getTotalConsumptionAt(((CpsUpperNode) set.getCpsObject()).getNodes(),model.getCurIteration());
|
|
|
|
+ controller.addTextToConsole(val+"");
|
|
|
|
+ val *= -1;
|
|
|
|
+ break;
|
|
|
|
+ case TrackedDataSet.AMOUNT_SUBNETS:
|
|
|
|
+ set.setValAt(controller.getSimManager().getSubNets().size(), model.getCurIteration());
|
|
break;
|
|
break;
|
|
|
|
+
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -347,7 +381,7 @@ public class StatisticGraph extends JPanel {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* create Path for percent values
|
|
* create Path for percent values
|
|
*
|
|
*
|
|
@@ -358,13 +392,14 @@ public class StatisticGraph extends JPanel {
|
|
path.moveTo(0, 0);
|
|
path.moveTo(0, 0);
|
|
for (int i = 0; i < model.getCurIteration(); i++) {
|
|
for (int i = 0; i < model.getCurIteration(); i++) {
|
|
if (init && set.getValues()[i] != -1) {
|
|
if (init && set.getValues()[i] != -1) {
|
|
- path.moveTo(i * this.getWidth() / model.getIterations() - 1, convertToCanvasY(set.getValues()[i]*maximum));
|
|
|
|
|
|
+ path.moveTo(i * this.getWidth() / model.getIterations() - 1,
|
|
|
|
+ convertToCanvasY(set.getValues()[i] * maximum));
|
|
init = false;
|
|
init = false;
|
|
}
|
|
}
|
|
if (!init) {
|
|
if (!init) {
|
|
if (set.getValues()[i + 1] != -1) {
|
|
if (set.getValues()[i + 1] != -1) {
|
|
path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
|
|
path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
|
|
- convertToCanvasY(set.getValues()[i + 1]*maximum));
|
|
|
|
|
|
+ convertToCanvasY(set.getValues()[i + 1] * maximum));
|
|
} else {
|
|
} else {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -372,18 +407,19 @@ public class StatisticGraph extends JPanel {
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* get the max total production of the given Objects
|
|
* get the max total production of the given Objects
|
|
*
|
|
*
|
|
- * @param objects List of Objects
|
|
|
|
|
|
+ * @param objects
|
|
|
|
+ * List of Objects
|
|
*/
|
|
*/
|
|
private float getMaxTotalProduction(ArrayList<AbstractCpsObject> objects) {
|
|
private float getMaxTotalProduction(ArrayList<AbstractCpsObject> objects) {
|
|
float val = 0;
|
|
float val = 0;
|
|
-
|
|
|
|
- for (AbstractCpsObject obj: objects) {
|
|
|
|
|
|
+
|
|
|
|
+ for (AbstractCpsObject obj : objects) {
|
|
if (obj instanceof HolonObject) {
|
|
if (obj instanceof HolonObject) {
|
|
- for (HolonElement ele: ((HolonObject) obj).getElements()) {
|
|
|
|
|
|
+ for (HolonElement ele : ((HolonObject) obj).getElements()) {
|
|
if (ele.getEnergy() > 0) {
|
|
if (ele.getEnergy() > 0) {
|
|
val += ele.getEnergy() * ele.getAmount();
|
|
val += ele.getEnergy() * ele.getAmount();
|
|
}
|
|
}
|
|
@@ -394,18 +430,19 @@ public class StatisticGraph extends JPanel {
|
|
}
|
|
}
|
|
return val;
|
|
return val;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* get the max total consumption of the given Objects
|
|
* get the max total consumption of the given Objects
|
|
*
|
|
*
|
|
- * @param objects List of Objects
|
|
|
|
|
|
+ * @param objects
|
|
|
|
+ * List of Objects
|
|
*/
|
|
*/
|
|
private float getMaxTotalConsumption(ArrayList<AbstractCpsObject> objects) {
|
|
private float getMaxTotalConsumption(ArrayList<AbstractCpsObject> objects) {
|
|
float val = 0;
|
|
float val = 0;
|
|
-
|
|
|
|
- for (AbstractCpsObject obj: objects) {
|
|
|
|
|
|
+
|
|
|
|
+ for (AbstractCpsObject obj : objects) {
|
|
if (obj instanceof HolonObject) {
|
|
if (obj instanceof HolonObject) {
|
|
- for (HolonElement ele: ((HolonObject) obj).getElements()) {
|
|
|
|
|
|
+ for (HolonElement ele : ((HolonObject) obj).getElements()) {
|
|
if (ele.getEnergy() < 0) {
|
|
if (ele.getEnergy() < 0) {
|
|
val += ele.getEnergy() * ele.getAmount();
|
|
val += ele.getEnergy() * ele.getAmount();
|
|
}
|
|
}
|
|
@@ -416,19 +453,20 @@ public class StatisticGraph extends JPanel {
|
|
}
|
|
}
|
|
return val;
|
|
return val;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* get the max total production of the given Objects
|
|
* get the max total production of the given Objects
|
|
*
|
|
*
|
|
- * @param objects List of Objects
|
|
|
|
- * @param tStep
|
|
|
|
|
|
+ * @param objects
|
|
|
|
+ * List of Objects
|
|
|
|
+ * @param tStep
|
|
*/
|
|
*/
|
|
private float getTotalProductionAt(ArrayList<AbstractCpsObject> objects, int tStep) {
|
|
private float getTotalProductionAt(ArrayList<AbstractCpsObject> objects, int tStep) {
|
|
float val = 0;
|
|
float val = 0;
|
|
-
|
|
|
|
- for (AbstractCpsObject obj: objects) {
|
|
|
|
|
|
+
|
|
|
|
+ for (AbstractCpsObject obj : objects) {
|
|
if (obj instanceof HolonObject) {
|
|
if (obj instanceof HolonObject) {
|
|
- for (HolonElement ele: ((HolonObject) obj).getElements()) {
|
|
|
|
|
|
+ for (HolonElement ele : ((HolonObject) obj).getElements()) {
|
|
if (ele.getEnergyAt()[tStep] > 0 && ele.getActive()) {
|
|
if (ele.getEnergyAt()[tStep] > 0 && ele.getActive()) {
|
|
val += ele.getEnergyAt()[tStep] * ele.getAmount();
|
|
val += ele.getEnergyAt()[tStep] * ele.getAmount();
|
|
}
|
|
}
|
|
@@ -439,19 +477,20 @@ public class StatisticGraph extends JPanel {
|
|
}
|
|
}
|
|
return val;
|
|
return val;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* get the total consumption of the given Objects at the given timestep
|
|
* get the total consumption of the given Objects at the given timestep
|
|
*
|
|
*
|
|
- * @param objects List of Objects
|
|
|
|
- * @param tStep
|
|
|
|
|
|
+ * @param objects
|
|
|
|
+ * List of Objects
|
|
|
|
+ * @param tStep
|
|
*/
|
|
*/
|
|
private float getTotalConsumptionAt(ArrayList<AbstractCpsObject> objects, int tStep) {
|
|
private float getTotalConsumptionAt(ArrayList<AbstractCpsObject> objects, int tStep) {
|
|
float val = 0;
|
|
float val = 0;
|
|
-
|
|
|
|
- for (AbstractCpsObject obj: objects) {
|
|
|
|
|
|
+
|
|
|
|
+ for (AbstractCpsObject obj : objects) {
|
|
if (obj instanceof HolonObject) {
|
|
if (obj instanceof HolonObject) {
|
|
- for (HolonElement ele: ((HolonObject) obj).getElements()) {
|
|
|
|
|
|
+ for (HolonElement ele : ((HolonObject) obj).getElements()) {
|
|
if (ele.getEnergyAt()[tStep] < 0 && ele.getActive()) {
|
|
if (ele.getEnergyAt()[tStep] < 0 && ele.getActive()) {
|
|
val += ele.getEnergyAt()[tStep] * ele.getAmount();
|
|
val += ele.getEnergyAt()[tStep] * ele.getAmount();
|
|
}
|
|
}
|
|
@@ -462,18 +501,19 @@ public class StatisticGraph extends JPanel {
|
|
}
|
|
}
|
|
return val;
|
|
return val;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * get the Percentage of how many objects with the given state are in the given List
|
|
|
|
|
|
+ * get the Percentage of how many objects with the given state are in the
|
|
|
|
+ * given List
|
|
*
|
|
*
|
|
- * @param objects List of Objects
|
|
|
|
|
|
+ * @param objects
|
|
|
|
+ * List of Objects
|
|
*/
|
|
*/
|
|
private float getPercentState(ArrayList<AbstractCpsObject> objects, int state) {
|
|
private float getPercentState(ArrayList<AbstractCpsObject> objects, int state) {
|
|
float count = controller.getNumberHolonObjects(objects);
|
|
float count = controller.getNumberHolonObjects(objects);
|
|
- float stateObjectss= controller.getNumberStateObjects(objects, state);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return stateObjectss/count;
|
|
|
|
|
|
+ float stateObjectss = controller.getNumberStateObjects(objects, state);
|
|
|
|
+
|
|
|
|
+ return stateObjectss / count;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|