Commit 34fcdf6b authored by Nils Richerzhagen's avatar Nils Richerzhagen
Browse files

Added configurable Enable/Disable function to cellDesctruction in

5GTopology.
parent b084c6d5
...@@ -47,6 +47,8 @@ public abstract class AbstractGridBasedTopologyDatabase ...@@ -47,6 +47,8 @@ public abstract class AbstractGridBasedTopologyDatabase
private final Map<Integer, FiveGTopologyDatabase.Entry> cloudletEntries; private final Map<Integer, FiveGTopologyDatabase.Entry> cloudletEntries;
public static int _visId = 1; public static int _visId = 1;
private boolean enableCellDestruction = false;
/** /**
* Grid-based {@link CellularTopologyDatabase} with a grid length (squares) * Grid-based {@link CellularTopologyDatabase} with a grid length (squares)
...@@ -69,12 +71,17 @@ public abstract class AbstractGridBasedTopologyDatabase ...@@ -69,12 +71,17 @@ public abstract class AbstractGridBasedTopologyDatabase
public void eventOccurred(Object content, int type) { public void eventOccurred(Object content, int type) {
VisualizationInjector.injectComponent("5G " + _visId++, -1, VisualizationInjector.injectComponent("5G " + _visId++, -1,
new FiveGVisualization( new FiveGVisualization(
AbstractGridBasedTopologyDatabase.this), AbstractGridBasedTopologyDatabase.this, enableCellDestruction),
false, true); false, true);
} }
}, null, 0); }, null, 0);
} }
} }
public void setEnableCellDestruction(boolean enableCellDestruction){
this.enableCellDestruction = enableCellDestruction;
}
public void setGridSize(int gridSize) { public void setGridSize(int gridSize) {
this.gridSize = gridSize; this.gridSize = gridSize;
...@@ -176,19 +183,25 @@ public abstract class AbstractGridBasedTopologyDatabase ...@@ -176,19 +183,25 @@ public abstract class AbstractGridBasedTopologyDatabase
@Override @Override
public double getDropProbability(boolean isUpload) { public double getDropProbability(boolean isUpload) {
if(!getConnectivity()) return 1; if(!getConnectivity()){
return 1;
}
return isUpload ? dropUp : dropDown; return isUpload ? dropUp : dropDown;
} }
@Override @Override
public long getLatency(boolean isUpload) { public long getLatency(boolean isUpload) {
if(!getConnectivity()) return 9999 * Time.MILLISECOND; if(!getConnectivity()){
return 9999 * Time.MILLISECOND;
}
return isUpload ? latencyUp : latencyDown; return isUpload ? latencyUp : latencyDown;
} }
@Override @Override
public long getBandwidth(boolean isUpload) { public long getBandwidth(boolean isUpload) {
if(!getConnectivity()) return 0; if(!getConnectivity()){
return 0;
}
return isUpload ? bandwidthUp : bandwidthDown; return isUpload ? bandwidthUp : bandwidthDown;
} }
......
...@@ -24,8 +24,12 @@ import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView; ...@@ -24,8 +24,12 @@ import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView;
import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView.CellLink; import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView.CellLink;
/** /**
* Database for the {@link FiveGTopologyView} - containing a mapping of * Database for the {@link FiveGTopologyView} - containing a mapping of position
* position IDs to the respective link characteristics. * IDs to the respective link characteristics.
*
* 06.10.2016 added by Nils Richerzhagen, Clemens Krug Functionality to
* 'destroy' cells using SHIFT + Left-click. Enable/Disable using the
* enableCellDestruction boolean.
* *
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, Nov 5, 2015 * @version 1.0, Nov 5, 2015
...@@ -59,6 +63,17 @@ public interface FiveGTopologyDatabase { ...@@ -59,6 +63,17 @@ public interface FiveGTopologyDatabase {
public FiveGTopologyDatabase.Entry getEntryFor(int segmentID, public FiveGTopologyDatabase.Entry getEntryFor(int segmentID,
boolean isCloudlet); boolean isCloudlet);
/**
* If wanted one can 'destroy' cells using this method. Destroy means that
* the cell is not available for the communication mean specified within
* that TopologyView.
*
* To be set by configuration.
*
* @param enableCellDestruction
*/
public void setEnableCellDestruction(boolean enableCellDestruction);
/** /**
* Data structure for the network parameters of a given segment ID - these * Data structure for the network parameters of a given segment ID - these
* are directly accessed by the {@link CellLink} object on each call (so * are directly accessed by the {@link CellLink} object on each call (so
...@@ -104,16 +119,19 @@ public interface FiveGTopologyDatabase { ...@@ -104,16 +119,19 @@ public interface FiveGTopologyDatabase {
/** /**
* Connectivity of the cell. * Connectivity of the cell.
* *
* @return <code>false</code> if the cell is broken down/damaged and upload/download isn't possible. * @return <code>false</code> if the cell is broken down/damaged and
* <code>true</code> otherwise. * upload/download isn't possible. <code>true</code> otherwise.
*/ */
boolean getConnectivity(); boolean getConnectivity();
/** /**
* Set the connectivity of the cell. When set to <code>false</code>, it should be impossible to upload or * Set the connectivity of the cell. When set to <code>false</code>, it
* download data via this cell. {@link CellLink} refers to this attribute when returning e.g. BW or drop rate. * should be impossible to upload or download data via this cell.
* {@link CellLink} refers to this attribute when returning e.g. BW or
* drop rate.
*
* @param connectivity * @param connectivity
*/ */
void setConnectivity(boolean connectivity); void setConnectivity(boolean connectivity);
} }
......
...@@ -35,18 +35,23 @@ import java.awt.image.BufferedImage; ...@@ -35,18 +35,23 @@ import java.awt.image.BufferedImage;
/** /**
* Visualization for the {@link FiveGTopologyView} * Visualization for the {@link FiveGTopologyView}
* *
* Added 06.10.2016 Nils Richerzhagen, Clemens Krug
* Functionality to 'destroy' cells using SHIFT + Left-click. Enable/Disable using the enableCellDestruction
*
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, Nov 5, 2015 * @version 1.0, Nov 5, 2015
*/ */
public class FiveGVisualization extends JComponent implements VisualizationInjector.MouseClickListener { public class FiveGVisualization extends JComponent implements VisualizationInjector.MouseClickListener {
private final boolean enableCellDestruction;
protected BufferedImage image; protected BufferedImage image;
protected volatile boolean needsRedraw = true; protected volatile boolean needsRedraw = true;
private final AbstractGridBasedTopologyDatabase database; private final AbstractGridBasedTopologyDatabase database;
public FiveGVisualization(AbstractGridBasedTopologyDatabase database) { public FiveGVisualization(AbstractGridBasedTopologyDatabase database, boolean enableCellDestruction) {
setBounds(0, 0, VisualizationInjector.getWorldX(), setBounds(0, 0, VisualizationInjector.getWorldX(),
VisualizationInjector.getWorldY()); VisualizationInjector.getWorldY());
setOpaque(true); setOpaque(true);
...@@ -56,6 +61,8 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec ...@@ -56,6 +61,8 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
image = new BufferedImage(VisualizationInjector.getWorldX(), image = new BufferedImage(VisualizationInjector.getWorldX(),
VisualizationInjector.getWorldY(), BufferedImage.TYPE_INT_ARGB); VisualizationInjector.getWorldY(), BufferedImage.TYPE_INT_ARGB);
this.enableCellDestruction = enableCellDestruction;
VisualizationInjector.addMouseListener(this); VisualizationInjector.addMouseListener(this);
} }
...@@ -169,7 +176,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec ...@@ -169,7 +176,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
public void mouseClicked(int x, int y, int modifier) public void mouseClicked(int x, int y, int modifier)
{ {
// 17 == Shift // 17 == Shift
if(modifier == 17) if(enableCellDestruction && modifier == 17)
{ {
int segID = database.getSegmentID(x, y); int segID = database.getSegmentID(x, y);
Entry entry = database.getEntryFor(segID, false); Entry entry = database.getEntryFor(segID, false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment