Loadpoint: fix reentrant lock
Follow-up to https://github.com/evcc-io/evcc/pull/18669
This commit is contained in:
parent
d3daa33821
commit
8d3d42b997
2 changed files with 10 additions and 5 deletions
|
|
@ -566,6 +566,11 @@ func (lp *Loadpoint) GetMaxPhaseCurrent() float64 {
|
|||
func (lp *Loadpoint) GetMinCurrent() float64 {
|
||||
lp.RLock()
|
||||
defer lp.RUnlock()
|
||||
return lp.getMinCurrent()
|
||||
}
|
||||
|
||||
// getMinCurrent returns the max loadpoint current
|
||||
func (lp *Loadpoint) getMinCurrent() float64 {
|
||||
return lp.minCurrent
|
||||
}
|
||||
|
||||
|
|
@ -631,15 +636,15 @@ func (lp *Loadpoint) SetMaxCurrent(current float64) error {
|
|||
|
||||
// GetMinPower returns the min loadpoint power for a single phase
|
||||
func (lp *Loadpoint) GetMinPower() float64 {
|
||||
lp.Lock()
|
||||
defer lp.Unlock()
|
||||
lp.RLock()
|
||||
defer lp.RUnlock()
|
||||
return Voltage * lp.effectiveMinCurrent()
|
||||
}
|
||||
|
||||
// GetMaxPower returns the max loadpoint power taking vehicle capabilities and phase scaling into account
|
||||
func (lp *Loadpoint) GetMaxPower() float64 {
|
||||
lp.Lock()
|
||||
defer lp.Unlock()
|
||||
lp.RLock()
|
||||
defer lp.RUnlock()
|
||||
return Voltage * lp.effectiveMaxCurrent() * float64(lp.maxActivePhases())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ func (lp *Loadpoint) SocBasedPlanning() bool {
|
|||
|
||||
// effectiveMinCurrent returns the effective min current
|
||||
func (lp *Loadpoint) effectiveMinCurrent() float64 {
|
||||
lpMin := lp.GetMinCurrent()
|
||||
lpMin := lp.getMinCurrent()
|
||||
var vehicleMin, chargerMin float64
|
||||
|
||||
if v := lp.GetVehicle(); v != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue