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

Splited ..


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Go/trunk/xaal-lib/apps@3108 b32b6428-25c9-4566-ad07-03861ab6144f
parent 61f1c238
No related branches found
No related tags found
No related merge requests found
......@@ -5,23 +5,17 @@ import (
"os"
"os/signal"
xAALLib "xAAL/lib"
"github.com/google/uuid"
)
func showMessage(msg *Message) {
if msg.IsAttributesChange() {
msg.Dump()
}
}
func main() {
eng := NewEngine()
eng := xAALLib.NewEngine()
eng.Start()
// eng.Subscribe(showMessage)
lamp := NewDevice("lamp.dimmer")
lamp := xAALLib.NewDevice("lamp.dimmer")
lamp.Address = uuid.MustParse("6558b72b-3ae6-4995-8c4c-e407b7119889")
light := lamp.AddAttribute("light", true)
brightness := lamp.AddAttribute("brightness", 0)
......@@ -30,31 +24,31 @@ func main() {
lamp.ProductID = "Really powerFull lamp"
lamp.URL = "http://example.com"
turn_on := func(MessageBody) *MessageBody {
turn_on := func(xAALLib.MessageBody) *xAALLib.MessageBody {
light.SetValue(true)
return nil
}
turn_off := func(MessageBody) *MessageBody {
turn_off := func(xAALLib.MessageBody) *xAALLib.MessageBody {
light.SetValue(false)
return nil
}
toggle := func(MessageBody) *MessageBody {
toggle := func(xAALLib.MessageBody) *xAALLib.MessageBody {
light.SetValue(!light.Value.(bool))
return nil
}
dim := func(args MessageBody) *MessageBody {
dim := func(args xAALLib.MessageBody) *xAALLib.MessageBody {
if value, ok := args["brightness"].(uint64); ok {
if value > 100 {
value = 100
}
brightness.SetValue(value)
if value == 0 {
turn_off(MessageBody{})
turn_off(xAALLib.MessageBody{})
} else {
turn_on(MessageBody{})
turn_on(xAALLib.MessageBody{})
}
}
return nil
......@@ -68,8 +62,6 @@ func main() {
lamp.Dump()
eng.AddDevice(lamp)
// eng.test()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
<-c
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment