From 42d2f0be1032d874a1c276f83a8999ceaf08cd6e Mon Sep 17 00:00:00 2001 From: Andrew Shvayka Date: Fri, 29 Mar 2019 18:23:58 +0200 Subject: [PATCH] Geofencing rule nodes --- .../engine/geo/AbstractGeofencingNode.java | 13 +++++++++++- .../engine/geo/EntityGeofencingState.java | 2 +- .../engine/geo/TbGpsGeofencingActionNode.java | 20 ++++++++----------- ...bGpsGeofencingActionNodeConfiguration.java | 1 - .../engine/geo/TbGpsGeofencingFilterNode.java | 8 +------- ...bGpsGeofencingFilterNodeConfiguration.java | 13 ++++++++++-- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/AbstractGeofencingNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/AbstractGeofencingNode.java index f876967917..2aec28f08b 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/AbstractGeofencingNode.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/AbstractGeofencingNode.java @@ -97,7 +97,14 @@ public abstract class AbstractGeofencingNode { @@ -68,7 +68,7 @@ public class TbGpsGeofencingActionNode extends AbstractGeofencingNode (entityState.isInside() ? config.getMinInsideDuration() : config.getMinOutsideDuration())) { setStaid(ctx, msg.getOriginator(), entityState); + ctx.tellNext(msg, entityState.isInside() ? "Inside" : "Outside"); } } } @@ -90,12 +91,12 @@ public class TbGpsGeofencingActionNode extends AbstractGeofencingNode attributeKvEntryList = Collections.singletonList(entry); ctx.getAttributesService().save(ctx.getTenantId(), entityId, DataConstants.SERVER_SCOPE, attributeKvEntryList); } - @Override - public void destroy() { - - } - @Override protected Class getConfigClazz() { return TbGpsGeofencingActionNodeConfiguration.class; diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingActionNodeConfiguration.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingActionNodeConfiguration.java index dac9e7d23d..f6b275e008 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingActionNodeConfiguration.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingActionNodeConfiguration.java @@ -37,7 +37,6 @@ public class TbGpsGeofencingActionNodeConfiguration extends TbGpsGeofencingFilte configuration.setLatitudeKeyName("latitude"); configuration.setLongitudeKeyName("longitude"); configuration.setFetchPerimeterInfoFromMessage(true); - configuration.setPerimeters(Collections.emptyList()); configuration.setMinInsideDuration(TimeUnit.MINUTES.toMillis(1)); configuration.setMinOutsideDuration(TimeUnit.MINUTES.toMillis(1)); return configuration; diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingFilterNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingFilterNode.java index 66a23ca2a8..e816cb6cdc 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingFilterNode.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/geo/TbGpsGeofencingFilterNode.java @@ -55,13 +55,7 @@ public class TbGpsGeofencingFilterNode extends AbstractGeofencingNode perimeters; + + private PerimeterType perimeterType; + + //For Polygons + private String polygonsDefinition; + + //For Circles + private Double centerLatitude; + private Double centerLongitude; + private Double range; + private RangeUnit rangeUnit; @Override public TbGpsGeofencingFilterNodeConfiguration defaultConfiguration() { @@ -41,7 +51,6 @@ public class TbGpsGeofencingFilterNodeConfiguration implements NodeConfiguration configuration.setLatitudeKeyName("latitude"); configuration.setLongitudeKeyName("longitude"); configuration.setFetchPerimeterInfoFromMessage(true); - configuration.setPerimeters(Collections.emptyList()); return configuration; } }