Skip to content

Commit

Permalink
Add support for additional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Dec 6, 2013
1 parent 0f775fe commit 6b7554a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type Adaptor struct {
Name string
Port string
Connected bool
Params map[string]string
Params map[string]interface{}
}

func (Adaptor) NewAdaptor(a Adaptor) Adaptor {
Expand Down
7 changes: 6 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ type Connection struct {
Adaptor interface{}
Port string
Robot *Robot `json:"-"`
Params map[string]string
Params map[string]interface{}
}

func NewConnection(a interface{}, r *Robot) *Connection {
c := new(Connection)
c.Name = reflect.ValueOf(a).Elem().FieldByName("Name").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.Adaptor = a
return c
Expand Down

0 comments on commit 6b7554a

Please sign in to comment.