Skip to content
Snippets Groups Projects
Commit a75cfaa1 authored by jkerdreu's avatar jkerdreu
Browse files

More tests


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Go/trunk/xaal-lib/apps@3236 b32b6428-25c9-4566-ad07-03861ab6144f
parent cbed4893
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ func main() {
grpID, _ := uuid.NewRandom()
addr := uuid.MustParse("820f3c5c-029a-4799-8105-8d6d5357462b")
addr := uuid.MustParse("820f3c5c-029a-4799-8105-8d6d5357462a")
lamp := schemas.NewLampDimmer(addr)
lamp.Info = "Fake (Go)lamp from schemas"
lamp.HWID = "0x1234"
......@@ -25,21 +25,24 @@ func main() {
light := lamp.GetAttribute("light")
brightness := lamp.GetAttribute("brightness")
// change the brightness type to int ;)
brightness.Value = 50
light.SetValue(true)
// Switch on the lamp
turnOn := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(true)
brightness.SetValue(brightness.Value.(float64) + 1)
brightness.SetValue(brightness.Value.(int) + 10)
return nil
}
// Switch off the lamp
// turnOff := func(xaal.MessageBody) *xaal.MessageBody {
// light.SetValue(false)
// return nil
// }
lamp.GetMethods()["turn_on"] = turnOn
// lamp.GetMethods()["turn_off"] = turnOff
turnOff := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(false)
brightness.SetValue(brightness.Value.(int) - 10)
return nil
}
lamp.SetMethod("turn_on", turnOn)
lamp.SetMethod("turn_off", turnOff)
addr = uuid.MustParse("820f3c5c-029a-4799-8105-8d6d5357462c")
btn := schemas.NewButton(addr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment