2013-12-31 08:51:21 +08:00
|
|
|
package gobot
|
|
|
|
|
2014-04-11 21:02:21 +08:00
|
|
|
type null struct{}
|
|
|
|
|
|
|
|
func (null) Write(p []byte) (int, error) {
|
|
|
|
return len(p), nil
|
|
|
|
}
|
|
|
|
|
2013-12-31 08:51:21 +08:00
|
|
|
type testDriver struct {
|
|
|
|
Driver
|
|
|
|
}
|
|
|
|
|
2014-04-01 06:26:35 +08:00
|
|
|
func (me *testDriver) Init() bool { return true }
|
2013-12-31 08:51:21 +08:00
|
|
|
func (me *testDriver) Start() bool { return true }
|
2014-04-01 05:25:20 +08:00
|
|
|
func (me *testDriver) Halt() bool { return true }
|
2013-12-31 08:51:21 +08:00
|
|
|
|
|
|
|
type testAdaptor struct {
|
|
|
|
Adaptor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (me *testAdaptor) Finalize() bool { return true }
|
|
|
|
func (me *testAdaptor) Connect() bool { return true }
|
|
|
|
func (me *testAdaptor) Disconnect() bool { return true }
|
|
|
|
func (me *testAdaptor) Reconnect() bool { return true }
|
|
|
|
|
|
|
|
func newTestDriver(name string) *testDriver {
|
|
|
|
d := new(testDriver)
|
|
|
|
d.Name = name
|
2013-12-31 09:22:16 +08:00
|
|
|
d.Commands = []string{
|
|
|
|
"DriverCommand1",
|
|
|
|
"DriverCommand2",
|
|
|
|
"DriverCommand3",
|
|
|
|
}
|
2013-12-31 08:51:21 +08:00
|
|
|
return d
|
|
|
|
}
|
2014-04-15 14:16:35 +08:00
|
|
|
|
2013-12-31 08:51:21 +08:00
|
|
|
func newTestAdaptor(name string) *testAdaptor {
|
|
|
|
a := new(testAdaptor)
|
|
|
|
a.Name = name
|
2014-04-15 14:16:35 +08:00
|
|
|
a.Params = map[string]interface{}{
|
|
|
|
"param1": "1",
|
|
|
|
"param2": 2,
|
|
|
|
}
|
2013-12-31 08:51:21 +08:00
|
|
|
return a
|
|
|
|
}
|
2014-01-01 05:16:25 +08:00
|
|
|
|
2014-04-15 14:16:35 +08:00
|
|
|
func newTestRobot(name string) *Robot {
|
|
|
|
return &Robot{
|
2014-01-01 05:16:25 +08:00
|
|
|
Name: name,
|
|
|
|
Connections: []Connection{newTestAdaptor("Connection 1"), newTestAdaptor("Connection 2"), newTestAdaptor("Connection 3")},
|
|
|
|
Devices: []Device{newTestDriver("Device 1"), newTestDriver("Device 2"), newTestDriver("Device 3")},
|
2014-04-15 14:16:35 +08:00
|
|
|
Work: func() {},
|
2014-01-01 05:16:25 +08:00
|
|
|
Commands: map[string]interface{}{
|
|
|
|
"Command1": func() {},
|
|
|
|
"Command2": func() {},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|