|
@@ -1,13 +1,10 @@
|
|
|
package de.tu_darmstadt.tk.SmartHomeNetworkSim.control;
|
|
|
|
|
|
-import java.util.Collection;
|
|
|
import java.util.Observer;
|
|
|
|
|
|
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
|
|
|
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
|
|
|
+
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
|
|
|
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SimulationManager;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
|
|
|
@@ -76,135 +73,6 @@ public class Controller {
|
|
|
return networkController;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Moves the SmartDevice device to the specified location, if it exists
|
|
|
- *
|
|
|
- * @param device
|
|
|
- * the device to move
|
|
|
- * @param x
|
|
|
- * new x position
|
|
|
- * @param y
|
|
|
- * new y position
|
|
|
- * @param z
|
|
|
- * new z position
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#moveSmartDevice(SmartDevice,int,int,int)} instead
|
|
|
- */
|
|
|
- public void moveSmartDevice(SmartDevice device, int x, int y, int z) {
|
|
|
- networkController.moveSmartDevice(device, x, y, z);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Changes the dimension of the model, without scaling the SmartDevice
|
|
|
- * positions
|
|
|
- *
|
|
|
- * @param width
|
|
|
- * the new width to set
|
|
|
- * @param height
|
|
|
- * the new height to set
|
|
|
- * @param depth
|
|
|
- * the new depth to set
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setDimension(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int,int,int)} instead
|
|
|
- */
|
|
|
- public void setDimension(int width, int height, int depth) {
|
|
|
- settingsController.setDimension(width, height, depth);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Changes the dimension of the model and moves SmartDevices to new relative
|
|
|
- * positions if {@code stretchModel} is true
|
|
|
- *
|
|
|
- * @param width
|
|
|
- * the new width to set
|
|
|
- * @param height
|
|
|
- * the new height to set
|
|
|
- * @param depth
|
|
|
- * the new depth to set
|
|
|
- * @param stretchModel
|
|
|
- * true, if smartDevice positions should be stretched
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setDimension(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int,int,int,boolean)} instead
|
|
|
- */
|
|
|
- public void setDimension(int width, int height, int depth, boolean stretchModel) {
|
|
|
- settingsController.setDimension(width, height, depth, stretchModel);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Validate all device positions, move all devices into the bounds, if they are outside the visualization
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#validateDevicePosition(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
|
|
|
- */
|
|
|
- public void validateDevicePosition() {
|
|
|
- networkController.validateDevicePosition();
|
|
|
- }
|
|
|
- /**
|
|
|
- * Calculates the new scaled position, which should be in Bounds:
|
|
|
- * {@code radius < newPosition <
|
|
|
- * (upperBound - radius)}
|
|
|
- *
|
|
|
- * @param oldPosition
|
|
|
- * previous position that should be scaled
|
|
|
- * @param factor
|
|
|
- * how much it is stretched/shrunk
|
|
|
- * @param upperBound
|
|
|
- * upper bound of the frame, which should not be exceeded
|
|
|
- * @return new position that was calculated
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#scalePos(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int,double,int)} instead
|
|
|
- */
|
|
|
- int scalePos(int oldPosition, double factor, int upperBound) {
|
|
|
- return settingsController.scalePos(oldPosition, factor, upperBound);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Adds SmartDevice to the Model and verifies that it is inside the model
|
|
|
- * bounds
|
|
|
- *
|
|
|
- * @param sd
|
|
|
- * SmartDevice which should be added to the model
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addSmartDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,SmartDevice)} instead
|
|
|
- */
|
|
|
- public void addSmartDevice(SmartDevice sd) {
|
|
|
- networkController.addSmartDevice(sd);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Creates a new SmartDevice at the given Position. The Device is moved
|
|
|
- * into the model bounds, if the position is outside the bounds
|
|
|
- *
|
|
|
- * @param name
|
|
|
- * name of the smartDevice
|
|
|
- * @param x_pos
|
|
|
- * position on the x-Axis
|
|
|
- * @param y_pos
|
|
|
- * position on the y-Axis
|
|
|
- * @param z_pos
|
|
|
- * position on the z-Axis
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#createSmartDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,String,int,int,int)} instead
|
|
|
- */
|
|
|
- public void createSmartDevice(String name, int x_pos, int y_pos, int z_pos) {
|
|
|
- networkController.createSmartDevice(name, x_pos, y_pos, z_pos);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Deletes the given SmartDevice toDelete, removes it from its links and
|
|
|
- * connections.
|
|
|
- *
|
|
|
- * @param toDelete
|
|
|
- * the SmartDevice to delete
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteSmartDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,SmartDevice)} instead
|
|
|
- */
|
|
|
- public void deleteSmartDevice(SmartDevice toDelete) {
|
|
|
- networkController.deleteSmartDevice(toDelete);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Removes the SmartDevice from the given Link
|
|
|
- *
|
|
|
- * @param toRemove the Device that should be removed from the link
|
|
|
- * @param link the Link, which contains the SmartDevice
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeSmartDeviceFromLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,SmartDevice,Link)} instead
|
|
|
- */
|
|
|
- public void removeSmartDeviceFromLink(SmartDevice toRemove, Link link) {
|
|
|
- networkController.removeSmartDeviceFromLink(toRemove, link);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Notifies Observer, which may update their visualization/state
|
|
|
*/
|
|
@@ -230,228 +98,7 @@ public class Controller {
|
|
|
public void removeObserver(Observer observer){
|
|
|
model.deleteObserver(observer);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * @return the width
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#getWidth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
|
|
|
- */
|
|
|
- public int getWidth() {
|
|
|
- return settingsController.getWidth();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param width the width to set
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setWidth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int)} instead
|
|
|
- */
|
|
|
- public void setWidth(int width) {
|
|
|
- settingsController.setWidth(width);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return the height
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#getHeight(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
|
|
|
- */
|
|
|
- public int getHeight() {
|
|
|
- return settingsController.getHeight();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param height the height to set
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setHeight(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int)} instead
|
|
|
- */
|
|
|
- public void setHeight(int height) {
|
|
|
- settingsController.setHeight(height);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return the depth
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.ImportController#getDepth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
|
|
|
- */
|
|
|
- public int getDepth() {
|
|
|
- return settingsController.getDepth();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param depth the depth to set
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setDepth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int)} instead
|
|
|
- */
|
|
|
- public void setDepth(int depth) {
|
|
|
- settingsController.setDepth(depth);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return the device_visualization_radius
|
|
|
- * @deprecated
|
|
|
- */
|
|
|
- int getDevice_visualization_radius() {
|
|
|
- return settingsController.getDeviceVisualizationRadius();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Adds Link to the model
|
|
|
- * @param link link to add
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link)} instead
|
|
|
- */
|
|
|
- public void addLink(Link link){
|
|
|
- networkController.addLink(link);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Removes Link from the Model
|
|
|
- * @param link link to remove
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link)} instead
|
|
|
- */
|
|
|
- public void removeLink(Link link){
|
|
|
- networkController.removeLink(link);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#getLinks(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
|
|
|
- */
|
|
|
- public Collection<Link> getLinks(){
|
|
|
- return networkController.getLinks();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection)} instead
|
|
|
- */
|
|
|
- public void addConnection(Connection connection){
|
|
|
- networkController.addConnection(connection);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection)} instead
|
|
|
- */
|
|
|
- public void removeConnection(Connection connection){
|
|
|
- networkController.removeConnection(connection);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#getConnections(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
|
|
|
- */
|
|
|
- public Collection<Connection> getConnections(){
|
|
|
- return networkController.getConnections();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addLinkToDevice(Link,SmartDevice)} instead
|
|
|
- */
|
|
|
- public void addLinkToDevice(Link newLink, SmartDevice smartDevice) {
|
|
|
- networkController.addLinkToDevice(newLink, smartDevice);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeLinkFromDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link,SmartDevice)} instead
|
|
|
- */
|
|
|
- public void removeLinkFromDevice(Link link, SmartDevice smartDevice) {
|
|
|
- networkController.removeLinkFromDevice(link, smartDevice);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Changes Roles of the device to the newRole, returns true, if the role was successfully changed, false if not.
|
|
|
- * If false is returned, the device will no longer be part of this connection.
|
|
|
- *
|
|
|
- * @param protocol protocol which should be edited
|
|
|
- * @param device device which should be added
|
|
|
- * @param newRole new role of the device
|
|
|
- * @return true if new role was set, false if not
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeRoleOfDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Protocol,Connection,Port,int)} instead
|
|
|
- */
|
|
|
- public boolean changeRoleOfDevice(Protocol protocol, Connection con, Port device, int newRole){
|
|
|
- return networkController.changeRoleOfDevice(protocol, con, device, newRole);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Removes Device p from the Connection
|
|
|
- * @param p Port/Device to remove
|
|
|
- * @param connection connection, which should remove the device
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeDeviceFromConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Port,Connection)} instead
|
|
|
- */
|
|
|
- public void removeDeviceFromConnection(Port p, Connection connection){
|
|
|
- networkController.removeDeviceFromConnection(p, connection);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Adds Device p to the connection with the specified role
|
|
|
- * @param p Port/Device to be added
|
|
|
- * @param connection Connection
|
|
|
- * @param role new role of the device (See {@link Protocol} Roles)
|
|
|
- * @return true, if the device was added
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addDeviceToConnection(Port,Connection,int)} instead
|
|
|
- */
|
|
|
- public boolean addDeviceToConnection(Port p, Connection connection, int role){
|
|
|
- return networkController.addDeviceToConnection(p, connection, role);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Changes the link of the given connection to the new link. Returns true if it was successfully changed, false if it could not be changed.
|
|
|
- * @param connection
|
|
|
- * @param newLink
|
|
|
- * @return true on successful change, false on failure & restore
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeLinkOfConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection,Link)} instead
|
|
|
- */
|
|
|
- public boolean changeLinkOfConnection(Connection connection, Link newLink) {
|
|
|
- return networkController.changeLinkOfConnection(connection, newLink);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Changes the type of the connection to the new Type and updates all references
|
|
|
- * @param connection connection to be updated
|
|
|
- * @param newConnectionClass class of new type
|
|
|
- * @return newly created connection
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeConnectionType(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection,Class<? extends Connection>)} instead
|
|
|
- */
|
|
|
- public Connection changeConnectionType(Connection connection, Class<? extends Connection> newConnectionClass) {
|
|
|
- return networkController.changeConnectionType(connection, newConnectionClass);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Deletes the network model, removes all Devices, Connections and Links
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteNetworkModel(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
|
|
|
- */
|
|
|
- public void deleteNetworkModel(){
|
|
|
- networkController.deleteNetworkModel();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Deletes the Connection c and all references
|
|
|
- * @param c Connection to be deleted
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection)} instead
|
|
|
- */
|
|
|
- public void deleteConnection(Connection c) {
|
|
|
- networkController.deleteConnection(c);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Deletes Link l and all references
|
|
|
- * @param l Link to be deleted
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link)} instead
|
|
|
- */
|
|
|
- public void deleteLink(Link l) {
|
|
|
- networkController.deleteLink(l);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Removes Connection from Link
|
|
|
- * @param c Connection to be removed
|
|
|
- * @param l Link to be removed
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeConnectionFromLink(Connection,Link)} instead
|
|
|
- */
|
|
|
- public void removeConnectionFromLink(Connection c, Link l) {
|
|
|
- networkController.removeConnectionFromLink(c, l);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Changes the type of the link to new type, specified by the given Link-class
|
|
|
- * @param oldLink oldLink, whose attributes will b copied to the new Link
|
|
|
- * @param newType Type/Class of the new Link
|
|
|
- * @return newly created Link, null on failure/error
|
|
|
- * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeLinkType(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link,Class<? extends Link>)} instead
|
|
|
- */
|
|
|
- public Link changeLinkType(Link oldLink, Class<? extends Link> newType) {
|
|
|
- return networkController.changeLinkType(oldLink, newType);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
// TODO: Maybe Settings controller ?
|
|
|
/**
|
|
|
* Reset Simulation
|