use of org.openremote.app.client.assets.attributes.AttributeView in project openremote by openremote.
the class AssetViewActivity method onAttributeEvent.
protected void onAttributeEvent(AttributeEvent attributeEvent) {
for (AttributeView attributeView : attributeViews) {
AssetAttribute assetAttribute = attributeView.getAttribute();
Optional<AttributeRef> assetAttributeRef = assetAttribute.getReference();
if (assetAttributeRef.map(ref -> ref.equals(attributeEvent.getAttributeRef())).orElse(false)) {
assetAttribute.setValue(attributeEvent.getValue().orElse(null), attributeEvent.getTimestamp());
attributeView.onAttributeChanged(attributeEvent.getTimestamp());
break;
}
}
}
use of org.openremote.app.client.assets.attributes.AttributeView in project openremote by openremote.
the class AbstractAssetActivity method writeAttributeToView.
protected void writeAttributeToView(AssetAttribute attribute, boolean addToView) {
AttributeView attributeView = createAttributeView(attribute);
attributeViews.add(attributeView);
if (addToView) {
view.addAttributeViews(Collections.singletonList(attributeView));
validateAttribute(true, attribute, result -> processValidationResults(Collections.singletonList(result)));
}
}
use of org.openremote.app.client.assets.attributes.AttributeView in project openremote by openremote.
the class AssetViewActivity method onAgentStatusEvent.
protected void onAgentStatusEvent(AgentStatusEvent event) {
for (AttributeView attributeView : attributeViews) {
AssetAttribute assetAttribute = attributeView.getAttribute();
Optional<AttributeRef> assetAttributeRef = assetAttribute.getReference();
if (asset.getWellKnownType() == AssetType.AGENT) {
if (assetAttributeRef.map(ref -> ref.equals(event.getProtocolConfiguration())).orElse(false)) {
attributeView.setStatus(event.getConnectionStatus());
}
} else {
AgentLink.getAgentLink(assetAttribute).filter(agentLink -> agentLink.equals(event.getProtocolConfiguration())).ifPresent(agentLink -> {
attributeView.setStatus(event.getConnectionStatus());
});
}
}
}
use of org.openremote.app.client.assets.attributes.AttributeView in project openremote by openremote.
the class AssetViewActivity method enableLiveUpdates.
@Override
public void enableLiveUpdates(boolean enable) {
liveUpdates = enable;
for (AttributeView attributeView : attributeViews) {
if (attributeView instanceof AttributeViewImpl) {
((AttributeViewImpl) attributeView).getActionButtons().forEach(button -> {
if (button.getStyleName().contains(READ_BUTTON_CLASS)) {
(button).setEnabled(!enable);
}
});
}
}
if (enable) {
// Poll all values once so we have some state
readAllAttributeValues();
}
subscribeLiveUpdates(enable);
}
Aggregations