Search in sources :

Example 1 with AttributeView

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;
        }
    }
}
Also used : SimulatorState(org.openremote.model.simulator.SimulatorState) DatapointInterval(org.openremote.model.datapoint.DatapointInterval) AssetMapper(org.openremote.app.client.assets.AssetMapper) Environment(org.openremote.app.client.Environment) ProtocolConfiguration(org.openremote.model.asset.agent.ProtocolConfiguration) AttributeRef(org.openremote.model.attribute.AttributeRef) AssetDatapointResource(org.openremote.model.datapoint.AssetDatapointResource) AttributeViewImpl(org.openremote.app.client.assets.attributes.AttributeViewImpl) ObjectValueMapper(org.openremote.app.client.interop.value.ObjectValueMapper) FormButton(org.openremote.app.client.widget.FormButton) NumberDatapoint(org.openremote.model.datapoint.NumberDatapoint) ArrayList(java.util.ArrayList) AgentLink(org.openremote.model.asset.agent.AgentLink) Inject(javax.inject.Inject) ReadAssetAttributesEvent(org.openremote.model.asset.ReadAssetAttributesEvent) TenantFilter(org.openremote.model.event.shared.TenantFilter) AttributeEvent(org.openremote.model.attribute.AttributeEvent) URL(com.google.gwt.http.client.URL) AbstractAttributeViewExtension(org.openremote.app.client.assets.attributes.AbstractAttributeViewExtension) AttributeView(org.openremote.app.client.assets.attributes.AttributeView) AgentStatusEventMapper(org.openremote.app.client.assets.AgentStatusEventMapper) Consumer(org.openremote.model.interop.Consumer) AgentResource(org.openremote.model.asset.agent.AgentResource) MapResource(org.openremote.model.map.MapResource) AgentStatusEvent(org.openremote.model.asset.agent.AgentStatusEvent) AssetType(org.openremote.model.asset.AssetType) DatapointBrowser(org.openremote.app.client.datapoint.DatapointBrowser) JsonEditor(org.openremote.app.client.app.dialog.JsonEditor) Constants(org.openremote.model.Constants) AssetResource(org.openremote.model.asset.AssetResource) Provider(com.google.inject.Provider) List(java.util.List) AssetBrowser(org.openremote.app.client.assets.browser.AssetBrowser) NumberDatapointArrayMapper(org.openremote.app.client.datapoint.NumberDatapointArrayMapper) Optional(java.util.Optional) Values(org.openremote.model.value.Values) TextUtil.isNullOrEmpty(org.openremote.model.util.TextUtil.isNullOrEmpty) AssetAttribute(org.openremote.model.asset.AssetAttribute) Datapoint(org.openremote.model.datapoint.Datapoint) Collections(java.util.Collections) Simulator(org.openremote.app.client.simulator.Simulator) AttributeExecuteStatus(org.openremote.model.attribute.AttributeExecuteStatus) AttributeView(org.openremote.app.client.assets.attributes.AttributeView) AttributeRef(org.openremote.model.attribute.AttributeRef) AssetAttribute(org.openremote.model.asset.AssetAttribute)

Example 2 with AttributeView

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)));
    }
}
Also used : AttributeView(org.openremote.app.client.assets.attributes.AttributeView)

