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

- Added schemas to Golang too ;)

- Added tidy to Makefile




git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Go/trunk/xaal-lib/apps@3228 b32b6428-25c9-4566-ad07-03861ab6144f
parent 95b7319b
No related branches found
No related tags found
No related merge requests found
package main
import (
xaal "xAAL/xaal"
schemas "xAAL/xaalschemas"
"github.com/google/uuid"
)
func main() {
eng := xaal.NewEngine()
eng.Start()
grpID, _ := uuid.NewRandom()
addr := uuid.MustParse("820f3c5c-029a-4799-8105-8d6d5357462b")
lamp := schemas.NewLamp(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
// Switch on the lamp
turnOn := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(true)
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
addr = uuid.MustParse("820f3c5c-029a-4799-8105-8d6d5357462c")
btn := schemas.NewButton(addr)
btn.Info = "Fake button from schemas"
btn.GroupID = grpID
btn.Dump()
eng.AddDevice(lamp)
eng.AddDevice(btn)
eng.Run()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment