Model.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
  2. import java.util.LinkedList;
  3. import java.util.List;
  4. import java.util.Observable;
  5. /**
  6. * Model of the smart home, which contains all the important parts of the simulation, like {@link SmartDevice} and their {@link Link}.
  7. *
  8. * @author Andreas T. Meyer-Berg
  9. */
  10. public class Model extends Observable{
  11. private List<SmartDevice> devices;
  12. private List<Link> connectionNetworks;
  13. private List<Connection> connections;
  14. /**
  15. * Width of the smart home model, 0 <= device.x < width
  16. */
  17. private int width;
  18. /**
  19. * Height of the smart home model, 0 <= device.y < height
  20. */
  21. private int height;
  22. /**
  23. * Depth of the smart home model, 0 <= device.y < depth
  24. */
  25. private int depth;
  26. /**
  27. * Simulation Manager which allows simulation of this model
  28. */
  29. private SimulationManager sim;
  30. /**
  31. * Configurations of the Program
  32. */
  33. private ConfigurationManager config;
  34. /**
  35. * Initializes the Model, with 3 default devices for testing purposes
  36. */
  37. public Model() {
  38. setSim(new SimulationManager(this));
  39. setWidth(640);
  40. setHeight(480);
  41. setDepth(480);
  42. config = new ConfigurationManager();
  43. devices = new LinkedList<SmartDevice>();
  44. connectionNetworks = new LinkedList<Link>();
  45. connections = new LinkedList<Connection>();
  46. }
  47. /**
  48. * @return the connectionNetworks
  49. */
  50. public List<Link> getConnectionNetworks() {
  51. return connectionNetworks;
  52. }
  53. /**
  54. * Adds network connection
  55. * @param connectionNetwork the connectionNetwork to add
  56. */
  57. public void addConnectionNetwork(Link connectionNetwork) {
  58. this.connectionNetworks.add(connectionNetwork);
  59. }
  60. /**
  61. * @return the devices
  62. */
  63. public List<SmartDevice> getDevices() {
  64. return devices;
  65. }
  66. /**
  67. * @param device the smartDevice to add to the smart home
  68. */
  69. public void addDevices(SmartDevice device) {
  70. this.devices.add(device);
  71. }
  72. /**
  73. * @return the width
  74. */
  75. public int getWidth() {
  76. return width;
  77. }
  78. /**
  79. * @param width the width to set
  80. */
  81. public void setWidth(int width) {
  82. this.width = width;
  83. }
  84. /**
  85. * @return the height
  86. */
  87. public int getHeight() {
  88. return height;
  89. }
  90. /**
  91. * @param height the height to set
  92. */
  93. public void setHeight(int height) {
  94. this.height = height;
  95. }
  96. /**
  97. * @return the depth
  98. */
  99. public int getDepth() {
  100. return depth;
  101. }
  102. /**
  103. * @param depth the depth to set
  104. */
  105. public void setDepth(int depth) {
  106. this.depth = depth;
  107. }
  108. /**
  109. * @return the connections
  110. */
  111. public List<Connection> getConnections() {
  112. return connections;
  113. }
  114. /**
  115. * @param connection the connection to add
  116. */
  117. public void addConnection(Connection connection) {
  118. this.connections.add(connection);
  119. }
  120. public void setChanged(){
  121. super.setChanged();
  122. }
  123. /**
  124. * @return the sim
  125. */
  126. public SimulationManager getSim() {
  127. return sim;
  128. }
  129. /**
  130. * @param sim the sim to set
  131. */
  132. public void setSim(SimulationManager sim) {
  133. this.sim = sim;
  134. }
  135. /**
  136. * @return the configurations
  137. */
  138. public ConfigurationManager getConfigurator() {
  139. return config;
  140. }
  141. }