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