Shuffle and loop
This commit is contained in:
parent
097776962c
commit
079cd7efc9
1 changed files with 11 additions and 16 deletions
25
main.go
25
main.go
|
@ -176,23 +176,18 @@ func scrape() error {
|
|||
vals := make(map[uint16]float64)
|
||||
start := time.Now()
|
||||
scrapeStart.SetToCurrentTime()
|
||||
if err := readRegs(vals, client, 5000, 24); err != nil {
|
||||
|
||||
ranges := []struct{ start, qty uint16 }{
|
||||
{5000, 24}, {5030, 7}, {5048, 1},
|
||||
{5082, 18}, {5112, 1}, {5143, 6},
|
||||
}
|
||||
rand.Shuffle(len(ranges), func(i, j int) {
|
||||
ranges[i], ranges[j] = ranges[j], ranges[i]
|
||||
})
|
||||
for _, r := range ranges {
|
||||
if err := readRegs(vals, client, r.start, r.qty); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := readRegs(vals, client, 5030, 7); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := readRegs(vals, client, 5048, 1); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := readRegs(vals, client, 5082, 18); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := readRegs(vals, client, 5112, 1); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := readRegs(vals, client, 5143, 6); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lastValues = vals
|
||||
|
|
Loading…
Reference in a new issue