updated some log traces and plugin files

This commit is contained in:
Ziver Koc 2016-08-19 16:38:03 +02:00
parent 253e359483
commit 6b4b565a62
3 changed files with 21 additions and 12 deletions

View file

@ -57,7 +57,7 @@ public class ControllerManager implements HalSensorReportListener,
public void register(Sensor sensor) { public void register(Sensor sensor) {
if(sensor.getDeviceConfig() == null) { if(sensor.getDeviceConfig() == null) {
logger.warning("Sensor data is null: "+ sensor); logger.warning("Sensor config is null: "+ sensor);
return; return;
} }
if(!availableSensors.contains(sensor.getDeviceConfig().getClass())) { if(!availableSensors.contains(sensor.getDeviceConfig().getClass())) {
@ -77,7 +77,7 @@ public class ControllerManager implements HalSensorReportListener,
public void deregister(Sensor sensor){ public void deregister(Sensor sensor){
if(sensor.getDeviceConfig() == null) { if(sensor.getDeviceConfig() == null) {
logger.warning("Sensor data is null: "+ sensor); logger.warning("Sensor config is null: "+ sensor);
return; return;
} }
@ -147,7 +147,7 @@ public class ControllerManager implements HalSensorReportListener,
public void register(Event event) { public void register(Event event) {
if(event.getDeviceConfig() == null) { if(event.getDeviceConfig() == null) {
logger.warning("Event data is null: "+ event); logger.warning("Event config is null: "+ event);
return; return;
} }
if(!availableEvents.contains(event.getDeviceConfig().getClass())) { if(!availableEvents.contains(event.getDeviceConfig().getClass())) {
@ -167,7 +167,7 @@ public class ControllerManager implements HalSensorReportListener,
public void deregister(Event event){ public void deregister(Event event){
if(event.getDeviceConfig() == null) { if(event.getDeviceConfig() == null) {
logger.warning("Event data is null: "+ event); logger.warning("Event config is null: "+ event);
return; return;
} }
@ -291,7 +291,7 @@ public class ControllerManager implements HalSensorReportListener,
controller = c.newInstance(); controller = c.newInstance();
if (controller instanceof HalAutoScannableController && if (controller instanceof HalAutoScannableController &&
! ((HalAutoScannableController)controller).isAvailable()) { ! ((HalAutoScannableController)controller).isAvailable()) {
logger.warning("Controller not available: "+c.getName()); logger.warning("Controller is not available: "+c.getName());
return null; return null;
} }
logger.info("Instantiating new controller: " + c.getName()); logger.info("Instantiating new controller: " + c.getName());

View file

@ -4,7 +4,7 @@
"interfaces": [ "interfaces": [
{"se.hal.intf.HalAutoScannableController": "se.hal.plugin.tellstick.TellstickSerialComm"}, {"se.hal.intf.HalAutoScannableController": "se.hal.plugin.tellstick.TellstickSerialComm"},
{"se.hal.intf.HalSensorData": "se.hal.plugin.tellstick.protocols.Oregon0x1A2D"}, {"se.hal.intf.HalSensorData": "se.hal.plugin.tellstick.device.Oregon0x1A2D"},
{"se.hal.intf.HalEventData": "se.hal.plugin.tellstick.protocols.NexaSelfLearning"} {"se.hal.intf.HalEventData": "se.hal.plugin.tellstick.device.NexaSelfLearning"}
] ]
} }

View file

@ -26,7 +26,7 @@ public abstract class AbstractDevice<T,D> extends DBBean {
/** Sensor specific configuration **/ /** Sensor specific configuration **/
private transient T deviceConfig; private transient T deviceConfig;
/** latest device data received **/ /** latest device data received **/
private transient D latestDeviceData; private transient D deviceData;
// User configuration // User configuration
@DBColumn("user_id") @DBColumn("user_id")
@ -72,10 +72,12 @@ public abstract class AbstractDevice<T,D> extends DBBean {
*/ */
public void setDeviceConfig(T data) { public void setDeviceConfig(T data) {
if(data != null) { if(data != null) {
deviceConfig = data;
type = data.getClass().getName(); type = data.getClass().getName();
deviceConfig = data;
deviceData = readDeviceData();
} else { } else {
deviceConfig = null; deviceConfig = null;
deviceData = null;
type = null; type = null;
config = null; config = null;
} }
@ -115,14 +117,21 @@ public abstract class AbstractDevice<T,D> extends DBBean {
* @return the latest known data from the device * @return the latest known data from the device
*/ */
public D getDeviceData(){ public D getDeviceData(){
return latestDeviceData; return deviceData;
} }
public void setDeviceData(D latest){ public void setDeviceData(D latest){
this.latestDeviceData = latest; this.deviceData = latest;
} }
/**************** OTHER VALUES ******************/ /**
* Reads latest device data from DB
*/
private D readDeviceData(){
return null; // TODO: how to do this in a good way?
}
/**************** OTHER ******************/
public String getName() { public String getName() {
return name; return name;