100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
More docs
Christian Bauer5d3bc3fa7f8b
diff --git a/agent/src/main/java/org/openremote/agent3/protocol/Protocol.java b/agent/src/main/java/org/openremote/agent3/protocol/Protocol.javaindex 66bc2d062..ef53e06ba 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/Protocol.java+++ b/agent/src/main/java/org/openremote/agent3/protocol/Protocol.java@@ -27,9 +27,10 @@ import java.util.Collection;/*** A Protocol implementation must have a unique name in a VM. TODO This is not enforced.* <p>- * OpenRemote protocols are in {@link org.openremote.Constants#PROTOCOL_NAMESPACE}.+ * OpenRemote protocols are in {@link org.openremote.Constants#PROTOCOL_NAMESPACE}, third-party protocols+ * should use their own URN namespace identifier.* <p>- * The Protocol implementation can receive {@link org.openremote.model.AttributeValueChange} messages on the+ * The protocol implementation can receive {@link org.openremote.model.AttributeValueChange} messages on the* {@link #ACTUATOR_TOPIC}. It can produce {@link org.openremote.model.AttributeValueChange} messages on the* {@link #SENSOR_TOPIC}.* <p>diff --git a/agent/src/main/java/org/openremote/agent3/protocol/simulator/SimulatorProtocol.java b/agent/src/main/java/org/openremote/agent3/protocol/simulator/SimulatorProtocol.javaindex 9664fc812..b9aaeb062 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/simulator/SimulatorProtocol.java+++ b/agent/src/main/java/org/openremote/agent3/protocol/simulator/SimulatorProtocol.java@@ -85,6 +85,9 @@ public class SimulatorProtocol extends AbstractProtocol {putState(attributeRef, value, true);}+ /**+ * @param isSensorUpdate <code>true</code> if an {@link AttributeValueChange} message should be produced+ */public void putState(AttributeRef attributeRef, JsonValue value, boolean isSensorUpdate) {synchronized (elements) {LOG.fine("Put state '" + attributeRef + "': " + (value != null ? value.asString() : "null"));diff --git a/manager/client/src/main/java/org/openremote/manager/client/toast/Toast.java b/manager/client/src/main/java/org/openremote/manager/client/toast/Toast.javaindex cfa04367e..62e9709a3 100644--- a/manager/client/src/main/java/org/openremote/manager/client/toast/Toast.java+++ b/manager/client/src/main/java/org/openremote/manager/client/toast/Toast.java@@ -57,8 +57,11 @@ public class Toast {return maxAgeMillis;}+ public boolean isDurableFailure() {+ return getText() != null && getType().equals(Type.DURABLE_FAILURE);+ }+public boolean isExpired() {- return !getType().equals(Type.DURABLE_FAILURE)- && (getTimestamp() + getMaxAgeMillis()) <= System.currentTimeMillis();+ return !isDurableFailure() && (getTimestamp() + getMaxAgeMillis()) <= System.currentTimeMillis();}}diff --git a/shared/src/main/java/org/openremote/model/AttributeSchedule.java b/shared/src/main/java/org/openremote/model/AttributeSchedule.javanew file mode 100644index 000000000..9107246f7--- /dev/null+++ b/shared/src/main/java/org/openremote/model/AttributeSchedule.java@@ -0,0 +1,67 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model;++import org.openremote.Function;++import java.util.LinkedList;++/**+ * Apply a sequence of <code>[AttributeValueChange, Seconds]</code> items, each lasting for the given duration.+ * <p>+ * Optionally, repeat the schedule when the last item has expired.+ */+public class AttributeSchedule extends LinkedList<AttributeSchedule.Item> {++ public class Item {+ final AttributeValueChange attributeValueChange;+ final int delayNextSeconds;++ public Item(AttributeValueChange attributeValueChange, int delayNextSeconds) {+ this.attributeValueChange = attributeValueChange;+ this.delayNextSeconds = delayNextSeconds;+ }++ public AttributeValueChange getAttributeValueChange() {+ return attributeValueChange;+ }++ public int getDelayNextSeconds() {+ return delayNextSeconds;+ }+ }++ final protected boolean repeat;++ public AttributeSchedule(boolean repeat) {+ this.repeat = repeat;+ }++ public boolean isRepeat() {+ return repeat;+ }++ /**+ * TODO+ */+ public void apply(Function<AttributeRef, Attribute> attributeResolver) {+ throw new UnsupportedOperationException("TODO Implement this");+ }+}diff --git a/shared/src/main/java/org/openremote/model/Metadata.java b/shared/src/main/java/org/openremote/model/Metadata.javaindex 368297103..99247ab51 100644--- a/shared/src/main/java/org/openremote/model/Metadata.java+++ b/shared/src/main/java/org/openremote/model/Metadata.java@@ -27,6 +27,11 @@ import org.openremote.Function;import java.util.ArrayList;import java.util.List;+/**+ * An array of {@link MetadataItem} elements.+ *+ * Note that duplicate item names are allowed for multi-valued elements.+ */public class Metadata {final protected JsonArray jsonArray;diff --git a/shared/src/main/java/org/openremote/model/asset/AgentAttributes.java b/shared/src/main/java/org/openremote/model/asset/AgentAttributes.javaindex 9994a02dc..5d0f1fad5 100644--- a/shared/src/main/java/org/openremote/model/asset/AgentAttributes.java+++ b/shared/src/main/java/org/openremote/model/asset/AgentAttributes.java@@ -30,8 +30,7 @@ import java.util.List;public class AgentAttributes extends Attributes {public AgentAttributes() {- super();- initialize();+ setEnabled(false);}public AgentAttributes(Asset agentAsset) {@@ -56,10 +55,6 @@ public class AgentAttributes extends Attributes {return new ProtocolConfiguration(attribute);}- public void initialize() {- setEnabled(false);- }-public boolean isEnabled() {return hasAttribute("enabled") && get("enabled").isValueTrue();}diff --git a/shared/src/main/java/org/openremote/model/asset/ProtocolConfiguration.java b/shared/src/main/java/org/openremote/model/asset/ProtocolConfiguration.javaindex b87f375ad..8ac5e0364 100644--- a/shared/src/main/java/org/openremote/model/asset/ProtocolConfiguration.java+++ b/shared/src/main/java/org/openremote/model/asset/ProtocolConfiguration.java@@ -21,16 +21,25 @@ package org.openremote.model.asset;import elemental.json.Json;import elemental.json.JsonObject;-import org.openremote.Constants;import org.openremote.model.Attribute;import org.openremote.model.AttributeType;+import java.util.Locale;++/**+ * Agent attributes can be named protocol configurations, the value is a protocol URN.+ * <p>+ * Configuration details are managed as {@link org.openremote.model.Metadata} of the attribute.+ */public class ProtocolConfiguration extends Attribute {+ /**+ * A protocol configuration attribute value must be a URN string representation starting with "urn:".+ */public static boolean isProtocolConfiguration(Attribute attribute) {return attribute.getType() == AttributeType.STRING&& attribute.getValue() != null- && attribute.getValueAsString().startsWith(Constants.PROTOCOL_NAMESPACE);+ && attribute.getValueAsString().toLowerCase(Locale.ROOT).startsWith("urn:");}public ProtocolConfiguration(Attribute attribute) {