Commit 8aa75563 authored by Stephan Korsholm's avatar Stephan Korsholm
Browse files

Resolve "EPP 10 - EPP for Cellular results display"

Showing with 160 additions and 39 deletions
+160 -39
package org.seamcat.model.eventprocessing;
import static org.seamcat.model.plugin.system.BuiltInSystem.*;
import static org.seamcat.model.plugin.system.StandardResults.*;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.seamcat.model.Scenario;
import org.seamcat.model.factory.Factory;
import org.seamcat.model.plugin.Config;
......@@ -14,8 +16,10 @@ import org.seamcat.model.simulation.result.*;
import org.seamcat.model.types.Description;
import org.seamcat.model.types.Unit;
import org.seamcat.model.types.result.DescriptionImpl;
import org.seamcat.model.workspace.result.CollectorImpl;
public class DemoEPP_10_OFDMA_Internals implements EventProcessingPlugin<DemoEPP_10_OFDMA_Internals.Input> {
private static final Logger LOG = LogManager.getRootLogger();
public static VectorDef SINR_ACHIEVED_ALL = Factory.results().vector(ValueName.SINR_ACHIEVED_ALL, Unit.dB);
public static VectorDef BIT_RATE_ACHIEVED_ALL = Factory.results().vector(ValueName.BITRATE_ACHIEVED_ALL, Unit.kbps);
public static VectorDef RECEIVED_POWER_ALL = Factory.results().vector(ValueName.RECEIVED_POWER_ALL, Unit.dBm);
......@@ -29,9 +33,6 @@ public class DemoEPP_10_OFDMA_Internals implements EventProcessingPlugin<DemoEPP
String name = scenario.getVictim().getName();
for (int i = 0; i < vCollector.getVictims().size(); i++) {
collector.add(Factory.results().vector(ValueName.DISTANCES, name + "_" + String.valueOf(i), Unit.km, false),
vCollector.getVictims().get(i).getLinkResult().getTxRxDistance());
if (input.externalInterferenceUnwanted()) {
collector.add(Factory.results().vector(
"External interference unwanted", name + "_" + String.valueOf(i), Unit.dBm, false),
......@@ -44,30 +45,52 @@ public class DemoEPP_10_OFDMA_Internals implements EventProcessingPlugin<DemoEPP
}
}
handle(input.frequency(), FREQUENCY_ALL, collector, vCollector, name);
handle(input.bitRateAchieved(), BIT_RATE_ACHIEVED_ALL, collector, vCollector, name);
handle(input.receivedPower(), RECEIVED_POWER_ALL, collector, vCollector, name);
handle(input.SINRAchieved(), SINR_ACHIEVED_ALL, collector, vCollector, name);
handle(input.currentTransmitPower(), CURRENT_TRANSMIT_POWER_ALL, collector, vCollector, name);
handle(input.interferencePower(), INTERFERENCE_POWER_ALL, collector, vCollector, name);
handle(input.interSystemInterference(), INTER_SYSTEM_INTERFERENCE_ALL, collector, vCollector, name);
handle(input.pathLoss(), PATH_LOSS_ALL, collector, vCollector, name);
handle(input.effectivePathLoss(), EFFECTIVE_PATH_LOSS_ALL, collector, vCollector, name);
handle(input.frequency(), ValueName.FREQUENCY, collector, vCollector, name);
handle(input.bitRateAchieved(), ValueName.BITRATE_ACHIEVED, collector, vCollector, name);
handle(input.receivedPower(), ValueName.RECEIVED_POWER, collector, vCollector, name);
handle(input.SINRAchieved(), ValueName.SINR_ACHIEVED, collector, vCollector, name);
handle(input.currentTransmitPower(), ValueName.CURRENT_TRANSMIT_POWER, collector, vCollector, name);
handle(input.interferencePower(), ValueName.INTERFERENCE_POWER, collector, vCollector, name);
handle(input.interSystemInterference(), ValueName.INTER_SYSTEM_INTERFERENCE, collector, vCollector, name);
handle(input.pathLoss(), ValueName.PATH_LOSS, collector, vCollector, name);
handle(input.effectivePathLoss(), ValueName.EFFECTIVE_PATH_LOSS, collector, vCollector, name);
}
private void handle(boolean relevant, VectorDef def, Collector col, VictimResultCollector vCol, String name) {
private void handle(boolean relevant, String def, Collector col, VictimResultCollector vCol, String name) {
if (relevant) {
List<Double> vector = vCol.getSamples(def);
VectorDef rDef;
VectorDef vector = findVector(((CollectorImpl) vCol).samples().keySet(), def);
if (vector != null) {
List<Double> vectorSamples = vCol.getSamples(vector);
VectorDef rDef;
int count = 0;
for (double v : vector) {
rDef = Factory.results().vector(
def.name().replace("(all)", ""), name + "_" + String.valueOf(count++), def.unit(), false);
for (double v : vectorSamples) {
rDef = Factory.results().vector(vector.name().replace("(ref. cell)", ""),
name + "_" + String.valueOf(count++), vector.unit(), false);
col.add(rDef, v);
}
} else {
String message = "Vector '" + def + "' not found for system '" + name + "'";
LOG.warn(message);
}
}
}
private VectorDef findVector(Iterable<VectorDef> vectorDefinitions, String def) {
List<VectorDef> candidates = new ArrayList<>();
for (VectorDef vector : vectorDefinitions) {
if (vector.name().contains(def)) {
candidates.add(vector);
}
}
if (candidates.size() == 1) {
return candidates.get(0);
}
for (VectorDef vector : candidates) {
if (vector.name().toLowerCase().contains("all")) {
return vector;
}
}
return null;
}
@Override
......@@ -111,24 +134,12 @@ public class DemoEPP_10_OFDMA_Internals implements EventProcessingPlugin<DemoEPP
@Config(order = 10, name = "Inter system interference")
boolean interSystemInterference();
/* @Config(order = 11, name="External interference")
boolean externalInterference();*/
@Config(order = 12, name = "External interference blocking")
boolean externalInterferenceBlocking();
@Config(order = 13, name = "External interference unwanted")
boolean externalInterferenceUnwanted();
@Config(order = 14, name = "Base station bit rate achieved")
boolean baseStationBitRate();
/* @Config(order = 15, name = "Power control PL")
boolean powerControlPL();*/
/* @Config(order = 16, name = "Power control PLilx")
boolean powerControlPLilx();*/
@Config(order = 17, name = "Path loss")
boolean pathLoss();
......
......@@ -106,9 +106,7 @@ public class OFDMAUpLinkSimulation implements SimulationInstance {
for (Victim victim : collector.getVictims()) {
VictimImpl v = (VictimImpl) victim;
collector.sample(FREQUENCY_ALL, v.getUEFrequency());
collector.sample(BIT_RATE_ACHIEVED_ALL, v.getAchievedBitrate());
collector.sample(RECEIVED_POWER_ALL, v.getReceivePower());
collector.sample(SINR_ACHIEVED_ALL, v.getAchievedSINR());
collector.sample(PATH_LOSS_ALL, v.getLinkResult().getTxRxPathLoss());
collector.sample(EFFECTIVE_PATH_LOSS_ALL, v.getLinkResult().getEffectiveTxRxPathLoss());
......@@ -116,9 +114,7 @@ public class OFDMAUpLinkSimulation implements SimulationInstance {
if (v.isConnectedToReferenceCell()) {
collector.sample(plugin.FREQUENCY, v.getUEFrequency());
collector.sample(plugin.BIT_RATE_ACHIEVED, v.getAchievedBitrate());
collector.sample(plugin.RECEIVED_POWER, v.getReceivePower());
collector.sample(plugin.SINR_ACHIEVED, v.getAchievedSINR());
collector.sample(plugin.PATH_LOSS, v.getLinkResult().getTxRxPathLoss());
collector.sample(plugin.EFFECTIVE_PATH_LOSS, v.getLinkResult().getEffectiveTxRxPathLoss());
......@@ -197,9 +193,12 @@ public class OFDMAUpLinkSimulation implements SimulationInstance {
for (Victim victim : vCollector.getVictims()) {
VictimImpl vi = (VictimImpl) victim;
vi.calculateAchievedSINRWatt();
double sinr = Mathematics.dB2Linear(vi.getAchievedSINR());
double sinr = vi.getAchievedSINR();
vCollector.sample(SINR_ACHIEVED_ALL, sinr);
sinr = Mathematics.dB2Linear(vi.getAchievedSINR());
vi.calculateAchievedBitrate();
double ach = vi.getAchievedBitrate();
vCollector.sample(BIT_RATE_ACHIEVED_ALL, ach);
totalBitrate += ach;
if (vi.isConnectedToReferenceCell()) {
sinrRefCellSum += sinr;
......@@ -207,6 +206,8 @@ public class OFDMAUpLinkSimulation implements SimulationInstance {
refCellBitrate += ach;
dRSS += Mathematics.dB2Linear(vi.getReceivePower());
ISI += vi.getTotalInterferenceWatt();
vCollector.sample(plugin.BIT_RATE_ACHIEVED, ach);
vCollector.sample(plugin.SINR_ACHIEVED, Mathematics.linear2dB(sinr));
}
sinrSum += sinr;
}
......
package org.seamcat.model.eventprocessing;
import static org.junit.Assert.*;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.stream.StreamSupport;
import org.junit.Test;
import org.seamcat.integrationtests.DeterministicWorkspaceLoader;
import org.seamcat.model.factory.ProxyHelper;
import org.seamcat.model.plugin.system.SystemPlugin;
import org.seamcat.model.simulation.result.Collector;
import org.seamcat.model.simulation.result.EventResult;
import org.seamcat.model.simulation.result.ValueName;
import org.seamcat.model.simulation.result.VectorDef;
import org.seamcat.model.types.Configuration;
import org.seamcat.model.workspace.WorkspaceModel;
public class TestDemoEPP_10_OFDMA_Internals extends DeterministicWorkspaceLoader {
@Test
public void testDistance() throws Exception {
loadWorkspace("/WS_generic_allCellSystems_Test2.sws");
EventResult result = runSimulation(1L);
List<EventProcessingConfiguration> epps = workspace.getEventProcessingList();
assertEquals(1, epps.size());
EventProcessingConfiguration epp10 = epps.get(0);
Iterable<VectorDef> vectors = getVectorDefs(result);
for (VectorDef vector : vectors) {
// Distances should not be part of what is reported by this EPP
assertFalse(vector.group().contains(ValueName.DISTANCES));
}
}
private static Iterable<VectorDef> getVectorDefs(EventResult result) {
List<Collector> eventProcessingResults = result.getEventProcessingResults();
Collector collector = eventProcessingResults.get(0);
Iterable<VectorDef> vectors = collector.getVectorDefinitions();
return vectors;
}
@Test
public void testInput() throws Exception {
loadWorkspace("/WS_generic_allCellSystems_Test2.sws");
WorkspaceModel model = workspace.getModel();
List<Configuration> configs = model.pluginConfigurations();
assertEquals(1, configs.size());
Configuration conf = configs.get(0);
if (conf instanceof EventProcessingConfiguration) {
EventProcessingConfiguration eppConf = (EventProcessingConfiguration) conf;
Object inputModel = eppConf.getModel();
if (inputModel instanceof DemoEPP_10_OFDMA_Internals.Input) {
DemoEPP_10_OFDMA_Internals.Input epp10model = (DemoEPP_10_OFDMA_Internals.Input) inputModel;
Map<Method, Object> values = ProxyHelper.getProxyValues(epp10model);
List<SystemPlugin> systems = workspace.getSystemPlugins();
for (SystemPlugin system : systems) {
String name = system.getUI().description().name();
if (!name.contains("Generic")) {
// Disable all values
for (Method method : values.keySet()) {
values.put(method, Boolean.valueOf(false));
}
workspace.setVictimSystemId(system.getUI().id());
EventResult result = runSimulation(1L);
Iterable<VectorDef> vectors = getVectorDefs(result);
for (VectorDef vector : vectors) {
// There should be no results
fail();
}
int factor = result.getAllInterferenceLinkResults().size();
testInputValue(values, "frequency", factor);
setInputValue(values, "bitRateAchieved", true);
setInputValue(values, "receivedPower", true);
setInputValue(values, "SINRAchieved", true);
setInputValue(values, "currentTransmitPower", true);
setInputValue(values, "interferencePower", false);
setInputValue(values, "interSystemInterference", false);
setInputValue(values, "externalInterferenceBlocking", true);
setInputValue(values, "externalInterferenceUnwanted", true);
setInputValue(values, "pathLoss", true);
testInputValue(values, "effectivePathLoss", factor * 9);
}
}
} else {
fail();
}
} else {
fail();
}
}
private void testInputValue(Map<Method, Object> values, String valueName, int expectedCount) {
setInputValue(values, valueName, true);
EventResult result = runSimulation(1L);
Iterable<VectorDef> vectors = getVectorDefs(result);
int count = (int) StreamSupport.stream(vectors.spliterator(), false).count();
if (expectedCount != count) {
assertEquals(expectedCount, count);
}
}
private void setInputValue(Map<Method, Object> values, String valueName, boolean b) {
for (Method method : values.keySet()) {
if (method.getName().contains(valueName)) {
values.put(method, Boolean.valueOf(b));
return;
}
}
}
}
File added
......@@ -78,9 +78,9 @@ public class ValueName {
public static final String DRSS = "dRSS";
public static final String SUM_DRSS = "Sum dRSS";
public static final String EFFECTIVE_ANTENNA_HEIGHT = "Effective Antenna Height";
public static final String EFFECTIVE_PATH_LOSS = "Effective Path loss";
public static final String EFFECTIVE_PATH_LOSS_ALL = "Effective path loss (all)";
public static final String EFFECTIVE_PATH_LOSS_REF = "Effective path loss (ref. ";
public static final String EFFECTIVE_PATH_LOSS = "Effective path loss";
public static final String EFFECTIVE_PATH_LOSS_ALL = EFFECTIVE_PATH_LOSS + " (all)";
public static final String EFFECTIVE_PATH_LOSS_REF = EFFECTIVE_PATH_LOSS + " (ref. ";
public static final String ELECTRICAL_ELEVATION_OFFSET = "Electrical elevation offset";
public static final String ELEMENT_GAIN = "Element gain";
public static final String ELEVATION = "Elevation ";
......
Supports Markdown
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