Add MaxACPower hybrid battery setting (#16609)
This commit is contained in:
parent
ccade7c1f0
commit
3a88cb4add
28 changed files with 1472 additions and 171 deletions
|
|
@ -6,7 +6,7 @@ type capacity struct {
|
|||
|
||||
// var _ api.BatteryCapacity = (*capacity)(nil)
|
||||
|
||||
// Decorator returns the capacity decorator if capacity is specified or nil otherwise
|
||||
// Decorator returns the capacity decorator
|
||||
func (m *capacity) Decorator() func() float64 {
|
||||
if m.Capacity == 0 {
|
||||
return nil
|
||||
15
meter/battery_power.go
Normal file
15
meter/battery_power.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package meter
|
||||
|
||||
type maxpower struct {
|
||||
MaxACPower float64
|
||||
}
|
||||
|
||||
// MaxACPowerDecorator returns the max AC power decorator
|
||||
func (m *maxpower) Decorator() func() float64 {
|
||||
if m.MaxACPower == 0 {
|
||||
return nil
|
||||
}
|
||||
return func() float64 {
|
||||
return m.MaxACPower
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ func init() {
|
|||
registry.AddCtx(api.Custom, NewConfigurableFromConfig)
|
||||
}
|
||||
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateMeter -b api.Meter -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.PhasePowers,Powers,func() (float64, float64, float64, error)" -t "api.Battery,Soc,func() (float64, error)" -t "api.BatteryCapacity,Capacity,func() float64" -t "api.BatteryController,SetBatteryMode,func(api.BatteryMode) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateMeter -b api.Meter -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.PhasePowers,Powers,func() (float64, float64, float64, error)" -t "api.Battery,Soc,func() (float64, error)" -t "api.BatteryCapacity,Capacity,func() float64" -t "api.BatteryMaxACPower,MaxACPower,func() float64" -t "api.BatteryController,SetBatteryMode,func(api.BatteryMode) error"
|
||||
|
||||
// NewConfigurableFromConfig creates api.Meter from config
|
||||
func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}) (api.Meter, error) {
|
||||
|
|
@ -26,6 +26,7 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
|
|||
|
||||
// battery
|
||||
capacity `mapstructure:",squash"`
|
||||
maxpower `mapstructure:",squash"`
|
||||
battery `mapstructure:",squash"`
|
||||
Soc *provider.Config // optional
|
||||
LimitSoc *provider.Config // optional
|
||||
|
|
@ -82,7 +83,7 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
|
|||
batModeS = cc.battery.ModeController(modeS)
|
||||
}
|
||||
|
||||
res := m.Decorate(energyG, currentsG, voltagesG, powersG, socG, cc.capacity.Decorator(), batModeS)
|
||||
res := m.Decorate(energyG, currentsG, voltagesG, powersG, socG, cc.capacity.Decorator(), cc.maxpower.Decorator(), batModeS)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
|
@ -107,10 +108,11 @@ func (m *Meter) Decorate(
|
|||
voltages func() (float64, float64, float64, error),
|
||||
powers func() (float64, float64, float64, error),
|
||||
batterySoc func() (float64, error),
|
||||
capacity func() float64,
|
||||
batteryCapacity func() float64,
|
||||
batteryMaxACPower func() float64,
|
||||
setBatteryMode func(api.BatteryMode) error,
|
||||
) api.Meter {
|
||||
return decorateMeter(m, totalEnergy, currents, voltages, powers, batterySoc, capacity, setBatteryMode)
|
||||
return decorateMeter(m, totalEnergy, currents, voltages, powers, batterySoc, batteryCapacity, batteryMaxACPower, setBatteryMode)
|
||||
}
|
||||
|
||||
// CurrentPower implements the api.Meter interface
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func NewMovingAverageFromConfig(ctx context.Context, other map[string]interface{
|
|||
powers = m.Powers
|
||||
}
|
||||
|
||||
return meter.Decorate(totalEnergy, currents, voltages, powers, batterySoc, cc.Meter.capacity.Decorator(), nil), nil
|
||||
return meter.Decorate(totalEnergy, currents, voltages, powers, batterySoc, cc.Meter.capacity.Decorator(), nil, nil), nil
|
||||
}
|
||||
|
||||
type MovingAverage struct {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -138,7 +138,7 @@ func NewOpenWBFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res := m.Decorate(nil, currents, nil, nil, soc, capacity, nil)
|
||||
res := m.Decorate(nil, currents, nil, nil, soc, capacity, nil, nil)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue