SubNet.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package classes;
  2. import java.util.ArrayList;
  3. /**
  4. * The class "subNet" represents ....
  5. *
  6. * @author Gruppe14
  7. *
  8. */
  9. public class SubNet {
  10. private ArrayList<HolonObject> subNetObjects;
  11. private ArrayList<CpsEdge> subNetEdges;
  12. private ArrayList<HolonSwitch> subNetSwitches;
  13. /**
  14. * Constructor for a Subnet.
  15. *
  16. * @param objects
  17. * Objects in the Subnet
  18. * @param edges
  19. * Edges in the Subnet
  20. * @param switches
  21. * Switches in the Subnet
  22. */
  23. public SubNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches) {
  24. subNetObjects = objects;
  25. subNetEdges = edges;
  26. subNetSwitches = switches;
  27. }
  28. /**
  29. * Return all Objects in the Subnet.
  30. *
  31. * @return all Objects in the Subnet
  32. */
  33. public ArrayList<HolonObject> getObjects() {
  34. return subNetObjects;
  35. }
  36. /**
  37. * Return all Edges in the Subnet.
  38. *
  39. * @return all Edges in the Subnet
  40. */
  41. public ArrayList<CpsEdge> getEdges() {
  42. return subNetEdges;
  43. }
  44. /**
  45. * Return all Switches in the Subnet.
  46. *
  47. * @return all Switches in the Subnet
  48. */
  49. public ArrayList<HolonSwitch> getSwitches() {
  50. return subNetSwitches;
  51. }
  52. public String toString(int timeStep) {
  53. StringBuilder sb = new StringBuilder();
  54. sb.append(" Objects:");
  55. for (int j = 0; j < getObjects().size(); j++) {
  56. HolonObject hl = getObjects().get(j);
  57. sb.append(" " + hl.getName() + " " + hl.getId());
  58. }
  59. System.out.println(" Edges:");
  60. for (int j = 0; j < getEdges().size(); j++) {
  61. CpsEdge edge = getEdges().get(j);
  62. sb.append(" " + edge.getA().getName() + " connected To " + edge.getB().getName());
  63. }
  64. System.out.println(" Switches:");
  65. for (int j = 0; j < getSwitches().size(); j++) {
  66. HolonSwitch sw = getSwitches().get(j);
  67. sb.append(" " + sw.getName() + " " + sw.getId() + " State:" + sw.getActiveAt()[timeStep]);
  68. }
  69. return sb.toString();
  70. }
  71. public String toString() {
  72. StringBuilder sb = new StringBuilder();
  73. sb.append(" Objects:");
  74. for (int j = 0; j < getObjects().size(); j++) {
  75. HolonObject hl = getObjects().get(j);
  76. sb.append(" " + hl.getName() + " " + hl.getId());
  77. }
  78. System.out.println(" Edges:");
  79. for (int j = 0; j < getEdges().size(); j++) {
  80. CpsEdge edge = getEdges().get(j);
  81. sb.append(" " + edge.getA().getName() + " connected To " + edge.getB().getName());
  82. }
  83. System.out.println(" Switches:");
  84. for (int j = 0; j < getSwitches().size(); j++) {
  85. HolonSwitch sw = getSwitches().get(j);
  86. sb.append(" " + sw.getName() + " " + sw.getId() + " State:" + sw.getActiveAt());
  87. }
  88. return sb.toString();
  89. }
  90. }