123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- package classes;
- import java.util.ArrayList;
- /**
- * The class "subNet" represents ....
- *
- * @author Gruppe14
- *
- */
- public class SubNet {
- private ArrayList<HolonObject> subNetObjects;
- private ArrayList<CpsEdge> subNetEdges;
- private ArrayList<HolonSwitch> subNetSwitches;
- private ArrayList<HolonBattery> subNetBatteries;
- /**
- * Constructor for a Subnet.
- *
- * @param objects
- * Objects in the Subnet
- * @param edges
- * Edges in the Subnet
- * @param switches
- * Switches in the Subnet
- */
- public SubNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches, ArrayList<HolonBattery> batteries) {
- subNetObjects = objects;
- subNetEdges = edges;
- subNetSwitches = switches;
- subNetBatteries = batteries;
- }
- /**
- * Return all Objects in the Subnet.
- *
- * @return all Objects in the Subnet
- */
- public ArrayList<HolonObject> getObjects() {
- return subNetObjects;
- }
- /**
- * Return all Edges in the Subnet.
- *
- * @return all Edges in the Subnet
- */
- public ArrayList<CpsEdge> getEdges() {
- return subNetEdges;
- }
- /**
- * Return all Switches in the Subnet.
- *
- * @return all Switches in the Subnet
- */
- public ArrayList<HolonSwitch> getSwitches() {
- return subNetSwitches;
- }
- public ArrayList<HolonBattery> getBatteries() {
- return subNetBatteries;
- }
- public String toString(int timeStep) {
- StringBuilder sb = new StringBuilder();
- sb.append(" Objects:");
- for (int j = 0; j < getObjects().size(); j++) {
- HolonObject hl = getObjects().get(j);
- sb.append(" " + hl.getName() + " " + hl.getId());
- }
- sb.append(" Edges:");
- for (int j = 0; j < getEdges().size(); j++) {
- CpsEdge edge = getEdges().get(j);
- sb.append(" " + edge.getA().getName() + " connected To " + edge.getB().getName());
- }
- sb.append(" Switches:");
- for (int j = 0; j < getSwitches().size(); j++) {
- HolonSwitch sw = getSwitches().get(j);
- sb.append(" " + sw.getName() + " " + sw.getId() + " State:" + sw.getState(timeStep));
- }
- return sb.toString();
- }
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("\nObjects:");
- for (HolonObject hl: getObjects()) {
- sb.append(" " + hl.getName() + "[ID:" + hl.getId()+ "]");
- }
- sb.append("\nEdges:");
- for (CpsEdge edge :getEdges()) {
- sb.append(" " + edge.getA().getName() + " connected To " + edge.getB().getName());
- }
- sb.append("\nSwitches:");
- for (HolonSwitch sw : getSwitches()) {
- sb.append(" " + sw.getName() + "[ID:" + sw.getId()+ "]");
- }
- sb.append("\nBatteries:");
- for (HolonBattery hB: getBatteries()) {
- sb.append(" " + hB.getName() + "[ID:" + hB.getId()+ "]");
- }
- return sb.toString();
- }
- }
|