ImportConfiguration.java 8.5 KB

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