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

- Rename xaal



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Go/trunk/xaal-lib/apps@3130 b32b6428-25c9-4566-ad07-03861ab6144f
parent 4ec4eec8
No related branches found
No related tags found
No related merge requests found
......@@ -5,17 +5,17 @@ package main
import (
"time"
xAALLib "xAAL/lib"
"xAAL/xaal"
"github.com/google/uuid"
)
type Lamp struct {
dev *xAALLib.Device
dev *xaal.Device
}
func newLamp(addr uuid.UUID, group uuid.UUID) *Lamp {
dev := xAALLib.NewDevice("lamp.dimmer")
dev := xaal.NewDevice("lamp.dimmer")
l := &Lamp{dev: dev}
dev.Address = addr
dev.VendorID = "IMT Atlantique"
......@@ -32,7 +32,7 @@ func newLamp(addr uuid.UUID, group uuid.UUID) *Lamp {
}
// turnOn set the brightness to 50 to test attributes grouped msg
func (l *Lamp) turnOn(xAALLib.MessageBody) *xAALLib.MessageBody {
func (l *Lamp) turnOn(xaal.MessageBody) *xaal.MessageBody {
light := l.dev.GetAttribute("light")
brightness := l.dev.GetAttribute("brightness")
......@@ -47,7 +47,7 @@ func (l *Lamp) turnOn(xAALLib.MessageBody) *xAALLib.MessageBody {
}
// turnOff set the brightness to 0 to test attributes grouped msg
func (l *Lamp) turnOff(xAALLib.MessageBody) *xAALLib.MessageBody {
func (l *Lamp) turnOff(xaal.MessageBody) *xaal.MessageBody {
light := l.dev.GetAttribute("light")
brightness := l.dev.GetAttribute("brightness")
......@@ -60,7 +60,7 @@ func (l *Lamp) turnOff(xAALLib.MessageBody) *xAALLib.MessageBody {
}
// toggle the light, to blink it
func (l *Lamp) toggle(xAALLib.MessageBody) *xAALLib.MessageBody {
func (l *Lamp) toggle(xaal.MessageBody) *xaal.MessageBody {
light := l.dev.GetAttribute("light")
if light.Value.(bool) == true {
l.turnOff(nil)
......@@ -70,7 +70,7 @@ func (l *Lamp) toggle(xAALLib.MessageBody) *xAALLib.MessageBody {
return nil
}
func (l *Lamp) setBrightness(args xAALLib.MessageBody) *xAALLib.MessageBody {
func (l *Lamp) setBrightness(args xaal.MessageBody) *xaal.MessageBody {
if value, ok := args["brightness"].(int64); ok {
if value > 100 {
value = 100
......@@ -81,7 +81,7 @@ func (l *Lamp) setBrightness(args xAALLib.MessageBody) *xAALLib.MessageBody {
}
// used to make it blink w/ a goroutine
func (l *Lamp) blink(args xAALLib.MessageBody) *xAALLib.MessageBody {
func (l *Lamp) blink(args xaal.MessageBody) *xaal.MessageBody {
for {
l.toggle(nil)
time.Sleep(time.Second * 3)
......@@ -89,7 +89,7 @@ func (l *Lamp) blink(args xAALLib.MessageBody) *xAALLib.MessageBody {
}
func main() {
eng := xAALLib.NewEngine()
eng := xaal.NewEngine()
eng.Start()
baseAddr := uuid.MustParse("89b11138-a76b-11ee-91c7-d6bd5fe18700")
......
......@@ -3,10 +3,10 @@ package main
import (
"fmt"
xAALLib "xAAL/lib"
"xAAL/xaal"
)
func showMessage(msg *xAALLib.Message) {
func showMessage(msg *xaal.Message) {
if msg.IsAlive() == false {
msg.Dump()
fmt.Println()
......@@ -15,7 +15,7 @@ func showMessage(msg *xAALLib.Message) {
func main() {
eng := xAALLib.NewEngine()
eng := xaal.NewEngine()
eng.Start()
eng.Subscribe(showMessage)
......
package main
import (
xAALLib "xAAL/lib"
xaal "xAAL/xaal"
"github.com/google/uuid"
)
func main() {
eng := xAALLib.NewEngine()
eng := xaal.NewEngine()
eng.Start()
lamp := xAALLib.NewDevice("lamp.dimmer")
lamp := xaal.NewDevice("lamp.dimmer")
lamp.Address = uuid.MustParse("6558b72b-3ae6-4995-8c4c-e407b7119889")
light := lamp.AddAttribute("light", true)
......@@ -21,31 +21,31 @@ func main() {
lamp.ProductID = "Golang test lamp"
lamp.URL = "http://example.com"
turn_on := func(xAALLib.MessageBody) *xAALLib.MessageBody {
turn_on := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(true)
return nil
}
turn_off := func(xAALLib.MessageBody) *xAALLib.MessageBody {
turn_off := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(false)
return nil
}
toggle := func(xAALLib.MessageBody) *xAALLib.MessageBody {
toggle := func(xaal.MessageBody) *xaal.MessageBody {
light.SetValue(!light.Value.(bool))
return nil
}
dim := func(args xAALLib.MessageBody) *xAALLib.MessageBody {
dim := func(args xaal.MessageBody) *xaal.MessageBody {
if value, ok := args["brightness"].(uint64); ok {
if value > 100 {
value = 100
}
brightness.SetValue(value)
if value == 0 {
turn_off(xAALLib.MessageBody{})
turn_off(xaal.MessageBody{})
} else {
turn_on(xAALLib.MessageBody{})
turn_on(xaal.MessageBody{})
}
}
return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment