Add soc push event every 10% charge progress (#2337)
This commit is contained in:
parent
9bb68bd819
commit
479377f0d4
6 changed files with 86 additions and 3 deletions
29
core/progress.go
Normal file
29
core/progress.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package core
|
||||
|
||||
type Progress struct {
|
||||
min, step, current float64
|
||||
}
|
||||
|
||||
func NewProgress(min, step float64) *Progress {
|
||||
return &Progress{
|
||||
min: min,
|
||||
step: step,
|
||||
current: min,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Progress) NextStep(value float64) bool {
|
||||
if value >= p.current {
|
||||
for p.current <= value {
|
||||
p.current += p.step
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *Progress) Reset() {
|
||||
p.current = p.min
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue