Commit c14e4e1f authored by Clemens Krug's avatar Clemens Krug
Browse files

Merge remote-tracking branch 'remotes/origin/master' into nr/resAlloc-clemens

parents 829d5123 2ac40564
...@@ -91,6 +91,8 @@ public class DefaultTopologyComponent implements TopologyComponent { ...@@ -91,6 +91,8 @@ public class DefaultTopologyComponent implements TopologyComponent {
private MovementModel movementModel; private MovementModel movementModel;
private PlacementModel placementModel; private PlacementModel placementModel;
private final boolean registerAsInformationProviderInSiS;
/** /**
* Create a TopologyComponent for the current host. * Create a TopologyComponent for the current host.
...@@ -100,7 +102,7 @@ public class DefaultTopologyComponent implements TopologyComponent { ...@@ -100,7 +102,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
* @param movementModel * @param movementModel
*/ */
public DefaultTopologyComponent(SimHost host, Topology topology, public DefaultTopologyComponent(SimHost host, Topology topology,
MovementModel movementModel, PlacementModel placementModel) { MovementModel movementModel, PlacementModel placementModel, boolean registerAsInformationProviderInSiS) {
this.topology = topology; this.topology = topology;
this.host = host; this.host = host;
this.position = new PositionVector(0, 0); this.position = new PositionVector(0, 0);
...@@ -114,6 +116,7 @@ public class DefaultTopologyComponent implements TopologyComponent { ...@@ -114,6 +116,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
if (this.placementModel != null) { if (this.placementModel != null) {
this.placementModel.addComponent(this); this.placementModel.addComponent(this);
} }
this.registerAsInformationProviderInSiS = registerAsInformationProviderInSiS;
} }
@Override @Override
...@@ -132,52 +135,54 @@ public class DefaultTopologyComponent implements TopologyComponent { ...@@ -132,52 +135,54 @@ public class DefaultTopologyComponent implements TopologyComponent {
position.set(placementModel.place(this)); position.set(placementModel.place(this));
} }
try { if (registerAsInformationProviderInSiS) {
final SiSComponent sis = host.getComponent(SiSComponent.class); try {
sis.provide().nodeState(SiSTypes.PHY_LOCATION, final SiSComponent sis = host.getComponent(SiSComponent.class);
new SiSDataCallback<Location>() { sis.provide().nodeState(SiSTypes.PHY_LOCATION,
new SiSDataCallback<Location>() {
Set<INodeID> localID = INodeID
.getSingleIDSet(getHost().getId()); Set<INodeID> localID = INodeID
.getSingleIDSet(getHost().getId());
@Override
public Location getValue(INodeID nodeID, @Override
SiSProviderHandle providerHandle) public Location getValue(INodeID nodeID,
throws InformationNotAvailableException { SiSProviderHandle providerHandle)
if (nodeID.equals(getHost().getId())) { throws InformationNotAvailableException {
return getLastLocation(); if (nodeID.equals(getHost().getId())) {
} else { return getLastLocation();
throw new InformationNotAvailableException(); } else {
throw new InformationNotAvailableException();
}
} }
@Override
public Set<INodeID> getObservedNodes() {
return localID;
}
@Override
public SiSInfoProperties getInfoProperties() {
return new SiSInfoProperties();
}
});
// Provide Underlay topology
Event.scheduleImmediately(new EventHandler() {
@Override
public void eventOccurred(Object content, int type) {
if (getHost().getLinkLayer().hasPhy(PhyType.WIFI)) {
new SiSTopologyProvider(sis, SiSTypes.NEIGHBORS_WIFI,
DefaultTopologyComponent.this,
getTopologyID(NetInterfaceName.WIFI, true),
DefaultTopologyComponent.class);
} }
@Override
public Set<INodeID> getObservedNodes() {
return localID;
}
@Override
public SiSInfoProperties getInfoProperties() {
return new SiSInfoProperties();
}
});
// Provide Underlay topology
Event.scheduleImmediately(new EventHandler() {
@Override
public void eventOccurred(Object content, int type) {
if (getHost().getLinkLayer().hasPhy(PhyType.WIFI)) {
new SiSTopologyProvider(sis, SiSTypes.NEIGHBORS_WIFI,
DefaultTopologyComponent.this,
getTopologyID(NetInterfaceName.WIFI, true),
DefaultTopologyComponent.class);
} }
} }, null, 0);
}, null, 0);
} catch (ComponentNotAvailableException e) {
} catch (ComponentNotAvailableException e) { // OK
// OK }
} }
} }
......
...@@ -71,6 +71,8 @@ public class TopologyFactory implements HostComponentFactory { ...@@ -71,6 +71,8 @@ public class TopologyFactory implements HostComponentFactory {
private WaypointModel waypointModel; private WaypointModel waypointModel;
private ObstacleModel obstacleModel; private ObstacleModel obstacleModel;
private boolean registerAsInformationProviderInSiS = false;
private static NetMeasurementDB measurementDB = null; private static NetMeasurementDB measurementDB = null;
...@@ -125,7 +127,7 @@ public class TopologyFactory implements HostComponentFactory { ...@@ -125,7 +127,7 @@ public class TopologyFactory implements HostComponentFactory {
* movement model. * movement model.
*/ */
TopologyComponent toCo = new DefaultTopologyComponent(host, topo, TopologyComponent toCo = new DefaultTopologyComponent(host, topo,
movement, placement); movement, placement, registerAsInformationProviderInSiS);
/* /*
* Need to register TopoViews as movement listeners, as they might need * Need to register TopoViews as movement listeners, as they might need
...@@ -227,6 +229,17 @@ public class TopologyFactory implements HostComponentFactory { ...@@ -227,6 +229,17 @@ public class TopologyFactory implements HostComponentFactory {
public void setUseRegionGroups(boolean useRegionGroups) { public void setUseRegionGroups(boolean useRegionGroups) {
TopologyFactory.useRegionGroups = useRegionGroups; TopologyFactory.useRegionGroups = useRegionGroups;
} }
/**
* Option to disable the default behavior of nodes registering as
* topology providers.
*
* @param registerAsLocationProviderInSiS
*/
public void setRegisterAsInformationProviderInSiS(
boolean registerAsInformationProviderInSiS) {
this.registerAsInformationProviderInSiS = registerAsInformationProviderInSiS;
}
/** /**
* Allows GNP-based strategies to retrieve the unique * Allows GNP-based strategies to retrieve the unique
......
...@@ -168,6 +168,41 @@ public class MeasurementDAO extends DAO { ...@@ -168,6 +168,41 @@ public class MeasurementDAO extends DAO {
groupMetric, observationDuration, describesWholeSimulation); groupMetric, observationDuration, describesWholeSimulation);
addToPersistQueue(measurement); addToPersistQueue(measurement);
} }
/**
* Stores a statistical description of a series of values for group of
* hosts and a given spatial coordinate.
*
* @param metricDesc
* The {@link MetricDescription} which describes the metric.
* @param groupName
* The host group
* @param time
* A time for the measurement in simulation time
* @param stats
* the {@link DescriptiveStatistics} object used as input
* @param observationDuration
* duration of this observation in simulation time
* @param describesWholeSimulation
* true, if this measurement is a description of the WHOLE
* simulation
* @param locationX
* x coordinate for spatial sampling
* @param locationY
* y coordinate for spatial sampling
*/
public static void storeSpatialGroupStatisticsMeasurement(
MetricDescription metricDesc, String groupName, long time,
DescriptiveStatistics stats, long observationDuration,
boolean describesWholeSimulation, int locationX, int locationY) {
Metric metric = MetricDAO.lookupStatisticsMetric(metricDesc);
GroupMetric groupMetric = GroupMetricDAO.lookupGroupMetric(metric,
groupName);
MeasurementStatistic measurement = new MeasurementStatistic(time, stats,
groupMetric, observationDuration, describesWholeSimulation, locationX, locationY);
addToPersistQueue(measurement);
}
/** /**
* Store a list-based measurement with a key (i.e., as a * Store a list-based measurement with a key (i.e., as a
......
...@@ -118,12 +118,15 @@ public class MeasurementStatistic implements GroupMetricBound { ...@@ -118,12 +118,15 @@ public class MeasurementStatistic implements GroupMetricBound {
@Column(nullable = true, name = "[perc5]") @Column(nullable = true, name = "[perc5]")
private Double perc5; // 5 private Double perc5; // 5
@Column(nullable = true, name = "[skewness]") @Column(nullable = true, name = "[locationX]")
private Double skewness; private Integer locationX;
@Column(nullable = true, name = "[kurtosis]") @Column(nullable = true, name = "[locationY]")
private Double kurtosis; private Integer locationY;
@Column(nullable = true, name = "[isSpatial]")
private boolean isSpatial;
/** /**
* Mapping to group metric * Mapping to group metric
...@@ -155,6 +158,36 @@ public class MeasurementStatistic implements GroupMetricBound { ...@@ -155,6 +158,36 @@ public class MeasurementStatistic implements GroupMetricBound {
this.groupMetric = groupMetric; this.groupMetric = groupMetric;
} }
/**
* Creates a {@link Measurement}-Object using the provided
* {@link DescriptiveStatistics} object, with spatial data attached.
*
* @param time
* The simulation time for to this measurement as Date
* @param stats
* the {@link DescriptiveStatistics} object
* @param hostMetric
* The reference to the {@link HostMetric}-Object, which
* describes this metric. Is used for the mapping.
* @param observationDuration
* duration of the observation
* @param describesWholeSimulation
* true, if this measurement describes the whole simulation
* @param locationX
* x coordinate for spatial sampling
* @param locationY
* y coordinate for spatial sampling
*/
public MeasurementStatistic(long time, DescriptiveStatistics stats,
GroupMetric groupMetric, long observationDuration,
boolean describesWholeSimulation, int locationX, int locationY) {
this(time, stats, observationDuration, describesWholeSimulation);
this.groupMetric = groupMetric;
this.locationX = locationX;
this.locationY = locationY;
this.isSpatial = true;
}
/** /**
* Internal - write statistics * Internal - write statistics
* *
...@@ -182,9 +215,8 @@ public class MeasurementStatistic implements GroupMetricBound { ...@@ -182,9 +215,8 @@ public class MeasurementStatistic implements GroupMetricBound {
this.perc97 = checkForSpecialNumbers(stats.getPercentile(97.7)); this.perc97 = checkForSpecialNumbers(stats.getPercentile(97.7));
this.perc5 = checkForSpecialNumbers(stats.getPercentile(5)); this.perc5 = checkForSpecialNumbers(stats.getPercentile(5));
this.perc95 = checkForSpecialNumbers(stats.getPercentile(95)); this.perc95 = checkForSpecialNumbers(stats.getPercentile(95));
this.skewness = checkForSpecialNumbers(stats.getSkewness());
this.kurtosis = checkForSpecialNumbers(stats.getKurtosis());
this.std = checkForSpecialNumbers(stats.getStandardDeviation()); this.std = checkForSpecialNumbers(stats.getStandardDeviation());
this.isSpatial = 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