Browse Source

Added code for statistic Table properties (20,21,22,23)

Kevin Trometer 7 years ago
parent
commit
df613fff75

+ 1 - 1
src/classes/TrackedDataSet.java

@@ -27,7 +27,7 @@ public class TrackedDataSet {
 	public static final int AVG_WASTED_ENERGY_IN_HOLONS = 17;
 	public static final int AMOUNT_BROKEN_EDGES = 18;
 	public static final int RATIO_PRODUCERS_CONSUMERS = 19;
-	public static final int AMOUNT_CLOSED_SWITCHES_IN_HOLONS = 20;
+	public static final int AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS = 20;
 	public static final int AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS = 21;
 	public static final int AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS = 22;
 	public static final int AVG_PRODUCED_ENERGY_IN_HOLONS = 23;

+ 65 - 2
src/ui/view/StatisticGraph.java

@@ -114,6 +114,10 @@ public class StatisticGraph extends JPanel {
 				case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
 				case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
 				case TrackedDataSet.AMOUNT_BROKEN_EDGES:
+				case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
+				case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
+				case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
+				case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
 					createPathFloats(set);
 					break;
 				case TrackedDataSet.ON_OFF:
@@ -251,6 +255,8 @@ public class StatisticGraph extends JPanel {
 				}
 				break;
 			case TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS:
+			case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
+			case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
 				float eCount = 0;
 				for (SubNet sub : controller.getSimManager().getSubNets()) {
 					for (HolonObject obj : sub.getObjects()) {
@@ -293,6 +299,22 @@ public class StatisticGraph extends JPanel {
 			case TrackedDataSet.RATIO_PRODUCERS_CONSUMERS:
 				val = 1;
 				break;
+			case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					float tempVal = sub.getSwitches().size();
+					if (val < tempVal) {
+						val = tempVal;
+					}
+				}
+				break;
+			case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					float tempVal = getMaxTotalProduction(new ArrayList<AbstractCpsObject>(sub.getObjects()));
+					if (val < tempVal) {
+						val = tempVal;
+					}
+				}
+				break;
 			default:
 				maximum = 0;
 				break;
@@ -454,12 +476,53 @@ public class StatisticGraph extends JPanel {
 					for (HolonObject obj : sub.getObjects()) {
 						if (obj.getCurrentEnergyAtTimeStep(model.getCurIteration()) > 0) {
 							prod++;
-						} else if(obj.getCurrentEnergyAtTimeStep(model.getCurIteration()) < 0) {
+						} else if (obj.getCurrentEnergyAtTimeStep(model.getCurIteration()) < 0) {
 							cons++;
 						}
 					}
 				}
-				val = prod/(prod+cons);
+				val = prod / (prod + cons);
+				set.setValAt(val, model.getCurIteration());
+				break;
+			case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					val += sub.getSwitches().size();
+				}
+				val /=controller.getSimManager().getSubNets().size();
+				set.setValAt(val, model.getCurIteration());
+				break;
+			case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					for (HolonObject obj : sub.getObjects()) {
+						for (HolonElement ele: obj.getElements()) {
+							if (ele.getActive()) {
+								val++;
+							}
+						}
+					}
+				}
+				val /= controller.getSimManager().getSubNets().size();
+				set.setValAt(val, model.getCurIteration());
+				break;
+			case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					for (HolonObject obj : sub.getObjects()) {
+						for (HolonElement ele: obj.getElements()) {
+							if (!ele.getActive()) {
+								val++;
+							}
+						}
+					}
+				}
+				val /= controller.getSimManager().getSubNets().size();
+				set.setValAt(val, model.getCurIteration());
+				break;
+			case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
+				for (SubNet sub : controller.getSimManager().getSubNets()) {
+					val += getTotalProductionAt(new ArrayList<AbstractCpsObject>(sub.getObjects()),
+							model.getCurIteration());
+				}
+				val /= controller.getSimManager().getSubNets().size();
 				set.setValAt(val, model.getCurIteration());
 				break;
 			default:

+ 37 - 1
src/ui/view/StatisticGraphPanel.java

@@ -189,7 +189,43 @@ public class StatisticGraphPanel extends JPanel {
 			property = "Percentage of partial supplied";
 			break;
 		case TrackedDataSet.AMOUNT_HOLONS:
-			property = "Amount of Subnets";
+			property = "Amount of holons";
+			break;
+		case TrackedDataSet.AMOUNT_CLOSED_SWITCHES:
+			property = "Amount of Closed Switches";
+			break;
+		case TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS:
+			property = "Avg. Amount of Objects in Holons";
+			break;
+		case TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS:
+			property = "Avg. Amount of Elements in Holons";
+			break;
+		case TrackedDataSet.AVG_AMOUNT_PRODUCERS_IN_HOLONS:
+			property = "Avg. Amount Producers in Holons";
+			break;
+		case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
+			property = "Avg. Consumed Energy in Holons";
+			break;
+		case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
+			property = "Avg. Wasted Energy in Holons";
+			break;
+		case TrackedDataSet.AMOUNT_BROKEN_EDGES:
+			property = "Amount of Broken Edged";
+			break;
+		case TrackedDataSet.RATIO_PRODUCERS_CONSUMERS:
+			property = "Ratio Producers:Consumers";
+			break;
+		case TrackedDataSet.AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS:
+			property = "Avg. Amount of Closed Switches in Holons";
+			break;
+		case TrackedDataSet.AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS:
+			property = "Avg. Amount of Active Elements in Holons";
+			break;
+		case TrackedDataSet.AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS:
+			property = "Avg. Amount of Inactive Elements in Holons";
+			break;
+		case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
+			property = "Avg. Produced Energy in Holons";
 			break;
 		default:
 			property = "null";