Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Rules: Added support for historic value, sum, maximum, minimum, average, median, derivative, and integral blocks in flow rules (#1525)

Panos Kalogeropoulosad4e05a0172d
diff --git a/manager/src/main/java/org/openremote/manager/rules/FlowRulesBuilder.java b/manager/src/main/java/org/openremote/manager/rules/FlowRulesBuilder.java
index 65597f7fa..9c2aead76 100644
--- a/manager/src/main/java/org/openremote/manager/rules/FlowRulesBuilder.java
+++ b/manager/src/main/java/org/openremote/manager/rules/FlowRulesBuilder.java
@@ -72,7 +72,7 @@ public class FlowRulesBuilder {
}
private Rule createRule(String name, NodeCollection collection, Node outputNode) throws Exception {
- Object implementationResult = NodeModel.getImplementationFor(outputNode.getName()).execute(new NodeExecutionRequestInfo(collection, outputNode, null, null, assetsFacade, usersFacade, notificationFacade, historicDatapointsFacade, predictedDatapointsFacade));
+ Object implementationResult = NodeModel.getImplementationFor(outputNode.getName()).execute(new NodeExecutionRequestInfo(collection, outputNode, null, null, assetsFacade, usersFacade, notificationFacade, historicDatapointsFacade, predictedDatapointsFacade, LOG));
if (!(implementationResult instanceof RulesBuilder.Action action))
throw new Exception(outputNode.getName() + " node does not return an action");
diff --git a/manager/src/main/java/org/openremote/manager/rules/flow/FlowResourceImpl.java b/manager/src/main/java/org/openremote/manager/rules/flow/FlowResourceImpl.java
index 9fea537fa..6d1af8f81 100644
--- a/manager/src/main/java/org/openremote/manager/rules/flow/FlowResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/rules/flow/FlowResourceImpl.java
@@ -1,12 +1,12 @@
package org.openremote.manager.rules.flow;
+import org.openremote.model.Container;
import org.openremote.container.timer.TimerService;
+import org.openremote.container.util.MapAccess;
import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.manager.web.ManagerWebResource;
import org.openremote.model.http.RequestParams;
-import org.openremote.model.rules.flow.FlowResource;
-import org.openremote.model.rules.flow.Node;
-import org.openremote.model.rules.flow.NodeType;
+import org.openremote.model.rules.flow.*;
import java.util.Arrays;
import java.util.logging.Logger;
@@ -15,21 +15,26 @@ public class FlowResourceImpl extends ManagerWebResource implements FlowResource
private static final Logger LOG = Logger.getLogger(FlowResourceImpl.class.getName());
+ private final Node[] nodes;
+
public FlowResourceImpl(TimerService timerService, ManagerIdentityService identityService) {
super(timerService, identityService);
- for (Node node : Arrays.stream(NodeModel.values()).map(NodeModel::getDefinition).toArray(Node[]::new)) {
- LOG.finest("Node found: " + node.getName());
- }
+ Arrays.stream(NodeModel.values()).map(NodeModel::getDefinition).forEach(n -> {
+ LOG.finest("Node found: " + n.getName());
+ });
+
+ nodes = Arrays.stream(NodeModel.values()).map(NodeModel::getDefinition).toArray(Node[]::new);
+
}
@Override
public Node[] getAllNodeDefinitions(RequestParams requestParams) {
- return Arrays.stream(NodeModel.values()).map(NodeModel::getDefinition).toArray(Node[]::new);
+ return nodes;
}
@Override
public Node[] getAllNodeDefinitionsByType(RequestParams requestParams, NodeType type) {
- return Arrays.stream(NodeModel.values()).filter((n) -> n.getDefinition().getType().equals(type)).map(NodeModel::getDefinition).toArray(Node[]::new);
+ return Arrays.stream(nodes).filter(n -> n.getType() == type).toArray(Node[]::new);
}
@Override
diff --git a/manager/src/main/java/org/openremote/manager/rules/flow/NodeExecutionRequestInfo.java b/manager/src/main/java/org/openremote/manager/rules/flow/NodeExecutionRequestInfo.java
index b861d6674..09ec8eec0 100644
--- a/manager/src/main/java/org/openremote/manager/rules/flow/NodeExecutionRequestInfo.java
+++ b/manager/src/main/java/org/openremote/manager/rules/flow/NodeExecutionRequestInfo.java
@@ -7,6 +7,7 @@ import org.openremote.model.rules.flow.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.logging.Logger;
import java.util.stream.Collectors;
public class NodeExecutionRequestInfo {
@@ -27,6 +28,7 @@ public class NodeExecutionRequestInfo {
private Notifications notifications;
private HistoricDatapoints historicDatapoints;
private PredictedDatapoints predictedDatapoints;
+ protected Logger LOG;
public NodeExecutionRequestInfo() {
collection = new NodeCollection();
@@ -65,7 +67,7 @@ public class NodeExecutionRequestInfo {
public NodeExecutionRequestInfo(NodeCollection collection, Node node, NodeSocket socket, RulesFacts facts,
Assets assets, Users users, Notifications notifications,
- HistoricDatapoints historicDatapoints, PredictedDatapoints predictedDatapoints) {
+ HistoricDatapoints historicDatapoints, PredictedDatapoints predictedDatapoints, Logger log) {
if (socket != null && Arrays.stream(node.getOutputs()).noneMatch(c -> c.getNodeId().equals(node.getId())))
throw new IllegalArgumentException("Given socket does not belong to given node");
@@ -94,13 +96,14 @@ public class NodeExecutionRequestInfo {
this.notifications = notifications;
this.historicDatapoints = historicDatapoints;
this.predictedDatapoints = predictedDatapoints;
+ this.LOG = log;
}
public Object getValueFromInput(int index) {
NodeSocket aSocket = getInputs()[index];
Node aNode = getCollection().getNodeById(aSocket.getNodeId());
return NodeModel.getImplementationFor(aNode.getName()).execute(
- new NodeExecutionRequestInfo(getCollection(), aNode, aSocket, getFacts(), getAssets(), getUsers(), getNotifications(), getHistoricDatapoints(), getPredictedDatapoints())
+ new NodeExecutionRequestInfo(getCollection(), aNode, aSocket, getFacts(), getAssets(), getUsers(), getNotifications(), getHistoricDatapoints(), getPredictedDatapoints(), LOG)
);
}
diff --git a/manager/src/main/java/org/openremote/manager/rules/flow/NodeModel.java b/manager/src/main/java/org/openremote/manager/rules/flow/NodeModel.java
index b2900c88c..1f0dd7383 100644
--- a/manager/src/main/java/org/openremote/manager/rules/flow/NodeModel.java
+++ b/manager/src/main/java/org/openremote/manager/rules/flow/NodeModel.java
@@ -2,14 +2,18 @@ package org.openremote.manager.rules.flow;
import org.openremote.manager.rules.RulesBuilder;
import org.openremote.model.attribute.AttributeInfo;
+import org.openremote.model.attribute.AttributeRef;
+import org.openremote.model.datapoint.ValueDatapoint;
+import org.openremote.model.datapoint.query.AssetDatapointNearestQuery;
import org.openremote.model.query.AssetQuery;
import org.openremote.model.rules.flow.*;
import org.openremote.model.util.ValueUtil;
import org.openremote.model.value.ValueHolder;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.time.Instant;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.stream.IntStream;
public enum NodeModel {
READ_ATTRIBUTE(
@@ -42,6 +46,158 @@ public enum NodeModel {
}
),
+ DERIVATIVE(
+ new Node(NodeType.INPUT, new NodeInternal[]{
+ new NodeInternal("Attribute", new Picker(PickerType.ASSET_ATTRIBUTE))
+ },
+ new NodeSocket[0], new NodeSocket[]{
+ new NodeSocket("value", NodeDataType.NUMBER)
+ }),
+ info -> {
+ AttributeInternalValue assetAttributePair = ValueUtil.JSON.convertValue(info.getInternals()[0].getValue(), AttributeInternalValue.class);
+ String assetId = assetAttributePair.getAssetId();
+ String attributeName = assetAttributePair.getAttributeName();
+ Optional<AttributeInfo> attr = info.getFacts().matchFirstAssetState(new AssetQuery().ids(assetId).attributeName(attributeName));
+ if (attr.isPresent()) {
+ AttributeInfo attributeInfo = attr.get();
+ Optional<Object> currentValueOpt = attributeInfo.getValue();
+ Optional<Object> oldValueOpt = attributeInfo.getOldValue();
+ long currentTimestamp = attributeInfo.getTimestamp();
+ long oldTimestamp = attributeInfo.getOldValueTimestamp();
+
+ if (currentValueOpt.isPresent() && oldValueOpt.isPresent()) {
+ double currentValue = ((Number) currentValueOpt.get()).doubleValue();
+ double oldValue = ((Number) oldValueOpt.get()).doubleValue();
+ double timeDifference = (currentTimestamp - oldTimestamp) / 1000.0; // Convert milliseconds to seconds
+
+ if (timeDifference != 0) {
+ return (currentValue - oldValue) / timeDifference; // Δx formula
+ }
+ }
+ }
+
+ return null;
+ },
+ params -> {
+ AttributeInternalValue internal = ValueUtil.JSON.convertValue(params.getNode().getInternals()[0].getValue(), AttributeInternalValue.class);
+ String assetId = internal.getAssetId();
+ String attributeName = internal.getAttributeName();
+ Optional<AttributeInfo> x = params.getFacts().getAssetStates().stream()
+ .filter(assetState ->
+ Objects.equals(assetState.getId(), assetId)
+ && Objects.equals(assetState.getName(), attributeName))
+ .findFirst();
+
+ List<AttributeInfo> allAssets = params.getFacts().matchAssetState(new AssetQuery().ids(assetId).attributeName(attributeName)
+ ).toList();
+
+ return allAssets.stream().anyMatch(state -> {
+ long timestamp = state.getTimestamp();
+ long triggerStamp = params.getBuilder().getTriggerMap().getOrDefault(params.getRuleName(), -1L);
+ if (triggerStamp == -1L) return true; //The flow has never been executed
+ return timestamp > triggerStamp && !Objects.equals(state.getValue().orElse(null), state.getOldValue().orElse(null));
+ });
+ }
+ ),
+ INTEGRAL(
+ new Node(NodeType.INPUT, new NodeInternal[]{
+ new NodeInternal("Attribute", new Picker(PickerType.ASSET_ATTRIBUTE))
+ },
+ new NodeSocket[0], new NodeSocket[]{
+ new NodeSocket("value", NodeDataType.NUMBER)
+ }),
+ info -> {
+ AttributeInternalValue assetAttributePair = ValueUtil.JSON.convertValue(info.getInternals()[0].getValue(), AttributeInternalValue.class);
+ String assetId = assetAttributePair.getAssetId();
+ String attributeName = assetAttributePair.getAttributeName();
+ Optional<AttributeInfo> attr = info.getFacts().matchAssetState(new AssetQuery().ids(assetId).attributeName(attributeName)).findFirst();
+
+ double integral = 0.0;
+ if (attr.isPresent()) {
+ AttributeInfo attributeInfo = attr.get();
+ Optional<Object> currentValueOpt = attributeInfo.getValue();
+ Optional<Object> oldValueOpt = attributeInfo.getOldValue();
+ long currentTimestamp = attributeInfo.getTimestamp();
+ long oldTimestamp = attributeInfo.getOldValueTimestamp();
+
+ if (currentValueOpt.isPresent() && oldValueOpt.isPresent()) {
+ double currentValue = ((Number) currentValueOpt.get()).doubleValue();
+ double previousValue = ((Number) oldValueOpt.get()).doubleValue();
+ double timeDifference = (currentTimestamp - oldTimestamp) / 1000.0; // Convert milliseconds to seconds
+
+ integral += ((currentValue + previousValue) * timeDifference) / 2;
+ }
+ }
+
+ return integral;
+ },
+ params -> {
+ AttributeInternalValue internal = ValueUtil.JSON.convertValue(params.getNode().getInternals()[0].getValue(), AttributeInternalValue.class);
+ String assetId = internal.getAssetId();
+ String attributeName = internal.getAttributeName();
+ List<AttributeInfo> allAssets = params.getFacts().matchAssetState(new AssetQuery().ids(assetId).attributeName(attributeName)).toList();
+
+ return allAssets.stream().anyMatch(state -> {
+ long timestamp = state.getTimestamp();
+ long triggerStamp = params.getBuilder().getTriggerMap().getOrDefault(params.getRuleName(), -1L);
+ if (triggerStamp == -1L) return true; // The flow has never been executed
+ return timestamp > triggerStamp && !Objects.equals(state.getValue().orElse(null), state.getOldValue().orElse(null));
+ });
+ }
+ ),
+ HISTORIC_VALUE(
+ new Node(NodeType.INPUT, new NodeInternal[]
+ {
+ new NodeInternal("attribute", new Picker(PickerType.ASSET_ATTRIBUTE), NodeInternal.BreakType.NEW_LINE),
+ new NodeInternal("time_period", new Picker(PickerType.DATE), NodeInternal.BreakType.SPACER),
+ new NodeInternal("time_unit", new Picker(PickerType.DROPDOWN, Arrays.stream(TimePeriod.values()).map(it -> new Option(it.label, it.name())).toArray(Option[]::new)), NodeInternal.BreakType.SPACER)
+ },
+ new NodeSocket[0],
+ new NodeSocket[]{
+ new NodeSocket("value", NodeDataType.ANY)
+ }
+ ),
+ info -> {
+ AttributeInternalValue assetAttributePair = ValueUtil.JSON.convertValue(info.getInternals()[0].getValue(), AttributeInternalValue.class);
+ AttributeRef ref = new AttributeRef(assetAttributePair.getAssetId(), assetAttributePair.getAttributeName());
+ Number timePeriod;
+ Number timeUnit;
+ timePeriod = TimePeriod.valueOf(info.getInternals()[2].getValue().toString()).getMillis();
+ timeUnit = Long.parseLong(info.getInternals()[1].getValue().toString());
+ if(timePeriod == null) return null;
+
+ long currentMillis = info.getFacts().getClock().getCurrentTimeMillis();
+
+ Instant pastInstant = Instant.ofEpochMilli(currentMillis-(timePeriod.longValue()*timeUnit.longValue()));
+
+ final ValueDatapoint<?>[] valueDatapoints = info.getHistoricDatapoints().getValueDatapoints(ref, new AssetDatapointNearestQuery(pastInstant.toEpochMilli()));
+ return valueDatapoints.length > 0 ? valueDatapoints[0].getValue() : null;
+ },
+ params -> {
+ AttributeInternalValue internal = ValueUtil.JSON.convertValue(params.getNode().getInternals()[0].getValue(), AttributeInternalValue.class);
+ String assetId = internal.getAssetId();
+ String attributeName = internal.getAttributeName();
+ List<AttributeInfo> allAssets = params.getFacts().matchAssetState(new AssetQuery().ids(assetId).attributeName(attributeName)
+ ).toList();
+
+ return allAssets.stream().anyMatch(state -> {
+ long timestamp = state.getTimestamp();
+ long triggerStamp = params.getBuilder().getTriggerMap().getOrDefault(params.getRuleName(), -1L);
+ if (triggerStamp == -1L) return true; //The flow has never been executed
+ return timestamp > triggerStamp && !Objects.equals(state.getValue().orElse(null), state.getOldValue().orElse(null));
+ });
+ }
+ ),
+
+ LOG_OUTPUT(new Node(NodeType.OUTPUT, new NodeInternal[0], new NodeSocket[]{
+ new NodeSocket("value", NodeDataType.ANY)
+ }, new NodeSocket[0]),
+ info -> ((RulesBuilder.Action) facts -> {
+ info.setFacts(facts);
+ Object obj = info.getValueFromInput(0);
+ info.LOG.log(Level.INFO, ValueUtil.asJSON(obj).orElseGet(() -> "Couldn't parse JSON"));
+ })),
+
WRITE_ATTRIBUTE(new Node(NodeType.OUTPUT, new NodeInternal[]{
new NodeInternal("Attribute", new Picker(PickerType.ASSET_ATTRIBUTE))
}, new NodeSocket[]{
@@ -119,7 +275,7 @@ public enum NodeModel {
}),
info -> ValueUtil.convert(info.getInternals()[0].getValue(), Double.class)),
- ADD_OPERATOR(new Node(NodeType.PROCESSOR, "+", new NodeInternal[0], new NodeSocket[]{
+ ADD_OPERATOR(new Node(NodeType.PROCESSOR, 1, "+", new NodeInternal[0], new NodeSocket[]{
new NodeSocket("a", NodeDataType.NUMBER),
new NodeSocket("b", NodeDataType.NUMBER),
}, new NodeSocket[]{
@@ -131,7 +287,7 @@ public enum NodeModel {
return a != null && b != null ? a.doubleValue() + b.doubleValue() : null;
}),
- SUBTRACT_OPERATOR(new Node(NodeType.PROCESSOR, "-", new NodeInternal[0], new NodeSocket[]{
+ SUBTRACT_OPERATOR(new Node(NodeType.PROCESSOR, 2, "-", new NodeInternal[0], new NodeSocket[]{
new NodeSocket("a", NodeDataType.NUMBER),
new NodeSocket("b", NodeDataType.NUMBER),
}, new NodeSocket[]{
@@ -143,7 +299,7 @@ public enum NodeModel {
return a != null && b != null ? a.doubleValue() - b.doubleValue() : null;
}),
- MULTIPLY_OPERATOR(new Node(NodeType.PROCESSOR, "×", new NodeInternal[0], new NodeSocket[]{
+ MULTIPLY_OPERATOR(new Node(NodeType.PROCESSOR, 3, "×", new NodeInternal[0], new NodeSocket[]{
new NodeSocket("a", NodeDataType.NUMBER),
new NodeSocket("b", NodeDataType.NUMBER),
}, new NodeSocket[]{
@@ -155,7 +311,7 @@ public enum NodeModel {
return a != null && b != null ? a.doubleValue() * b.doubleValue() : null;
}),
- DIVIDE_OPERATOR(new Node(NodeType.PROCESSOR, "÷", new NodeInternal[0], new NodeSocket[]{
+ DIVIDE_OPERATOR(new Node(NodeType.PROCESSOR,4, "÷", new NodeInternal[0], new NodeSocket[]{
new NodeSocket("a", NodeDataType.NUMBER),
new NodeSocket("b", NodeDataType.NUMBER),
}, new NodeSocket[]{
@@ -187,6 +343,55 @@ public enum NodeModel {
return a != null && b != null && Objects.equals(a, b);
}),
+ SUM_PROCESSOR(new Node(NodeType.PROCESSOR,5, "Σ", new NodeInternal[0], new NodeSocket[]{
+ new NodeSocket("a", NodeDataType.NUMBER_ARRAY)
+ }, new NodeSocket[]{
+ new NodeSocket("b", NodeDataType.NUMBER),
+ }),
+ info -> IntStream.range(0, info.getInputs().length)
+ .mapToObj(info::getValueFromInput).mapToDouble(value -> ((Number) value).doubleValue()).sum()
+ ),
+ MAX_PROCESSOR(new Node(NodeType.PROCESSOR, "max", new NodeInternal[0], new NodeSocket[]{
+ new NodeSocket("a", NodeDataType.NUMBER_ARRAY)
+ }, new NodeSocket[]{
+ new NodeSocket("b", NodeDataType.NUMBER),
+ }),
+ info -> IntStream.range(0, info.getInputs().length)
+ .mapToObj(info::getValueFromInput).mapToDouble(value -> ((Number) value).doubleValue()).max().orElseThrow()
+ ),
+ MIN_PROCESSOR(new Node(NodeType.PROCESSOR, "min", new NodeInternal[0], new NodeSocket[]{
+ new NodeSocket("a", NodeDataType.NUMBER_ARRAY)
+ }, new NodeSocket[]{
+ new NodeSocket("b", NodeDataType.NUMBER),
+ }),
+ info -> IntStream.range(0, info.getInputs().length)
+ .mapToObj(info::getValueFromInput).mapToDouble(value -> ((Number) value).doubleValue()).min().orElseThrow()
+ ),
+ AVERAGE_PROCESSOR(new Node(NodeType.PROCESSOR, "avg", new NodeInternal[0], new NodeSocket[]{
+ new NodeSocket("a", NodeDataType.NUMBER_ARRAY)
+ }, new NodeSocket[]{
+ new NodeSocket("b", NodeDataType.NUMBER),
+ }),
+ info -> IntStream.range(0, info.getInputs().length)
+ .mapToObj(info::getValueFromInput).mapToDouble(value -> ((Number) value).doubleValue()).average().orElseThrow()
+ ),
+ MEDIAN_PROCESSOR(new Node(NodeType.PROCESSOR, "med", new NodeInternal[0], new NodeSocket[]{
+ new NodeSocket("a", NodeDataType.NUMBER_ARRAY)
+ }, new NodeSocket[]{
+ new NodeSocket("b", NodeDataType.NUMBER),
+ }),
+ info -> {
+ final double[] sortedDoubles = IntStream.range(0, info.getInputs().length)
+ .mapToObj(info::getValueFromInput).mapToDouble(value -> ((Number) value).doubleValue()).sorted().toArray();
+ if (sortedDoubles.length == 0) {
+ return 0.0;
+ } else if (sortedDoubles.length % 2 == 0) {
+ return (sortedDoubles[sortedDoubles.length / 2 - 1] + sortedDoubles[sortedDoubles.length / 2]) / 2.0;
+ } else {
+ return sortedDoubles[sortedDoubles.length / 2];
+ }
+ }
+ ),
GREATER_THAN(new Node(NodeType.PROCESSOR, ">", new NodeInternal[0], new NodeSocket[]{
new NodeSocket("a", NodeDataType.NUMBER),
new NodeSocket("b", NodeDataType.NUMBER),
@@ -401,6 +606,31 @@ public enum NodeModel {
this.triggerFunction = triggerFunction;
}
+
+ private enum TimePeriod {
+ SECONDS("seconds ago", 1000L),
+ MINUTES("minutes ago", SECONDS.millis * 60),
+ HOURS("hours ago", MINUTES.millis * 24),
+ DAYS("days ago", HOURS.millis * 30),
+ MONTHS("months ago", DAYS.millis * 12);
+
+ private final String label;
+ private final Long millis;
+
+ TimePeriod(String label, Long millis) {
+ this.label = label;
+ this.millis = millis;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public Long getMillis() {
+ return millis;
+ }
+ }
+
private Node definition;
private NodeImplementation implementation;
private NodeTriggerFunction triggerFunction;
diff --git a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointNearestQuery.java b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointNearestQuery.java
new file mode 100644
index 000000000..d06cc39df
--- /dev/null
+++ b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointNearestQuery.java
@@ -0,0 +1,42 @@
+package org.openremote.model.datapoint.query;
+
+import org.openremote.model.attribute.AttributeRef;
+
+import java.util.HashMap;
+
+/**
+ * This `AssetDatapointQuery` retrieves the value of a datapoint
+ * associated with a specific `AttributeRef` at a specified timestamp. It is designed to find the
+ * closest datapoint that precedes the requested timestamp.
+ */
+public class AssetDatapointNearestQuery extends AssetDatapointQuery {
+
+ public AssetDatapointNearestQuery() {
+ }
+
+ public AssetDatapointNearestQuery(long timestamp) {
+ // Convert to seconds from millis
+ this.fromTimestamp = timestamp/1000;
+ }
+
+ @Override
+ public String getSQLQuery(String tableName, Class<?> attributeType) throws IllegalStateException {
+ return "SELECT timestamp as X, cast(value as numeric) as Y " +
+ " FROM " + tableName + " " +
+ " WHERE entity_id = ? AND attribute_name = ? " +
+ " AND timestamp <= to_timestamp(?) " +
+ " ORDER BY timestamp DESC " +
+ " LIMIT 1";
+ }
+
+ @Override
+ public HashMap<Integer, Object> getSQLParameters(AttributeRef attributeRef) {
+ HashMap<Integer, Object> parameters = new HashMap<>();
+ // nearest_row parameters
+ parameters.put(1, attributeRef.getId());
+ parameters.put(2, attributeRef.getName());
+ parameters.put(3, this.fromTimestamp);
+
+ return parameters;
+ }
+}
diff --git a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointQuery.java b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointQuery.java
index 32a396290..e12690d63 100644
--- a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointQuery.java
+++ b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointQuery.java
@@ -30,7 +30,9 @@ import java.util.HashMap;
@JsonSubTypes({
@JsonSubTypes.Type(value = AssetDatapointAllQuery.class, name = "all"),
@JsonSubTypes.Type(value = AssetDatapointLTTBQuery.class, name = "lttb"),
- @JsonSubTypes.Type(value = AssetDatapointIntervalQuery.class, name = "interval")
+ @JsonSubTypes.Type(value = AssetDatapointIntervalQuery.class, name = "interval"),
+ @JsonSubTypes.Type(value = AssetDatapointNearestQuery.class, name = "nearest")
+
})
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
diff --git a/model/src/main/java/org/openremote/model/rules/flow/Node.java b/model/src/main/java/org/openremote/model/rules/flow/Node.java
index 09c9aeb85..f7b1d380e 100644
--- a/model/src/main/java/org/openremote/model/rules/flow/Node.java
+++ b/model/src/main/java/org/openremote/model/rules/flow/Node.java
@@ -4,6 +4,7 @@ public class Node {
// Generation of ID is the responsibility of the front end and is unique for every node in a structure, not for every node in the system
private String id;
private NodeType type;
+ private int priority = 999;
private String name;
private NodePosition position;
private NodePosition size;
@@ -22,6 +23,20 @@ public class Node {
this.outputs = outputs;
this.displayCharacter = null;
}
+ public Node(NodeType type, int priority, String displayCharacter, NodeInternal[] internals, NodeSocket[] inputs, NodeSocket[] outputs) {
+ if (internals.length != 0)
+ throw new IllegalArgumentException("A node cannot have internals when a display character is specified");
+
+ this.id = "INVALID ID";
+ this.type = type;
+ this.priority = priority;
+ this.position = new NodePosition(0, 0);
+ this.size = new NodePosition(0, 0);
+ this.internals = internals;
+ this.inputs = inputs;
+ this.outputs = outputs;
+ this.displayCharacter = displayCharacter;
+ }
public Node(NodeType type, String displayCharacter, NodeInternal[] internals, NodeSocket[] inputs, NodeSocket[] outputs) {
if (internals.length != 0)
diff --git a/model/src/main/java/org/openremote/model/rules/flow/NodeDataType.java b/model/src/main/java/org/openremote/model/rules/flow/NodeDataType.java
index b35bcbe71..a074d1f2c 100644
--- a/model/src/main/java/org/openremote/model/rules/flow/NodeDataType.java
+++ b/model/src/main/java/org/openremote/model/rules/flow/NodeDataType.java
@@ -2,6 +2,7 @@ package org.openremote.model.rules.flow;
public enum NodeDataType {
NUMBER,
+ NUMBER_ARRAY,
STRING,
BOOLEAN,
@Deprecated
diff --git a/model/src/main/java/org/openremote/model/rules/flow/NodeInternal.java b/model/src/main/java/org/openremote/model/rules/flow/NodeInternal.java
index a99c48d1d..710001bd6 100644
--- a/model/src/main/java/org/openremote/model/rules/flow/NodeInternal.java
+++ b/model/src/main/java/org/openremote/model/rules/flow/NodeInternal.java
@@ -4,19 +4,35 @@ public class NodeInternal {
private String name;
private Picker picker;
private Object value;
+ private BreakType breakType;
+
+ public enum BreakType{
+ NEW_LINE,
+ SPACER
+ }
public NodeInternal(String name, Picker picker, Object value) {
this.name = name;
this.picker = picker;
this.value = value;
+ this.breakType = BreakType.NEW_LINE;
}
public NodeInternal(String name, Picker picker) {
this.name = name;
this.picker = picker;
this.value = picker.getOptions().length == 0 ? null : picker.getOptions()[0].getValue();
+ this.breakType = BreakType.NEW_LINE;
+
+ }
+ public NodeInternal(String name, Picker picker, BreakType breakType) {
+ this.name = name;
+ this.picker = picker;
+ this.value = picker.getOptions().length == 0 ? null : picker.getOptions()[0].getValue();
+ this.breakType = breakType;
}
+
public NodeInternal() {
name = null;
picker = new Picker();
diff --git a/model/src/main/java/org/openremote/model/rules/flow/PickerType.java b/model/src/main/java/org/openremote/model/rules/flow/PickerType.java
index 35db145e5..d9a287fdc 100644
--- a/model/src/main/java/org/openremote/model/rules/flow/PickerType.java
+++ b/model/src/main/java/org/openremote/model/rules/flow/PickerType.java
@@ -8,6 +8,7 @@ public enum PickerType {
DOUBLE_DROPDOWN,
CHECKBOX,
ASSET_ATTRIBUTE,
- COLOR
+ COLOR,
+ DATE
}
diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovy
index f2c7462c3..4ab9b766e 100644
--- a/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/residence/FlowRulesTest.groovy
@@ -1,21 +1,31 @@
package org.openremote.test.rules.residence
-
+import org.openremote.container.timer.TimerService
import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
+import org.openremote.manager.datapoint.AssetDatapointService
import org.openremote.manager.rules.RulesService
import org.openremote.manager.rules.RulesetStorageService
import org.openremote.manager.setup.SetupService
-import org.openremote.setup.integration.ManagerTestSetup
+import org.openremote.model.Constants
+import org.openremote.model.asset.impl.ShipAsset
+import org.openremote.model.attribute.Attribute
import org.openremote.model.attribute.AttributeEvent
+import org.openremote.model.attribute.AttributeRef
+import org.openremote.model.attribute.MetaItem
import org.openremote.model.rules.GlobalRuleset
import org.openremote.model.rules.Ruleset
import org.openremote.model.rules.flow.NodeCollection
+import org.openremote.model.util.UniqueIdentifierGenerator
import org.openremote.model.util.ValueUtil
+import org.openremote.model.value.MetaItemType
+import org.openremote.setup.integration.ManagerTestSetup
import org.openremote.test.ManagerContainerTrait
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
+import java.time.temporal.ChronoUnit
+
import static org.openremote.model.rules.RulesetStatus.DEPLOYED
class FlowRulesTest extends Specification implements ManagerContainerTrait {
@@ -74,4 +84,100 @@ class FlowRulesTest extends Specification implements ManagerContainerTrait {
}
}
+
+ def "Test multi-input processors and DERIVATIVE, INTEGRAL, HISTORIC_VALUE"() {
+ given: "expected conditions"
+ def conditions = new PollingConditions(timeout: 10, delay: 0.2)
+
+ and: "the container is started"
+ def container = startContainer(defaultConfig(), defaultServices())
+ def rulesService = container.getService(RulesService.class)
+ def rulesetStorageService = container.getService(RulesetStorageService.class)
+ def assetStorageService = container.getService(AssetStorageService.class)
+ def assetProcessingService = container.getService(AssetProcessingService.class)
+ def assetDatapointService = container.getService(AssetDatapointService.class);
+ def timerService = container.getService(TimerService.class);
+
+ when: "An asset is created"
+ def asset = new ShipAsset("Flow ship")
+ .setRealm(Constants.MASTER_REALM)
+ .addOrReplaceAttributes(
+ new Attribute<Object>(ShipAsset.SPEED, null, timerService.getNow().minus(10, ChronoUnit.HOURS).toEpochMilli()).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("historicOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("sumOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("minOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("avgOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("medOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("maxOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("derOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true)),
+ new Attribute<Object>("intOutput", null).addMeta(new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true),new MetaItem<>(MetaItemType.RULE_STATE, true))
+ )
+ asset = assetStorageService.merge(asset);
+
+ and: "Some datapoints are added to the living room"
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(new AttributeRef(asset.getId(), ShipAsset.SPEED.name), 30D, timerService.getNow().minus(30, ChronoUnit.MINUTES).toEpochMilli()));
+ sleep(100)
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(new AttributeRef(asset.getId(), ShipAsset.SPEED.name), 20D, timerService.getNow().minus(20, ChronoUnit.MINUTES).toEpochMilli()));
+ sleep(100)
+ def previousTime = timerService.getNow().minus(10, ChronoUnit.MINUTES);
+ def previousValue = 10D
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(new AttributeRef(asset.getId(), ShipAsset.SPEED.name), previousValue, previousTime.toEpochMilli()));
+ sleep(100)
+
+ def currentTime = timerService.getNow();
+ def currentValue = 1D;
+ assetProcessingService.sendAttributeEvent(new AttributeEvent(new AttributeRef(asset.getId(), ShipAsset.SPEED.name), currentValue, currentTime.toEpochMilli()));
+ sleep(100)
+
+ then: "They are queryable"
+ conditions.eventually {
+ def dps = assetDatapointService.getDatapoints(new AttributeRef(asset.getId(), ShipAsset.SPEED.name));
+ assert dps.size() == 4
+ }
+
+ when: "The flow rule is added"
+ String json = getClass().getResource("/org/openremote/test/rules/HistoricAndMultiInputProcessorTest.flow").text
+ json = json.replaceAll("%ASSETID%", asset.getId())
+ json = json.replaceAll("%HISTORIC_ATTRIBUTE%", ShipAsset.SPEED.name)
+ json = json.replaceAll("%HISTORIC_VALUE_OUTPUT%", "historicOutput")
+ json = json.replaceAll("%SUM_OUTPUT%", "sumOutput")
+ json = json.replaceAll("%MIN_OUTPUT%", "minOutput")
+ json = json.replaceAll("%AVG_OUTPUT%", "avgOutput")
+ json = json.replaceAll("%MED_OUTPUT%", "medOutput")
+ json = json.replaceAll("%MAX_OUTPUT%", "maxOutput")
+ json = json.replaceAll("%DER_OUTPUT%", "derOutput")
+ json = json.replaceAll("%INT_OUTPUT%", "intOutput")
+
+ def ruleset = (new GlobalRuleset(
+ "HistoricValueAndProcessorsTest",
+ Ruleset.Lang.FLOW,
+ json
+ ))
+ rulesetStorageService.merge(ruleset)
+
+ and: "the integral and derivative values are calculated"
+ def derivative = (currentValue - previousValue) / (((currentTime.toEpochMilli() - previousTime.toEpochMilli())/1000.0))
+ def integral = ((currentValue + previousValue) * ((currentTime.toEpochMilli() - previousTime.toEpochMilli())/1000.0)) / 2
+
+ then: "The rule compiles successfully"
+ conditions.eventually {
+ assert rulesService.globalEngine.get() != null
+ assert rulesService.globalEngine.get().isRunning()
+ assert rulesService.globalEngine.get().deployments.values().any({ it.name == "HistoricValueAndProcessorsTest" && it.status == DEPLOYED})
+ }
+
+ and: "The rule runs and the various attributes are updated accordingly"
+ conditions.eventually {
+ asset = assetStorageService.find(asset.getId(), ShipAsset.class);
+ def currentValueSpeed = asset.getAttribute(ShipAsset.SPEED).get().getValue().get()
+ assert asset.getAttribute("historicOutput").get().getValue().get() == 20
+ assert asset.getAttribute("sumOutput").get().getValue().get() == 10
+ assert asset.getAttribute("minOutput").get().getValue().get() == 1
+ assert asset.getAttribute("avgOutput").get().getValue().get() == 2.5
+ assert asset.getAttribute("medOutput").get().getValue().get() == 2.5
+ assert asset.getAttribute("maxOutput").get().getValue().get() == 4
+ assert asset.getAttribute("derOutput").get().getValue().get() == derivative
+ assert asset.getAttribute("intOutput").get().getValue().get() == integral
+ }
+ }
}
diff --git a/test/src/test/resources/org/openremote/test/rules/HistoricAndMultiInputProcessorTest.flow b/test/src/test/resources/org/openremote/test/rules/HistoricAndMultiInputProcessorTest.flow
new file mode 100644
index 000000000..1c3f5a354
--- /dev/null
+++ b/test/src/test/resources/org/openremote/test/rules/HistoricAndMultiInputProcessorTest.flow
@@ -0,0 +1,829 @@
+{
+ "name": "Exported on Wed Jan 29 2025 13:38:35 GMT+0100 (Central European Standard Time)",
+ "description": "",
+ "connections": [
+ {
+ "from": "l8m0Xfblk1",
+ "to": "Plw-23m3UD"
+ },
+ {
+ "from": "l8m0Xfblk1",
+ "to": "_UbNW2NMZX"
+ },
+ {
+ "from": "l8m0Xfblk1",
+ "to": "OfMXeFICP3"
+ },
+ {
+ "from": "l8m0Xfblk1",
+ "to": "n38uQmyS0P"
+ },
+ {
+ "from": "l8m0Xfblk1",
+ "to": "u6vgHGdXVB"
+ },
+ {
+ "from": "Et-AtVtMwq",
+ "to": "Plw-23m3UD"
+ },
+ {
+ "from": "Et-AtVtMwq",
+ "to": "_UbNW2NMZX"
+ },
+ {
+ "from": "Et-AtVtMwq",
+ "to": "OfMXeFICP3"
+ },
+ {
+ "from": "Et-AtVtMwq",
+ "to": "n38uQmyS0P"
+ },
+ {
+ "from": "Et-AtVtMwq",
+ "to": "u6vgHGdXVB"
+ },
+ {
+ "from": "PcQTq9ZA6E",
+ "to": "Plw-23m3UD"
+ },
+ {
+ "from": "PcQTq9ZA6E",
+ "to": "_UbNW2NMZX"
+ },
+ {
+ "from": "PcQTq9ZA6E",
+ "to": "OfMXeFICP3"
+ },
+ {
+ "from": "PcQTq9ZA6E",
+ "to": "n38uQmyS0P"
+ },
+ {
+ "from": "PcQTq9ZA6E",
+ "to": "u6vgHGdXVB"
+ },
+ {
+ "from": "EYXgtqN36x",
+ "to": "Plw-23m3UD"
+ },
+ {
+ "from": "EYXgtqN36x",
+ "to": "_UbNW2NMZX"
+ },
+ {
+ "from": "EYXgtqN36x",
+ "to": "OfMXeFICP3"
+ },
+ {
+ "from": "EYXgtqN36x",
+ "to": "n38uQmyS0P"
+ },
+ {
+ "from": "EYXgtqN36x",
+ "to": "u6vgHGdXVB"
+ },
+ {
+ "from": "noi4wpQvru",
+ "to": "Zqdu4EY1vr"
+ },
+ {
+ "from": "aKvoI1ygc6",
+ "to": "63kPcJOI7o"
+ },
+ {
+ "from": "dNQT0-Z0nn",
+ "to": "jhZ_G8S_2J"
+ },
+ {
+ "from": "5si-rF0I5r",
+ "to": "YVe6YE__jE"
+ },
+ {
+ "from": "yxeE5JsXuj",
+ "to": "wnPWAkU5HT"
+ },
+ {
+ "from": "4smGpfRo3R",
+ "to": "4usCwdHKjX"
+ },
+ {
+ "from": "yzZWignuWs",
+ "to": "4lSI8fHHgW"
+ },
+ {
+ "from": "1lNBEX5i1v",
+ "to": "rJQPUZ9N4I"
+ }
+ ],
+ "nodes": [
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER_ARRAY",
+ "nodeId": "W73OlWW4q",
+ "id": "Plw-23m3UD"
+ }
+ ],
+ "internals": [],
+ "name": "SUM_PROCESSOR",
+ "displayCharacter": "Σ",
+ "outputs": [
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "W73OlWW4q",
+ "id": "noi4wpQvru"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -127.5,
+ "y": -524
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "W73OlWW4q"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER_ARRAY",
+ "nodeId": "BR-YrMi9b",
+ "id": "_UbNW2NMZX"
+ }
+ ],
+ "internals": [],
+ "name": "MIN_PROCESSOR",
+ "displayCharacter": "min",
+ "outputs": [
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "BR-YrMi9b",
+ "id": "aKvoI1ygc6"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -127.61328125,
+ "y": -440
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "BR-YrMi9b"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER_ARRAY",
+ "nodeId": "bPmyCC-xc",
+ "id": "OfMXeFICP3"
+ }
+ ],
+ "internals": [],
+ "name": "AVERAGE_PROCESSOR",
+ "displayCharacter": "avg",
+ "outputs": [
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "bPmyCC-xc",
+ "id": "dNQT0-Z0nn"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -128.55859375,
+ "y": -338
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "bPmyCC-xc"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER_ARRAY",
+ "nodeId": "pohnl4n9v",
+ "id": "n38uQmyS0P"
+ }
+ ],
+ "internals": [],
+ "name": "MEDIAN_PROCESSOR",
+ "displayCharacter": "med",
+ "outputs": [
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "pohnl4n9v",
+ "id": "5si-rF0I5r"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -130.953125,
+ "y": -256
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "pohnl4n9v"
+ },
+ {
+ "inputs": [
+ {
+ "name": "a",
+ "type": "NUMBER_ARRAY",
+ "nodeId": "RQnaJ-QfH",
+ "id": "u6vgHGdXVB"
+ }
+ ],
+ "internals": [],
+ "name": "MAX_PROCESSOR",
+ "displayCharacter": "max",
+ "outputs": [
+ {
+ "name": "b",
+ "type": "NUMBER",
+ "nodeId": "RQnaJ-QfH",
+ "id": "yxeE5JsXuj"
+ }
+ ],
+ "type": "PROCESSOR",
+ "position": {
+ "x": -129.39453125,
+ "y": -170
+ },
+ "size": {
+ "x": 0,
+ "y": 0
+ },
+ "id": "RQnaJ-QfH"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%HISTORIC_ATTRIBUTE%"
+ }
+ }
+ ],
+ "name": "DERIVATIVE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "VBhSCyRYr",
+ "id": "4smGpfRo3R"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -541.9568426145001,
+ "y": -82.97627790822276
+ },
+ "size": {
+ "x": 137.516,
+ "y": 32
+ },
+ "id": "VBhSCyRYr"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%HISTORIC_ATTRIBUTE%"
+ }
+ },
+ {
+ "name": "time_period",
+ "picker": {
+ "type": "DATE"
+ },
+ "breakType": "SPACER",
+ "value": 15
+ },
+ {
+ "name": "time_unit",
+ "picker": {
+ "type": "DROPDOWN",
+ "options": [
+ {
+ "name": "seconds ago",
+ "value": "SECONDS"
+ },
+ {
+ "name": "minutes ago",
+ "value": "MINUTES"
+ },
+ {
+ "name": "hours ago",
+ "value": "HOURS"
+ },
+ {
+ "name": "days ago",
+ "value": "DAYS"
+ },
+ {
+ "name": "months ago",
+ "value": "MONTHS"
+ }
+ ]
+ },
+ "value": "MINUTES",
+ "breakType": "SPACER"
+ }
+ ],
+ "name": "HISTORIC_VALUE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "LO0c5186r",
+ "id": "1lNBEX5i1v"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -577.3570576098139,
+ "y": 146.96923787161813
+ },
+ "size": {
+ "x": 137.516,
+ "y": 32
+ },
+ "id": "LO0c5186r"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%HISTORIC_ATTRIBUTE%"
+ }
+ }
+ ],
+ "name": "READ_ATTRIBUTE",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "1ZUXhXToL",
+ "id": "l8m0Xfblk1"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -545.890625,
+ "y": -554
+ },
+ "size": {
+ "x": 137.516,
+ "y": 32
+ },
+ "id": "1ZUXhXToL"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "value",
+ "picker": {
+ "type": "NUMBER"
+ },
+ "breakType": "NEW_LINE",
+ "value": 2
+ }
+ ],
+ "name": "NUMBER_INPUT",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "hVLL4d3dT",
+ "id": "Et-AtVtMwq"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -562.390625,
+ "y": -444.25
+ },
+ "size": {
+ "x": 139,
+ "y": 17.5
+ },
+ "id": "hVLL4d3dT"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "value",
+ "picker": {
+ "type": "NUMBER"
+ },
+ "breakType": "NEW_LINE",
+ "value": 3
+ }
+ ],
+ "name": "NUMBER_INPUT",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "nkUEfHIsP",
+ "id": "PcQTq9ZA6E"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -548.390625,
+ "y": -340.25
+ },
+ "size": {
+ "x": 139,
+ "y": 17.5
+ },
+ "id": "nkUEfHIsP"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "value",
+ "picker": {
+ "type": "NUMBER"
+ },
+ "breakType": "NEW_LINE",
+ "value": 4
+ }
+ ],
+ "name": "NUMBER_INPUT",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "Qwy6F603D",
+ "id": "EYXgtqN36x"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -551.390625,
+ "y": -197.25
+ },
+ "size": {
+ "x": 139,
+ "y": 17.5
+ },
+ "id": "Qwy6F603D"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "hhsFex9CE",
+ "id": "Zqdu4EY1vr"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%SUM_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 18.08840397765998,
+ "y": -641.166580246977
+ },
+ "size": {
+ "x": 140.75,
+ "y": 32
+ },
+ "id": "hhsFex9CE"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "I27p6YNGk",
+ "id": "63kPcJOI7o"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%MIN_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 26.747163280400965,
+ "y": -522.4178812379586
+ },
+ "size": {
+ "x": 153.211,
+ "y": 32
+ },
+ "id": "I27p6YNGk"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "eEObE676S",
+ "id": "4usCwdHKjX"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%DER_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 42.82771627120554,
+ "y": -80.82115679817173
+ },
+ "size": {
+ "x": 136.602,
+ "y": 32
+ },
+ "id": "eEObE676S"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "f5NXYVriM",
+ "id": "jhZ_G8S_2J"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%AVG_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 34.16895696846465,
+ "y": -420.9867008344222
+ },
+ "size": {
+ "x": 165.641,
+ "y": 32
+ },
+ "id": "f5NXYVriM"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "XV3NU2kxf",
+ "id": "YVe6YE__jE"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%MED_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 32.93199135378739,
+ "y": -314.6076579721765
+ },
+ "size": {
+ "x": 173.43,
+ "y": 32
+ },
+ "id": "XV3NU2kxf"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "akKivqz-8",
+ "id": "wnPWAkU5HT"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%MAX_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 35.40592258314193,
+ "y": -215.6504087979945
+ },
+ "size": {
+ "x": 177.32,
+ "y": 32
+ },
+ "id": "akKivqz-8"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "yZpr9Bye_",
+ "id": "4lSI8fHHgW"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%INT_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 53.960406803300955,
+ "y": 60.19292327503819
+ },
+ "size": {
+ "x": 161.641,
+ "y": 32
+ },
+ "id": "yZpr9Bye_"
+ },
+ {
+ "inputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "ZYHIQquuW",
+ "id": "rJQPUZ9N4I"
+ }
+ ],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%HISTORIC_VALUE_OUTPUT%"
+ }
+ }
+ ],
+ "name": "WRITE_ATTRIBUTE",
+ "outputs": [],
+ "type": "OUTPUT",
+ "position": {
+ "x": 57.671303647332756,
+ "y": 185.12648810663788
+ },
+ "size": {
+ "x": 106.289,
+ "y": 32
+ },
+ "id": "ZYHIQquuW"
+ },
+ {
+ "inputs": [],
+ "internals": [
+ {
+ "name": "Attribute",
+ "picker": {
+ "type": "ASSET_ATTRIBUTE"
+ },
+ "breakType": "NEW_LINE",
+ "value": {
+ "assetId": "%ASSETID%",
+ "attributeName": "%HISTORIC_ATTRIBUTE%"
+ }
+ }
+ ],
+ "name": "INTEGRAL",
+ "outputs": [
+ {
+ "name": "value",
+ "type": "NUMBER",
+ "nodeId": "ebpcqYFB7",
+ "id": "yzZWignuWs"
+ }
+ ],
+ "type": "INPUT",
+ "position": {
+ "x": -541.0200538564685,
+ "y": 25.557886064074456
+ },
+ "size": {
+ "x": 137.516,
+ "y": 32
+ },
+ "id": "ebpcqYFB7"
+ }
+ ]
+}
diff --git a/ui/app/shared/locales/ar/or.json b/ui/app/shared/locales/ar/or.json
index 96c0fc66c..ae2d43063 100644
--- a/ui/app/shared/locales/ar/or.json
+++ b/ui/app/shared/locales/ar/or.json
@@ -110,25 +110,40 @@
"timeframe": "الإطار الزمني",
"addAttribute": "إضافة خاصية",
"add": "إضافة",
- "EQUALS_COMPARATOR": "يساوي",
- "GREATER_THAN": "أكبر من",
- "LESS_THAN": "أقل من",
- "READ_ATTRIBUTE": "قرائة الخاصية",
- "WRITE_ATTRIBUTE": "كتابة الخاصية",
- "BOOLEAN_INPUT": "القيمة المنطقية",
- "NUMBER_INPUT": "الرقم",
- "TEXT_INPUT": "النص",
- "ADD_OPERATOR": "إضافة",
- "SUBTRACT_OPERATOR": "ناقص",
- "COMBINE_TEXT": "تجميع النص",
- "MULTIPLY_OPERATOR": "ضرب",
- "DIVIDE_OPERATOR": "تقسيم",
- "AND_GATE": "و البوابة",
- "OR_GATE": "أو البوابة ",
- "NOT_GATE": "لا بوابة ",
- "NUMBER_SWITCH": "تبديل الرقم ",
- "TEXT_SWITCH": "تبديل النص ",
- "ROUND_NODE": " تقريب القيمة إلى",
+ "flow": {
+ "EQUALS_COMPARATOR": "يساوي",
+ "GREATER_THAN": "أكبر من",
+ "LESS_THAN": "أقل من",
+ "READ_ATTRIBUTE": "قرائة الخاصية",
+ "WRITE_ATTRIBUTE": "كتابة الخاصية",
+ "BOOLEAN_INPUT": "القيمة المنطقية",
+ "NUMBER_INPUT": "الرقم",
+ "TEXT_INPUT": "النص",
+ "ADD_OPERATOR": "إضافة",
+ "SUBTRACT_OPERATOR": "ناقص",
+ "COMBINE_TEXT": "تجميع النص",
+ "MULTIPLY_OPERATOR": "ضرب",
+ "DIVIDE_OPERATOR": "تقسيم",
+ "AND_GATE": "و البوابة",
+ "OR_GATE": "أو البوابة ",
+ "NOT_GATE": "لا بوابة ",
+ "NUMBER_SWITCH": "تبديل الرقم ",
+ "TEXT_SWITCH": "تبديل النص ",
+ "ROUND_NODE": " تقريب القيمة إلى",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "إدخال",
"processors": "معالجات",
"output": "المخرج",
diff --git a/ui/app/shared/locales/cn/or.json b/ui/app/shared/locales/cn/or.json
index dbff0f3b0..8a259c90f 100644
--- a/ui/app/shared/locales/cn/or.json
+++ b/ui/app/shared/locales/cn/or.json
@@ -114,25 +114,40 @@
"clearTable": "Clear",
"addAssetAttribute": "添加资源参数",
"add": "添加",
- "EQUALS_COMPARATOR": "等于",
- "GREATER_THAN": "大于",
- "LESS_THAN": "小于",
- "READ_ATTRIBUTE": "读取参数",
- "WRITE_ATTRIBUTE": "写入参数",
- "BOOLEAN_INPUT": "布尔值",
- "NUMBER_INPUT": "数值",
- "TEXT_INPUT": "文本",
- "ADD_OPERATOR": "加",
- "SUBTRACT_OPERATOR": "减",
- "COMBINE_TEXT": "合并文本",
- "MULTIPLY_OPERATOR": "乘",
- "DIVIDE_OPERATOR": "除",
- "AND_GATE": "与门",
- "OR_GATE": "或门",
- "NOT_GATE": "非门",
- "NUMBER_SWITCH": "数值逻辑",
- "TEXT_SWITCH": "文本逻辑",
- "ROUND_NODE": "四舍五入",
+ "flow": {
+ "EQUALS_COMPARATOR": "等于",
+ "GREATER_THAN": "大于",
+ "LESS_THAN": "小于",
+ "READ_ATTRIBUTE": "读取参数",
+ "WRITE_ATTRIBUTE": "写入参数",
+ "BOOLEAN_INPUT": "布尔值",
+ "NUMBER_INPUT": "数值",
+ "TEXT_INPUT": "文本",
+ "ADD_OPERATOR": "加",
+ "SUBTRACT_OPERATOR": "减",
+ "COMBINE_TEXT": "合并文本",
+ "MULTIPLY_OPERATOR": "乘",
+ "DIVIDE_OPERATOR": "除",
+ "AND_GATE": "与门",
+ "OR_GATE": "或门",
+ "NOT_GATE": "非门",
+ "NUMBER_SWITCH": "数值逻辑",
+ "TEXT_SWITCH": "文本逻辑",
+ "ROUND_NODE": "四舍五入",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "输入",
"processors": "进程",
"output": "输出",
diff --git a/ui/app/shared/locales/de/or.json b/ui/app/shared/locales/de/or.json
index d11562b11..4c26f103f 100644
--- a/ui/app/shared/locales/de/or.json
+++ b/ui/app/shared/locales/de/or.json
@@ -128,25 +128,40 @@
"export": "exportieren",
"addAssetAttribute": "Asset Attribute hinzufügen",
"add": "Hinzufügen",
- "EQUALS_COMPARATOR": "Gleich",
- "GREATER_THAN": "Größer als",
- "LESS_THAN": "Kleiner als",
- "READ_ATTRIBUTE": "Attribut lesen",
- "WRITE_ATTRIBUTE": "Attribut schreiben",
- "BOOLEAN_INPUT": "Boolesch",
- "NUMBER_INPUT": "Numerisch",
- "TEXT_INPUT": "Text",
- "ADD_OPERATOR": "Addieren",
- "SUBTRACT_OPERATOR": "Subtrahieren",
- "COMBINE_TEXT": "Text zusammenfügen",
- "MULTIPLY_OPERATOR": "Multiplizieren",
- "DIVIDE_OPERATOR": "Dividieren",
- "AND_GATE": "Und Gatter",
- "OR_GATE": "Oder Gatter",
- "NOT_GATE": "Nicht Gatter",
- "NUMBER_SWITCH": "Numerischer Schalter",
- "TEXT_SWITCH": "Textueller Schalter",
- "ROUND_NODE": "Runden",
+ "flow": {
+ "EQUALS_COMPARATOR": "Gleich",
+ "GREATER_THAN": "Größer als",
+ "LESS_THAN": "Kleiner als",
+ "READ_ATTRIBUTE": "Attribut lesen",
+ "WRITE_ATTRIBUTE": "Attribut schreiben",
+ "BOOLEAN_INPUT": "Boolesch",
+ "NUMBER_INPUT": "Numerisch",
+ "TEXT_INPUT": "Text",
+ "ADD_OPERATOR": "Addieren",
+ "SUBTRACT_OPERATOR": "Subtrahieren",
+ "COMBINE_TEXT": "Text zusammenfügen",
+ "MULTIPLY_OPERATOR": "Multiplizieren",
+ "DIVIDE_OPERATOR": "Dividieren",
+ "AND_GATE": "Und Gatter",
+ "OR_GATE": "Oder Gatter",
+ "NOT_GATE": "Nicht Gatter",
+ "NUMBER_SWITCH": "Numerischer Schalter",
+ "TEXT_SWITCH": "Textueller Schalter",
+ "ROUND_NODE": "Runden",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Eingabe",
"processors": "Prozessoren",
"output": "Ausgabe",
diff --git a/ui/app/shared/locales/en/or.json b/ui/app/shared/locales/en/or.json
index b18418d0f..605ad4e2e 100644
--- a/ui/app/shared/locales/en/or.json
+++ b/ui/app/shared/locales/en/or.json
@@ -169,25 +169,6 @@
"export": "Export",
"addAssetAttribute": "Add asset attribute",
"add": "Add",
- "EQUALS_COMPARATOR": "Equals",
- "GREATER_THAN": "Greater than",
- "LESS_THAN": "Less than",
- "READ_ATTRIBUTE": "Read attribute",
- "WRITE_ATTRIBUTE": "Write attribute",
- "BOOLEAN_INPUT": "Boolean",
- "NUMBER_INPUT": "Number",
- "TEXT_INPUT": "Text",
- "ADD_OPERATOR": "Add",
- "SUBTRACT_OPERATOR": "Subtract",
- "COMBINE_TEXT": "Combine text",
- "MULTIPLY_OPERATOR": "Multiply",
- "DIVIDE_OPERATOR": "Divide",
- "AND_GATE": "And gate",
- "OR_GATE": "Or gate",
- "NOT_GATE": "Not gate",
- "NUMBER_SWITCH": "Number switch",
- "TEXT_SWITCH": "Text switch",
- "ROUND_NODE": "Round",
"input": "Input",
"processors": "Processors",
"output": "Output",
@@ -210,6 +191,40 @@
"fitView": "Fit view",
"areYouSure": "Are you sure?",
"flowEditor": "Flow editor",
+ "flow": {
+ "EQUALS_COMPARATOR": "Equals",
+ "GREATER_THAN": "Greater than",
+ "LESS_THAN": "Less than",
+ "READ_ATTRIBUTE": "Read attribute",
+ "WRITE_ATTRIBUTE": "Write attribute",
+ "BOOLEAN_INPUT": "Boolean",
+ "NUMBER_INPUT": "Number",
+ "TEXT_INPUT": "Text",
+ "ADD_OPERATOR": "Add",
+ "SUBTRACT_OPERATOR": "Subtract",
+ "COMBINE_TEXT": "Combine text",
+ "MULTIPLY_OPERATOR": "Multiply",
+ "DIVIDE_OPERATOR": "Divide",
+ "AND_GATE": "And gate",
+ "OR_GATE": "Or gate",
+ "NOT_GATE": "Not gate",
+ "NUMBER_SWITCH": "Number switch",
+ "TEXT_SWITCH": "Text switch",
+ "ROUND_NODE": "Round",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"else": "else",
"english": "English",
"arabic": "Arabic",
diff --git a/ui/app/shared/locales/es/or.json b/ui/app/shared/locales/es/or.json
index bca59bbce..76c0fb4fc 100644
--- a/ui/app/shared/locales/es/or.json
+++ b/ui/app/shared/locales/es/or.json
@@ -115,25 +115,40 @@
"clearTable": "Clara",
"addAssetAttribute": "Adicionar atributo de ativo",
"add": "Añadir",
- "EQUALS_COMPARATOR": "Iguales",
- "GREATER_THAN": "Mas grande que",
- "LESS_THAN": "Menos que",
- "READ_ATTRIBUTE": "Leer atributo",
- "WRITE_ATTRIBUTE": "Escribir atributo",
- "BOOLEAN_INPUT": "Booleano",
- "NUMBER_INPUT": "Número",
- "TEXT_INPUT": "Texto",
- "ADD_OPERATOR": "Añadir",
- "SUBTRACT_OPERATOR": "Sustraer",
- "COMBINE_TEXT": "Combinar texto",
- "MULTIPLY_OPERATOR": "Multiplicar",
- "DIVIDE_OPERATOR": "Dividir",
- "AND_GATE": "Y puerta",
- "OR_GATE": "O puerta",
- "NOT_GATE": "No puerta",
- "NUMBER_SWITCH": "Interruptor de número",
- "TEXT_SWITCH": "Interruptor de texto",
- "ROUND_NODE": "Redondo",
+ "flow": {
+ "EQUALS_COMPARATOR": "Iguales",
+ "GREATER_THAN": "Mas grande que",
+ "LESS_THAN": "Menos que",
+ "READ_ATTRIBUTE": "Leer atributo",
+ "WRITE_ATTRIBUTE": "Escribir atributo",
+ "BOOLEAN_INPUT": "Booleano",
+ "NUMBER_INPUT": "Número",
+ "TEXT_INPUT": "Texto",
+ "ADD_OPERATOR": "Añadir",
+ "SUBTRACT_OPERATOR": "Sustraer",
+ "COMBINE_TEXT": "Combinar texto",
+ "MULTIPLY_OPERATOR": "Multiplicar",
+ "DIVIDE_OPERATOR": "Dividir",
+ "AND_GATE": "Y puerta",
+ "OR_GATE": "O puerta",
+ "NOT_GATE": "No puerta",
+ "NUMBER_SWITCH": "Interruptor de número",
+ "TEXT_SWITCH": "Interruptor de texto",
+ "ROUND_NODE": "Redondo",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Entrada",
"processors": "Procesadores",
"output": "Salida",
diff --git a/ui/app/shared/locales/fr/or.json b/ui/app/shared/locales/fr/or.json
index dc1766b8d..78e04babb 100644
--- a/ui/app/shared/locales/fr/or.json
+++ b/ui/app/shared/locales/fr/or.json
@@ -115,25 +115,40 @@
"clearTable": "Effacer",
"addAssetAttribute": "Ajouter un attribut de ressource",
"add": "Ajouter",
- "EQUALS_COMPARATOR": "Équivaut à",
- "GREATER_THAN": "Plus grand que",
- "LESS_THAN": "Plus petit que",
- "READ_ATTRIBUTE": "Attribut de lecture",
- "WRITE_ATTRIBUTE": "Attribut d'écriture",
- "BOOLEAN_INPUT": "Booléens",
- "NUMBER_INPUT": "Nombre",
- "TEXT_INPUT": "Texte",
- "ADD_OPERATOR": "Ajouter",
- "SUBTRACT_OPERATOR": "Soustraire",
- "COMBINE_TEXT": "Combiner du texte",
- "MULTIPLY_OPERATOR": "Multiplier",
- "DIVIDE_OPERATOR": "Diviser",
- "AND_GATE": "Porte and",
- "OR_GATE": "Porte or",
- "NOT_GATE": "Porte not",
- "NUMBER_SWITCH": "Commutateur de numéro",
- "TEXT_SWITCH": "Commutateur de texte",
- "ROUND_NODE": "Arrondir",
+ "flow": {
+ "EQUALS_COMPARATOR": "Équivaut à",
+ "GREATER_THAN": "Plus grand que",
+ "LESS_THAN": "Plus petit que",
+ "READ_ATTRIBUTE": "Attribut de lecture",
+ "WRITE_ATTRIBUTE": "Attribut d'écriture",
+ "BOOLEAN_INPUT": "Booléens",
+ "NUMBER_INPUT": "Nombre",
+ "TEXT_INPUT": "Texte",
+ "ADD_OPERATOR": "Ajouter",
+ "SUBTRACT_OPERATOR": "Soustraire",
+ "COMBINE_TEXT": "Combiner du texte",
+ "MULTIPLY_OPERATOR": "Multiplier",
+ "DIVIDE_OPERATOR": "Diviser",
+ "AND_GATE": "Porte and",
+ "OR_GATE": "Porte or",
+ "NOT_GATE": "Porte not",
+ "NUMBER_SWITCH": "Commutateur de numéro",
+ "TEXT_SWITCH": "Commutateur de texte",
+ "ROUND_NODE": "Arrondir",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Champs de saisie",
"processors": "Processeurs",
"output": "Champs de sortie",
diff --git a/ui/app/shared/locales/it/or.json b/ui/app/shared/locales/it/or.json
index a228c9308..65e025d6f 100644
--- a/ui/app/shared/locales/it/or.json
+++ b/ui/app/shared/locales/it/or.json
@@ -114,25 +114,40 @@
"clearTable": "Chiara",
"addAssetAttribute": "Aggiungere l'attributo di asset",
"add": "Aggiungi",
- "EQUALS_COMPARATOR": "Uguale a",
- "GREATER_THAN": "Maggiore di",
- "LESS_THAN": "Meno di",
- "READ_ATTRIBUTE": "Leggi attributo",
- "WRITE_ATTRIBUTE": "Scrivi attributo",
- "BOOLEAN_INPUT": "Booleano",
- "NUMBER_INPUT": "Numero",
- "TEXT_INPUT": "Testo",
- "ADD_OPERATOR": "Aggiungi",
- "SUBTRACT_OPERATOR": "Sottrarre",
- "COMBINE_TEXT": "Combina testo",
- "MULTIPLY_OPERATOR": "Moltiplica",
- "DIVIDE_OPERATOR": "Dividere",
- "AND_GATE": "And gate",
- "OR_GATE": "Or gate",
- "NOT_GATE": "Not gate",
- "NUMBER_SWITCH": "Number switch",
- "TEXT_SWITCH": "Text switch",
- "ROUND_NODE": "Rotondo",
+ "flow": {
+ "EQUALS_COMPARATOR": "Uguale a",
+ "GREATER_THAN": "Maggiore di",
+ "LESS_THAN": "Meno di",
+ "READ_ATTRIBUTE": "Leggi attributo",
+ "WRITE_ATTRIBUTE": "Scrivi attributo",
+ "BOOLEAN_INPUT": "Booleano",
+ "NUMBER_INPUT": "Numero",
+ "TEXT_INPUT": "Testo",
+ "ADD_OPERATOR": "Aggiungi",
+ "SUBTRACT_OPERATOR": "Sottrarre",
+ "COMBINE_TEXT": "Combina testo",
+ "MULTIPLY_OPERATOR": "Moltiplica",
+ "DIVIDE_OPERATOR": "Dividere",
+ "AND_GATE": "And gate",
+ "OR_GATE": "Or gate",
+ "NOT_GATE": "Not gate",
+ "NUMBER_SWITCH": "Number switch",
+ "TEXT_SWITCH": "Text switch",
+ "ROUND_NODE": "Rotondo",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Input",
"processors": "Processori",
"output": "Output",
diff --git a/ui/app/shared/locales/nl/or.json b/ui/app/shared/locales/nl/or.json
index 3a99c710b..cc7da6d01 100644
--- a/ui/app/shared/locales/nl/or.json
+++ b/ui/app/shared/locales/nl/or.json
@@ -169,25 +169,40 @@
"export": "exporteer",
"addAssetAttribute": "Voeg asset attribuut toe",
"add": "toevoegen",
- "EQUALS_COMPARATOR": "Gelijk aan",
- "GREATER_THAN": "Groter dan",
- "LESS_THAN": "Kleiner dan",
- "READ_ATTRIBUTE": "Lees attribuut",
- "WRITE_ATTRIBUTE": "Schrijf attribuut",
- "BOOLEAN_INPUT": "Boolean",
- "NUMBER_INPUT": "Nummer",
- "TEXT_INPUT": "Tekst",
- "ADD_OPERATOR": "Optellen",
- "SUBTRACT_OPERATOR": "Aftrekken",
- "COMBINE_TEXT": "Combineer tekst",
- "MULTIPLY_OPERATOR": "Vermenigvuldigen",
- "DIVIDE_OPERATOR": "Delen door",
- "AND_GATE": "En-poort",
- "OR_GATE": "Of-poort",
- "NOT_GATE": "Niet-poort",
- "NUMBER_SWITCH": "Nummer schakeling",
- "TEXT_SWITCH": "Tekst schakeling",
- "ROUND_NODE": "Afronden",
+ "flow":{
+ "EQUALS_COMPARATOR": "Gelijk aan",
+ "GREATER_THAN": "Groter dan",
+ "LESS_THAN": "Kleiner dan",
+ "READ_ATTRIBUTE": "Lees attribuut",
+ "WRITE_ATTRIBUTE": "Schrijf attribuut",
+ "BOOLEAN_INPUT": "Boolean",
+ "NUMBER_INPUT": "Nummer",
+ "TEXT_INPUT": "Tekst",
+ "ADD_OPERATOR": "Optellen",
+ "SUBTRACT_OPERATOR": "Aftrekken",
+ "COMBINE_TEXT": "Combineer tekst",
+ "MULTIPLY_OPERATOR": "Vermenigvuldigen",
+ "DIVIDE_OPERATOR": "Delen door",
+ "AND_GATE": "En-poort",
+ "OR_GATE": "Of-poort",
+ "NOT_GATE": "Niet-poort",
+ "NUMBER_SWITCH": "Nummer schakeling",
+ "TEXT_SWITCH": "Tekst schakeling",
+ "ROUND_NODE": "Afronden",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Input",
"processors": "Processors",
"output": "Output",
diff --git a/ui/app/shared/locales/pt/or.json b/ui/app/shared/locales/pt/or.json
index f61cd9803..bee70d679 100644
--- a/ui/app/shared/locales/pt/or.json
+++ b/ui/app/shared/locales/pt/or.json
@@ -114,25 +114,40 @@
"clearTable": "Limpar",
"addAssetAttribute": "Adicionar atributo de ativo",
"add": "Adicionar",
- "EQUALS_COMPARATOR": "Igual a",
- "GREATER_THAN": "Maior que",
- "LESS_THAN": "Menor que",
- "READ_ATTRIBUTE": "Ler atributo",
- "WRITE_ATTRIBUTE": "Atributo de escrita",
- "BOOLEAN_INPUT": "Booleano",
- "NUMBER_INPUT": "Número",
- "TEXT_INPUT": "Texto",
- "ADD_OPERATOR": "Adicionar",
- "SUBTRACT_OPERATOR": "Subtrair",
- "COMBINE_TEXT": "Combinar texto",
- "MULTIPLY_OPERATOR": "Multiplicar",
- "DIVIDE_OPERATOR": "Divide",
- "AND_GATE": "And gate",
- "OR_GATE": "Or gate",
- "NOT_GATE": "Not gate",
- "NUMBER_SWITCH": "Mudança numérica",
- "TEXT_SWITCH": "Mudança de texto",
- "ROUND_NODE": "Rodada",
+ "flow":{
+ "EQUALS_COMPARATOR": "Igual a",
+ "GREATER_THAN": "Maior que",
+ "LESS_THAN": "Menor que",
+ "READ_ATTRIBUTE": "Ler atributo",
+ "WRITE_ATTRIBUTE": "Atributo de escrita",
+ "BOOLEAN_INPUT": "Booleano",
+ "NUMBER_INPUT": "Número",
+ "TEXT_INPUT": "Texto",
+ "ADD_OPERATOR": "Adicionar",
+ "SUBTRACT_OPERATOR": "Subtrair",
+ "COMBINE_TEXT": "Combinar texto",
+ "MULTIPLY_OPERATOR": "Multiplicar",
+ "DIVIDE_OPERATOR": "Divide",
+ "AND_GATE": "And gate",
+ "OR_GATE": "Or gate",
+ "NOT_GATE": "Not gate",
+ "NUMBER_SWITCH": "Mudança numérica",
+ "TEXT_SWITCH": "Mudança de texto",
+ "ROUND_NODE": "Rodada",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Input",
"processors": "Processadores",
"output": "Output",
diff --git a/ui/app/shared/locales/ro/or.json b/ui/app/shared/locales/ro/or.json
index e5704d0d7..25c67ebb8 100644
--- a/ui/app/shared/locales/ro/or.json
+++ b/ui/app/shared/locales/ro/or.json
@@ -162,25 +162,40 @@
"export": "Exportă",
"addAssetAttribute": "Adaugă atribut obiectului",
"add": "Adaugă",
- "EQUALS_COMPARATOR": "E egal cu",
- "GREATER_THAN": "Mai mare decât",
- "LESS_THAN": "Mai mic decât",
- "READ_ATTRIBUTE": "Citește atribut",
- "WRITE_ATTRIBUTE": "Scrie atribut",
- "BOOLEAN_INPUT": "Bolean",
- "NUMBER_INPUT": "Număr",
- "TEXT_INPUT": "Text",
- "ADD_OPERATOR": "Plus",
- "SUBTRACT_OPERATOR": "Minus",
- "COMBINE_TEXT": "Combină text",
- "MULTIPLY_OPERATOR": "Ori",
- "DIVIDE_OPERATOR": "Supra",
- "AND_GATE": "Poartă SI",
- "OR_GATE": "Poartă SAU",
- "NOT_GATE": "Poartă NU",
- "NUMBER_SWITCH": "Comutator număr",
- "TEXT_SWITCH": "Comutator text",
- "ROUND_NODE": "Rotunjește",
+ "flow": {
+ "EQUALS_COMPARATOR": "E egal cu",
+ "GREATER_THAN": "Mai mare decât",
+ "LESS_THAN": "Mai mic decât",
+ "READ_ATTRIBUTE": "Citește atribut",
+ "WRITE_ATTRIBUTE": "Scrie atribut",
+ "BOOLEAN_INPUT": "Bolean",
+ "NUMBER_INPUT": "Număr",
+ "TEXT_INPUT": "Text",
+ "ADD_OPERATOR": "Plus",
+ "SUBTRACT_OPERATOR": "Minus",
+ "COMBINE_TEXT": "Combină text",
+ "MULTIPLY_OPERATOR": "Ori",
+ "DIVIDE_OPERATOR": "Supra",
+ "AND_GATE": "Poartă SI",
+ "OR_GATE": "Poartă SAU",
+ "NOT_GATE": "Poartă NU",
+ "NUMBER_SWITCH": "Comutator număr",
+ "TEXT_SWITCH": "Comutator text",
+ "ROUND_NODE": "Rotunjește",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Intrare",
"processors": "Procesare",
"output": "Ieșire",
diff --git a/ui/app/shared/locales/uk/or.json b/ui/app/shared/locales/uk/or.json
index 820fdd76e..bed8169e6 100644
--- a/ui/app/shared/locales/uk/or.json
+++ b/ui/app/shared/locales/uk/or.json
@@ -167,25 +167,40 @@
"export": "Експорт",
"addAssetAttribute": "Додати атрибут активу",
"add": "Додати",
- "EQUALS_COMPARATOR": "Дорівнює",
- "GREATER_THAN": "Більше ніж",
- "LESS_THAN": "Менше ніж",
- "READ_ATTRIBUTE": "Читати атрибут",
- "WRITE_ATTRIBUTE": "Записати атрибут",
- "BOOLEAN_INPUT": "Булеве значення",
- "NUMBER_INPUT": "Число",
- "TEXT_INPUT": "Текст",
- "ADD_OPERATOR": "Додати",
- "SUBTRACT_OPERATOR": "Відняти",
- "COMBINE_TEXT": "Об'єднати текст",
- "MULTIPLY_OPERATOR": "Помножити",
- "DIVIDE_OPERATOR": "Ділення",
- "AND_GATE": "І-вентиль",
- "OR_GATE": "Або-вентиль",
- "NOT_GATE": "Не-вентиль",
- "NUMBER_SWITCH": "Перемикач чисел",
- "TEXT_SWITCH": "Текстовий перемикач",
- "ROUND_NODE": "Коло",
+ "flow": {
+ "EQUALS_COMPARATOR": "Дорівнює",
+ "GREATER_THAN": "Більше ніж",
+ "LESS_THAN": "Менше ніж",
+ "READ_ATTRIBUTE": "Читати атрибут",
+ "WRITE_ATTRIBUTE": "Записати атрибут",
+ "BOOLEAN_INPUT": "Булеве значення",
+ "NUMBER_INPUT": "Число",
+ "TEXT_INPUT": "Текст",
+ "ADD_OPERATOR": "Додати",
+ "SUBTRACT_OPERATOR": "Відняти",
+ "COMBINE_TEXT": "Об'єднати текст",
+ "MULTIPLY_OPERATOR": "Помножити",
+ "DIVIDE_OPERATOR": "Ділення",
+ "AND_GATE": "І-вентиль",
+ "OR_GATE": "Або-вентиль",
+ "NOT_GATE": "Не-вентиль",
+ "NUMBER_SWITCH": "Перемикач чисел",
+ "TEXT_SWITCH": "Текстовий перемикач",
+ "ROUND_NODE": "Коло",
+ "LOG_OUTPUT": "Write to Logs",
+ "DERIVATIVE": "Read attribute derivative",
+ "INTEGRAL": "Read attribute integral",
+ "HISTORIC_VALUE": "Read attribute history",
+ "MAX_PROCESSOR": "Maximum",
+ "MIN_PROCESSOR": "Minimum",
+ "AVERAGE_PROCESSOR": "Average",
+ "MEDIAN_PROCESSOR": "Median",
+ "SUM_OPERATOR": "Sum",
+ "max": "Max",
+ "min": "Min",
+ "avg": "Avg",
+ "med": "Med"
+ },
"input": "Вхід",
"processors": "Процесори",
"output": "Вихід",
diff --git a/ui/component/or-rules/src/flow-viewer/components/flow-editor.ts b/ui/component/or-rules/src/flow-viewer/components/flow-editor.ts
index 72eeb5a62..82bdc93bc 100644
--- a/ui/component/or-rules/src/flow-viewer/components/flow-editor.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/flow-editor.ts
@@ -101,6 +101,8 @@ export class FlowEditor extends translate(i18next)(LitElement) implements RuleVi
--input-color-h: hsl(222, 58%, 54%);
--processor-color-h: hsl(102, 48%, 49%);
--output-color-h: hsl(282, 58%, 54%);
+
+ overflow: hidden;
}`];
}
@@ -123,7 +125,7 @@ export class FlowEditor extends translate(i18next)(LitElement) implements RuleVi
return html`
${(this.showTopbar ? html`<top-bar .application="${this}" style="grid-area: topbar"></top-bar>` : ``)}
- <node-panel .application="${this}" style="grid-area: node-panel" .nodes= "${integration.nodes}"></node-panel>
+ <node-panel .application="${this}" style="grid-area: node-panel; overflow:auto;" .nodes= "${integration.nodes}"></node-panel>
<editor-workspace .application="${this}" id="workspace" style="grid-area: workspace"></editor-workspace>
<context-menu></context-menu>
<popup-modal id="popup-modal"></popup-modal>
diff --git a/ui/component/or-rules/src/flow-viewer/components/flow-node-socket.ts b/ui/component/or-rules/src/flow-viewer/components/flow-node-socket.ts
index b0657a90a..82e27c29d 100644
--- a/ui/component/or-rules/src/flow-viewer/components/flow-node-socket.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/flow-node-socket.ts
@@ -38,7 +38,6 @@ export class FlowNodeSocket extends translate(i18next)(LitElement) {
display:inline-block;
vertical-align: top;
color: rgba(0,0,0,.5);
- text-transform: lowercase;
}
.circle{
box-sizing: border-box;
@@ -52,7 +51,10 @@ export class FlowNodeSocket extends translate(i18next)(LitElement) {
}
public get socketTypeString() {
- return this.socket.type!.toString().toLowerCase();
+ const socketType: string = this.socket.type!.toString().toLowerCase();
+ // If the socket type is NUMBER_ARRAY, remove the array part, since we only allow the input of NUMBER into that
+ // socket, just multiple ones. Also helps with displaying the correct color.
+ return socketType.replace("_array", "")
}
@property({ type: Object }) public socket!: NodeSocket;
@property({ type: String }) public side!: "input" | "output";
@@ -119,7 +121,7 @@ export class FlowNodeSocket extends translate(i18next)(LitElement) {
</div>`;
if (!this.renderLabel) { return socket; }
- const label = html`<div class="label">${i18next.t(this.socket.name!)}</div>`;
+ const label = html`<div class="label">${i18next.t(Utilities.humanLike(this.socket.name!))}</div>`;
if (this.side === "input") {
return html`${socket}${label}`;
} else {
diff --git a/ui/component/or-rules/src/flow-viewer/components/flow-node.ts b/ui/component/or-rules/src/flow-viewer/components/flow-node.ts
index bec8a80b9..c1c98df96 100644
--- a/ui/component/or-rules/src/flow-viewer/components/flow-node.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/flow-node.ts
@@ -1,13 +1,14 @@
-import { html, css } from "lit";
+import {css, html} from "lit";
import {customElement, property} from "lit/decorators.js";
-import { Node, NodeSocket } from "@openremote/model";
-import { IdentityDomLink } from "../node-structure";
-import { FlowNodeStyle } from "../styles/flow-node-style";
-import { i18next } from "@openremote/or-translate";
-import { nodeConverter } from "../converters/node-converter";
-import { SelectableElement } from "./selectable-element";
-import { EditorWorkspace } from "./editor-workspace";
-import { project, newIds } from "./flow-editor";
+import {Node, NodeInternal, NodeInternalBreakType} from "@openremote/model";
+import {IdentityDomLink} from "../node-structure";
+import {FlowNodeStyle} from "../styles/flow-node-style";
+import {i18next} from "@openremote/or-translate";
+import {nodeConverter} from "../converters/node-converter";
+import {SelectableElement} from "./selectable-element";
+import {EditorWorkspace} from "./editor-workspace";
+import {newIds, project} from "./flow-editor";
+import {Utilities} from "../utils";
@customElement("flow-node")
export class FlowNode extends SelectableElement {
@@ -23,7 +24,21 @@ export class FlowNode extends SelectableElement {
}
public static get styles() {
- return FlowNodeStyle;
+ return [FlowNodeStyle,
+ css`
+ .internal-item {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ flex: 0 0 auto;
+ }
+ .internal-title {
+ font-size: 0.8em;
+ margin-bottom: 0;
+ margin-top:3px;
+ text-align: left;
+ }
+ `]
}
public disconnectedCallback() {
@@ -79,21 +94,38 @@ export class FlowNode extends SelectableElement {
this.style.boxShadow = this.selected ? "var(--highlight) 0 0 0 3px" : "";
const title = this.minimal ?
- html`<div class="title minimal" ?singlechar="${this.node.displayCharacter!.length === 1}">${i18next.t(this.node.displayCharacter!)}</div>` :
- html`<div class="title ${this.node.type!.toLowerCase()}" @mousedown="${this.startDrag}">${i18next.t(this.node.name!) || "invalid"}</div>`;
+ html`<div class="title minimal" ?singlechar="${this.node.displayCharacter!.length === 1}">${i18next.t("flow."+this.node.displayCharacter!, this.node.displayCharacter!)}</div>` :
+ html`<div class="title ${this.node.type!.toLowerCase()}" @mousedown="${this.startDrag}">${i18next.t("flow."+this.node.name!) || "invalid"}</div>`;
const inputSide = html`<div class="socket-side inputs">${this.node.inputs!.map((i) => html`<flow-node-socket ?renderlabel="${!this.minimal}" .socket="${i}" side="input"></flow-node-socket>`)}</div>`;
const outputSide = html`<div class="socket-side outputs">${this.node.outputs!.map((i) => html`<flow-node-socket ?renderlabel="${!this.minimal}" .socket="${i}" side="output"></flow-node-socket>`)}</div>`;
const spacer = html`<div style="width: 10px"></div>`;
+ // Gather the elements between NEW_LINES in distinct groups, that can then be iterated per-group and per-element below. Should help with adding as many internals in any configuration we would like.
return html`
${title}
${this.node.inputs!.length > 0 ? inputSide : spacer}
- ${(this.minimal) ? null : html`<div class="internal-container">${this.node.internals!.map((i) =>
- html`<internal-picker style="pointer-events: ${(this.frozen ? "none" : "normal")}" @picked="${async () => {
- this.forceUpdate();
- await this.updateComplete;
- project.removeInvalidConnections();
- }}" .node="${this.node}" .internalIndex="${this.node.internals!.indexOf(i)}"></internal-picker>`)}</div>`}
+ ${(this.minimal) ? null : html`
+ <div class="internal-container" style="padding-top: 8px">
+ ${this.node.internals!.reduce((acc, i, index, array) => {
+ acc[acc.length - 1].push(i);
+ if (i.breakType === NodeInternalBreakType.NEW_LINE && index < array.length - 1) {
+ acc.push([]);
+ }
+ return acc;
+ }, [[]] as NodeInternal[][]).map((group) => html`
+ <div class="internal-group" style="max-width: fit-content; min-width: fit-content; padding-bottom: 8px;">
+ ${group.map((i) => html`
+ <div class="internal-item" style="display: inline-block">
+ <internal-picker style="pointer-events: ${(this.frozen ? "none" : "normal")};" @picked="${async () => {
+ this.forceUpdate();
+ await this.updateComplete;
+ project.removeInvalidConnections();
+ }}" .node="${this.node}" .internalIndex="${this.node.internals!.indexOf(i)}"></internal-picker>
+ </div>
+ `)}
+ </div>
+ `)}
+ </div>`}
${this.node.outputs!.length > 0 ? outputSide : spacer}
${(this.frozen ? html`<or-icon class="lock-icon ${this.node.type!.toLowerCase()}" icon="lock"></or-icon>` : ``)}
`;
diff --git a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts b/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts
index 9319766c5..09a94f14f 100644
--- a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts
@@ -14,6 +14,7 @@ import { Util } from "@openremote/core";
import { OrAttributePicker, OrAttributePickerPickedEvent } from "@openremote/or-attribute-picker";
import { showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";
import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";
+import {ifDefined} from "lit/directives/if-defined.js";
@customElement("internal-picker")
export class InternalPicker extends translate(i18next)(LitElement) {
@@ -107,8 +108,10 @@ export class InternalPicker extends translate(i18next)(LitElement) {
return this.dropdownInput;
case PickerType.MULTILINE:
return this.multilineInput;
+ case PickerType.DATE:
+ return this.getNumberInput(0, undefined, 50);
case PickerType.NUMBER:
- return this.numberInput;
+ return this.getNumberInput(undefined, undefined, undefined);
case PickerType.TEXT:
return this.textInput;
default:
@@ -247,12 +250,18 @@ export class InternalPicker extends translate(i18next)(LitElement) {
}}" style="${sizeString}" @input="${(e: any) => this.setValue(e.target.value)}" placeholder="${this.internal.name!}">${this.internal.value || ""}</textarea>`;
}
- private get numberInput(): TemplateResult {
- return html`<input @wheel="${(e: any) => {
- if (e.target === this.shadowRoot!.activeElement) {
- return e.stopPropagation();
- }
- }}" @input="${(e: any) => this.setValue(parseFloat(e.target.value))}" value="${this.internal.value || 0}" type="number" placeholder="${this.internal.name!}"/>`;
+ private getNumberInput(min?: number, max?: number, width?: number): TemplateResult {
+ return html`<input
+ @wheel="${(e: any) => {
+ if (e.target === this.shadowRoot!.activeElement) {
+ return e.stopPropagation();
+ }
+ }}"
+ @input="${(e: any) => this.setValue(parseFloat(e.target.value))}"
+ value="${this.internal.value || 0}" type="number" placeholder="${this.internal.name!}"
+ style="max-width: ${ifDefined(width)}px"
+ min="${ifDefined(min)}" max="${ifDefined(max)}"
+ />`;
}
private get textInput(): TemplateResult {
diff --git a/ui/component/or-rules/src/flow-viewer/components/node-menu-item.ts b/ui/component/or-rules/src/flow-viewer/components/node-menu-item.ts
index 928ce7a36..2c4af6ac0 100644
--- a/ui/component/or-rules/src/flow-viewer/components/node-menu-item.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/node-menu-item.ts
@@ -86,8 +86,8 @@ export class NodeMenuItem extends translate(i18next)(LitElement) {
}
private get flowNodeName() {
- return i18next.t(this.node.displayCharacter || this.node.name!,
- this.node.displayCharacter || Utilities.humanLike(this.node.name || "invalid node name"));
+ return i18next.t(this.node.displayCharacter ? "flow."+this.node.displayCharacter : "flow."+this.node.name!,
+ this.node.displayCharacter || this.node.name || "invalid node name");
}
private startDrag = (e: MouseEvent) => {
diff --git a/ui/component/or-rules/src/flow-viewer/components/node-panel.ts b/ui/component/or-rules/src/flow-viewer/components/node-panel.ts
index 2ebe2513d..6185c5daf 100644
--- a/ui/component/or-rules/src/flow-viewer/components/node-panel.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/node-panel.ts
@@ -79,7 +79,7 @@ export class NodePanel extends translate(i18next)(LitElement) {
<div class="category"><span>${i18next.t("processors", "Processors")}</span>
<div class="small-node-grid">
- ${this.nodes.filter((n) => n.type === NodeType.PROCESSOR && n.displayCharacter).map((n) => this.nodeTemplate(n))}
+ ${this.nodes.filter((n) => n.type === NodeType.PROCESSOR && n.displayCharacter).sort((a, b) => a.priority! - b.priority!).map((n) => this.nodeTemplate(n))}
</div>
${this.nodes.filter((n) => n.type === NodeType.PROCESSOR && !n.displayCharacter).map((n) => this.nodeTemplate(n))}
</div>
diff --git a/ui/component/or-rules/src/flow-viewer/components/workspace-contextmenu-options.ts b/ui/component/or-rules/src/flow-viewer/components/workspace-contextmenu-options.ts
index ce2101780..8287e1cb0 100644
--- a/ui/component/or-rules/src/flow-viewer/components/workspace-contextmenu-options.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/workspace-contextmenu-options.ts
@@ -25,7 +25,7 @@ export const createContextMenuButtons = (workspace: EditorWorkspace, e: MouseEve
nB = nB.concat(integration.nodes.filter((n) => n.type === type).map((node) => {
const b: ContextMenuButton = {
type: "button",
- label: i18next.t(node.name!, Utilities.humanLike(node.name!)),
+ label: i18next.t("flow."+node.name!, Utilities.humanLike(node.name!)),
action: () => {
const copy = CopyMachine.copy(node);
copy.position = workspace.offsetToWorld({ x: e.offsetX - workspace.offsetLeft, y: e.offsetY - workspace.offsetTop });
diff --git a/ui/component/or-rules/src/flow-viewer/node-structure/index.ts b/ui/component/or-rules/src/flow-viewer/node-structure/index.ts
index 4de14ca28..2fa6e6a5d 100644
--- a/ui/component/or-rules/src/flow-viewer/node-structure/index.ts
+++ b/ui/component/or-rules/src/flow-viewer/node-structure/index.ts
@@ -1,5 +1,4 @@
export { NodeUtilities } from "./utils";
export { IdentityAssigner } from "./identity.assigner";
export { IdentityDomLink } from "./identity.dom.link";
-export { SocketTypeMatcher } from "./socket.type.matcher";
export { CopyMachine } from "./copy.machine";
diff --git a/ui/component/or-rules/src/flow-viewer/node-structure/socket.type.matcher.ts b/ui/component/or-rules/src/flow-viewer/node-structure/socket.type.matcher.ts
index c18273876..cc6135bf3 100644
--- a/ui/component/or-rules/src/flow-viewer/node-structure/socket.type.matcher.ts
+++ b/ui/component/or-rules/src/flow-viewer/node-structure/socket.type.matcher.ts
@@ -1,6 +1,4 @@
-import { NodeDataType } from "@openremote/model";
-
-// TODO this should be defined in the back end
+import {NodeDataType} from "@openremote/model";
export class SocketTypeMatcher {
@@ -15,6 +13,7 @@ export class SocketTypeMatcher {
matches: [
NodeDataType.NUMBER,
NodeDataType.STRING,
+ NodeDataType.NUMBER_ARRAY
]
},
{
@@ -43,5 +42,11 @@ export class SocketTypeMatcher {
NodeDataType.STRING,
]
},
+ {
+ type: NodeDataType.NUMBER_ARRAY,
+ matches: [
+ NodeDataType.NUMBER
+ ]
+ }
];
}
diff --git a/ui/component/or-rules/src/flow-viewer/services/project.ts b/ui/component/or-rules/src/flow-viewer/services/project.ts
index e1c240d96..a51a89d70 100644
--- a/ui/component/or-rules/src/flow-viewer/services/project.ts
+++ b/ui/component/or-rules/src/flow-viewer/services/project.ts
@@ -1,8 +1,10 @@
-import { Node, NodeConnection, NodeSocket, NodeCollection, RulesetUnion } from "@openremote/model";
-import { EventEmitter } from "events";
-import { SocketTypeMatcher, NodeUtilities } from "../node-structure";
-import { EditorWorkspace } from "../components/editor-workspace";
-import { input } from "../components/flow-editor";
+import {Node, NodeCollection, NodeConnection, NodeSocket} from "@openremote/model";
+import {EventEmitter} from "events";
+import {EditorWorkspace} from "../components/editor-workspace";
+import {input} from "../components/flow-editor";
+import manager from "@openremote/core";
+import {NodeUtilities} from "../node-structure";
+import {SocketTypeMatcher} from "../node-structure/socket.type.matcher";
export class Project extends EventEmitter {
public nodes: Node[] = [];
@@ -191,12 +193,9 @@ export class Project extends EventEmitter {
return false;
}
- if (!SocketTypeMatcher.match(fromSocket.type!, toSocket.type!) ||
+ return !(!SocketTypeMatcher.match(fromSocket.type!, toSocket.type!) ||
fromSocket.id === toSocket.id ||
- fromSocket.nodeId === toSocket.nodeId) {
- return false;
- }
- return true;
+ fromSocket.nodeId === toSocket.nodeId);
}
public createConnection(fromSocket: string, toSocket: string): boolean {
@@ -205,10 +204,15 @@ export class Project extends EventEmitter {
to: toSocket
};
- if (!this.isValidConnection(connection)) { return false; }
+ if (!(this.isValidConnection(connection))) { return false; }
- for (const c of this.connections.filter((j) => j.to === toSocket)) {
- this.removeConnection(c);
+
+ // If the type contains _ARRAY, then assume that we allow multiple nodes to connect to that socket.
+ if(!((NodeUtilities.getSocketFromID(connection.to, this.nodes)!.type)!.includes("_ARRAY"))){
+ for (const c of this.connections.filter((j) => j.to === toSocket)) {
+ // TODO: this.connections should contain the types of the other nodes, so that we only remove
+ this.removeConnection(c);
+ }
}
this.connections.push(connection);
@@ -217,8 +221,15 @@ export class Project extends EventEmitter {
}
public removeInvalidConnections() {
- for (const c of this.connections.filter((j) => !this.isValidConnection(j))) {
+ for (const c of this.connections.map(c => this.enrichConnection(c)).filter(async (j) => !(this.isValidConnection(j)))) {
this.removeConnection(c);
}
}
+
+ private enrichConnection(c: NodeConnection): NodeConnection {
+ return {
+ from: NodeUtilities.getSocketFromID(c.from, this.nodes),
+ to: NodeUtilities.getSocketFromID(c.to, this.nodes)
+ }
+ }
}
diff --git a/ui/component/or-rules/src/flow-viewer/styles/flow-node-style.ts b/ui/component/or-rules/src/flow-viewer/styles/flow-node-style.ts
index f4c69a272..787e6b84d 100644
--- a/ui/component/or-rules/src/flow-viewer/styles/flow-node-style.ts
+++ b/ui/component/or-rules/src/flow-viewer/styles/flow-node-style.ts
@@ -27,14 +27,6 @@ export const FlowNodeStyle = css`
grid-template-areas:
"input title output";
}
-.internal-container{
- grid-area: internal;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 8px 0 8px 0;
-}
.socket-side{
display: flex;
flex-direction: column;
diff --git a/ui/component/or-rules/src/flow-viewer/styles/picker-styles.ts b/ui/component/or-rules/src/flow-viewer/styles/picker-styles.ts
index 232d906ec..3552e5680 100644
--- a/ui/component/or-rules/src/flow-viewer/styles/picker-styles.ts
+++ b/ui/component/or-rules/src/flow-viewer/styles/picker-styles.ts
@@ -3,16 +3,20 @@ import { css } from "lit";
export const PickerStyle = css`
input{
border: 0;
+ height: max-content;
}
-textarea{
+textarea {
min-width: 150px;
min-height: 37px;
+}
+input[type=number] {
+ padding: 11px 10px;
}
-textarea, input[type=text], input[type=number], select{
+textarea, input[type=text], select{
font-family: inherit;
padding: 10px;
border-radius: var(--roundness);
- width: auto;
+ width: fit-content;
border: none;
}
.attribute-label{