Browse Source

Adds In-/ActiveSwitches in InformationPanel

amountHolon fix
Tom Troppmann 4 years ago
parent
commit
43da451e72

+ 20 - 8
src/exampleAlgorithms/InformationPanel.java

@@ -30,6 +30,7 @@ import ui.controller.FlexManager.FlexWrapper;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedState;
+import ui.model.DecoratedSwitch.SwitchState;
 import ui.model.VisualRepresentationalState;
 
 public class InformationPanel implements AddOn {
@@ -41,6 +42,8 @@ public class InformationPanel implements AddOn {
 	
 	//Fields
 	private int amountSwitch;
+	private int amountActiveSwitch;
+	private int amountInactiveSwitch;
 	private int amountHolonObjects;
 		private int amountConsumer;
 			private int	amountUnderSupplied;
@@ -67,9 +70,8 @@ public class InformationPanel implements AddOn {
 		private int amountProducingFlexibilities;
 	private int amountPassiv;
 		
+	private int amountGroupNodes;
 	private int amountHolons;
-	private float averageConsumption;
-	private float averageProduction;
 	
 	List<Entry> entryList = new ArrayList<Entry>();
 
@@ -82,6 +84,8 @@ public class InformationPanel implements AddOn {
 
 
 
+
+
 	
 	
 	public InformationPanel(){
@@ -124,6 +128,9 @@ public class InformationPanel implements AddOn {
 		entryList.add(new Entry(() -> Integer.toString(amountPassiv) + addPercentage(amountPassiv, amountHolonObjects), "\tamountPassiv", middle));
 		addSeperator(middle);
 		entryList.add(new Entry(() -> Integer.toString(amountSwitch), "amountSwitch (not a HolonObject)", middle));
+		entryList.add(new Entry(() -> Integer.toString(amountActiveSwitch) + addPercentage(amountActiveSwitch, amountSwitch), "\tamountActiveSwitch", middle));
+		entryList.add(new Entry(() -> Integer.toString(amountInactiveSwitch) + addPercentage(amountInactiveSwitch, amountSwitch), "\tamountInactiveSwitch", middle));
+		
 		addSeperator(middle);
 		entryList.add(new Entry(() -> Integer.toString(amountHolonElements), "amountHolonElements", middle));
 		entryList.add(new Entry(() -> Integer.toString(amountActiveHolonElements) + addPercentage(amountActiveHolonElements, amountHolonElements), "\tamountActiveHolonElements", middle));
@@ -146,10 +153,8 @@ public class InformationPanel implements AddOn {
 		entryList.add(new Entry(() -> Integer.toString(amountActiveHigh) + addPercentage(amountActiveHigh, amountActiveFlexibilities), "\tamountActiveHigh", middle));
 		entryList.add(new Entry(() -> Integer.toString(amountActiveEssential) + addPercentage(amountActiveEssential, amountActiveFlexibilities), "\tamountActiveEssential", middle));
 		addSeperator(middle);
+		entryList.add(new Entry(() -> Integer.toString(amountGroupNodes), "amountGroupNodes", middle));
 		entryList.add(new Entry(() -> Integer.toString(amountHolons), "amountHolons", middle));
-		addSeperator(middle);
-		entryList.add(new Entry(() -> String.format (Locale.US, "%.2f", averageConsumption), "averageConsumption", middle));
-		entryList.add(new Entry(() -> String.format (Locale.US, "%.2f", averageProduction), "averageProduction", middle));
 		
 		return middle;
 	}
@@ -193,6 +198,8 @@ public class InformationPanel implements AddOn {
 		DecoratedState dState = control.getSimManager().getActualDecorState();
 		amountConsumer = dState.getNetworkList().stream().map(net -> net.getAmountOfConsumer()).reduce(0, Integer::sum);
 		this.amountSwitch = dState.getDecoratedSwitches().size();
+		amountActiveSwitch = (int)dState.getDecoratedSwitches().stream().filter(dswitch -> (dswitch.getState() == SwitchState.Closed)).count();
+		amountInactiveSwitch = amountSwitch - amountActiveSwitch;
 		this.amountUnderSupplied = dState.getNetworkList().stream().map(net -> net.getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED)).reduce(0, Integer::sum);
 		this.amountPatiallySupplied = dState.getNetworkList().stream().map(net -> net.getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED)).reduce(0, Integer::sum);
 		this.amountFullySupplied = dState.getNetworkList().stream().map(net -> net.getAmountOfConsumerWithState(HolonObjectState.SUPPLIED)).reduce(0, Integer::sum);
@@ -234,9 +241,14 @@ public class InformationPanel implements AddOn {
 		amountActiveLow = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low).count();
 		this.amountActiveFlexibilities = amountActiveEssential + amountActiveHigh + amountActiveMedium + amountActiveLow;
 		VisualRepresentationalState visualState =control.getSimManager().getActualVisualRepresentationalState();
-		amountHolons = visualState.getAmountOfHolons();
-		averageConsumption =  visualState.getAverageConsumption();
-		averageProduction =  visualState.getAverageProduction();
+		amountGroupNodes = visualState.getAmountOfHolons();
+		
+		
+		amountHolons = dState.getNetworkList().size();
+		
+		
+		
+		
 		int cost = 0;
 		int consumingFlex = 0;
 		float consumingFlexEnergy = 0.0f;

+ 4 - 4
src/ui/model/DecoratedGroupNode.java

@@ -76,8 +76,8 @@ public class DecoratedGroupNode {
 	
 	
 	//Returns the amount of holons and count himself 
-	public int getAmountOfHolons() {
-		return 1 + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfHolons()).reduce(0, Integer::sum);
+	public int getAmountOfGroupNodes() {
+		return 1 + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfGroupNodes()).reduce(0, Integer::sum);
 	}
 	
 	
@@ -119,10 +119,10 @@ public class DecoratedGroupNode {
 	}
 	
 	public float getAverageConsumption() {
-		return getConsumptionFromConsumer() / (float)getAmountOfHolons();
+		return getConsumptionFromConsumer() / (float)getAmountOfGroupNodes();
 	}
 	public float getAverageProduction() {
-		return getProductionFromSupplier() / (float)getAmountOfHolons();
+		return getProductionFromSupplier() / (float)getAmountOfGroupNodes();
 	}
 	
 	

+ 1 - 1
src/ui/model/VisualRepresentationalState.java

@@ -279,7 +279,7 @@ public class VisualRepresentationalState {
 	
 	
 	public int getAmountOfHolons() {
-		return 1 + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfHolons()).reduce(0, Integer::sum);
+		return groupNodeList.stream().map(groupNode -> groupNode.getAmountOfGroupNodes()).reduce(0, Integer::sum);
 	}