Search in sources :

Example 1 with AsymmetricEssNature

use of io.openems.api.device.nature.ess.AsymmetricEssNature in project openems by OpenEMS.

the class AsymmetricSymmetricCombinationEssNature method loadEss.

private void loadEss() {
    String essId;
    try {
        essId = ess.value();
        // remove old ess
        if (essNature != null) {
            gridMode.removeChannel(essNature.gridMode());
            soc.removeChannel(essNature.soc());
            allowedApparent.removeChannel(essNature.allowedApparent());
            allowedCharge.removeChannel(essNature.allowedCharge());
            allowedDischarge.removeChannel(essNature.allowedDischarge());
            systemState.removeChannel(essNature.systemState());
            capacity.removeChannel(essNature.capacity());
            maxNominalPower.removeChannel(essNature.maxNominalPower());
            activePowerL1.removeChannel(essNature.activePowerL1());
            activePowerL1.removeChannel(essNature.activePowerL2());
            activePowerL1.removeChannel(essNature.activePowerL3());
            activePowerL2.removeChannel(essNature.activePowerL1());
            activePowerL2.removeChannel(essNature.activePowerL2());
            activePowerL2.removeChannel(essNature.activePowerL3());
            activePowerL3.removeChannel(essNature.activePowerL1());
            activePowerL3.removeChannel(essNature.activePowerL2());
            activePowerL3.removeChannel(essNature.activePowerL3());
            activePower.removeChannel(essNature.activePowerL1());
            activePower.removeChannel(essNature.activePowerL2());
            activePower.removeChannel(essNature.activePowerL3());
            reactivePowerL1.removeChannel(essNature.reactivePowerL1());
            reactivePowerL1.removeChannel(essNature.reactivePowerL2());
            reactivePowerL1.removeChannel(essNature.reactivePowerL3());
            reactivePowerL2.removeChannel(essNature.reactivePowerL1());
            reactivePowerL2.removeChannel(essNature.reactivePowerL2());
            reactivePowerL2.removeChannel(essNature.reactivePowerL3());
            reactivePowerL3.removeChannel(essNature.reactivePowerL1());
            reactivePowerL3.removeChannel(essNature.reactivePowerL2());
            reactivePowerL3.removeChannel(essNature.reactivePowerL3());
            reactivePower.removeChannel(essNature.reactivePowerL1());
            reactivePower.removeChannel(essNature.reactivePowerL2());
            reactivePower.removeChannel(essNature.reactivePowerL3());
            setActivePowerL1.removeChannel(essNature.setActivePowerL1());
            setActivePowerL1.removeChannel(essNature.setActivePowerL2());
            setActivePowerL1.removeChannel(essNature.setActivePowerL3());
            setActivePowerL2.removeChannel(essNature.setActivePowerL1());
            setActivePowerL2.removeChannel(essNature.setActivePowerL2());
            setActivePowerL2.removeChannel(essNature.setActivePowerL3());
            setActivePowerL3.removeChannel(essNature.setActivePowerL1());
            setActivePowerL3.removeChannel(essNature.setActivePowerL2());
            setActivePowerL3.removeChannel(essNature.setActivePowerL3());
            setReactivePowerL1.removeChannel(essNature.setReactivePowerL1());
            setReactivePowerL1.removeChannel(essNature.setReactivePowerL2());
            setReactivePowerL1.removeChannel(essNature.setReactivePowerL3());
            setReactivePowerL2.removeChannel(essNature.setReactivePowerL1());
            setReactivePowerL2.removeChannel(essNature.setReactivePowerL2());
            setReactivePowerL2.removeChannel(essNature.setReactivePowerL3());
            setReactivePowerL3.removeChannel(essNature.setReactivePowerL1());
            setReactivePowerL3.removeChannel(essNature.setReactivePowerL2());
            setReactivePowerL3.removeChannel(essNature.setReactivePowerL3());
            setWorkState.removeChannel(essNature.setWorkState());
            power = null;
            nativeAsymmetricPower = null;
        }
        essNature = null;
        if (essId != null) {
            Optional<Thing> nature = repo.getThingById(essId);
            if (nature.isPresent()) {
                if (nature.get() instanceof AsymmetricEssNature) {
                    AsymmetricEssNature ess = (AsymmetricEssNature) nature.get();
                    essNature = ess;
                    // Add channels to functionalChannels
                    if (essNature != null) {
                        gridMode.setChannel(essNature.gridMode());
                        soc.setChannel(essNature.soc());
                        allowedApparent.setChannel(essNature.allowedApparent());
                        allowedDischarge.setChannel(essNature.allowedDischarge());
                        allowedCharge.setChannel(essNature.allowedCharge());
                        systemState.setChannel(essNature.systemState());
                        capacity.setChannel(essNature.capacity());
                        maxNominalPower.setChannel(essNature.maxNominalPower());
                        activePowerL1.addChannel(essNature.activePowerL1());
                        activePowerL1.addChannel(essNature.activePowerL2());
                        activePowerL1.addChannel(essNature.activePowerL3());
                        activePowerL2.addChannel(essNature.activePowerL1());
                        activePowerL2.addChannel(essNature.activePowerL2());
                        activePowerL2.addChannel(essNature.activePowerL3());
                        activePowerL3.addChannel(essNature.activePowerL1());
                        activePowerL3.addChannel(essNature.activePowerL2());
                        activePowerL3.addChannel(essNature.activePowerL3());
                        activePower.addChannel(essNature.activePowerL1());
                        activePower.addChannel(essNature.activePowerL2());
                        activePower.addChannel(essNature.activePowerL3());
                        reactivePowerL1.addChannel(essNature.reactivePowerL1());
                        reactivePowerL1.addChannel(essNature.reactivePowerL2());
                        reactivePowerL1.addChannel(essNature.reactivePowerL3());
                        reactivePowerL2.addChannel(essNature.reactivePowerL1());
                        reactivePowerL2.addChannel(essNature.reactivePowerL2());
                        reactivePowerL2.addChannel(essNature.reactivePowerL3());
                        reactivePowerL3.addChannel(essNature.reactivePowerL1());
                        reactivePowerL3.addChannel(essNature.reactivePowerL2());
                        reactivePowerL3.addChannel(essNature.reactivePowerL3());
                        reactivePower.addChannel(essNature.reactivePowerL1());
                        reactivePower.addChannel(essNature.reactivePowerL2());
                        reactivePower.addChannel(essNature.reactivePowerL3());
                        setActivePowerL1.addChannel(essNature.setActivePowerL1());
                        setActivePowerL1.addChannel(essNature.setActivePowerL2());
                        setActivePowerL1.addChannel(essNature.setActivePowerL3());
                        setActivePowerL2.addChannel(essNature.setActivePowerL1());
                        setActivePowerL2.addChannel(essNature.setActivePowerL2());
                        setActivePowerL2.addChannel(essNature.setActivePowerL3());
                        setActivePowerL3.addChannel(essNature.setActivePowerL1());
                        setActivePowerL3.addChannel(essNature.setActivePowerL2());
                        setActivePowerL3.addChannel(essNature.setActivePowerL3());
                        setReactivePowerL1.addChannel(essNature.setReactivePowerL1());
                        setReactivePowerL1.addChannel(essNature.setReactivePowerL2());
                        setReactivePowerL1.addChannel(essNature.setReactivePowerL3());
                        setReactivePowerL2.addChannel(essNature.setReactivePowerL1());
                        setReactivePowerL2.addChannel(essNature.setReactivePowerL2());
                        setReactivePowerL2.addChannel(essNature.setReactivePowerL3());
                        setReactivePowerL3.addChannel(essNature.setReactivePowerL1());
                        setReactivePowerL3.addChannel(essNature.setReactivePowerL2());
                        setReactivePowerL3.addChannel(essNature.setReactivePowerL3());
                        setWorkState.addChannel(essNature.setWorkState());
                        power = new SymmetricPowerProxy(essNature.maxNominalPower().value(), getParent().getBridge());
                        nativeAsymmetricPower = new AsymmetricPower(essNature.allowedDischarge().required(), essNature.allowedCharge().required(), essNature.allowedApparent().required(), essNature.setActivePowerL1().required(), essNature.setActivePowerL2().required(), essNature.setActivePowerL3().required(), essNature.setReactivePowerL1().required(), essNature.setReactivePowerL2().required(), essNature.setReactivePowerL3().required());
                    }
                } else {
                    log.error("ThingID: " + essId + " is no AsymmetricEss!");
                }
            } else {
                log.warn("meter: " + essId + " not found!");
            }
        }
    } catch (InvalidValueException e) {
        log.error("esss value is invalid!", e);
    }
}
Also used : InvalidValueException(io.openems.api.exception.InvalidValueException) AsymmetricPower(io.openems.core.utilities.AsymmetricPower) SymmetricPowerProxy(io.openems.core.utilities.power.symmetric.SymmetricPowerProxy) Thing(io.openems.api.thing.Thing) AsymmetricEssNature(io.openems.api.device.nature.ess.AsymmetricEssNature)

