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

- Switch log.Printf in schemas (same as Python)

- Fix a bug in SetValue() if no Engine




git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Go/trunk/xaal-lib/apps@3232 b32b6428-25c9-4566-ad07-03861ab6144f
parent e5418cef
No related branches found
No related tags found
No related merge requests found
......@@ -15,29 +15,31 @@ func main() {
grpID, _ := uuid.NewRandom()
addr := uuid.MustParse("820f3c5c-029a-4799-8105-8d6d5357462b")
lamp := schemas.NewLamp(addr)
lamp := schemas.NewLampDimmer(addr)
lamp.Info = "Fake (Go)lamp from schemas"
lamp.HWID = "0x1234"
lamp.VendorID = "IMT Atlantique"
lamp.ProductID = "Golang test lamp"
lamp.GroupID = grpID
lamp.Dump()
light := lamp.GetAttribute("light")
light.Value = true
brightness := lamp.GetAttribute("brightness")
light.SetValue(true)
// Switch on the lamp
turnOn := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(true)
brightness.SetValue(brightness.Value.(float64) + 1)
return nil
}
// Switch off the lamp
turnOff := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(false)
return nil
}
// turnOff := func(xaal.MessageBody) *xaal.MessageBody {
// light.SetValue(false)
// return nil
// }
lamp.GetMethods()["turn_on"] = turnOn
lamp.GetMethods()["turn_off"] = turnOff
// lamp.GetMethods()["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