1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00
hybridgroup.gobot/adaptor.go

41 lines
587 B
Go
Raw Normal View History

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