Example 2 with AsymmetricEssNature

use of io.openems.api.device.nature.ess.AsymmetricEssNature in project openems by OpenEMS.

the class SimulatorGridMeter method update.

@Override
protected void update() {
    super.update();
    long activePower = 0;
    long activePowerL1 = 0;
    long activePowerL2 = 0;
    long activePowerL3 = 0;
    if (activePowerLoad != null) {
        factorL1 = SimulatorTools.addRandomDouble(factorL1, 0, 1, 0.01);
        factorL2 = SimulatorTools.addRandomDouble(factorL2, 0, 1 - factorL1, 0.01);
        factorL3 = 1 - factorL1 - factorL2;
        long load = activePowerLoad.getLoad();
        activePower = load;
        activePowerL1 = (long) (load * factorL1);
        activePowerL2 = (long) (load * factorL2);
        activePowerL3 = (long) (load * factorL3);
    }
    long reactivePower = 0;
    long reactivePowerL1 = 0;
    long reactivePowerL2 = 0;
    long reactivePowerL3 = 0;
    if (reactivePowerLoad != null) {
        reactivePower = reactivePowerLoad.getLoad();
        reactivePowerL1 = reactivePower / 3;
        reactivePowerL2 = reactivePower / 3;
        reactivePowerL3 = reactivePower / 3;
    }
    for (EssNature entry : essNatures) {
        if (entry instanceof SymmetricEssNature) {
            SymmetricEssNature ess = (SymmetricEssNature) entry;
            activePower -= ess.activePower().valueOptional().orElse(0L);
            activePowerL1 -= ess.activePower().valueOptional().orElse(0L) / 3;
            activePowerL2 -= ess.activePower().valueOptional().orElse(0L) / 3;
            activePowerL3 -= ess.activePower().valueOptional().orElse(0L) / 3;
            reactivePower -= ess.reactivePower().valueOptional().orElse(0L);
            reactivePowerL1 -= ess.reactivePower().valueOptional().orElse(0L) / 3;
            reactivePowerL2 -= ess.reactivePower().valueOptional().orElse(0L) / 3;
            reactivePowerL3 -= ess.reactivePower().valueOptional().orElse(0L) / 3;
        } else if (entry instanceof AsymmetricEssNature) {
            AsymmetricEssNature ess = (AsymmetricEssNature) entry;
            activePower -= ess.activePowerL1().valueOptional().orElse(0L) + ess.activePowerL2().valueOptional().orElse(0L) + ess.activePowerL3().valueOptional().orElse(0L);
            activePowerL1 -= ess.activePowerL1().valueOptional().orElse(0L);
            activePowerL2 -= ess.activePowerL2().valueOptional().orElse(0L);
            activePowerL3 -= ess.activePowerL3().valueOptional().orElse(0L);
            reactivePower -= ess.reactivePowerL1().valueOptional().orElse(0L) + ess.reactivePowerL2().valueOptional().orElse(0L) + ess.reactivePowerL3().valueOptional().orElse(0L);
            reactivePowerL1 -= ess.reactivePowerL1().valueOptional().orElse(0L);
            reactivePowerL2 -= ess.reactivePowerL2().valueOptional().orElse(0L);
            reactivePowerL3 -= ess.reactivePowerL3().valueOptional().orElse(0L);
        }
    }
    for (MeterNature entry : meterNatures) {
        if (entry instanceof SymmetricMeterNature) {
            SymmetricMeterNature meter = (SymmetricMeterNature) entry;
            activePower -= meter.activePower().valueOptional().orElse(0L);
            activePowerL1 -= meter.activePower().valueOptional().orElse(0L) / 3;
            activePowerL2 -= meter.activePower().valueOptional().orElse(0L) / 3;
            activePowerL3 -= meter.activePower().valueOptional().orElse(0L) / 3;
            reactivePower -= meter.reactivePower().valueOptional().orElse(0L);
            reactivePowerL1 -= meter.reactivePower().valueOptional().orElse(0L) / 3;
            reactivePowerL2 -= meter.reactivePower().valueOptional().orElse(0L) / 3;
            reactivePowerL3 -= meter.reactivePower().valueOptional().orElse(0L) / 3;
        } else if (entry instanceof AsymmetricMeterNature) {
            AsymmetricMeterNature meter = (AsymmetricMeterNature) entry;
            activePower -= meter.activePowerL1().valueOptional().orElse(0L) + meter.activePowerL2().valueOptional().orElse(0L) + meter.activePowerL3().valueOptional().orElse(0L);
            activePowerL1 -= meter.activePowerL1().valueOptional().orElse(0L);
            activePowerL2 -= meter.activePowerL2().valueOptional().orElse(0L);
            activePowerL3 -= meter.activePowerL3().valueOptional().orElse(0L);
            reactivePower -= meter.reactivePowerL1().valueOptional().orElse(0L) + meter.reactivePowerL2().valueOptional().orElse(0L) + meter.reactivePowerL3().valueOptional().orElse(0L);
            reactivePowerL1 -= meter.reactivePowerL1().valueOptional().orElse(0L);
            reactivePowerL2 -= meter.reactivePowerL2().valueOptional().orElse(0L);
            reactivePowerL3 -= meter.reactivePowerL3().valueOptional().orElse(0L);
        }
    }
    if (isOffGrid(essNatures)) {
        this.activePower.updateValue(null);
        this.activePowerL1.updateValue(null);
        this.activePowerL2.updateValue(null);
        this.activePowerL3.updateValue(null);
        this.reactivePower.updateValue(null);
        this.reactivePowerL1.updateValue(null);
        this.reactivePowerL2.updateValue(null);
        this.reactivePowerL3.updateValue(null);
    } else {
        this.activePower.updateValue(activePower);
        this.activePowerL1.updateValue(activePowerL1);
        this.activePowerL2.updateValue(activePowerL2);
        this.activePowerL3.updateValue(activePowerL3);
        this.reactivePower.updateValue(reactivePower);
        this.reactivePowerL1.updateValue(reactivePowerL1);
        this.reactivePowerL2.updateValue(reactivePowerL2);
        this.reactivePowerL3.updateValue(reactivePowerL3);
    }
}
Also used : AsymmetricEssNature(io.openems.api.device.nature.ess.AsymmetricEssNature) EssNature(io.openems.api.device.nature.ess.EssNature) SymmetricEssNature(io.openems.api.device.nature.ess.SymmetricEssNature) SymmetricMeterNature(io.openems.api.device.nature.meter.SymmetricMeterNature) AsymmetricMeterNature(io.openems.api.device.nature.meter.AsymmetricMeterNature) MeterNature(io.openems.api.device.nature.meter.MeterNature) SymmetricMeterNature(io.openems.api.device.nature.meter.SymmetricMeterNature) AsymmetricMeterNature(io.openems.api.device.nature.meter.AsymmetricMeterNature) SymmetricEssNature(io.openems.api.device.nature.ess.SymmetricEssNature) AsymmetricEssNature(io.openems.api.device.nature.ess.AsymmetricEssNature)

