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

- Remove unused type

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Go/trunk/xaal-lib/apps@3160 b32b6428-25c9-4566-ad07-03861ab6144f
parent e9ae987e
Branches
Tags
No related merge requests found
......@@ -4,6 +4,7 @@
package main
import (
"fmt"
"time"
"xAAL/xaal"
......@@ -22,7 +23,7 @@ func newLamp(addr uuid.UUID, group uuid.UUID) *Lamp {
dev.ProductID = "Golang Chandelier Lamp"
dev.GroupID = group
dev.AddAttribute("light", false)
dev.AddAttribute("brightness", uint64(50))
dev.AddAttribute("brightness", 50)
dev.AddMethod("turn_on", l.turnOn)
dev.AddMethod("turn_off", l.turnOff)
dev.AddMethod("toggle", l.toggle)
......@@ -36,11 +37,11 @@ func (l *Lamp) turnOn(xaal.MessageBody) *xaal.MessageBody {
light := l.dev.GetAttribute("light")
brightness := l.dev.GetAttribute("brightness")
if light.Value.(bool) == true {
if light.Value == true {
return nil
}
light.SetValue(true)
if brightness.Value == uint64(0) {
if brightness.Value == 0 {
brightness.SetValue(50)
}
return nil
......@@ -51,7 +52,7 @@ func (l *Lamp) turnOff(xaal.MessageBody) *xaal.MessageBody {
light := l.dev.GetAttribute("light")
brightness := l.dev.GetAttribute("brightness")
if light.Value.(bool) == false {
if light.Value == false {
return nil
}
light.SetValue(false)
......@@ -62,7 +63,7 @@ func (l *Lamp) turnOff(xaal.MessageBody) *xaal.MessageBody {
// toggle the light, to blink it
func (l *Lamp) toggle(xaal.MessageBody) *xaal.MessageBody {
light := l.dev.GetAttribute("light")
if light.Value.(bool) == true {
if light.Value == true {
l.turnOff(nil)
} else {
l.turnOn(nil)
......@@ -75,6 +76,7 @@ func (l *Lamp) setBrightness(args xaal.MessageBody) *xaal.MessageBody {
if value > 100 {
value = 100
}
fmt.Println("set brightness to", value)
l.dev.GetAttribute("brightness").SetValue(value)
}
return nil
......
......@@ -15,7 +15,7 @@ func main() {
lamp.Address = uuid.MustParse("6558b72b-3ae6-4995-8c4c-e407b7119889")
light := lamp.AddAttribute("light", true)
brightness := lamp.AddAttribute("brightness", uint64(50))
brightness := lamp.AddAttribute("brightness", 50)
lamp.VendorID = "IMT Atlantique"
lamp.ProductID = "Golang test lamp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment