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
private final Map<Integer, FiveGTopologyDatabase.Entry> cloudletEntries;
public static int _visId = 1;
private boolean enableCellDestruction = false;
/**
* Grid-based {@link CellularTopologyDatabase} with a grid length (squares)
......@@ -69,12 +71,17 @@ public abstract class AbstractGridBasedTopologyDatabase
public void eventOccurred(Object content, int type) {
VisualizationInjector.injectComponent("5G " + _visId++, -1,
new FiveGVisualization(
AbstractGridBasedTopologyDatabase.this),
AbstractGridBasedTopologyDatabase.this, enableCellDestruction),
false, true);
}
}, null, 0);
}
}
public void setEnableCellDestruction(boolean enableCellDestruction){
this.enableCellDestruction = enableCellDestruction;
}
public void setGridSize(int gridSize) {
this.gridSize = gridSize;
......@@ -176,19 +183,25 @@ public abstract class AbstractGridBasedTopologyDatabase
@Override
public double getDropProbability(boolean isUpload) {
if(!getConnectivity()) return 1;
if(!getConnectivity()){
return 1;
}
return isUpload ? dropUp : dropDown;
}
@Override
public long getLatency(boolean isUpload) {
if(!getConnectivity()) return 9999 * Time.MILLISECOND;
if(!getConnectivity()){
return 9999 * Time.MILLISECOND;
}
return isUpload ? latencyUp : latencyDown;
}
@Override
public long getBandwidth(boolean isUpload) {
if(!getConnectivity()) return 0;
if(!getConnectivity()){
return 0;
}
return isUpload ? bandwidthUp : bandwidthDown;
}
......
......@@ -24,8 +24,12 @@ import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView;
import de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView.CellLink;
/**
* Database for the {@link FiveGTopologyView} - containing a mapping of
* position IDs to the respective link characteristics.
* Database for the {@link FiveGTopologyView} - containing a mapping of position
* 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
* @version 1.0, Nov 5, 2015
......@@ -59,6 +63,17 @@ public interface FiveGTopologyDatabase {
public FiveGTopologyDatabase.Entry getEntryFor(int segmentID,
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
* are directly accessed by the {@link CellLink} object on each call (so
......@@ -104,16 +119,19 @@ public interface FiveGTopologyDatabase {
/**
* Connectivity of the cell.
*
* @return <code>false</code> if the cell is broken down/damaged and upload/download isn't possible.
* <code>true</code> otherwise.
*/
* @return <code>false</code> if the cell is broken down/damaged and
* upload/download isn't possible. <code>true</code> otherwise.
*/
boolean getConnectivity();
/**
* Set the connectivity of the cell. When set to <code>false</code>, it 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.
* Set the connectivity of the cell. When set to <code>false</code>, it
* 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
*/
*/
void setConnectivity(boolean connectivity);
}
......
......@@ -35,18 +35,23 @@ import java.awt.image.BufferedImage;
/**
* 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
* @version 1.0, Nov 5, 2015
*/
public class FiveGVisualization extends JComponent implements VisualizationInjector.MouseClickListener {
private final boolean enableCellDestruction;
protected BufferedImage image;
protected volatile boolean needsRedraw = true;
private final AbstractGridBasedTopologyDatabase database;
public FiveGVisualization(AbstractGridBasedTopologyDatabase database) {
public FiveGVisualization(AbstractGridBasedTopologyDatabase database, boolean enableCellDestruction) {
setBounds(0, 0, VisualizationInjector.getWorldX(),
VisualizationInjector.getWorldY());
setOpaque(true);
......@@ -56,6 +61,8 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
image = new BufferedImage(VisualizationInjector.getWorldX(),
VisualizationInjector.getWorldY(), BufferedImage.TYPE_INT_ARGB);
this.enableCellDestruction = enableCellDestruction;
VisualizationInjector.addMouseListener(this);
}
......@@ -169,7 +176,7 @@ public class FiveGVisualization extends JComponent implements VisualizationInjec
public void mouseClicked(int x, int y, int modifier)
{
// 17 == Shift
if(modifier == 17)
if(enableCellDestruction && modifier == 17)
{
int segID = database.getSegmentID(x, y);
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