Refactoring of of inheritance structure, ControllerManagers will now also be able to be provided through plugins
This commit is contained in:
parent
28bc108921
commit
c0188cd5cc
73 changed files with 1083 additions and 991 deletions
|
|
@ -61,8 +61,7 @@ public class TellstickSerialComm implements Runnable,
|
|||
|
||||
protected TellstickParser parser;
|
||||
|
||||
private HalSensorReportListener sensorListener;
|
||||
private HalEventReportListener eventListener;
|
||||
private HalDeviceReportListener deviceListener;
|
||||
private List<TellstickDevice> registeredDevices;
|
||||
|
||||
|
||||
|
|
@ -186,10 +185,8 @@ public class TellstickSerialComm implements Runnable,
|
|||
set.add(data);
|
||||
}
|
||||
private void reportEvent(TellstickDevice tellstickDevice, HalDeviceData deviceData){
|
||||
if (sensorListener != null && tellstickDevice instanceof HalSensorConfig)
|
||||
sensorListener.reportReceived((HalSensorConfig) tellstickDevice, (HalSensorData) deviceData);
|
||||
else if (eventListener != null && tellstickDevice instanceof HalEventConfig)
|
||||
eventListener.reportReceived((HalEventConfig) tellstickDevice, (HalEventData) deviceData);
|
||||
if (deviceListener != null)
|
||||
deviceListener.reportReceived((HalDeviceConfig) tellstickDevice, deviceData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -225,18 +222,11 @@ public class TellstickSerialComm implements Runnable,
|
|||
// --------------------------
|
||||
|
||||
@Override
|
||||
public void register(HalEventConfig event) {
|
||||
if(event instanceof TellstickDevice)
|
||||
registeredDevices.add((TellstickDevice) event);
|
||||
public void register(HalDeviceConfig deviceConfig) {
|
||||
if(deviceConfig instanceof TellstickDevice)
|
||||
registeredDevices.add((TellstickDevice) deviceConfig);
|
||||
else throw new IllegalArgumentException(
|
||||
"Device config is not an instance of "+TellstickDevice.class+": "+event.getClass());
|
||||
}
|
||||
@Override
|
||||
public void register(HalSensorConfig sensor) {
|
||||
if(sensor instanceof TellstickDevice)
|
||||
registeredDevices.add((TellstickDevice) sensor);
|
||||
else throw new IllegalArgumentException(
|
||||
"Device config is not an instance of "+TellstickDevice.class+": "+sensor.getClass());
|
||||
"Device config is not an instance of " + TellstickDevice.class + ": " + deviceConfig.getClass());
|
||||
}
|
||||
|
||||
public <T> List<T> getRegisteredDevices(Class<T> clazz){
|
||||
|
|
@ -249,12 +239,8 @@ public class TellstickSerialComm implements Runnable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deregister(HalEventConfig event) {
|
||||
registeredDevices.remove(event);
|
||||
}
|
||||
@Override
|
||||
public void deregister(HalSensorConfig sensor) {
|
||||
registeredDevices.remove(sensor);
|
||||
public void deregister(HalDeviceConfig deviceConfig) {
|
||||
registeredDevices.remove(deviceConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -263,12 +249,8 @@ public class TellstickSerialComm implements Runnable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setListener(HalEventReportListener listener) {
|
||||
eventListener = listener;
|
||||
}
|
||||
@Override
|
||||
public void setListener(HalSensorReportListener listener) {
|
||||
sensorListener = listener;
|
||||
public void setListener(HalDeviceReportListener listener) {
|
||||
deviceListener = listener;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -101,11 +101,11 @@ public class NexaSelfLearning implements HalEventConfig,TellstickDevice,Tellstic
|
|||
|
||||
|
||||
@Override
|
||||
public Class<? extends HalEventController> getEventControllerClass() {
|
||||
public Class<? extends HalEventController> getDeviceControllerClass() {
|
||||
return TellstickSerialComm.class;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends HalEventData> getEventDataClass() {
|
||||
public Class<? extends HalEventData> getDeviceDataClass() {
|
||||
return OnOffEventData.class;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,11 +81,11 @@ public class NexaSelfLearningDimmer implements HalEventConfig,TellstickDevice {
|
|||
|
||||
|
||||
@Override
|
||||
public Class<? extends HalEventController> getEventControllerClass() {
|
||||
public Class<? extends HalEventController> getDeviceControllerClass() {
|
||||
return TellstickSerialComm.class;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends HalEventData> getEventDataClass() {
|
||||
public Class<? extends HalEventData> getDeviceDataClass() {
|
||||
return DimmerEventData.class;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends HalSensorController> getSensorControllerClass() {
|
||||
public Class<? extends HalSensorController> getDeviceControllerClass() {
|
||||
return TellstickSerialComm.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends HalSensorData> getSensorDataClass() {
|
||||
public Class<? extends HalSensorData> getDeviceDataClass() {
|
||||
if (sensorType != null) {
|
||||
switch (sensorType) {
|
||||
case HUMIDITY:
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class TelstickSerialCommEventTest {
|
|||
// Setup
|
||||
TellstickSerialComm tellstick = new TellstickSerialComm();
|
||||
final ArrayList<HalEventConfig> list = new ArrayList<>();
|
||||
tellstick.setListener(new HalEventReportListener() {
|
||||
tellstick.setListener(new HalDeviceReportListener<HalEventConfig,HalEventData>() {
|
||||
@Override
|
||||
public void reportReceived(HalEventConfig e, HalEventData d) {
|
||||
list.add(e);
|
||||
|
|
@ -62,7 +62,7 @@ public class TelstickSerialCommEventTest {
|
|||
// Setup
|
||||
TellstickSerialComm tellstick = new TellstickSerialComm();
|
||||
final ArrayList<HalEventConfig> list = new ArrayList<>();
|
||||
tellstick.setListener(new HalEventReportListener() {
|
||||
tellstick.setListener(new HalDeviceReportListener<HalEventConfig,HalEventData>() {
|
||||
@Override
|
||||
public void reportReceived(HalEventConfig e, HalEventData d) {
|
||||
list.add(e);
|
||||
|
|
@ -101,9 +101,9 @@ public class TelstickSerialCommEventTest {
|
|||
|
||||
|
||||
@Override
|
||||
public Class<? extends HalEventController> getEventControllerClass() { return null; }
|
||||
public Class<? extends HalEventController> getDeviceControllerClass() { return null; }
|
||||
@Override
|
||||
public Class<? extends HalEventData> getEventDataClass() {
|
||||
public Class<? extends HalEventData> getDeviceDataClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class TelstickSerialCommSensorTest {
|
|||
// Setup
|
||||
TellstickSerialComm tellstick = new TellstickSerialComm();
|
||||
final ArrayList<HalSensorConfig> list = new ArrayList<>();
|
||||
tellstick.setListener(new HalSensorReportListener() {
|
||||
tellstick.setListener(new HalDeviceReportListener<HalSensorConfig,HalSensorData>() {
|
||||
@Override
|
||||
public void reportReceived(HalSensorConfig e, HalSensorData d) {
|
||||
list.add(e);
|
||||
|
|
@ -47,7 +47,7 @@ public class TelstickSerialCommSensorTest {
|
|||
// Setup
|
||||
TellstickSerialComm tellstick = new TellstickSerialComm();
|
||||
final ArrayList<HalSensorConfig> list = new ArrayList<>();
|
||||
tellstick.setListener(new HalSensorReportListener() {
|
||||
tellstick.setListener(new HalDeviceReportListener<HalSensorConfig,HalSensorData>() {
|
||||
@Override
|
||||
public void reportReceived(HalSensorConfig e, HalSensorData d) {
|
||||
list.add(e);
|
||||
|
|
@ -94,9 +94,9 @@ public class TelstickSerialCommSensorTest {
|
|||
@Override
|
||||
public AggregationMethod getAggregationMethod() { return null; }
|
||||
@Override
|
||||
public Class<? extends HalSensorController> getSensorControllerClass() { return null; }
|
||||
public Class<? extends HalSensorController> getDeviceControllerClass() { return null; }
|
||||
@Override
|
||||
public Class<? extends HalSensorData> getSensorDataClass() {
|
||||
public Class<? extends HalSensorData> getDeviceDataClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue