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
Fixed protocol status issues
Christian Bauer655c8219b3bd
diff --git a/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.javaindex e90028c37..cb75c4626 100644--- a/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java@@ -173,6 +173,7 @@ public class TimerProtocol extends AbstractProtocol {}if (protocolConfiguration.isEnabled()) {+ updateStatus(protocolRef, ConnectionStatus.CONNECTED);CronExpression cronExpression = createCronExpression(expressionParser.buildCronExpression());if (cronExpression != null) {getCronScheduler()@@ -181,6 +182,8 @@ public class TimerProtocol extends AbstractProtocol {cronExpression,() -> doTriggerAction(protocolConfiguration));+ } else {+ updateStatus(protocolRef, ConnectionStatus.DISABLED);}}}diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewActivity.java b/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewActivity.javaindex 6bfba3cc7..2b17e4089 100644--- a/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewActivity.java+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/asset/AssetViewActivity.java@@ -106,7 +106,7 @@ public class AssetViewActivity@Overridepublic void onStop() {subscribeLiveUpdates(false);- if (asset.getWellKnownType() == AssetType.AGENT) {+ if (isAgentOrHasAgentLinks()) {subscribeAgentStatus(false);}super.onStop();@@ -124,8 +124,7 @@ public class AssetViewActivity}// If this is an agent or an asset with attributes linked to an agent, start polling all agents status- if (asset.getWellKnownType() == AssetType.AGENT- || asset.getAttributesStream().anyMatch(attribute -> AgentLink.getAgentLink(attribute).isPresent())) {+ if (isAgentOrHasAgentLinks()) {subscribeAgentStatus(true);}@@ -143,6 +142,7 @@ public class AssetViewActivitythis::onAgentStatusEvent));+ // Fetch initial agent statusif (asset.getWellKnownType() == AssetType.AGENT) {fetchAgentStatus(assetId);} else {@@ -151,10 +151,16 @@ public class AssetViewActivity.filter(Optional::isPresent).map(Optional::get).map(AttributeRef::getEntityId)+ .distinct().forEach(this::fetchAgentStatus);}}+ protected boolean isAgentOrHasAgentLinks() {+ return asset.getWellKnownType() == AssetType.AGENT+ || asset.getAttributesStream().anyMatch(attribute -> AgentLink.getAgentLink(attribute).isPresent());+ }+@Overridepublic void centerMap() {view.flyTo(asset.getCoordinates());@@ -237,16 +243,13 @@ public class AssetViewActivityif (asset.getWellKnownType() == AssetType.AGENT) {if (assetAttributeRef.map(ref -> ref.equals(event.getProtocolConfiguration())).orElse(false)) {attributeView.setStatus(event.getConnectionStatus());- break;}} else {- if (AgentLink.getAgentLink(assetAttribute)+ AgentLink.getAgentLink(assetAttribute).filter(agentLink -> agentLink.equals(event.getProtocolConfiguration()))- .map(agentLink -> {+ .ifPresent(agentLink -> {attributeView.setStatus(event.getConnectionStatus());- return true;- }).orElse(false))- break;+ });}}