Add support for additional parameters
This commit is contained in:
parent
0f775fe6ae
commit
6b7554a900
|
@ -4,7 +4,7 @@ type Adaptor struct {
|
||||||
Name string
|
Name string
|
||||||
Port string
|
Port string
|
||||||
Connected bool
|
Connected bool
|
||||||
Params map[string]string
|
Params map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Adaptor) NewAdaptor(a Adaptor) Adaptor {
|
func (Adaptor) NewAdaptor(a Adaptor) Adaptor {
|
||||||
|
|
|
@ -10,13 +10,18 @@ type Connection struct {
|
||||||
Adaptor interface{}
|
Adaptor interface{}
|
||||||
Port string
|
Port string
|
||||||
Robot *Robot `json:"-"`
|
Robot *Robot `json:"-"`
|
||||||
Params map[string]string
|
Params map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConnection(a interface{}, r *Robot) *Connection {
|
func NewConnection(a interface{}, r *Robot) *Connection {
|
||||||
c := new(Connection)
|
c := new(Connection)
|
||||||
c.Name = reflect.ValueOf(a).Elem().FieldByName("Name").String()
|
c.Name = reflect.ValueOf(a).Elem().FieldByName("Name").String()
|
||||||
c.Port = reflect.ValueOf(a).Elem().FieldByName("Port").String()
|
c.Port = reflect.ValueOf(a).Elem().FieldByName("Port").String()
|
||||||
|
c.Params = make(map[string]interface{})
|
||||||
|
keys := reflect.ValueOf(a).Elem().FieldByName("Params").MapKeys()
|
||||||
|
for k := range keys {
|
||||||
|
c.Params[keys[k].String()] = reflect.ValueOf(a).Elem().FieldByName("Params").MapIndex(keys[k])
|
||||||
|
}
|
||||||
c.Robot = r
|
c.Robot = r
|
||||||
c.Adaptor = a
|
c.Adaptor = a
|
||||||
return c
|
return c
|
||||||
|
|
Loading…
Reference in New Issue