Commit 0a668d0a6f61ec2f46e8f22412886c6e6057c37a
Committed by
Andrew Shvayka
1 parent
42d2f0be
add time-units to ActionNode and UI
Showing
5 changed files
with
21 additions
and
11 deletions
... | ... | @@ -78,7 +78,7 @@ public abstract class AbstractGeofencingNode<T extends TbGpsGeofencingFilterNode |
78 | 78 | } |
79 | 79 | |
80 | 80 | protected List<Perimeter> getPerimeters(TbMsg msg, JsonObject msgDataObj) throws TbNodeException { |
81 | - if (config.isFetchPerimeterInfoFromMessage()) { | |
81 | + if (config.isFetchPerimeterInfoFromMessageMetadata()) { | |
82 | 82 | //TODO: add fetching perimeters from the message itself, if configuration is empty. |
83 | 83 | if (!StringUtils.isEmpty(msg.getMetaData().getValue("perimeter"))) { |
84 | 84 | Perimeter perimeter = new Perimeter(); | ... | ... |
... | ... | @@ -49,7 +49,9 @@ import java.util.concurrent.TimeoutException; |
49 | 49 | configClazz = TbGpsGeofencingActionNodeConfiguration.class, |
50 | 50 | relationTypes = {"Entered", "Left", "Inside", "Outside"}, |
51 | 51 | nodeDescription = "Produces incoming messages using GPS based geofencing", |
52 | - nodeDetails = "Extracts latitude and longitude parameters from incoming message and returns different events based on configuration parameters") | |
52 | + nodeDetails = "Extracts latitude and longitude parameters from incoming message and returns different events based on configuration parameters", | |
53 | + uiResources = {"static/rulenode/rulenode-core-config.js"}, | |
54 | + configDirective = "tbActionNodeGpsGeofencingConfig") | |
53 | 55 | public class TbGpsGeofencingActionNode extends AbstractGeofencingNode<TbGpsGeofencingActionNodeConfiguration> { |
54 | 56 | |
55 | 57 | private final Map<EntityId, EntityGeofencingState> entityStates = new HashMap<>(); |
... | ... | @@ -81,7 +83,8 @@ public class TbGpsGeofencingActionNode extends AbstractGeofencingNode<TbGpsGeofe |
81 | 83 | ctx.tellNext(msg, matches ? "Entered" : "Left"); |
82 | 84 | } else if (!entityState.isStayed()) { |
83 | 85 | long stayTime = ts - entityState.getStateSwitchTime(); |
84 | - if (stayTime > (entityState.isInside() ? config.getMinInsideDuration() : config.getMinOutsideDuration())) { | |
86 | + if (stayTime > (entityState.isInside() ? | |
87 | + TimeUnit.valueOf(config.getMinInsideDurationTimeUnit()).toMillis(config.getMinInsideDuration()) : TimeUnit.valueOf(config.getMinOutsideDurationTimeUnit()).toMillis(config.getMinOutsideDuration()))) { | |
85 | 88 | setStaid(ctx, msg.getOriginator(), entityState); |
86 | 89 | ctx.tellNext(msg, entityState.isInside() ? "Inside" : "Outside"); |
87 | 90 | } | ... | ... |
... | ... | @@ -28,17 +28,22 @@ import java.util.concurrent.TimeUnit; |
28 | 28 | @Data |
29 | 29 | public class TbGpsGeofencingActionNodeConfiguration extends TbGpsGeofencingFilterNodeConfiguration { |
30 | 30 | |
31 | - private double minInsideDuration; | |
32 | - private double minOutsideDuration; | |
31 | + private int minInsideDuration; | |
32 | + private int minOutsideDuration; | |
33 | + | |
34 | + private String minInsideDurationTimeUnit; | |
35 | + private String minOutsideDurationTimeUnit; | |
33 | 36 | |
34 | 37 | @Override |
35 | 38 | public TbGpsGeofencingActionNodeConfiguration defaultConfiguration() { |
36 | 39 | TbGpsGeofencingActionNodeConfiguration configuration = new TbGpsGeofencingActionNodeConfiguration(); |
37 | 40 | configuration.setLatitudeKeyName("latitude"); |
38 | 41 | configuration.setLongitudeKeyName("longitude"); |
39 | - configuration.setFetchPerimeterInfoFromMessage(true); | |
40 | - configuration.setMinInsideDuration(TimeUnit.MINUTES.toMillis(1)); | |
41 | - configuration.setMinOutsideDuration(TimeUnit.MINUTES.toMillis(1)); | |
42 | + configuration.setFetchPerimeterInfoFromMessageMetadata(true); | |
43 | + configuration.setMinInsideDurationTimeUnit(TimeUnit.MINUTES.name()); | |
44 | + configuration.setMinOutsideDurationTimeUnit(TimeUnit.MINUTES.name()); | |
45 | + configuration.setMinInsideDuration(1); | |
46 | + configuration.setMinOutsideDuration(1); | |
42 | 47 | return configuration; |
43 | 48 | } |
44 | 49 | } | ... | ... |
... | ... | @@ -50,7 +50,9 @@ import java.util.List; |
50 | 50 | configClazz = TbGpsGeofencingFilterNodeConfiguration.class, |
51 | 51 | relationTypes = {"True", "False"}, |
52 | 52 | nodeDescription = "Filter incoming messages by GPS based geofencing", |
53 | - nodeDetails = "Extracts latitude and longitude parameters from incoming message and returns 'True' if they are inside configured perimeters, 'False' otherwise.") | |
53 | + nodeDetails = "Extracts latitude and longitude parameters from incoming message and returns 'True' if they are inside configured perimeters, 'False' otherwise.", | |
54 | + uiResources = {"static/rulenode/rulenode-core-config.js"}, | |
55 | + configDirective = "tbFilterNodeGpsGeofencingConfig") | |
54 | 56 | public class TbGpsGeofencingFilterNode extends AbstractGeofencingNode<TbGpsGeofencingFilterNodeConfiguration> { |
55 | 57 | |
56 | 58 | @Override | ... | ... |
... | ... | @@ -32,7 +32,7 @@ public class TbGpsGeofencingFilterNodeConfiguration implements NodeConfiguration |
32 | 32 | |
33 | 33 | private String latitudeKeyName; |
34 | 34 | private String longitudeKeyName; |
35 | - private boolean fetchPerimeterInfoFromMessage; | |
35 | + private boolean fetchPerimeterInfoFromMessageMetadata; | |
36 | 36 | |
37 | 37 | private PerimeterType perimeterType; |
38 | 38 | |
... | ... | @@ -50,7 +50,7 @@ public class TbGpsGeofencingFilterNodeConfiguration implements NodeConfiguration |
50 | 50 | TbGpsGeofencingFilterNodeConfiguration configuration = new TbGpsGeofencingFilterNodeConfiguration(); |
51 | 51 | configuration.setLatitudeKeyName("latitude"); |
52 | 52 | configuration.setLongitudeKeyName("longitude"); |
53 | - configuration.setFetchPerimeterInfoFromMessage(true); | |
53 | + configuration.setFetchPerimeterInfoFromMessageMetadata(true); | |
54 | 54 | return configuration; |
55 | 55 | } |
56 | 56 | } | ... | ... |