chore: minor
This commit is contained in:
parent
caa9dea43a
commit
0211046343
1 changed files with 10 additions and 14 deletions
|
|
@ -273,22 +273,17 @@ func (c *Connection) GetPhaseFloatStates(entities []string) (float64, float64, f
|
|||
return 0, 0, 0, errors.New("invalid phase entities")
|
||||
}
|
||||
|
||||
var l1, l2, l3 float64
|
||||
var err error
|
||||
var res [3]float64
|
||||
|
||||
if l1, err = c.GetFloatState(entities[0]); err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("phase L1: %w", err)
|
||||
for i := range res {
|
||||
f, err := c.GetFloatState(entities[i])
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("phase L%d: %w", i+1, err)
|
||||
}
|
||||
res[i] = f
|
||||
}
|
||||
|
||||
if l2, err = c.GetFloatState(entities[1]); err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("phase L2: %w", err)
|
||||
}
|
||||
|
||||
if l3, err = c.GetFloatState(entities[2]); err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("phase L3: %w", err)
|
||||
}
|
||||
|
||||
return l1, l2, l3, nil
|
||||
return res[0], res[1], res[2], nil
|
||||
}
|
||||
|
||||
// ValidatePhaseEntities validates that phase entity arrays contain 1 or 3 entities
|
||||
|
|
@ -297,12 +292,13 @@ func ValidatePhaseEntities(phases []string) ([]string, error) {
|
|||
t := strings.TrimSpace(s)
|
||||
return t, t != ""
|
||||
})
|
||||
|
||||
switch len(entities) {
|
||||
case 0:
|
||||
return nil, nil
|
||||
case 3:
|
||||
return entities, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("must contain three-phase entities (L1, L2, L3), got %d", len(entities))
|
||||
return nil, errors.New("invalid phase entities")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue