Secondary #2
@@ -37,6 +37,9 @@ public class Hue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCurrentLuminiscence() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
public void turnOff() {
|
public void turnOff() {
|
||||||
for (String light : allLights.keySet()) {
|
for (String light : allLights.keySet()) {
|
||||||
String callURL = lightsURL + light + "/state";
|
String callURL = lightsURL + light + "/state";
|
||||||
|
|||||||
@@ -19,14 +19,17 @@ public class Sensor {
|
|||||||
public String password = "raz4reti2";
|
public String password = "raz4reti2";
|
||||||
|
|
||||||
public IZWayApi zwayApi;
|
public IZWayApi zwayApi;
|
||||||
DeviceList allZWaveDevices;
|
private DeviceList allZWaveDevices;
|
||||||
DeviceList devices;
|
private DeviceList devices;
|
||||||
|
private Integer nodeId;
|
||||||
|
|
||||||
public Sensor() {
|
public Sensor() {
|
||||||
this(null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor (Integer nodeId) {
|
public Sensor (Integer nodeId) {
|
||||||
|
this.nodeId = nodeId;
|
||||||
|
|
||||||
// create an instance of the Z-Way library; all the params are mandatory (we are not going to use the remote service/id)
|
// create an instance of the Z-Way library; all the params are mandatory (we are not going to use the remote service/id)
|
||||||
zwayApi = new ZWayApiHttp(ipAddress, 8083, "http", username, password, 0, false, new ZWaySimpleCallback());
|
zwayApi = new ZWayApiHttp(ipAddress, 8083, "http", username, password, 0, false, new ZWaySimpleCallback());
|
||||||
|
|
||||||
@@ -53,10 +56,11 @@ public class Sensor {
|
|||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void update(int nodeId) throws InterruptedException {
|
synchronized public void update(int timeout) throws InterruptedException {
|
||||||
|
//setInitialValues();
|
||||||
for (Device device : devices.getAllDevices())
|
for (Device device : devices.getAllDevices())
|
||||||
device.update();
|
device.update();
|
||||||
wait(10000);
|
wait(timeout);
|
||||||
}
|
}
|
||||||
/*public boolean IsLowLuminescence(int Luminescence) {
|
/*public boolean IsLowLuminescence(int Luminescence) {
|
||||||
if (dev.getProbeType().equalsIgnoreCase("Luminescence"))
|
if (dev.getProbeType().equalsIgnoreCase("Luminescence"))
|
||||||
|
|||||||
@@ -6,27 +6,39 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TestSensor {
|
public class TestSensor {
|
||||||
Sensor sensor = new Sensor(5);
|
Sensor sensor = new Sensor(2);
|
||||||
Hue lights = new Hue();
|
Hue lights;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
synchronized public void firstTestSensor() throws InterruptedException {
|
synchronized public void firstTestSensor() throws InterruptedException {
|
||||||
sensor.update(5);
|
sensor.update(2);
|
||||||
System.out.println(sensor.luminiscenceLevel());
|
System.out.println(sensor.luminiscenceLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void secondTestSensor() throws InterruptedException {
|
synchronized public void secondTestSensor() throws InterruptedException {
|
||||||
sensor.update(5);
|
int i=0;
|
||||||
|
lights = new Hue();
|
||||||
Set<String> toRemove = new HashSet<>();
|
Set<String> toRemove = new HashSet<>();
|
||||||
|
|
||||||
for(String str: lights.getNameLights())
|
for(String str: lights.getNameLights())
|
||||||
if(!str.equals("4"))
|
if(!str.equals("4"))
|
||||||
toRemove.add(str);
|
toRemove.add(str);
|
||||||
lights.removeLights(toRemove);
|
lights.removeLights(toRemove);
|
||||||
|
lights.turnOn();
|
||||||
|
|
||||||
if(sensor.luminiscenceLevel() < 100) {
|
while(i<999999) {
|
||||||
lights.turnOn();
|
if (sensor.luminiscenceLevel() < 200) {
|
||||||
lights.setBrightness(200);
|
lights.getCurrentLuminiscence();
|
||||||
|
lights.setBrightness(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sensor.luminiscenceLevel() > 600) {
|
||||||
|
lights.setBrightness(0);
|
||||||
|
}
|
||||||
|
System.out.println(i+"-"+sensor.luminiscenceLevel());
|
||||||
|
sensor.update(100);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user