hybridgroup.gobot/adaptor.go

41 lines
582 B
Go
Raw Normal View History

2013-10-23 07:45:31 +08:00
package gobot
2013-10-24 13:00:03 +08:00
type Adaptor struct {
2013-11-14 12:44:54 +08:00
Name string
Port string
Connected bool
Params map[string]string
2013-10-24 13:00:03 +08:00
}
func (Adaptor) NewAdaptor(a Adaptor) Adaptor {
2013-11-14 12:44:54 +08:00
return a
2013-10-24 13:00:03 +08:00
}
2013-11-14 12:44:54 +08:00
func (a *Adaptor) Finalize() bool {
if a.IsConnected() {
a.Disconnect()
}
return true
2013-10-24 13:00:03 +08:00
}
func (a *Adaptor) Connect() bool {
2013-11-14 12:44:54 +08:00
a.Connected = true
return true
2013-10-24 13:00:03 +08:00
}
func (a *Adaptor) Disconnect() bool {
2013-11-14 12:44:54 +08:00
a.Connected = false
return true
2013-10-24 13:00:03 +08:00
}
func (a *Adaptor) Reconnect() bool {
2013-11-14 12:44:54 +08:00
if !a.IsConnected() {
return a.Connect()
}
return true
2013-10-24 13:00:03 +08:00
}
func (a *Adaptor) IsConnected() bool {
2013-11-14 12:44:54 +08:00
return a.Connected
2013-10-24 13:00:03 +08:00
}