diff --git a/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java b/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java index 29fc0df2..7324b91a 100755 --- a/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java +++ b/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java @@ -1,6 +1,8 @@ package se.hal.plugin.tellstick; +import se.hal.plugin.tellstick.device.NexaSelfLearning; import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol; +import se.hal.struct.devicedata.SwitchEventData; /** * Created by Ziver on 2015-11-19. @@ -17,30 +19,32 @@ public class TelstickSerialCommNexaOnOffTest { Thread.sleep(1000); - NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol(); + NexaSelfLearning nexaDevice = new NexaSelfLearning(); //nexa.setHouse(11772006); - nexa.setHouse(14160770); - nexa.setGroup(false); - nexa.setUnit(1); + nexaDevice.setHouse(14160770); + nexaDevice.setGroup(false); + nexaDevice.setUnit(1); + + SwitchEventData nexaData = new SwitchEventData(); System.out.println("Up and Running"); while(true) { Thread.sleep(2000); - nexa.turnOn(); - nexa.setUnit(0); - comm.write(nexa); + nexaData.turnOn(); + nexaDevice.setUnit(0); + comm.send(nexaDevice, nexaData); Thread.sleep(2000); - nexa.setUnit(1); - comm.write(nexa); + nexaDevice.setUnit(1); + comm.send(nexaDevice, nexaData); Thread.sleep(2000); - nexa.turnOff(); - nexa.setUnit(0); - comm.write(nexa); + nexaData.turnOff(); + nexaDevice.setUnit(0); + comm.send(nexaDevice, nexaData); Thread.sleep(2000); - nexa.setUnit(1); - comm.write(nexa); + nexaDevice.setUnit(1); + comm.send(nexaDevice, nexaData); } } catch (Exception e) { e.printStackTrace(); diff --git a/test/se/hal/plugin/tellstick/TelstickSerialCommTest.java b/test/se/hal/plugin/tellstick/TelstickSerialCommTest.java index 54da4312..d31a0bd2 100755 --- a/test/se/hal/plugin/tellstick/TelstickSerialCommTest.java +++ b/test/se/hal/plugin/tellstick/TelstickSerialCommTest.java @@ -2,11 +2,13 @@ package se.hal.plugin.tellstick; import org.junit.Before; import org.junit.Test; -import se.hal.intf.HalEventConfig; -import se.hal.intf.HalEventReportListener; +import se.hal.intf.*; +import se.hal.struct.devicedata.SwitchEventData; +import se.hal.struct.devicedata.TemperatureSensorData; import zutil.converter.Converter; import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; @@ -45,7 +47,7 @@ public class TelstickSerialCommTest { final ArrayList list = new ArrayList<>(); tellstick.setListener(new HalEventReportListener() { @Override - public void reportReceived(HalEventConfig e) { + public void reportReceived(HalEventConfig e, HalDeviceData d) { list.add(e); } }); @@ -63,7 +65,7 @@ public class TelstickSerialCommTest { final ArrayList list = new ArrayList<>(); tellstick.setListener(new HalEventReportListener() { @Override - public void reportReceived(HalEventConfig e) { + public void reportReceived(HalEventConfig e, HalDeviceData d) { list.add(e); } }); @@ -79,7 +81,7 @@ public class TelstickSerialCommTest { - private static class TestEvent extends TellstickProtocol implements HalEventConfig { + private static class TestEvent extends TellstickProtocol implements HalEventConfig,TellstickDevice { public int testData; public TestEvent(){ @@ -87,16 +89,22 @@ public class TelstickSerialCommTest { } @Override - public void decode(byte[] data) { + public List decode(byte[] data) { testData = Converter.toInt(data); + + ArrayList list = new ArrayList<>(); + list.add(new TellstickDecodedEntry( + this, new TemperatureSensorData(testData) + )); + return list; } @Override - public String encode() {return null;} - @Override - public double getData() {return 0;} + public Class getEventController() { return null; } + @Override public boolean equals(Object obj) {return testData == ((TestEvent)obj).testData;} + } }