123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- package ui.model;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collector;
- import java.util.stream.Collectors;
- import classes.CpsNode;
- import classes.CpsUpperNode;
- import classes.IntermediateCalculationCable;
- import ui.model.DecoratedHolonObject.HolonObjectState;
- import classes.ExitCable;
- /**
- * For the @VisualRepresentationalState only.
- * @author Tom
- *
- */
- public class DecoratedGroupNode {
- private CpsUpperNode model;
- private ArrayList<Supplier> supplierList;
- private ArrayList<Passiv> passivList;
- private ArrayList<Consumer> consumerList;
- private ArrayList<CpsNode> nodeList;
- /**
- * Cables that only exist on that group node. From a object in that group node to a object in that group Node.
- * Not exit the group node (a layer down).
- */
- private ArrayList<DecoratedCable> internCableList;
- /**
- * Cables that exit this group node (a Layer Up). From a object in this group node to a object in a upper layer.
- */
- private ArrayList<ExitCable> exitCableList;
- private ArrayList<DecoratedSwitch> switchList;
- private ArrayList<DecoratedGroupNode> groupNodeList;
- public DecoratedGroupNode(CpsUpperNode model) {
- this.model = model;
- this.supplierList = new ArrayList<Supplier>();
- this.passivList = new ArrayList<Passiv>();
- this.consumerList = new ArrayList<Consumer>();
- this.nodeList = new ArrayList<CpsNode>();
- this.internCableList = new ArrayList<DecoratedCable>();
- this.exitCableList = new ArrayList<ExitCable>();
- this.switchList = new ArrayList<DecoratedSwitch>();
- this.groupNodeList = new ArrayList<DecoratedGroupNode>();
- }
- public CpsUpperNode getModel() {
- return model;
- }
- public ArrayList<Supplier> getSupplierList() {
- return supplierList;
- }
- public ArrayList<Passiv> getPassivList() {
- return passivList;
- }
- public ArrayList<Consumer> getConsumerList() {
- return consumerList;
- }
- public ArrayList<CpsNode> getNodeList() {
- return nodeList;
- }
- public ArrayList<DecoratedCable> getInternCableList() {
- return internCableList;
- }
- public ArrayList<ExitCable> getExitCableList() {
- return exitCableList;
- }
- public ArrayList<DecoratedSwitch> getSwitchList() {
- return switchList;
- }
- public ArrayList<DecoratedGroupNode> getGroupNodeList() {
- return groupNodeList;
- }
-
- //Gather Informations:
- public int getAmountOfSupplier() {
- return supplierList.size() + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfSupplier()).reduce(0, (a,b)->a+b);
- }
- public int getAmountOfConsumer() {
- return consumerList.size() + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfConsumer()).reduce(0, (a,b)->a+b);
- }
- public int getAmountOfPassiv() {
- return passivList.size() + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfPassiv()).reduce(0, (a,b)->a+b);
- }
-
- public int getAmountOfConsumerWithState(HolonObjectState state) {
- return ((int) consumerList.stream().map(con -> con.getState()).filter(rightState -> (rightState == state)).count()) + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfConsumerWithState(state)).reduce(0, (a,b)->a+b);
- }
-
- public int getAmountOfElemntsFromHolonObjects() {
- return passivList.stream().map(object -> object.getModel().getElements().size()).reduce(0, (a, b) -> a + b)+
- supplierList.stream().map(object -> object.getModel().getElements().size()).reduce(0, (a, b) -> a + b)+
- consumerList.stream().map(object -> object.getModel().getElements().size()).reduce(0, (a, b) -> a + b)+
- groupNodeList.stream().map(groupNode -> groupNode.getAmountOfElemntsFromHolonObjects()).reduce(0, (a,b)->a+b);
- }
- public int getAmountOfAktiveElemntsFromHolonObjects() {
- return passivList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, (a, b) -> a + b)+
- supplierList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, (a, b) -> a + b)+
- consumerList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, (a, b) -> a + b)+
- groupNodeList.stream().map(groupNode -> groupNode.getAmountOfAktiveElemntsFromHolonObjects()).reduce(0, (a,b)->a+b);
- }
- public float getConsumptionFromConsumer() {
- return consumerList.stream().map(con -> con.getEnergyNeededFromNetwork()).reduce(0.f, (a, b) -> a + b)+
- groupNodeList.stream().map(groupNode -> groupNode.getConsumptionFromConsumer()).reduce(0.f, (a,b)->a+b);
- }
- public float getProductionFromSupplier() {
- return supplierList.stream().map(sup -> sup.getEnergyToSupplyNetwork()).reduce(0.f, (a, b) -> a + b)+
- groupNodeList.stream().map(groupNode -> groupNode.getProductionFromSupplier()).reduce(0.f, (a,b)->a+b);
- }
-
-
-
-
-
- public String toString() {
- return
- "GroupNode" + model.getId() + " with [Supplier:" + getAmountOfSupplier()
- + ", NotSupplied:" + getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED)
- + ", PartiallySupplied:" + getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED)
- + ", Supplied:" + getAmountOfConsumerWithState(HolonObjectState.SUPPLIED)
- + ", OverSupplied:" + getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED)
- + ", Passiv:"+ getAmountOfPassiv() + "]";
- }
- }
|