From 6b7554a900de8e0160f86d10171c273fe4326762 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Fri, 6 Dec 2013 14:44:48 -0800 Subject: [PATCH] Add support for additional parameters --- adaptor.go | 2 +- connection.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/adaptor.go b/adaptor.go index 1869cdc6..37f1f64f 100644 --- a/adaptor.go +++ b/adaptor.go @@ -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 { diff --git a/connection.go b/connection.go index 8f9b3380..8fe21630 100644 --- a/connection.go +++ b/connection.go @@ -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