Search in sources :

Example 1 with NoPBetweenLimitation

use of io.openems.core.utilities.power.symmetric.NoPBetweenLimitation in project openems by OpenEMS.

the class RefuEss method defineModbusProtocol.

@Override
protected ModbusProtocol defineModbusProtocol() throws ConfigException {
    ModbusProtocol protocol = new // 
    ModbusProtocol(new // 
    ModbusInputRegisterRange(// 
    0x100, new // 
    UnsignedWordElement(// 
    0x100, systemState = // 
    new ModbusReadLongChannel("SystemState", this).label(0, // 
    STOP).label(1, // 
    "Init").label(2, // 
    "Pre-operation").label(3, // 
    STANDBY).label(4, // 
    START).label(5, FAULT)), new // 
    UnsignedWordElement(// 
    0x101, // 
    new ModbusBitWrappingChannel("SystemError1", this, this.thingState).faultBit(0, // 
    FaultEss.BMSInError).faultBit(1, // 
    FaultEss.BMSInErrorSecond).faultBit(2, // 
    FaultEss.BMSUndervoltage).faultBit(3, // 
    FaultEss.BMSOvercurrent).faultBit(4, // 
    FaultEss.ErrorBMSLimitsNotInitialized).faultBit(5, // 
    FaultEss.ConnectError).faultBit(6, // 
    FaultEss.OvervoltageWarning).faultBit(7, // 
    FaultEss.UndervoltageWarning).faultBit(8, // 
    FaultEss.OvercurrentWarning).faultBit(9, // 
    FaultEss.BMSReady).faultBit(10, // 
    FaultEss.TREXReady)), new UnsignedWordElement(0x102, communicationInformations = // 
    new StatusBitChannel("CommunicationInformations", this).label(1, // 
    "Gateway Initialized").label(2, // 
    "Modbus Slave Status").label(4, // 
    "Modbus Master Status").label(8, // 
    "CAN Timeout").label(16, // 
    "First Communication Ok")), new UnsignedWordElement(0x103, inverterStatus = // 
    new StatusBitChannel("InverterStatus", this).label(1, // 
    "Ready to Power on").label(2, // 
    "Ready for Operating").label(4, // 
    "Enabled").label(8, // 
    "Fault").label(256, // 
    "Warning").label(512, // 
    "Voltage/Current mode").label(1024, // 
    "Power mode").label(2048, // 
    "AC relays close").label(4096, // 
    "DC relays 1 close").label(8192, // 
    "DC relays 2 close").label(16384, // 
    "Mains OK")), new UnsignedWordElement(0x104, errorCode = new ModbusReadLongChannel("ErrorCode", this)), new UnsignedWordElement(0x105, dcDcStatus = // 
    new StatusBitChannel("DCDCStatus", this).label(1, // 
    "Ready to Power on").label(2, // 
    "Ready for Operating").label(4, // 
    "Enabled").label(8, // 
    "DCDC Fault").label(128, // 
    "DCDC Warning").label(256, // 
    "Voltage/Current mode").label(512, // 
    "Power mode")), new UnsignedWordElement(0x106, dcDcError = new ModbusReadLongChannel("DCDCError", this)), new SignedWordElement(0x107, batteryCurrentPcs = new ModbusReadLongChannel("BatteryCurrentPcs", this).unit("mA").multiplier(// 
    2)), new SignedWordElement(0x108, batteryVoltagePcs = new ModbusReadLongChannel("BatteryVoltagePcs", this).unit("mV").multiplier(// 
    2)), new SignedWordElement(0x109, // 
    current = new ModbusReadLongChannel("Current", this).unit("mA").multiplier(2)), new SignedWordElement(0x10A, // 
    currentL1 = new ModbusReadLongChannel("CurrentL1", this).unit("mA").multiplier(2)), new SignedWordElement(0x10B, // 
    currentL2 = new ModbusReadLongChannel("CurrentL2", this).unit("mA").multiplier(2)), new SignedWordElement(0x10C, // 
    currentL3 = new ModbusReadLongChannel("CurrentL3", this).unit("mA").multiplier(2)), new SignedWordElement(0x10D, // 
    activePower = new ModbusReadLongChannel("ActivePower", this).unit("W").multiplier(2)), new SignedWordElement(0x10E, activePowerL1 = new ModbusReadLongChannel("ActivePowerL1", this).unit("W").multiplier(// 
    2)), new SignedWordElement(0x10F, activePowerL2 = new ModbusReadLongChannel("ActivePowerL2", this).unit("W").multiplier(// 
    2)), new SignedWordElement(0x110, activePowerL3 = new ModbusReadLongChannel("ActivePowerL3", this).unit("W").multiplier(// 
    2)), new SignedWordElement(0x111, reactivePower = new ModbusReadLongChannel("ReactivePower", this).unit("Var").multiplier(// 
    2)), new SignedWordElement(0x112, reactivePowerL1 = new ModbusReadLongChannel("ReactivePowerL1", this).unit("Var").multiplier(// 
    2)), new SignedWordElement(0x113, reactivePowerL2 = new ModbusReadLongChannel("ReactivePowerL2", this).unit("Var").multiplier(// 
    2)), new SignedWordElement(0x114, reactivePowerL3 = new ModbusReadLongChannel("ReactivePowerL3", this).unit("Var").multiplier(// 
    2)), // 
    new SignedWordElement(0x115, cosPhi3p = new ModbusReadLongChannel("CosPhi3p", this).unit("")), // 
    new SignedWordElement(0x116, cosPhiL1 = new ModbusReadLongChannel("CosPhiL1", this).unit("")), // 
    new SignedWordElement(0x117, cosPhiL2 = new ModbusReadLongChannel("CosPhiL2", this).unit("")), // 
    new SignedWordElement(0x118, cosPhiL3 = new ModbusReadLongChannel("CosPhiL3", this).unit(""))), new // 
    ModbusInputRegisterRange(// 
    0x11A, new SignedWordElement(0x11A, pcsAllowedCharge = new ModbusReadLongChannel("PcsAllowedCharge", this).unit("kW").multiplier(2)), new SignedWordElement(0x11B, pcsAllowedDischarge = new ModbusReadLongChannel("PcsAllowedDischarge", this).unit("kW").multiplier(2)), new // 
    UnsignedWordElement(// 
    0x11C, batteryState = // 
    new ModbusReadLongChannel("BatteryState", this).label(0, // 
    "Initial").label(1, // 
    STOP).label(2, // 
    "Starting").label(3, // 
    START).label(4, // 
    "Stopping").label(5, // 
    "Fault")), new // 
    UnsignedWordElement(// 
    0x11D, batteryMode = new ModbusReadLongChannel("BatteryMode", this).label(0, "Normal Mode")), new SignedWordElement(0x11E, batteryVoltage = new ModbusReadLongChannel("BatteryVoltage", this).unit("mV").multiplier(2)), new SignedWordElement(0x11F, batteryCurrent = new ModbusReadLongChannel("BatteryCurrent", this).unit("mA").multiplier(2)), new // 
    SignedWordElement(// 
    0x120, batteryPower = // 
    new ModbusReadLongChannel("BatteryPower", this).unit("W").multiplier(2)), new // 
    UnsignedWordElement(// 
    0x121, soc = new ModbusReadLongChannel("Soc", this).unit("%")), new // 
    UnsignedWordElement(// 
    0x122, allowedChargeCurrent = new ModbusReadLongChannel("AllowedChargeCurrent", this).unit(// 
    "mA").multiplier(// 
    2).negate()), new // 
    UnsignedWordElement(// 
    0x123, allowedDischargeCurrent = new ModbusReadLongChannel("AllowedDischargeCurrent", this).unit("mA").multiplier(2)), new // 
    UnsignedWordElement(// 
    0x124, allowedCharge = new ModbusReadLongChannel("AllowedCharge", this).unit("W").multiplier(2).negate()), new // 
    UnsignedWordElement(// 
    0x125, allowedDischarge = new ModbusReadLongChannel("AllowedDischarge", this).unit("W").multiplier(2)), new // 
    SignedDoublewordElement(// 
    0x126, batteryChargeEnergy = new ModbusReadLongChannel("BatteryChargeEnergy", this).unit("kWh")).wordorder(WordOrder.LSWMSW), new // 
    SignedDoublewordElement(// 
    0x128, batteryDischargeEnergy = new ModbusReadLongChannel("BatteryDischargeEnergy", this).unit("kWh")).wordorder(WordOrder.LSWMSW), new // 
    UnsignedWordElement(// 
    0x12A, batteryOperationStatus = new StatusBitChannel("BatteryOperationStatus", this).label(1, // 
    "Battery group 1 operating").label(2, // 
    "Battery group 2 operating").label(4, // 
    "Battery group 3 operating").label(8, "Battery group 4 operating")), new // 
    UnsignedWordElement(// 
    0x12B, batteryHighestVoltage = new ModbusReadLongChannel("BatteryHighestVoltage", this).unit("mV")), new // 
    UnsignedWordElement(// 
    0x12C, batteryLowestVoltage = new ModbusReadLongChannel("BatteryLowestVoltage", this).unit("mV")), new // 
    SignedWordElement(// 
    0x12D, batteryHighestTemperature = new ModbusReadLongChannel("BatteryHighestTemperature", this).unit("�C")), new // 
    SignedWordElement(// 
    0x12E, batteryLowestTemperature = new ModbusReadLongChannel("BatteryLowestTemperature", this).unit("�C")), new // 
    UnsignedWordElement(// 
    0x12F, batteryStopRequest = new ModbusReadLongChannel("BatteryStopRequest", this)), new // 
    UnsignedWordElement(// 
    0x130, // 
    new ModbusBitWrappingChannel("BatteryAlarm1", this, this.thingState).warningBit(0, // 
    WarningEss.NormalChargingOverCurrent).warningBit(1, // 
    WarningEss.CharginigCurrentOverLimit).warningBit(2, // 
    WarningEss.DischargingCurrentOverLimit).warningBit(3, // 
    WarningEss.NormalHighVoltage).warningBit(4, // 
    WarningEss.NormalLowVoltage).warningBit(5, // 
    WarningEss.AbnormalVoltageVariation).warningBit(6, // 
    WarningEss.NormalHighTemperature).warningBit(7, // 
    WarningEss.NormalLowTemperature).warningBit(8, // 
    WarningEss.AbnormalTemperatureVariation).warningBit(9, // 
    WarningEss.SeriousHighVoltage).warningBit(10, // 
    WarningEss.SeriousLowVoltage).warningBit(11, // 
    WarningEss.SeriousLowTemperature).warningBit(12, // 
    WarningEss.ChargingSeriousOverCurrent).warningBit(13, // 
    WarningEss.DischargingSeriousOverCurrent).warningBit(14, // 
    WarningEss.AbnormalCapacityAlarm)), new // 
    UnsignedWordElement(// 
    0x131, // 
    new ModbusBitWrappingChannel("BatteryAlarm2", this, this.thingState).warningBit(0, // 
    WarningEss.EEPROMParameterFailure).warningBit(1, WarningEss.SwitchOfInsideCombinedCabinet).warningBit(5, WarningEss.ShouldNotBeConnectedToGridDueToTheDCSideCondition).warningBit(7, // 
    WarningEss.EmergencyStopRequireFromSystemController)), new // 
    UnsignedWordElement(// 
    0x132, // 
    new ModbusBitWrappingChannel("BatteryAlarm3", this, this.thingState).warningBit(0, // 
    WarningEss.BatteryGroup1EnableAndNotConnectedToGrid).warningBit(1, // 
    WarningEss.BatteryGroup2EnableAndNotConnectedToGrid).warningBit(2, // 
    WarningEss.BatteryGroup3EnableAndNotConnectedToGrid).warningBit(3, // 
    WarningEss.BatteryGroup4EnableAndNotConnectedToGrid)), new // 
    UnsignedWordElement(// 
    0x133, // 
    new ModbusBitWrappingChannel("BatteryAlarm4", this, this.thingState).warningBit(0, WarningEss.TheIsolationSwitchOfBatteryGroup1Open).warningBit(1, WarningEss.TheIsolationSwitchOfBatteryGroup2Open).warningBit(2, WarningEss.TheIsolationSwitchOfBatteryGroup3Open).warningBit(3, // 
    WarningEss.TheIsolationSwitchOfBatteryGroup4Open)), // 
    new DummyElement(0x134), new UnsignedWordElement(0x135, // 
    new ModbusBitWrappingChannel("BatteryAlarm6", this, this.thingState).warningBit(0, // 
    WarningEss.BalancingSamplingFailureOfBatteryGroup1).warningBit(1, // 
    WarningEss.BalancingSamplingFailureOfBatteryGroup2).warningBit(2, // 
    WarningEss.BalancingSamplingFailureOfBatteryGroup3).warningBit(3, // 
    WarningEss.BalancingSamplingFailureOfBatteryGroup4)), new // 
    UnsignedWordElement(// 
    0x136, // 
    new ModbusBitWrappingChannel("BatteryAlarm7", this, this.thingState).warningBit(0, // 
    WarningEss.BalancingControlFailureOfBatteryGroup1).warningBit(1, // 
    WarningEss.BalancingControlFailureOfBatteryGroup2).warningBit(2, // 
    WarningEss.BalancingControlFailureOfBatteryGroup3).warningBit(3, // 
    WarningEss.BalancingControlFailureOfBatteryGroup4)), new // 
    UnsignedWordElement(// 
    0x137, // 
    new ModbusBitWrappingChannel("BatteryFault1", this, this.thingState).faultBit(0, // 
    FaultEss.NoEnableBateryGroupOrUsableBatteryGroup).faultBit(1, // 
    FaultEss.NormalLeakageOfBatteryGroup).faultBit(2, // 
    FaultEss.SeriousLeakageOfBatteryGroup).faultBit(3, // 
    FaultEss.BatteryStartFailure).faultBit(4, // 
    FaultEss.BatteryStopFailure).faultBit(5, // 
    FaultEss.InterruptionOfCANCommunicationBetweenBatteryGroupAndController).faultBit(10, // 
    FaultEss.EmergencyStopAbnormalOfAuxiliaryCollector).faultBit(11, // 
    FaultEss.LeakageSelfDetectionOnNegative).faultBit(12, // 
    FaultEss.LeakageSelfDetectionOnPositive).faultBit(13, // 
    FaultEss.SelfDetectionFailureOnBattery)), new // 
    UnsignedWordElement(// 
    0x138, // 
    new ModbusBitWrappingChannel("BatteryFault2", this, this.thingState).faultBit(0, // 
    FaultEss.CANCommunicationInterruptionBetweenBatteryGroupAndGroup1).faultBit(1, // 
    FaultEss.CANCommunicationInterruptionBetweenBatteryGroupAndGroup2).faultBit(2, // 
    FaultEss.CANCommunicationInterruptionBetweenBatteryGroupAndGroup3).faultBit(3, // 
    FaultEss.CANCommunicationInterruptionBetweenBatteryGroupAndGroup4)), new // 
    UnsignedWordElement(// 
    0x139, // 
    new ModbusBitWrappingChannel("BatteryFault3", this, this.thingState).faultBit(0, // 
    FaultEss.MainContractorAbnormalInBatterySelfDetectGroup1).faultBit(1, // 
    FaultEss.MainContractorAbnormalInBatterySelfDetectGroup2).faultBit(2, // 
    FaultEss.MainContractorAbnormalInBatterySelfDetectGroup3).faultBit(3, // 
    FaultEss.MainContractorAbnormalInBatterySelfDetectGroup4)), new // 
    UnsignedWordElement(// 
    0x13A, // 
    new ModbusBitWrappingChannel("BatteryFault4", this, this.thingState).faultBit(0, // 
    FaultEss.PreChargeContractorAbnormalOnBatterySelfDetectGroup1).faultBit(1, // 
    FaultEss.PreChargeContractorAbnormalOnBatterySelfDetectGroup2).faultBit(2, // 
    FaultEss.PreChargeContractorAbnormalOnBatterySelfDetectGroup3).faultBit(3, // 
    FaultEss.PreChargeContractorAbnormalOnBatterySelfDetectGroup4)), new // 
    UnsignedWordElement(// 
    0x13B, // 
    new ModbusBitWrappingChannel("BatteryFault5", this, this.thingState).faultBit(0, // 
    FaultEss.MainContactFailureOnBatteryControlGroup1).faultBit(1, // 
    FaultEss.MainContactFailureOnBatteryControlGroup2).faultBit(2, // 
    FaultEss.MainContactFailureOnBatteryControlGroup3).faultBit(3, // 
    FaultEss.MainContactFailureOnBatteryControlGroup4)), new // 
    UnsignedWordElement(// 
    0x13C, // 
    new ModbusBitWrappingChannel("BatteryFault6", this, this.thingState).faultBit(0, // 
    FaultEss.PreChargeFailureOnBatteryControlGroup1).faultBit(1, // 
    FaultEss.PreChargeFailureOnBatteryControlGroup2).faultBit(2, // 
    FaultEss.PreChargeFailureOnBatteryControlGroup3).faultBit(3, // 
    FaultEss.PreChargeFailureOnBatteryControlGroup4)), new // 
    UnsignedWordElement(// 
    0x13D, // 
    new ModbusBitWrappingChannel("BatteryFault7", this, this.thingState)), new // 
    UnsignedWordElement(// 
    0x13E, // 
    new ModbusBitWrappingChannel("BatteryFault8", this, this.thingState)), // 
    new // 
    UnsignedWordElement(// 
    0x13F, // 
    new ModbusBitWrappingChannel("BatteryFault9", this, this.thingState).faultBit(2, // 
    FaultEss.SamplingCircuitAbnormalForBMU).faultBit(3, // 
    FaultEss.PowerCableDisconnectFailure).faultBit(4, // 
    FaultEss.SamplingCircuitDisconnectFailure).faultBit(6, // 
    FaultEss.CANDisconnectForMasterAndSlave).faultBit(9, // 
    FaultEss.SammplingCircuitFailure).faultBit(10, // 
    FaultEss.SingleBatteryFailure).faultBit(11, // 
    FaultEss.CircuitDetectionAbnormalForMainContactor).faultBit(12, // 
    FaultEss.CircuitDetectionAbnormalForMainContactorSecond).faultBit(13, // 
    FaultEss.CircuitDetectionAbnormalForFancontactor).faultBit(14, // 
    FaultEss.BMUPowerContactorCircuitDetectionAbnormal).faultBit(15, // 
    FaultEss.CentralContactorCircuitDetectionAbnormal)), new // 
    UnsignedWordElement(// 
    0x140, // 
    new ModbusBitWrappingChannel("BatteryFault10", this, this.thingState).faultBit(2, // 
    FaultEss.SeriousTemperatureFault).faultBit(3, // 
    FaultEss.CommunicationFaultForSystemController).faultBit(7, // 
    FaultEss.FrogAlarm).faultBit(8, // 
    FaultEss.FuseFault).faultBit(10, // 
    FaultEss.NormalLeakage).faultBit(11, // 
    FaultEss.SeriousLeakage).faultBit(12, // 
    FaultEss.CANDisconnectionBetweenBatteryGroupAndBatteryStack).faultBit(13, // 
    FaultEss.CentralContactorCircuitOpen).faultBit(14, // 
    FaultEss.BMUPowerContactorOpen)), new // 
    UnsignedWordElement(// 
    0x141, // 
    new ModbusBitWrappingChannel("BatteryFault11", this, this.thingState)), new // 
    UnsignedWordElement(// 
    0x142, // 
    new ModbusBitWrappingChannel("BatteryFault12", this, this.thingState)), new UnsignedWordElement(0x143, // 
    batteryFault13 = new StatusBitChannel("BatteryFault13", this)), new UnsignedWordElement(0x144, // 
    batteryFault14 = new StatusBitChannel("BatteryFault14", this)), new // 
    UnsignedWordElement(// 
    0x145, // 
    batteryGroupControlStatus = new StatusBitChannel("BatteryGroupControlStatus", this)), new UnsignedWordElement(0x146, // 
    errorLog1 = new StatusBitChannel("ErrorLog1", this)), new UnsignedWordElement(0x147, // 
    errorLog2 = new StatusBitChannel("ErrorLog2", this)), new UnsignedWordElement(0x148, // 
    errorLog3 = new StatusBitChannel("ErrorLog3", this)), new UnsignedWordElement(0x149, // 
    errorLog4 = new StatusBitChannel("ErrorLog4", this)), new UnsignedWordElement(0x14a, // 
    errorLog5 = new StatusBitChannel("ErrorLog5", this)), new UnsignedWordElement(0x14b, // 
    errorLog6 = new StatusBitChannel("ErrorLog6", this)), new UnsignedWordElement(0x14c, // 
    errorLog7 = new StatusBitChannel("ErrorLog7", this)), new UnsignedWordElement(0x14d, // 
    errorLog8 = new StatusBitChannel("ErrorLog8", this)), new UnsignedWordElement(0x14e, // 
    errorLog9 = new StatusBitChannel("ErrorLog9", this)), new UnsignedWordElement(0x14f, // 
    errorLog10 = new StatusBitChannel("ErrorLog10", this)), new UnsignedWordElement(0x150, // 
    errorLog11 = new StatusBitChannel("ErrorLog11", this)), new UnsignedWordElement(0x151, // 
    errorLog12 = new StatusBitChannel("ErrorLog12", this)), new UnsignedWordElement(0x152, // 
    errorLog13 = new StatusBitChannel("ErrorLog13", this)), new UnsignedWordElement(0x153, // 
    errorLog14 = new StatusBitChannel("ErrorLog14", this)), new UnsignedWordElement(0x154, // 
    errorLog15 = new StatusBitChannel("ErrorLog15", this)), new UnsignedWordElement(0x155, // 
    errorLog16 = new StatusBitChannel("ErrorLog16", this))), new // 
    WriteableModbusRegisterRange(// 
    0x200, new // 
    UnsignedWordElement(// 
    0x200, setWorkState = // 
    new ModbusWriteLongChannel("SetWorkState", this).label(0, // 
    STOP).label(1, START)), new // 
    UnsignedWordElement(// 
    0x201, setSystemErrorReset = new ModbusWriteLongChannel("SetSystemErrorReset", // 
    this).label(0, // 
    OFF).label(1, ON)), new // 
    UnsignedWordElement(// 
    0x202, setOperationMode = // 
    new ModbusWriteLongChannel("SetOperationMode", this).label(0, // 
    "P/Q Set point").label(1, "IAC / cosphi set point"))), new WriteableModbusRegisterRange(0x203, new // 
    SignedWordElement(// 
    0x203, setActivePower = // 
    new ModbusWriteLongChannel("SetActivePower", this).unit("W").multiplier(2))), new WriteableModbusRegisterRange(0x204, new // 
    SignedWordElement(// 
    0x204, setActivePowerL1 = // 
    new ModbusWriteLongChannel("SetActivePowerL1", this).unit("W").multiplier(2)), new // 
    SignedWordElement(// 
    0x205, setActivePowerL2 = // 
    new ModbusWriteLongChannel("SetActivePowerL2", this).unit("W").multiplier(2)), new // 
    SignedWordElement(// 
    0x206, setActivePowerL3 = // 
    new ModbusWriteLongChannel("SetActivePowerL3", this).unit("W").multiplier(2))), new WriteableModbusRegisterRange(0x207, new // 
    SignedWordElement(// 
    0x207, setReactivePower = // 
    new ModbusWriteLongChannel("SetReactivePower", this).unit("W").multiplier(2))), new WriteableModbusRegisterRange(0x208, new // 
    SignedWordElement(// 
    0x208, setReactivePowerL1 = // 
    new ModbusWriteLongChannel("SetReactivePowerL1", this).unit("W").multiplier(2)), new // 
    SignedWordElement(// 
    0x209, setReactivePowerL2 = // 
    new ModbusWriteLongChannel("SetReactivePowerL2", this).unit("W").multiplier(2)), new // 
    SignedWordElement(// 
    0x20A, setReactivePowerL3 = // 
    new ModbusWriteLongChannel("SetReactivePowerL3", this).unit("W").multiplier(2))));
    this.power = new SymmetricPowerImpl(100000, setActivePower, setReactivePower, getParent().getBridge());
    this.allowedChargeLimit = new PGreaterEqualLimitation(power);
    this.allowedChargeLimit.setP(this.allowedCharge.valueOptional().orElse(0L));
    this.batFullLimit = new NoPBetweenLimitation(power);
    this.power.addStaticLimitation(batFullLimit);
    this.allowedCharge.addChangeListener(new ChannelChangeListener() {

        @Override
        public void channelChanged(Channel channel, Optional<?> newValue, Optional<?> oldValue) {
            allowedChargeLimit.setP(allowedCharge.valueOptional().orElse(0L));
            if (allowedCharge.isValuePresent()) {
                if (allowedCharge.getValue() > -100) {
                    batFullLimit.setP(0L, 5000L);
                } else {
                    batFullLimit.setP(null, null);
                }
            }
        }
    });
    this.power.addStaticLimitation(this.allowedChargeLimit);
    this.allowedDischargeLimit = new PSmallerEqualLimitation(power);
    this.allowedDischargeLimit.setP(this.allowedDischarge.valueOptional().orElse(0L));
    this.batEmptyLimit = new NoPBetweenLimitation(power);
    this.power.addStaticLimitation(batEmptyLimit);
    this.allowedDischarge.addChangeListener(new ChannelChangeListener() {

        @Override
        public void channelChanged(Channel channel, Optional<?> newValue, Optional<?> oldValue) {
            allowedDischargeLimit.setP(allowedDischarge.valueOptional().orElse(0L));
            if (allowedDischarge.isValuePresent()) {
                if (allowedDischarge.getValue() < 100) {
                    batEmptyLimit.setP(-5000L, 0L);
                } else {
                    batEmptyLimit.setP(null, null);
                }
            }
        }
    });
    return protocol;
}
Also used : ModbusReadLongChannel(io.openems.impl.protocol.modbus.ModbusReadLongChannel) WriteableModbusRegisterRange(io.openems.impl.protocol.modbus.internal.range.WriteableModbusRegisterRange) ReadChannel(io.openems.api.channel.ReadChannel) WriteChannel(io.openems.api.channel.WriteChannel) ConfigChannel(io.openems.api.channel.ConfigChannel) ModbusBitWrappingChannel(io.openems.impl.protocol.modbus.ModbusBitWrappingChannel) ModbusReadLongChannel(io.openems.impl.protocol.modbus.ModbusReadLongChannel) ModbusWriteLongChannel(io.openems.impl.protocol.modbus.ModbusWriteLongChannel) StatusBitChannel(io.openems.api.channel.StatusBitChannel) StaticValueChannel(io.openems.api.channel.StaticValueChannel) Channel(io.openems.api.channel.Channel) ModbusWriteLongChannel(io.openems.impl.protocol.modbus.ModbusWriteLongChannel) NoPBetweenLimitation(io.openems.core.utilities.power.symmetric.NoPBetweenLimitation) PGreaterEqualLimitation(io.openems.core.utilities.power.symmetric.PGreaterEqualLimitation) StatusBitChannel(io.openems.api.channel.StatusBitChannel) ModbusBitWrappingChannel(io.openems.impl.protocol.modbus.ModbusBitWrappingChannel) DummyElement(io.openems.impl.protocol.modbus.internal.DummyElement) SymmetricPowerImpl(io.openems.core.utilities.power.symmetric.SymmetricPowerImpl) UnsignedWordElement(io.openems.impl.protocol.modbus.internal.UnsignedWordElement) ChannelChangeListener(io.openems.api.channel.ChannelChangeListener) SignedWordElement(io.openems.impl.protocol.modbus.internal.SignedWordElement) ModbusProtocol(io.openems.impl.protocol.modbus.internal.ModbusProtocol) PSmallerEqualLimitation(io.openems.core.utilities.power.symmetric.PSmallerEqualLimitation)

