Small refactor
This commit is contained in:
parent
1563aa78fc
commit
216bbd3939
|
@ -17,11 +17,9 @@ func NewDevice(driver interface{}, r *Robot) *Device {
|
||||||
d := new(Device)
|
d := new(Device)
|
||||||
d.Name = reflect.ValueOf(driver).Elem().FieldByName("Name").String()
|
d.Name = reflect.ValueOf(driver).Elem().FieldByName("Name").String()
|
||||||
d.Robot = r
|
d.Robot = r
|
||||||
interval := reflect.ValueOf(driver).Elem().FieldByName("Interval").String()
|
if reflect.ValueOf(driver).Elem().FieldByName("Interval").String() == "" {
|
||||||
if interval == "" {
|
reflect.ValueOf(driver).Elem().FieldByName("Interval").SetString("0.1s")
|
||||||
interval = "0.1s"
|
|
||||||
}
|
}
|
||||||
reflect.ValueOf(driver).Elem().FieldByName("Interval").SetString(interval)
|
|
||||||
d.Driver = driver
|
d.Driver = driver
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue