Skip to content
Snippets Groups Projects
Commit 8e808f9d authored by FrankR's avatar FrankR
Browse files

Bugfix: STOMP message is sent if BT rawdata only contains rss-values and no distances

BT rawdata messages are ignored if neither distances nor rss-values are contained
UWB rawdata messages are ignored if no distances contained
testdata extended
parent de31795e
No related branches found
No related tags found
No related merge requests found
...@@ -122,7 +122,7 @@ public class Tooz { ...@@ -122,7 +122,7 @@ public class Tooz {
} }
List<Map.Entry<String, Double>> sortedDistances = extractSortedDistances(monitoredTarget); List<Map.Entry<String, Double>> sortedDistances = extractSortedDistances(monitoredTarget);
if (sortedDistances.size() == 0){ if (sortedDistances.size() == 0){
LOG.info("Could not update Tooz-backend for monitoring Target " + monitoredTarget.getTargetSensorId() + "as no distant entities are known yet."); LOG.info("Could not update Tooz-backend for monitoring Target " + monitoredTarget.getTargetSensorId() + " as no distant entities are known yet.");
return; return;
} }
Map.Entry<String, Double> nearestDistantEntity = sortedDistances.get(0); Map.Entry<String, Double> nearestDistantEntity = sortedDistances.get(0);
......
...@@ -41,17 +41,31 @@ public class ToozExt extends IPosExtension { ...@@ -41,17 +41,31 @@ public class ToozExt extends IPosExtension {
@Override @Override
public void handleRawdataEvent(IPosRawdataEvent iPosRawdataEvent) { public void handleRawdataEvent(IPosRawdataEvent iPosRawdataEvent) {
if (iPosRawdataEvent instanceof IPosUWBEvent){ if (iPosRawdataEvent instanceof IPosUWBEvent){
IPosUWBEvent iPosUWBEvent = (IPosUWBEvent) iPosRawdataEvent; handleIPosUWBEvent((IPosUWBEvent) iPosRawdataEvent);
handleIPosBeaconEvent((IPosBeaconEvent) iPosUWBEvent);
} }
if (iPosRawdataEvent instanceof IPosBTEvent){ if (iPosRawdataEvent instanceof IPosBTEvent){
IPosBTEvent iPosBTEvent = (IPosBTEvent) iPosRawdataEvent; handleIPosBTEvent((IPosBTEvent) iPosRawdataEvent);
if (null == iPosBTEvent.getDistances() && null != iPosBTEvent.getRss()) { }
iPosBTEvent.setDistances(translateRssToDistances(iPosBTEvent)); }
} private void handleIPosBTEvent(IPosBTEvent iPosRawdataEvent) {
IPosBTEvent iPosBTEvent = iPosRawdataEvent;
if ((iPosBTEvent.getDistances().size() == 0) && (iPosBTEvent.getRss().size() == 0)){
LOG.info("Ignoring IPosBTEvent, as it neither contains distances nor rss-values");
return;
}
if ((iPosBTEvent.getDistances().size() == 0) && (iPosBTEvent.getRss().size() > 0)) {
iPosBTEvent.setDistances(translateRssToDistances(iPosBTEvent));
}
handleIPosBeaconEvent((IPosBeaconEvent) iPosBTEvent);
}
handleIPosBeaconEvent((IPosBeaconEvent) iPosBTEvent); private void handleIPosUWBEvent(IPosUWBEvent iPosRawdataEvent) {
IPosUWBEvent iPosUWBEvent = iPosRawdataEvent;
if (iPosUWBEvent.getDistances().size() > 0) {
handleIPosBeaconEvent((IPosBeaconEvent) iPosUWBEvent);
}else{
LOG.info("Ignoring IPosUWBEvent as it does not contain any distances");
} }
} }
......
...@@ -65,8 +65,10 @@ public class ToozLocalAgent { ...@@ -65,8 +65,10 @@ public class ToozLocalAgent {
private String targetSensorId; private String targetSensorId;
public void addOrUpdateDistances(Map<String, Double> map){ public void addOrUpdateDistances(Map<String, Double> map){
map.entrySet().forEach(entry -> distances.put(entry.getKey(), entry.getValue())); // put-function creates new entry, or updates existing one if (map.size() > 0) {
this.hasChanged = true; map.entrySet().forEach(entry -> distances.put(entry.getKey(), entry.getValue())); // put-function creates new entry, or updates existing one
this.hasChanged = true;
}
} }
public String getLocalAgentId() { public String getLocalAgentId() {
......
{"uwbRawDataEvent" : [ {"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_uwb", "type": "UWB"}]}
{"bluetoothRawDataEvent" : [{"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_bt", "type": "BT"}]}
{"bluetoothRawDataEvent" : [{"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_bt", "type": "BT", "rss": {"beacon_1" : "12.7", "beacon_2" : "15.3", "beacon_3" : "18.7"}}]}
{"bluetoothRawDataEvent" : [{"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_bt", "distances": {"beacon_1" : "2.5", "beacon_2" : "5.5", "beacon_3" : "8.5"}, "type": "BT", "rss": {"beacon_1" : "12.7", "beacon_2" : "15.3", "beacon_3" : "18.7"}}]} {"bluetoothRawDataEvent" : [{"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_bt", "distances": {"beacon_1" : "2.5", "beacon_2" : "5.5", "beacon_3" : "8.5"}, "type": "BT", "rss": {"beacon_1" : "12.7", "beacon_2" : "15.3", "beacon_3" : "18.7"}}]}
{"bluetoothRawDataEvent" : [{"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_bt", "distances": {"beacon_1" : "2.5", "beacon_2" : "5.5", "beacon_3" : "8.5"}, "type": "BT"}]}
{"uwbRawDataEvent" : [ {"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_uwb", "distances": {"beacon_1" : "2.5", "beacon_2" : "5.5", "beacon_3" : "8.5"}, "type": "UWB"}]} {"uwbRawDataEvent" : [ {"timestamp" : "2022-02-02T16:03:20+00:00", "sensorId" : "tooz_employee_uwb", "distances": {"beacon_1" : "2.5", "beacon_2" : "5.5", "beacon_3" : "8.5"}, "type": "UWB"}]}
{"uwbRawDataEvent" : [ {"timestamp" : "2022-02-02T16:04:20+00:00", "sensorId" : "tooz_employee_uwb", "distances": {"beacon_1" : "15.0"}, "type": "UWB"}]} {"uwbRawDataEvent" : [ {"timestamp" : "2022-02-02T16:04:20+00:00", "sensorId" : "tooz_employee_uwb", "distances": {"beacon_1" : "15.0"}, "type": "UWB"}]}
{"uwbRawDataEvent" : [ {"timestamp" : "2022-02-02T16:05:20+00:00", "sensorId" : "tooz_employee_uwb", "distances": {"beacon_5" : "1.8"}, "type": "UWB"}]} {"uwbRawDataEvent" : [ {"timestamp" : "2022-02-02T16:05:20+00:00", "sensorId" : "tooz_employee_uwb", "distances": {"beacon_5" : "1.8"}, "type": "UWB"}]}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment