Class AbstractMaxCurrentHandler
- java.lang.Object
-
- io.openems.edge.battery.protection.currenthandler.AbstractMaxCurrentHandler
-
- Direct Known Subclasses:
ChargeMaxCurrentHandler
,DischargeMaxCurrentHandler
public abstract class AbstractMaxCurrentHandler extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractMaxCurrentHandler.Builder<T extends AbstractMaxCurrentHandler.Builder<?>>
-
Field Summary
Fields Modifier and Type Field Description protected int
bmsMaxEverCurrent
protected ClockProvider
clockProvider
protected AbstractForceChargeDischarge
forceChargeDischarge
protected java.lang.Double
lastCurrentLimit
protected java.time.Instant
lastResultTimestamp
protected PolyLine
temperatureToPercent
protected PolyLine
voltageToPercent
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMaxCurrentHandler(ClockProvider clockProvider, int initialBmsMaxEverCurrent, PolyLine voltageToPercent, PolyLine temperatureToPercent, java.lang.Double maxIncreasePerSecond, AbstractForceChargeDischarge forceChargeDischarge)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
calculateCurrentLimit(Battery battery)
Calculates the actual allowed current limit in [A] as minimum of:.protected abstract BatteryProtection.ChannelId
getBpBmsChannelId()
Gets the ChannelId for Battery-Protection Limit originating from BMS.protected abstract BatteryProtection.ChannelId
getBpForceCurrentChannelId()
Gets the ChannelId for Battery-Protection Limit by Force Charge/Discharge Mode.protected abstract BatteryProtection.ChannelId
getBpMaxIncreaseAmpereChannelId()
Gets the ChannelId for Battery-Protection Limit by Max-Increase-Ampere ramp.protected abstract BatteryProtection.ChannelId
getBpMaxTemperatureChannelId()
Gets the ChannelId for Battery-Protection Limit by Max-Cell-Temperature.protected abstract BatteryProtection.ChannelId
getBpMaxVoltageChannelId()
Gets the ChannelId for Battery-Protection Limit by Max-Cell-Voltage.protected abstract BatteryProtection.ChannelId
getBpMinTemperatureChannelId()
Gets the ChannelId for Battery-Protection Limit by Min-Cell-Temperature.protected abstract BatteryProtection.ChannelId
getBpMinVoltageChannelId()
Gets the ChannelId for Battery-Protection Limit by Min-Cell-Voltage.protected java.lang.Double
getForceCurrent(java.lang.Integer minCellVoltage, java.lang.Integer maxCellVoltage)
Calculates the Ampere limit in Force Charge/Discharge mode.protected java.lang.Double
getMaxCellVoltageToPercentLimit(java.lang.Integer minCellVoltage)
protected java.lang.Double
getMaxIncreaseAmpereLimit()
Calculates the maximum increase limit in Ampere from the 'maxIncreasePerSecond' parameter.protected java.lang.Double
getMinCellVoltageToPercentLimit(java.lang.Integer minCellVoltage)
protected java.lang.Double
percentToAmpere(java.lang.Double percent)
Convert a Percent value to a concrete Ampere value in [A] by multiplying it with 'bmsMaxEverAllowedChargeCurrent'.
-
-
-
Field Detail
-
clockProvider
protected final ClockProvider clockProvider
-
voltageToPercent
protected final PolyLine voltageToPercent
-
temperatureToPercent
protected final PolyLine temperatureToPercent
-
forceChargeDischarge
protected final AbstractForceChargeDischarge forceChargeDischarge
-
bmsMaxEverCurrent
protected int bmsMaxEverCurrent
-
lastResultTimestamp
protected java.time.Instant lastResultTimestamp
-
lastCurrentLimit
protected java.lang.Double lastCurrentLimit
-
-
Constructor Detail
-
AbstractMaxCurrentHandler
protected AbstractMaxCurrentHandler(ClockProvider clockProvider, int initialBmsMaxEverCurrent, PolyLine voltageToPercent, PolyLine temperatureToPercent, java.lang.Double maxIncreasePerSecond, AbstractForceChargeDischarge forceChargeDischarge)
-
-
Method Detail
-
getBpBmsChannelId
protected abstract BatteryProtection.ChannelId getBpBmsChannelId()
Gets the ChannelId for Battery-Protection Limit originating from BMS.- Returns:
- the
BatteryProtection.ChannelId
-
getBpMinVoltageChannelId
protected abstract BatteryProtection.ChannelId getBpMinVoltageChannelId()
Gets the ChannelId for Battery-Protection Limit by Min-Cell-Voltage.- Returns:
- the
BatteryProtection.ChannelId
-
getBpMaxVoltageChannelId
protected abstract BatteryProtection.ChannelId getBpMaxVoltageChannelId()
Gets the ChannelId for Battery-Protection Limit by Max-Cell-Voltage.- Returns:
- the
BatteryProtection.ChannelId
-
getBpMinTemperatureChannelId
protected abstract BatteryProtection.ChannelId getBpMinTemperatureChannelId()
Gets the ChannelId for Battery-Protection Limit by Min-Cell-Temperature.- Returns:
- the
BatteryProtection.ChannelId
-
getBpMaxTemperatureChannelId
protected abstract BatteryProtection.ChannelId getBpMaxTemperatureChannelId()
Gets the ChannelId for Battery-Protection Limit by Max-Cell-Temperature.- Returns:
- the
BatteryProtection.ChannelId
-
getBpForceCurrentChannelId
protected abstract BatteryProtection.ChannelId getBpForceCurrentChannelId()
Gets the ChannelId for Battery-Protection Limit by Force Charge/Discharge Mode.- Returns:
- the
BatteryProtection.ChannelId
-
getBpMaxIncreaseAmpereChannelId
protected abstract BatteryProtection.ChannelId getBpMaxIncreaseAmpereChannelId()
Gets the ChannelId for Battery-Protection Limit by Max-Increase-Ampere ramp. Mode.- Returns:
- the
BatteryProtection.ChannelId
-
calculateCurrentLimit
public int calculateCurrentLimit(Battery battery)
Calculates the actual allowed current limit in [A] as minimum of:.- Is the battery started? (block any charge/discharge if not)
- Is there any value from the BMS? (block any charge/discharge if not)
- Allowed Current Limit provided by Battery Management System
- Voltage-to-Percent characteristics for Min-Cell-Voltage
- Voltage-to-Percent characteristics for Max-Cell-Voltage
- Temperature-to-Percent characteristics for Min-Cell-Temperature
- Temperature-to-Percent characteristics for Max-Cell-Temperature
- Applied max increase limit (e.g. 0.5 A per second)
- Force Charge/Discharge mode (e.g. -1 A to enforce charge/discharge)
- Parameters:
battery
- theBattery
- Returns:
- the actual allowed current limit, mathematically rounded to [A]
-
getMinCellVoltageToPercentLimit
protected java.lang.Double getMinCellVoltageToPercentLimit(java.lang.Integer minCellVoltage)
-
getMaxCellVoltageToPercentLimit
protected java.lang.Double getMaxCellVoltageToPercentLimit(java.lang.Integer minCellVoltage)
-
getMaxIncreaseAmpereLimit
protected java.lang.Double getMaxIncreaseAmpereLimit()
Calculates the maximum increase limit in Ampere from the 'maxIncreasePerSecond' parameter.If maxIncreasePerSecond is 0.5, last limit was 10 A and 1 second passed, this method returns 10.5.
- Returns:
- the limit or null
-
getForceCurrent
protected java.lang.Double getForceCurrent(java.lang.Integer minCellVoltage, java.lang.Integer maxCellVoltage)
Calculates the Ampere limit in Force Charge/Discharge mode. Returns:- -1 -> in force charge/discharge mode
- 0 -> in block discharge/charge mode
- null -> otherwise
- Parameters:
minCellVoltage
- the Min-Cell-Voltage, possibly nullmaxCellVoltage
- the Max-Cell-Voltage, possibly null- Returns:
- the Current, possibly null
-
percentToAmpere
protected java.lang.Double percentToAmpere(java.lang.Double percent)
Convert a Percent value to a concrete Ampere value in [A] by multiplying it with 'bmsMaxEverAllowedChargeCurrent'.- null % -> null
- 0 % -> 0
- anything else -> calculate percent; at least '1 A'.
- Parameters:
percent
- the percent value in [0,1]- Returns:
- the ampere value in [A]
-
-