فهرست منبع

Adds ImportConfiguration, adds new ConnectionPrecision to config

Andreas T. Meyer-Berg 5 سال پیش
والد
کامیت
dd3ae84ad8

+ 1 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/ConfigurationController.java

@@ -36,6 +36,7 @@ public class ConfigurationController {
 	public ConfigurationManager getConfigurationManager(){
 		return model.getConfigurator();
 	}
+	
 	/**
 	 * @return the showConnections
 	 */

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/Controller.java

@@ -40,8 +40,8 @@ public class Controller {
 	 */
 	public Controller(Model model) {
 		this.model = model;
-		importController = new ImportController(this.model, this);
 		configurationController = new ConfigurationController(this.model, this);
+		importController = new ImportController(this.model, this);
 	}
 	
 	/**

+ 15 - 12
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/ImportController.java

@@ -12,6 +12,7 @@ import java.util.LinkedList;
 import javax.tools.JavaCompiler;
 import javax.tools.ToolProvider;
 
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ImportConfiguration;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
@@ -26,6 +27,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
 public class ImportController {
 	Model model;
 	Controller controller;
+	ImportConfiguration importConf;
 
 	/**
 	 * Creates a new ImportController
@@ -38,6 +40,7 @@ public class ImportController {
 	public ImportController(Model model, Controller controller) {
 		this.model = model;
 		this.controller = controller;
+		this.importConf = controller.getControllerConfiguration().getConfigurationManager().getImportConfiguration();
 	}
 
 	/**
@@ -49,7 +52,7 @@ public class ImportController {
 	 */
 	public boolean addLink(Class<? extends Link> Link) {
 		if (isValidLink(Link))
-			model.addLinkClass(Link);
+			importConf.addLinkClass(Link);
 		else
 			return false;
 		return true;
@@ -63,7 +66,7 @@ public class ImportController {
 	 *            Link to be removed
 	 */
 	public void removeLink(Class<? extends Link> Link) {
-		model.removeLinkClass(Link);
+		importConf.removeLinkClass(Link);
 	}
 	
 	/**
@@ -72,7 +75,7 @@ public class ImportController {
 	 * @return available links
 	 */
 	public LinkedList<Class<? extends Link>> getLinks() {
-		return model.getLinkClasses();
+		return importConf.getLinkClasses();
 	}
 	
 	/**
@@ -110,7 +113,7 @@ public class ImportController {
 	 */
 	public boolean addProtocol(Class<? extends Protocol> protocol) {
 		if (isValidProtocol(protocol))
-			model.addProtocolClass(protocol);
+			importConf.addProtocolClass(protocol);
 		else
 			return false;
 		return true;
@@ -124,7 +127,7 @@ public class ImportController {
 	 *            protocol to be removed
 	 */
 	public void removeProtocol(Class<? extends Protocol> protocol) {
-		model.removeProtocolClass(protocol);
+		importConf.removeProtocolClass(protocol);
 	}
 	
 	/**
@@ -133,7 +136,7 @@ public class ImportController {
 	 * @return available protocols
 	 */
 	public LinkedList<Class<? extends Protocol>> getProtocols() {
-		return model.getProtocolClasses();
+		return importConf.getProtocolClasses();
 	}
 	
 	/**
@@ -177,7 +180,7 @@ public class ImportController {
 	 */
 	public boolean addConnection(Class<? extends Connection> connection) {
 		if (isValidConnection(connection))
-			model.addConnectionClass(connection);
+			importConf.addConnectionClass(connection);
 		else
 			return false;
 		return true;
@@ -191,7 +194,7 @@ public class ImportController {
 	 *            Connection to be removed
 	 */
 	public void removeConnection(Class<? extends Connection> connection) {
-		model.removeConnectionClass(connection);
+		importConf.removeConnectionClass(connection);
 	}
 	
 	/**
@@ -200,7 +203,7 @@ public class ImportController {
 	 * @return available Connections
 	 */
 	public LinkedList<Class<? extends Connection>> getConnections() {
-		return model.getConnectionClasses();
+		return importConf.getConnectionClasses();
 	}
 	
 	/**
@@ -238,7 +241,7 @@ public class ImportController {
 	 */
 	public boolean addSmartDevice(Class<? extends SmartDevice> smartDevice) {
 		if (isValidSmartDevice(smartDevice))
-			model.addSmartDeviceClass(smartDevice);
+			importConf.addSmartDeviceClass(smartDevice);
 		else
 			return false;
 		return true;
@@ -252,7 +255,7 @@ public class ImportController {
 	 *            SmartDevice to be removed
 	 */
 	public void removeSmartDevice(Class<? extends SmartDevice> smartDevice) {
-		model.removeSmartDeviceClass(smartDevice);
+		importConf.removeSmartDeviceClass(smartDevice);
 	}
 	
 	/**
@@ -261,7 +264,7 @@ public class ImportController {
 	 * @return available SmartDevices
 	 */
 	public LinkedList<Class<? extends SmartDevice>> getSmartDevices() {
-		return model.getSmartDeviceClasses();
+		return importConf.getSmartDeviceClasses();
 	}
 	
 	/**

+ 15 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/ConfigurationManager.java

@@ -12,11 +12,17 @@ public class ConfigurationManager {
 	 */
 	private VisualizationConfiguration visual;
 	
+	/**
+	 * Import Configuration
+	 */
+	private ImportConfiguration importConf;
+	
 	/**
 	 * Initialize the Configuration Manager
 	 */
 	public ConfigurationManager() {
 		visual = new VisualizationConfiguration();
+		importConf = new ImportConfiguration();
 	}
 
 	/**
@@ -27,4 +33,13 @@ public class ConfigurationManager {
 	public VisualizationConfiguration getVisualizationConfiguration() {
 		return visual;
 	}
+	
+	/**
+	 * Returns the import configuration
+	 * 
+	 * @return the import configuration
+	 */
+	public ImportConfiguration getImportConfiguration(){
+		return importConf;
+	}
 }

+ 157 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/ImportConfiguration.java

@@ -0,0 +1,157 @@
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
+
+import java.util.LinkedList;
+
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.MQTT_protocol;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
+
+/**
+ * Class which stores the different imported classes
+ *
+ * @author Andreas T. Meyer-Berg
+ */
+public class ImportConfiguration {
+	
+
+	/*
+	 * standard classes of the model, and user imported classes 
+	 */
+	private LinkedList<Class<? extends Protocol>> standardProtocols = new LinkedList<Class<? extends Protocol>>();
+	private LinkedList<Class<? extends Protocol>> importedProtocols = new LinkedList<Class<? extends Protocol>>();
+	
+	private LinkedList<Class<? extends Link>> standardLinks = new LinkedList<Class<? extends Link>>();
+	private LinkedList<Class<? extends Link>> importedLinks = new LinkedList<Class<? extends Link>>();
+	
+	private LinkedList<Class<? extends Connection>> standardConnections = new LinkedList<Class<? extends Connection>>();
+	private LinkedList<Class<? extends Connection>> importedConnections = new LinkedList<Class<? extends Connection>>();
+	
+	private LinkedList<Class<? extends SmartDevice>> standardSmartDevices = new LinkedList<Class<? extends SmartDevice>>();
+	private LinkedList<Class<? extends SmartDevice>> importedSmartDevices = new LinkedList<Class<? extends SmartDevice>>();
+	
+	/**
+	 * Initializes the configuration and adds the standard classes
+	 */
+	public ImportConfiguration() {
+		//Add the default Classes
+		standardProtocols.add(MQTT_protocol.class);
+		standardProtocols.add(SimpleProtocol.class);
+		
+		standardLinks.add(SimpleLink.class);
+		
+		standardSmartDevices.add(SmartDevice.class);
+		
+		standardConnections.add(ConnectionPerformance.class);
+		standardConnections.add(ConnectionPrecision.class);
+	}
+	
+	
+	/**
+	 * Returns Protocol Classes of the Model
+	 * @return available Protocol Classes
+	 */
+	public LinkedList<Class<? extends Protocol>> getProtocolClasses(){
+		LinkedList<Class<? extends Protocol>> export = new LinkedList<Class<? extends Protocol>>();
+		export.addAll(standardProtocols);
+		export.addAll(importedProtocols);
+		return export;
+	}
+	
+	/**
+	 * Adds newProtocol to the available protocol classes
+	 * @param newProtocol new Protocol Class to be added
+	 */
+	public void addProtocolClass(Class<? extends Protocol> newProtocol){
+		importedProtocols.add(newProtocol);
+	}
+	
+	/**
+	 * Removes Protocol from the available protocol classes
+	 * @param remove protocol to be removed
+	 */
+	public void removeProtocolClass(Class<? extends Protocol> remove){
+		importedProtocols.remove(remove);
+	}
+	
+	/**
+	 * Returns Link Classes of the Model
+	 * @return available Link classes
+	 */
+	public LinkedList<Class<? extends Link>> getLinkClasses(){
+		LinkedList<Class<? extends Link>> export = new LinkedList<Class<? extends Link>>();
+		export.addAll(standardLinks);
+		export.addAll(importedLinks);
+		return export;
+	}
+	
+	/**
+	 * Adds newLink to the available Link classes
+	 * @param newLink new Link class to be added
+	 */
+	public void addLinkClass(Class<? extends Link> newLink){
+		importedLinks.add(newLink);
+	}
+	
+	/**
+	 * Removes Link from the available Link classes
+	 * @param remove Link Class to be removed
+	 */
+	public void removeLinkClass(Class<? extends Link> remove){
+		importedLinks.remove(remove);
+	}
+	
+	/**
+	 * Returns Connection Classes of the Model
+	 * @return available Connections classes
+	 */
+	public LinkedList<Class<? extends Connection>> getConnectionClasses(){
+		LinkedList<Class<? extends Connection>> export = new LinkedList<Class<? extends Connection>>();
+		export.addAll(standardConnections);
+		export.addAll(importedConnections);
+		return export;
+	}
+	
+	/**
+	 * Adds Connection Class to the available Connection Classes
+	 * @param newConnection new Connection to be added
+	 */
+	public void addConnectionClass(Class<? extends Connection> newConnection){
+		importedConnections.add(newConnection);
+	}
+	
+	/**
+	 * Removes Connection Class from the available Connection Classes
+	 * @param remove Connection Class to be removed
+	 */
+	public void removeConnectionClass(Class<? extends Connection> remove){
+		importedConnections.remove(remove);
+	}
+	
+	/**
+	 * Returns SmartDevice Classes of the Model
+	 * @return available SmartDevice Classes
+	 */
+	public LinkedList<Class<? extends SmartDevice>> getSmartDeviceClasses(){
+		LinkedList<Class<? extends SmartDevice>> export = new LinkedList<Class<? extends SmartDevice>>();
+		export.addAll(standardSmartDevices);
+		export.addAll(importedSmartDevices);
+		return export;
+	}
+	
+	/**
+	 * Adds newSmartDevice Class to the available SmartDevice Classes
+	 * @param newSmartDevice new SmartDevice Class to be added
+	 */
+	public void addSmartDeviceClass(Class<? extends SmartDevice> newSmartDevice){
+		importedSmartDevices.add(newSmartDevice);
+	}
+	
+	/**
+	 * Removes SmartDevice Class from the available SmartDevice Classes
+	 * @param remove SmartDevice Class to be removed
+	 */
+	public void removeSmartDeviceClass(Class<? extends SmartDevice> remove){
+		importedSmartDevices.remove(remove);
+	}
+
+}

+ 0 - 137
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/Model.java

@@ -4,10 +4,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Observable;
 
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.MQTT_protocol;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
-
 /**
  * Model of the smart home, which contains all the important parts of the simulation, like {@link SmartDevice} and their {@link Link}.
  *
@@ -19,21 +15,6 @@ public class Model extends Observable{
 	private List<Link> connectionNetworks;
 	private List<Connection> connections;
 	
-	/*
-	 * standard classes of the model, and user imported classes 
-	 */
-	private LinkedList<Class<? extends Protocol>> standardProtocols = new LinkedList<Class<? extends Protocol>>();
-	private LinkedList<Class<? extends Protocol>> importedProtocols = new LinkedList<Class<? extends Protocol>>();
-	
-	private LinkedList<Class<? extends Link>> standardLinks = new LinkedList<Class<? extends Link>>();
-	private LinkedList<Class<? extends Link>> importedLinks = new LinkedList<Class<? extends Link>>();
-	
-	private LinkedList<Class<? extends Connection>> standardConnections = new LinkedList<Class<? extends Connection>>();
-	private LinkedList<Class<? extends Connection>> importedConnections = new LinkedList<Class<? extends Connection>>();
-	
-	private LinkedList<Class<? extends SmartDevice>> standardSmartDevices = new LinkedList<Class<? extends SmartDevice>>();
-	private LinkedList<Class<? extends SmartDevice>> importedSmartDevices = new LinkedList<Class<? extends SmartDevice>>();
-	
 	/**
 	 * Width of the smart home model, 0 <= device.x < width
 	 */
@@ -73,16 +54,6 @@ public class Model extends Observable{
 		devices = new LinkedList<SmartDevice>();
 		connectionNetworks = new LinkedList<Link>();
 		connections = new LinkedList<Connection>();
-		
-		//Add the default Classes
-		standardProtocols.add(MQTT_protocol.class);
-		standardProtocols.add(SimpleProtocol.class);
-		
-		standardLinks.add(SimpleLink.class);
-		
-		standardSmartDevices.add(SmartDevice.class);
-		
-		standardConnections.add(ConnectionPerformance.class);
 	}
 
 	/**
@@ -187,114 +158,6 @@ public class Model extends Observable{
 	public void setSim(SimulationManager sim) {
 		this.sim = sim;
 	}
-	
-	/**
-	 * Returns Protocol Classes of the Model
-	 * @return available Protocol Classes
-	 */
-	public LinkedList<Class<? extends Protocol>> getProtocolClasses(){
-		LinkedList<Class<? extends Protocol>> export = new LinkedList<Class<? extends Protocol>>();
-		export.addAll(standardProtocols);
-		export.addAll(importedProtocols);
-		return export;
-	}
-	
-	/**
-	 * Adds newProtocol to the available protocol classes
-	 * @param newProtocol new Protocol Class to be added
-	 */
-	public void addProtocolClass(Class<? extends Protocol> newProtocol){
-		importedProtocols.add(newProtocol);
-	}
-	
-	/**
-	 * Removes Protocol from the available protocol classes
-	 * @param remove protocol to be removed
-	 */
-	public void removeProtocolClass(Class<? extends Protocol> remove){
-		importedProtocols.remove(remove);
-	}
-	
-	/**
-	 * Returns Link Classes of the Model
-	 * @return available Link classes
-	 */
-	public LinkedList<Class<? extends Link>> getLinkClasses(){
-		LinkedList<Class<? extends Link>> export = new LinkedList<Class<? extends Link>>();
-		export.addAll(standardLinks);
-		export.addAll(importedLinks);
-		return export;
-	}
-	
-	/**
-	 * Adds newLink to the available Link classes
-	 * @param newLink new Link class to be added
-	 */
-	public void addLinkClass(Class<? extends Link> newLink){
-		importedLinks.add(newLink);
-	}
-	
-	/**
-	 * Removes Link from the available Link classes
-	 * @param remove Link Class to be removed
-	 */
-	public void removeLinkClass(Class<? extends Link> remove){
-		importedLinks.remove(remove);
-	}
-	
-	/**
-	 * Returns Connection Classes of the Model
-	 * @return available Connections classes
-	 */
-	public LinkedList<Class<? extends Connection>> getConnectionClasses(){
-		LinkedList<Class<? extends Connection>> export = new LinkedList<Class<? extends Connection>>();
-		export.addAll(standardConnections);
-		export.addAll(importedConnections);
-		return export;
-	}
-	
-	/**
-	 * Adds Connection Class to the available Connection Classes
-	 * @param newConnection new Connection to be added
-	 */
-	public void addConnectionClass(Class<? extends Connection> newConnection){
-		importedConnections.add(newConnection);
-	}
-	
-	/**
-	 * Removes Connection Class from the available Connection Classes
-	 * @param remove Connection Class to be removed
-	 */
-	public void removeConnectionClass(Class<? extends Connection> remove){
-		importedConnections.remove(remove);
-	}
-	
-	/**
-	 * Returns SmartDevice Classes of the Model
-	 * @return available SmartDevice Classes
-	 */
-	public LinkedList<Class<? extends SmartDevice>> getSmartDeviceClasses(){
-		LinkedList<Class<? extends SmartDevice>> export = new LinkedList<Class<? extends SmartDevice>>();
-		export.addAll(standardSmartDevices);
-		export.addAll(importedSmartDevices);
-		return export;
-	}
-	
-	/**
-	 * Adds newSmartDevice Class to the available SmartDevice Classes
-	 * @param newSmartDevice new SmartDevice Class to be added
-	 */
-	public void addSmartDeviceClass(Class<? extends SmartDevice> newSmartDevice){
-		importedSmartDevices.add(newSmartDevice);
-	}
-	
-	/**
-	 * Removes SmartDevice Class from the available SmartDevice Classes
-	 * @param remove SmartDevice Class to be removed
-	 */
-	public void removeSmartDeviceClass(Class<? extends SmartDevice> remove){
-		importedSmartDevices.remove(remove);
-	}
 
 	/**
 	 * @return the configurations