ImportConfiguration.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration;
  2. import java.util.LinkedList;
  3. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
  4. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPerformance;
  5. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPrecision;
  6. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
  7. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PrecisionLink;
  8. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
  9. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
  10. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolCollectorDevice;
  11. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolSensorDevice;
  12. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatCollectorDevice;
  13. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatSensorDevice;
  14. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.MQTT_protocol;
  15. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.Ping_protocol;
  16. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;
  17. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleMQTT;
  18. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
  19. /**
  20. * Class which stores the different imported classes
  21. *
  22. * @author Andreas T. Meyer-Berg
  23. */
  24. public class ImportConfiguration {
  25. /*
  26. * standard classes of the model, and user imported classes
  27. */
  28. private LinkedList<Class<? extends Protocol>> standardProtocols = new LinkedList<Class<? extends Protocol>>();
  29. private LinkedList<Class<? extends Protocol>> importedProtocols = new LinkedList<Class<? extends Protocol>>();
  30. private LinkedList<Class<? extends Link>> standardLinks = new LinkedList<Class<? extends Link>>();
  31. private LinkedList<Class<? extends Link>> importedLinks = new LinkedList<Class<? extends Link>>();
  32. private LinkedList<Class<? extends Connection>> standardConnections = new LinkedList<Class<? extends Connection>>();
  33. private LinkedList<Class<? extends Connection>> importedConnections = new LinkedList<Class<? extends Connection>>();
  34. private LinkedList<Class<? extends SmartDevice>> standardSmartDevices = new LinkedList<Class<? extends SmartDevice>>();
  35. private LinkedList<Class<? extends SmartDevice>> importedSmartDevices = new LinkedList<Class<? extends SmartDevice>>();
  36. /**
  37. * Initializes the configuration and adds the standard classes
  38. */
  39. public ImportConfiguration() {
  40. //Add the default Classes
  41. standardProtocols.add(MQTT_protocol.class);
  42. standardProtocols.add(Ping_protocol.class);
  43. standardProtocols.add(SimpleProtocol.class);
  44. standardProtocols.add(SimpleMQTT.class);
  45. standardLinks.add(SimpleLink.class);
  46. standardLinks.add(PrecisionLink.class);
  47. standardSmartDevices.add(SmartDevice.class);
  48. standardSmartDevices.add(BoolCollectorDevice.class);
  49. standardSmartDevices.add(FloatCollectorDevice.class);
  50. standardSmartDevices.add(BoolSensorDevice.class);
  51. standardSmartDevices.add(FloatSensorDevice.class);
  52. standardConnections.add(ConnectionPerformance.class);
  53. standardConnections.add(ConnectionPrecision.class);
  54. }
  55. /**
  56. * Returns Protocol Classes of the Model
  57. * @return available Protocol Classes
  58. */
  59. public LinkedList<Class<? extends Protocol>> getProtocolClasses(){
  60. LinkedList<Class<? extends Protocol>> export = new LinkedList<Class<? extends Protocol>>();
  61. export.addAll(standardProtocols);
  62. export.addAll(importedProtocols);
  63. return export;
  64. }
  65. /**
  66. * Adds newProtocol to the available protocol classes
  67. * @param newProtocol new Protocol Class to be added
  68. */
  69. public void addProtocolClass(Class<? extends Protocol> newProtocol){
  70. importedProtocols.add(newProtocol);
  71. }
  72. /**
  73. * Removes Protocol from the available protocol classes
  74. * @param remove protocol to be removed
  75. */
  76. public void removeProtocolClass(Class<? extends Protocol> remove){
  77. importedProtocols.remove(remove);
  78. }
  79. /**
  80. * Returns Link Classes of the Model
  81. * @return available Link classes
  82. */
  83. public LinkedList<Class<? extends Link>> getLinkClasses(){
  84. LinkedList<Class<? extends Link>> export = new LinkedList<Class<? extends Link>>();
  85. export.addAll(standardLinks);
  86. export.addAll(importedLinks);
  87. return export;
  88. }
  89. /**
  90. * Adds newLink to the available Link classes
  91. * @param newLink new Link class to be added
  92. */
  93. public void addLinkClass(Class<? extends Link> newLink){
  94. importedLinks.add(newLink);
  95. }
  96. /**
  97. * Removes Link from the available Link classes
  98. * @param remove Link Class to be removed
  99. */
  100. public void removeLinkClass(Class<? extends Link> remove){
  101. importedLinks.remove(remove);
  102. }
  103. /**
  104. * Returns Connection Classes of the Model
  105. * @return available Connections classes
  106. */
  107. public LinkedList<Class<? extends Connection>> getConnectionClasses(){
  108. LinkedList<Class<? extends Connection>> export = new LinkedList<Class<? extends Connection>>();
  109. export.addAll(standardConnections);
  110. export.addAll(importedConnections);
  111. return export;
  112. }
  113. /**
  114. * Adds Connection Class to the available Connection Classes
  115. * @param newConnection new Connection to be added
  116. */
  117. public void addConnectionClass(Class<? extends Connection> newConnection){
  118. importedConnections.add(newConnection);
  119. }
  120. /**
  121. * Removes Connection Class from the available Connection Classes
  122. * @param remove Connection Class to be removed
  123. */
  124. public void removeConnectionClass(Class<? extends Connection> remove){
  125. importedConnections.remove(remove);
  126. }
  127. /**
  128. * Returns SmartDevice Classes of the Model
  129. * @return available SmartDevice Classes
  130. */
  131. public LinkedList<Class<? extends SmartDevice>> getSmartDeviceClasses(){
  132. LinkedList<Class<? extends SmartDevice>> export = new LinkedList<Class<? extends SmartDevice>>();
  133. export.addAll(standardSmartDevices);
  134. export.addAll(importedSmartDevices);
  135. return export;
  136. }
  137. /**
  138. * Adds newSmartDevice Class to the available SmartDevice Classes
  139. * @param newSmartDevice new SmartDevice Class to be added
  140. */
  141. public void addSmartDeviceClass(Class<? extends SmartDevice> newSmartDevice){
  142. importedSmartDevices.add(newSmartDevice);
  143. }
  144. /**
  145. * Removes SmartDevice Class from the available SmartDevice Classes
  146. * @param remove SmartDevice Class to be removed
  147. */
  148. public void removeSmartDeviceClass(Class<? extends SmartDevice> remove){
  149. importedSmartDevices.remove(remove);
  150. }
  151. }