chore: simplify
This commit is contained in:
parent
a014175b09
commit
91e146dd0e
1 changed files with 6 additions and 33 deletions
|
|
@ -252,15 +252,11 @@ func (c *Circuit) ValidatePower(old, new float64) float64 {
|
|||
}
|
||||
}
|
||||
|
||||
if c.parent != nil {
|
||||
res := c.parent.ValidatePower(old, new)
|
||||
if res != new {
|
||||
c.log.TRACE.Printf("validate power: %gW -> %gW at %gW: capped by parent at %gW", old, new, c.power, res)
|
||||
}
|
||||
return res
|
||||
if c.parent == nil {
|
||||
return new
|
||||
}
|
||||
|
||||
return new
|
||||
return c.parent.ValidatePower(old, new)
|
||||
}
|
||||
|
||||
// ValidateCurrent validates current request
|
||||
|
|
@ -277,32 +273,9 @@ func (c *Circuit) ValidateCurrent(old, new float64) float64 {
|
|||
}
|
||||
}
|
||||
|
||||
if c.parent != nil {
|
||||
res := c.parent.ValidateCurrent(old, new)
|
||||
if res != new {
|
||||
c.log.TRACE.Printf("validate current: %gA -> %gA at %gA: capped by parent at %gA", old, new, c.current, res)
|
||||
}
|
||||
return res
|
||||
if c.parent == nil {
|
||||
return new
|
||||
}
|
||||
|
||||
return new
|
||||
return c.parent.ValidateCurrent(old, new)
|
||||
}
|
||||
|
||||
// func (c *Circuit) validate(typ string, current, old, new float64, parentFunc func(o, n float64) float64) float64 {
|
||||
// delta := max(0, new-old)
|
||||
|
||||
// if c.maxPower != 0 {
|
||||
// if c.power+delta > c.maxPower {
|
||||
// new = max(0, c.maxPower-c.power)
|
||||
// c.log.TRACE.Printf("validate power: %g -> %g <= %g at %g: capped at %g", old, new, c.maxPower, c.power, new)
|
||||
// } else {
|
||||
// c.log.TRACE.Printf("validate power: %g -> %g <= %g at %g: ok", old, new, c.maxPower, c.power)
|
||||
// }
|
||||
// }
|
||||
|
||||
// if c.parent != nil {
|
||||
// return c.parent.ValidatePower(c.power, new)
|
||||
// }
|
||||
|
||||
// return new
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue