Add convenience functions
This commit is contained in:
parent
3f3444f7e7
commit
ba63c57a0b
4
gobot.go
4
gobot.go
|
@ -58,6 +58,10 @@ func (g *Gobot) Robots() *robots {
|
|||
return g.robots
|
||||
}
|
||||
|
||||
func (g *Gobot) AddRobot(r *Robot) *Robot {
|
||||
return g.Robots().Add(r)
|
||||
}
|
||||
|
||||
func (g *Gobot) Robot(name string) *Robot {
|
||||
for _, robot := range g.Robots().robots {
|
||||
if robot.Name == name {
|
||||
|
|
8
robot.go
8
robot.go
|
@ -113,6 +113,10 @@ func (r *Robot) Devices() *devices {
|
|||
return r.devices
|
||||
}
|
||||
|
||||
func (r *Robot) AddDevice(d Device) Device {
|
||||
return r.Devices().Add(d)
|
||||
}
|
||||
|
||||
func (r *Robot) Device(name string) Device {
|
||||
if r == nil {
|
||||
return nil
|
||||
|
@ -129,6 +133,10 @@ func (r *Robot) Connections() *connections {
|
|||
return r.connections
|
||||
}
|
||||
|
||||
func (r *Robot) AddConnection(c Connection) Connection {
|
||||
return r.Connections().Add(c)
|
||||
}
|
||||
|
||||
func (r *Robot) Connection(name string) Connection {
|
||||
if r == nil {
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue