1 //Create a class for battery
3 import Timer.SimulatedTimer
8 private String displayName
10 private int currentBattery
11 private int batteryLatestValue
13 Battery(String id, String label, String displayName, int battery) {
16 this.displayName = displayName
17 this.battery = battery
18 this.currentBattery = battery
19 this.batteryLatestValue = battery
23 def setValue(String value) {
24 println("the battery level with id:$id is changed to $value!")
25 this.battery = value.toInteger()
26 this.currentBattery = value.toInteger()
27 this.batteryLatestValue = value.toInteger()
30 def currentValue(String deviceFeature) {
31 if (deviceFeature == "battery") {
36 def latestValue(String deviceFeature) {
37 if (deviceFeature == "battery") {
38 return batteryLatestValue