ImportConfiguration.java 8.3 KB

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