Aggregations

Channel (io.openems.api.channel.Channel)1 ChannelChangeListener (io.openems.api.channel.ChannelChangeListener)1 ConfigChannel (io.openems.api.channel.ConfigChannel)1 ReadChannel (io.openems.api.channel.ReadChannel)1 StaticValueChannel (io.openems.api.channel.StaticValueChannel)1 StatusBitChannel (io.openems.api.channel.StatusBitChannel)1 WriteChannel (io.openems.api.channel.WriteChannel)1 NoPBetweenLimitation (io.openems.core.utilities.power.symmetric.NoPBetweenLimitation)1 PGreaterEqualLimitation (io.openems.core.utilities.power.symmetric.PGreaterEqualLimitation)1 PSmallerEqualLimitation (io.openems.core.utilities.power.symmetric.PSmallerEqualLimitation)1 SymmetricPowerImpl (io.openems.core.utilities.power.symmetric.SymmetricPowerImpl)1 ModbusBitWrappingChannel (io.openems.impl.protocol.modbus.ModbusBitWrappingChannel)1 ModbusReadLongChannel (io.openems.impl.protocol.modbus.ModbusReadLongChannel)1 ModbusWriteLongChannel (io.openems.impl.protocol.modbus.ModbusWriteLongChannel)1 DummyElement (io.openems.impl.protocol.modbus.internal.DummyElement)1 ModbusProtocol (io.openems.impl.protocol.modbus.internal.ModbusProtocol)1 SignedWordElement (io.openems.impl.protocol.modbus.internal.SignedWordElement)1 UnsignedWordElement (io.openems.impl.protocol.modbus.internal.UnsignedWordElement)1 WriteableModbusRegisterRange (io.openems.impl.protocol.modbus.internal.range.WriteableModbusRegisterRange)1