Example 3 with AsymmetricEssNature

use of io.openems.api.device.nature.ess.AsymmetricEssNature in project openems by OpenEMS.

the class Ess method toString.

@Override
public String toString() {
    StringBuilder b = new StringBuilder();
    b.append(// 
    ess.id() + " [" + "SOC:" + ess.soc().format() + "|");
    if (ess instanceof SymmetricEssNature) {
        SymmetricEssNature e = (SymmetricEssNature) ess;
        b.append("L:" + e.activePower().format() + ";" + e.reactivePower().format());
    }
    if (ess instanceof AsymmetricEssNature && ess instanceof SymmetricEssNature) {
        b.append("|");
    }
    if (ess instanceof AsymmetricEssNature) {
        AsymmetricEssNature e = (AsymmetricEssNature) ess;
        b.append(// 
        "L1:" + e.activePowerL1().format() + ";" + e.reactivePowerL1().format() + "|" + "L2:" + e.activePowerL2().format() + ";" + e.reactivePowerL2().format() + // 
        "|" + "L3:" + e.activePowerL3().format() + ";" + e.reactivePowerL3().format());
    }
    b.append(// 
    "|" + "Allowed:" + ess.allowedCharge().format() + ";" + ess.allowedDischarge().format());
    b.append(// 
    "|" + "GridMode:" + ess.gridMode().labelOptional().orElse("unknown"));
    List<ThingStateChannel> warningChannels = ess.getStateChannel().getWarningChannels().stream().filter(c -> c.isValuePresent() && c.getValue()).collect(Collectors.toList());
    List<ThingStateChannel> faultChannels = ess.getStateChannel().getFaultChannels().stream().filter(c -> c.isValuePresent() && c.getValue()).collect(Collectors.toList());
    if (warningChannels.size() > 0) {
        b.append("|Warn:");
        b.append(warningChannels.stream().map(c -> c.name()).collect(Collectors.joining(",")));
    }
    if (faultChannels.size() > 0) {
        b.append("|Fault:");
        b.append(faultChannels.stream().map(c -> c.name()).collect(Collectors.joining(",")));
    }
    b.append("]");
    return b.toString();
}
Also used : List(java.util.List) SymmetricEssNature(io.openems.api.device.nature.ess.SymmetricEssNature) AsymmetricEssNature(io.openems.api.device.nature.ess.AsymmetricEssNature) IsThingMap(io.openems.api.controller.IsThingMap) ThingMap(io.openems.api.controller.ThingMap) Collectors(java.util.stream.Collectors) ThingStateChannel(io.openems.api.channel.ThingStateChannel) EssNature(io.openems.api.device.nature.ess.EssNature) ThingStateChannel(io.openems.api.channel.ThingStateChannel) SymmetricEssNature(io.openems.api.device.nature.ess.SymmetricEssNature) AsymmetricEssNature(io.openems.api.device.nature.ess.AsymmetricEssNature)

Aggregations

AsymmetricEssNature (io.openems.api.device.nature.ess.AsymmetricEssNature)3 EssNature (io.openems.api.device.nature.ess.EssNature)2 SymmetricEssNature (io.openems.api.device.nature.ess.SymmetricEssNature)2 ThingStateChannel (io.openems.api.channel.ThingStateChannel)1 IsThingMap (io.openems.api.controller.IsThingMap)1 ThingMap (io.openems.api.controller.ThingMap)1 AsymmetricMeterNature (io.openems.api.device.nature.meter.AsymmetricMeterNature)1 MeterNature (io.openems.api.device.nature.meter.MeterNature)1 SymmetricMeterNature (io.openems.api.device.nature.meter.SymmetricMeterNature)1 InvalidValueException (io.openems.api.exception.InvalidValueException)1 Thing (io.openems.api.thing.Thing)1 AsymmetricPower (io.openems.core.utilities.AsymmetricPower)1 SymmetricPowerProxy (io.openems.core.utilities.power.symmetric.SymmetricPowerProxy)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1