Search in sources :

Example 1 with ElectricityStorageAsset

use of org.openremote.model.asset.impl.ElectricityStorageAsset in project openremote by openremote.

the class StorageSimulatorProtocol method doLinkedAttributeWrite.

@SuppressWarnings("unchecked")
@Override
protected void doLinkedAttributeWrite(Attribute<?> attribute, StorageSimulatorAgentLink agentLink, AttributeEvent event, Object processedValue) {
    // Power attribute is updated only by this protocol not by clients
    if (attribute.getName().equals(POWER.getName())) {
        return;
    }
    updateLinkedAttribute(new AttributeState(event.getAttributeRef(), processedValue));
    // Push write value into the asset and update
    String assetId = event.getAssetId();
    ((Attribute<Object>) attribute).setValue(processedValue);
    ElectricityStorageAsset asset = assetService.findAsset(assetId, ElectricityStorageAsset.class);
    asset.addOrReplaceAttributes(attribute);
    updateStorageAsset(asset);
}
Also used : AttributeState(org.openremote.model.attribute.AttributeState) ElectricityStorageAsset(org.openremote.model.asset.impl.ElectricityStorageAsset) Attribute(org.openremote.model.attribute.Attribute)

Aggregations

ElectricityStorageAsset (org.openremote.model.asset.impl.ElectricityStorageAsset)1 Attribute (org.openremote.model.attribute.Attribute)1 AttributeState (org.openremote.model.attribute.AttributeState)1