From c132f147c4200ddad1387b5a244ec987a736e034 Mon Sep 17 00:00:00 2001 From: Nikolay Viguro Date: Thu, 20 Nov 2014 09:59:11 +0300 Subject: [PATCH] =?UTF-8?q?PR1132:=20=D0=9F=D0=BE=D0=BB=D1=83=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D1=81=20=D1=81=D0=B5=D0=BD=D1=81=D0=BE=D1=80=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=92=D0=B5=D1=80=D1=81=D0=B8=D1=8F=201.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ src/main/java/ru/iris/noolite4j/gateway/HTTPCommand.java | 4 ++-- src/main/java/ru/iris/noolite4j/gateway/Sensor.java | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 308b944..4516965 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,11 @@ mvn package pr.turnOn(channel); pr.turnOff(channel); + List sensors = pr.getSensors(); + + // Температура с первого сенсора в списке + short temp = sensors.get(0).getTemperature(); + pc.open(); pc.turnOn(channel); diff --git a/src/main/java/ru/iris/noolite4j/gateway/HTTPCommand.java b/src/main/java/ru/iris/noolite4j/gateway/HTTPCommand.java index 2ad0c0c..32417fe 100644 --- a/src/main/java/ru/iris/noolite4j/gateway/HTTPCommand.java +++ b/src/main/java/ru/iris/noolite4j/gateway/HTTPCommand.java @@ -127,7 +127,7 @@ public List getSensors() Node nNode = nList.item(temp); - byte value = Byte.valueOf(nNode.getNodeValue()); + short value = Short.valueOf(nNode.getNodeValue()); /** * Найдем канал и связанный с ним сенсор @@ -162,7 +162,7 @@ public List getSensors() } else if(type.equals("snsh")) { - sensor.setHumidity(value); + sensor.setHumidity((byte)value); } else if(type.equals("snt")) { diff --git a/src/main/java/ru/iris/noolite4j/gateway/Sensor.java b/src/main/java/ru/iris/noolite4j/gateway/Sensor.java index 48f3c47..01eeae2 100644 --- a/src/main/java/ru/iris/noolite4j/gateway/Sensor.java +++ b/src/main/java/ru/iris/noolite4j/gateway/Sensor.java @@ -20,7 +20,7 @@ public class Sensor { private byte channel; - private byte temperature; + private short temperature; private byte humidity; private SensorState state; @@ -32,11 +32,11 @@ public void setChannel(byte channel) { this.channel = channel; } - public byte getTemperature() { + public short getTemperature() { return temperature; } - public void setTemperature(byte temperature) { + public void setTemperature(short temperature) { this.temperature = temperature; }