Example 3 with AttributeView

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());
            });
        }
    }
}
Also used : SimulatorState(org.openremote.model.simulator.SimulatorState) DatapointInterval(org.openremote.model.datapoint.DatapointInterval) AssetMapper(org.openremote.app.client.assets.AssetMapper) Environment(org.openremote.app.client.Environment) ProtocolConfiguration(org.openremote.model.asset.agent.ProtocolConfiguration) AttributeRef(org.openremote.model.attribute.AttributeRef) AssetDatapointResource(org.openremote.model.datapoint.AssetDatapointResource) AttributeViewImpl(org.openremote.app.client.assets.attributes.AttributeViewImpl) ObjectValueMapper(org.openremote.app.client.interop.value.ObjectValueMapper) FormButton(org.openremote.app.client.widget.FormButton) NumberDatapoint(org.openremote.model.datapoint.NumberDatapoint) ArrayList(java.util.ArrayList) AgentLink(org.openremote.model.asset.agent.AgentLink) Inject(javax.inject.Inject) ReadAssetAttributesEvent(org.openremote.model.asset.ReadAssetAttributesEvent) TenantFilter(org.openremote.model.event.shared.TenantFilter) AttributeEvent(org.openremote.model.attribute.AttributeEvent) URL(com.google.gwt.http.client.URL) AbstractAttributeViewExtension(org.openremote.app.client.assets.attributes.AbstractAttributeViewExtension) AttributeView(org.openremote.app.client.assets.attributes.AttributeView) AgentStatusEventMapper(org.openremote.app.client.assets.AgentStatusEventMapper) Consumer(org.openremote.model.interop.Consumer) AgentResource(org.openremote.model.asset.agent.AgentResource) MapResource(org.openremote.model.map.MapResource) AgentStatusEvent(org.openremote.model.asset.agent.AgentStatusEvent) AssetType(org.openremote.model.asset.AssetType) DatapointBrowser(org.openremote.app.client.datapoint.DatapointBrowser) JsonEditor(org.openremote.app.client.app.dialog.JsonEditor) Constants(org.openremote.model.Constants) AssetResource(org.openremote.model.asset.AssetResource) Provider(com.google.inject.Provider) List(java.util.List) AssetBrowser(org.openremote.app.client.assets.browser.AssetBrowser) NumberDatapointArrayMapper(org.openremote.app.client.datapoint.NumberDatapointArrayMapper) Optional(java.util.Optional) Values(org.openremote.model.value.Values) TextUtil.isNullOrEmpty(org.openremote.model.util.TextUtil.isNullOrEmpty) AssetAttribute(org.openremote.model.asset.AssetAttribute) Datapoint(org.openremote.model.datapoint.Datapoint) Collections(java.util.Collections) Simulator(org.openremote.app.client.simulator.Simulator) AttributeExecuteStatus(org.openremote.model.attribute.AttributeExecuteStatus) AttributeView(org.openremote.app.client.assets.attributes.AttributeView) AttributeRef(org.openremote.model.attribute.AttributeRef) AssetAttribute(org.openremote.model.asset.AssetAttribute)

Example 4 with AttributeView

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);
}
Also used : AttributeView(org.openremote.app.client.assets.attributes.AttributeView) AttributeViewImpl(org.openremote.app.client.assets.attributes.AttributeViewImpl)

Aggregations

AttributeView (org.openremote.app.client.assets.attributes.AttributeView)4 AttributeViewImpl (org.openremote.app.client.assets.attributes.AttributeViewImpl)3 URL (com.google.gwt.http.client.URL)2 Provider (com.google.inject.Provider)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Optional (java.util.Optional)2 Inject (javax.inject.Inject)2 Environment (org.openremote.app.client.Environment)2 JsonEditor (org.openremote.app.client.app.dialog.JsonEditor)2 AgentStatusEventMapper (org.openremote.app.client.assets.AgentStatusEventMapper)2 AssetMapper (org.openremote.app.client.assets.AssetMapper)2 AbstractAttributeViewExtension (org.openremote.app.client.assets.attributes.AbstractAttributeViewExtension)2 AssetBrowser (org.openremote.app.client.assets.browser.AssetBrowser)2 DatapointBrowser (org.openremote.app.client.datapoint.DatapointBrowser)2 NumberDatapointArrayMapper (org.openremote.app.client.datapoint.NumberDatapointArrayMapper)2 ObjectValueMapper (org.openremote.app.client.interop.value.ObjectValueMapper)2 Simulator (org.openremote.app.client.simulator.Simulator)2 FormButton (org.openremote.app.client.widget.FormButton)2