Rename HalEvent and HalSensor to HalEventData and HalSensorData
Former-commit-id: 2dac97a3080245639b43d290aa4e94127cb1bdd4
This commit is contained in:
parent
92e90c5eef
commit
cc6da8fccf
26 changed files with 71 additions and 95 deletions
|
|
@ -30,7 +30,7 @@ public class ControllerManager implements HalSensorReportListener, HalEventRepor
|
||||||
/** List of all registered sensors **/
|
/** List of all registered sensors **/
|
||||||
private ArrayList<Sensor> registeredSensors = new ArrayList<>();
|
private ArrayList<Sensor> registeredSensors = new ArrayList<>();
|
||||||
/** List of auto detected sensors **/
|
/** List of auto detected sensors **/
|
||||||
private ArrayList<HalSensor> detectedSensors = new ArrayList<>();
|
private ArrayList<HalSensorData> detectedSensors = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
/** All available event plugins **/
|
/** All available event plugins **/
|
||||||
|
|
@ -38,7 +38,7 @@ public class ControllerManager implements HalSensorReportListener, HalEventRepor
|
||||||
/** List of all registered events **/
|
/** List of all registered events **/
|
||||||
private ArrayList<Event> registeredEvents = new ArrayList<>();
|
private ArrayList<Event> registeredEvents = new ArrayList<>();
|
||||||
/** List of auto detected events **/
|
/** List of auto detected events **/
|
||||||
private ArrayList<HalEvent> detectedEvents = new ArrayList<>();
|
private ArrayList<HalEventData> detectedEvents = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
/** A map of all instantiated controllers **/
|
/** A map of all instantiated controllers **/
|
||||||
|
|
@ -87,12 +87,12 @@ public class ControllerManager implements HalSensorReportListener, HalEventRepor
|
||||||
return availableSensors;
|
return availableSensors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HalSensor> getDetectedSensors(){
|
public List<HalSensorData> getDetectedSensors(){
|
||||||
return detectedSensors;
|
return detectedSensors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reportReceived(HalSensor sensorData) {
|
public void reportReceived(HalSensorData sensorData) {
|
||||||
try{
|
try{
|
||||||
DBConnection db = HalContext.getDB();
|
DBConnection db = HalContext.getDB();
|
||||||
Sensor sensor = null;
|
Sensor sensor = null;
|
||||||
|
|
@ -165,12 +165,12 @@ public class ControllerManager implements HalSensorReportListener, HalEventRepor
|
||||||
return availableEvents;
|
return availableEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HalEvent> getDetectedEvents(){
|
public List<HalEventData> getDetectedEvents(){
|
||||||
return detectedEvents;
|
return detectedEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reportReceived(HalEvent eventData) {
|
public void reportReceived(HalEventData eventData) {
|
||||||
try {
|
try {
|
||||||
DBConnection db = HalContext.getDB();
|
DBConnection db = HalContext.getDB();
|
||||||
Event event = null;
|
Event event = null;
|
||||||
|
|
@ -259,12 +259,12 @@ public class ControllerManager implements HalSensorReportListener, HalEventRepor
|
||||||
Iterator<PluginData> it = pluginManager.iterator();
|
Iterator<PluginData> it = pluginManager.iterator();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()){
|
||||||
PluginData plugin = it.next();
|
PluginData plugin = it.next();
|
||||||
Iterator<Class<?>> pluginIt = plugin.getClassIterator(HalSensor.class);
|
Iterator<Class<?>> pluginIt = plugin.getClassIterator(HalSensorData.class);
|
||||||
while (pluginIt.hasNext()){
|
while (pluginIt.hasNext()){
|
||||||
manager.availableSensors.add(pluginIt.next());
|
manager.availableSensors.add(pluginIt.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginIt = plugin.getClassIterator(HalEvent.class);
|
pluginIt = plugin.getClassIterator(HalEventData.class);
|
||||||
while (pluginIt.hasNext()){
|
while (pluginIt.hasNext()){
|
||||||
manager.availableEvents.add(pluginIt.next());
|
manager.availableEvents.add(pluginIt.next());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import se.hal.bot.AliceBot;
|
||||||
import se.hal.intf.HalBot;
|
import se.hal.intf.HalBot;
|
||||||
import se.hal.intf.HalSpeachToText;
|
import se.hal.intf.HalSpeachToText;
|
||||||
import se.hal.intf.HalTextToSpeach;
|
import se.hal.intf.HalTextToSpeach;
|
||||||
import se.hal.struct.SwitchEvent;
|
import se.hal.struct.SwitchEventData;
|
||||||
import se.hal.stt.ManualSTTClient;
|
import se.hal.stt.ManualSTTClient;
|
||||||
import se.hal.tts.MaryRemoteTTSClient;
|
import se.hal.tts.MaryRemoteTTSClient;
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ import java.util.regex.Pattern;
|
||||||
* Time: 10:59
|
* Time: 10:59
|
||||||
*/
|
*/
|
||||||
public class HalSpeechClient {
|
public class HalSpeechClient {
|
||||||
private static HashMap<String, SwitchEvent> switches = new HashMap<String, SwitchEvent>();
|
private static HashMap<String, SwitchEventData> switches = new HashMap<String, SwitchEventData>();
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
|
|
@ -53,22 +53,22 @@ public class HalSpeechClient {
|
||||||
/* NexaSelfLearning nexa1 = new NexaSelfLearning();
|
/* NexaSelfLearning nexa1 = new NexaSelfLearning();
|
||||||
nexa1.setHouse(15087918);
|
nexa1.setHouse(15087918);
|
||||||
nexa1.setUnit(0);
|
nexa1.setUnit(0);
|
||||||
switches.put("livingroom", new SwitchEvent("livingroom", nexa1));
|
switches.put("livingroom", new SwitchEventData("livingroom", nexa1));
|
||||||
|
|
||||||
NexaSelfLearning nexa2 = new NexaSelfLearning();
|
NexaSelfLearning nexa2 = new NexaSelfLearning();
|
||||||
nexa2.setHouse(15087918);
|
nexa2.setHouse(15087918);
|
||||||
nexa2.setUnit(1);
|
nexa2.setUnit(1);
|
||||||
switches.put("bedroom", new SwitchEvent("bedroom", nexa2));
|
switches.put("bedroom", new SwitchEventData("bedroom", nexa2));
|
||||||
|
|
||||||
NexaSelfLearning nexa3 = new NexaSelfLearning();
|
NexaSelfLearning nexa3 = new NexaSelfLearning();
|
||||||
nexa3.setHouse(15087918);
|
nexa3.setHouse(15087918);
|
||||||
nexa3.setUnit(3);
|
nexa3.setUnit(3);
|
||||||
switches.put("kitchen", new SwitchEvent("kitchen", nexa3));
|
switches.put("kitchen", new SwitchEventData("kitchen", nexa3));
|
||||||
|
|
||||||
TellstickSerialComm.getInstance().setListener(new TellstickChangeListener() {
|
TellstickSerialComm.getInstance().setListener(new TellstickChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void stateChange(TellstickProtocol protocol) {
|
public void stateChange(TellstickProtocol protocol) {
|
||||||
for(SwitchEvent s : switches.values()) {
|
for(SwitchEventData s : switches.values()) {
|
||||||
if(s.equals(protocol)) {
|
if(s.equals(protocol)) {
|
||||||
String response = s.getName()+" window is "+(((NexaSelfLearning)protocol).isEnabled() ? "open": "closed");
|
String response = s.getName()+" window is "+(((NexaSelfLearning)protocol).isEnabled() ? "open": "closed");
|
||||||
System.out.println(">>> " + response);
|
System.out.println(">>> " + response);
|
||||||
|
|
@ -118,7 +118,7 @@ public class HalSpeechClient {
|
||||||
if(m.find()){
|
if(m.find()){
|
||||||
String name = m.group(1);
|
String name = m.group(1);
|
||||||
if(name.equals("all")){
|
if(name.equals("all")){
|
||||||
for(SwitchEvent s : switches.values())
|
for(SwitchEventData s : switches.values())
|
||||||
s.turnOn();
|
s.turnOn();
|
||||||
return "I've turned everything on for you";
|
return "I've turned everything on for you";
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,7 @@ public class HalSpeechClient {
|
||||||
if(m.find()){
|
if(m.find()){
|
||||||
String name = m.group(1);
|
String name = m.group(1);
|
||||||
if(name.equals("all")){
|
if(name.equals("all")){
|
||||||
for(SwitchEvent s : switches.values())
|
for(SwitchEventData s : switches.values())
|
||||||
s.turnOff();
|
s.turnOff();
|
||||||
return "I turned everything off";
|
return "I turned everything off";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ package se.hal.deamon;
|
||||||
import se.hal.HalContext;
|
import se.hal.HalContext;
|
||||||
import se.hal.intf.HalDaemon;
|
import se.hal.intf.HalDaemon;
|
||||||
import se.hal.struct.Sensor;
|
import se.hal.struct.Sensor;
|
||||||
import se.hal.intf.HalSensor.AggregationMethod;
|
import se.hal.intf.HalSensorData.AggregationMethod;
|
||||||
import se.hal.struct.PowerConsumptionSensor;
|
|
||||||
import se.hal.util.TimeUtility;
|
import se.hal.util.TimeUtility;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.SQLResultHandler;
|
import zutil.db.SQLResultHandler;
|
||||||
|
|
@ -43,7 +42,7 @@ public class SensorDataAggregatorDaemon implements HalDaemon {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void aggregateSensor(Sensor sensor) {
|
public void aggregateSensor(Sensor sensor) {
|
||||||
//if(sensor.getSensorData() instanceof PowerConsumptionSensor){
|
//if(sensor.getSensorData() instanceof PowerConsumptionSensorData){
|
||||||
logger.fine("The sensor is of type: " + sensor.getDeviceData().getClass().getName());
|
logger.fine("The sensor is of type: " + sensor.getDeviceData().getClass().getName());
|
||||||
logger.fine("aggregating raw data to five minute periods");
|
logger.fine("aggregating raw data to five minute periods");
|
||||||
aggregateRawData(sensor, TimeUtility.FIVE_MINUTES_IN_MS, 5);
|
aggregateRawData(sensor, TimeUtility.FIVE_MINUTES_IN_MS, 5);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package se.hal.deamon;
|
||||||
import se.hal.HalContext;
|
import se.hal.HalContext;
|
||||||
import se.hal.intf.HalDaemon;
|
import se.hal.intf.HalDaemon;
|
||||||
import se.hal.struct.Sensor;
|
import se.hal.struct.Sensor;
|
||||||
import se.hal.struct.PowerConsumptionSensor;
|
|
||||||
import se.hal.util.TimeUtility;
|
import se.hal.util.TimeUtility;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.SQLResultHandler;
|
import zutil.db.SQLResultHandler;
|
||||||
|
|
@ -42,7 +41,7 @@ public class SensorDataCleanupDaemon implements HalDaemon {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanupSensor(Sensor sensor) {
|
public void cleanupSensor(Sensor sensor) {
|
||||||
//if(sensor instanceof PowerConsumptionSensor){
|
//if(sensor instanceof PowerConsumptionSensorData){
|
||||||
logger.fine("The sensor is of type: " + sensor.getDeviceData().getClass().getName());
|
logger.fine("The sensor is of type: " + sensor.getDeviceData().getClass().getName());
|
||||||
if(sensor.getUser().isExternal()){
|
if(sensor.getUser().isExternal()){
|
||||||
cleanupExternalSensorData(sensor.getId(), TimeUtility.FIVE_MINUTES_IN_MS, TimeUtility.DAY_IN_MS);
|
cleanupExternalSensorData(sensor.getId(), TimeUtility.FIVE_MINUTES_IN_MS, TimeUtility.DAY_IN_MS);
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,18 @@ public interface HalEventController {
|
||||||
/**
|
/**
|
||||||
* Will register an event type to be handled by this controller
|
* Will register an event type to be handled by this controller
|
||||||
*/
|
*/
|
||||||
public void register(HalEvent event);
|
public void register(HalEventData event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deregisters an event from this controller, the controller
|
* Deregisters an event from this controller, the controller
|
||||||
* will no longer handle that type of event
|
* will no longer handle that type of event
|
||||||
*/
|
*/
|
||||||
public void deregister(HalEvent event);
|
public void deregister(HalEventData event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param event transmit this event if possible.
|
* @param event transmit this event if possible.
|
||||||
*/
|
*/
|
||||||
public void send(HalEvent event); // TODO: where to put data?
|
public void send(HalEventData event); // TODO: where to put data?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the number of registered objects
|
* @return the number of registered objects
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package se.hal.intf;
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-12-23.
|
* Created by Ziver on 2015-12-23.
|
||||||
*/
|
*/
|
||||||
public interface HalEvent {
|
public interface HalEventData {
|
||||||
|
|
||||||
long getTimestamp();
|
long getTimestamp();
|
||||||
|
|
||||||
|
|
@ -2,6 +2,6 @@ package se.hal.intf;
|
||||||
|
|
||||||
public interface HalEventReportListener {
|
public interface HalEventReportListener {
|
||||||
|
|
||||||
void reportReceived(HalEvent e);
|
void reportReceived(HalEventData e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -10,13 +10,13 @@ public interface HalSensorController {
|
||||||
/**
|
/**
|
||||||
* Will register a sensor type to be handled by this controller
|
* Will register a sensor type to be handled by this controller
|
||||||
*/
|
*/
|
||||||
void register(HalSensor sensor);
|
void register(HalSensorData sensor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deregisters a sensor from this controller, the controller
|
* Deregisters a sensor from this controller, the controller
|
||||||
* will no longer handle that type of sensor
|
* will no longer handle that type of sensor
|
||||||
*/
|
*/
|
||||||
void deregister(HalSensor sensor);
|
void deregister(HalSensorData sensor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the number of registered objects
|
* @return the number of registered objects
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package se.hal.intf;
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-12-23.
|
* Created by Ziver on 2015-12-23.
|
||||||
*/
|
*/
|
||||||
public interface HalSensor {
|
public interface HalSensorData {
|
||||||
enum AggregationMethod{
|
enum AggregationMethod{
|
||||||
SUM,
|
SUM,
|
||||||
AVERAGE
|
AVERAGE
|
||||||
|
|
@ -2,6 +2,6 @@ package se.hal.intf;
|
||||||
|
|
||||||
public interface HalSensorReportListener {
|
public interface HalSensorReportListener {
|
||||||
|
|
||||||
void reportReceived(HalSensor s);
|
void reportReceived(HalSensorData s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package se.hal.plugin.localsensor;
|
package se.hal.plugin.localsensor;
|
||||||
|
|
||||||
import se.hal.intf.HalSensor;
|
import se.hal.intf.HalSensorData;
|
||||||
import se.hal.intf.HalSensorController;
|
import se.hal.intf.HalSensorController;
|
||||||
import se.hal.intf.HalSensorReportListener;
|
import se.hal.intf.HalSensorReportListener;
|
||||||
|
|
||||||
|
|
@ -14,12 +14,12 @@ public class RPiController implements HalSensorController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(HalSensor sensor) {
|
public void register(HalSensorData sensor) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deregister(HalSensor sensor) {
|
public void deregister(HalSensorData sensor) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
package se.hal.plugin.localsensor;
|
package se.hal.plugin.localsensor;
|
||||||
|
|
||||||
import se.hal.intf.HalSensor;
|
|
||||||
import se.hal.intf.HalSensorController;
|
import se.hal.intf.HalSensorController;
|
||||||
import se.hal.struct.PowerConsumptionSensor;
|
import se.hal.struct.PowerConsumptionSensorData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ezivkoc on 2016-01-14.
|
* Created by ezivkoc on 2016-01-14.
|
||||||
*/
|
*/
|
||||||
public class RPiSensor implements PowerConsumptionSensor {
|
public class RPiSensor implements PowerConsumptionSensorData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
"version": 1.0,
|
"version": 1.0,
|
||||||
"name": "RPiImpulsCountSensor",
|
"name": "RPiImpulsCountSensor",
|
||||||
"interfaces": [
|
"interfaces": [
|
||||||
{"se.hal.intf.HalSensor": "se.hal.plugin.localsensor.RPiSensor"}
|
{"se.hal.intf.HalSensorData": "se.hal.plugin.localsensor.RPiSensor"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -122,10 +122,10 @@ public class TellstickSerialComm implements Runnable, HalSensorController, HalEv
|
||||||
protocol.setTimestamp(System.currentTimeMillis());
|
protocol.setTimestamp(System.currentTimeMillis());
|
||||||
set.add(data);
|
set.add(data);
|
||||||
|
|
||||||
if (sensorListener != null && protocol instanceof HalSensor)
|
if (sensorListener != null && protocol instanceof HalSensorData)
|
||||||
sensorListener.reportReceived((HalSensor) protocol);
|
sensorListener.reportReceived((HalSensorData) protocol);
|
||||||
else if (eventListener != null && protocol instanceof HalEvent)
|
else if (eventListener != null && protocol instanceof HalEventData)
|
||||||
eventListener.reportReceived((HalEvent) protocol);
|
eventListener.reportReceived((HalEventData) protocol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,7 +157,7 @@ public class TellstickSerialComm implements Runnable, HalSensorController, HalEv
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(HalEvent event) {
|
public void send(HalEventData event) {
|
||||||
if(event instanceof TellstickProtocol)
|
if(event instanceof TellstickProtocol)
|
||||||
write((TellstickProtocol) event);
|
write((TellstickProtocol) event);
|
||||||
}
|
}
|
||||||
|
|
@ -182,14 +182,14 @@ public class TellstickSerialComm implements Runnable, HalSensorController, HalEv
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(HalEvent event) {++registeredObjects;}
|
public void register(HalEventData event) {++registeredObjects;}
|
||||||
@Override
|
@Override
|
||||||
public void register(HalSensor sensor) {++registeredObjects;}
|
public void register(HalSensorData sensor) {++registeredObjects;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deregister(HalSensor sensor) {--registeredObjects;}
|
public void deregister(HalSensorData sensor) {--registeredObjects;}
|
||||||
@Override
|
@Override
|
||||||
public void deregister(HalEvent event) {--registeredObjects;}
|
public void deregister(HalEventData event) {--registeredObjects;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"version": 1.0,
|
"version": 1.0,
|
||||||
"name": "Tellstick",
|
"name": "Tellstick",
|
||||||
"interfaces": [
|
"interfaces": [
|
||||||
{"se.hal.intf.HalSensor": "se.hal.plugin.tellstick.protocols.Oregon0x1A2D"},
|
{"se.hal.intf.HalSensorData": "se.hal.plugin.tellstick.protocols.Oregon0x1A2D"},
|
||||||
{"se.hal.intf.HalEvent": "se.hal.plugin.tellstick.protocols.NexaSelfLearning"}
|
{"se.hal.intf.HalEventData": "se.hal.plugin.tellstick.protocols.NexaSelfLearning"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -23,13 +23,13 @@
|
||||||
package se.hal.plugin.tellstick.protocols;
|
package se.hal.plugin.tellstick.protocols;
|
||||||
|
|
||||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||||
import se.hal.struct.SwitchEvent;
|
import se.hal.struct.SwitchEventData;
|
||||||
import zutil.ui.Configurator;
|
import zutil.ui.Configurator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-02-18.
|
* Created by Ziver on 2015-02-18.
|
||||||
*/
|
*/
|
||||||
public class NexaSelfLearning extends TellstickProtocol implements SwitchEvent {
|
public class NexaSelfLearning extends TellstickProtocol implements SwitchEventData {
|
||||||
|
|
||||||
@Configurator.Configurable("House code")
|
@Configurator.Configurable("House code")
|
||||||
private int house = 0;
|
private int house = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package se.hal.plugin.tellstick.protocols;
|
package se.hal.plugin.tellstick.protocols;
|
||||||
|
|
||||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||||
import se.hal.struct.PowerConsumptionSensor;
|
import se.hal.struct.PowerConsumptionSensorData;
|
||||||
import zutil.ui.Configurator;
|
import zutil.ui.Configurator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-11-19.
|
* Created by Ziver on 2015-11-19.
|
||||||
*/
|
*/
|
||||||
public class Oregon0x1A2D extends TellstickProtocol implements PowerConsumptionSensor {
|
public class Oregon0x1A2D extends TellstickProtocol implements PowerConsumptionSensorData {
|
||||||
|
|
||||||
@Configurator.Configurable("Address")
|
@Configurator.Configurable("Address")
|
||||||
private int address = 0;
|
private int address = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package se.hal.struct;
|
package se.hal.struct;
|
||||||
|
|
||||||
import se.hal.intf.HalSensor;
|
|
||||||
import se.hal.intf.HalSensorController;
|
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.bean.DBBean;
|
import zutil.db.bean.DBBean;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
|
|
||||||
package se.hal.struct;
|
package se.hal.struct;
|
||||||
|
|
||||||
import se.hal.intf.HalEvent;
|
import se.hal.intf.HalEventData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-05-07.
|
* Created by Ziver on 2015-05-07.
|
||||||
*/
|
*/
|
||||||
public abstract class DimmerEvent implements HalEvent {
|
public abstract class DimmerEventData implements HalEventData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,32 +1,22 @@
|
||||||
package se.hal.struct;
|
package se.hal.struct;
|
||||||
|
|
||||||
import se.hal.intf.HalEvent;
|
import se.hal.intf.HalEventData;
|
||||||
import se.hal.intf.HalEventController;
|
import se.hal.intf.HalEventController;
|
||||||
import se.hal.intf.HalSensor;
|
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.bean.DBBean;
|
import zutil.db.bean.DBBean;
|
||||||
import zutil.db.bean.DBBeanSQLResultHandler;
|
import zutil.db.bean.DBBeanSQLResultHandler;
|
||||||
import zutil.io.StringInputStream;
|
|
||||||
import zutil.io.StringOutputStream;
|
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
import zutil.parser.json.JSONObjectInputStream;
|
|
||||||
import zutil.parser.json.JSONObjectOutputStream;
|
|
||||||
import zutil.parser.json.JSONParser;
|
|
||||||
import zutil.parser.json.JSONWriter;
|
|
||||||
import zutil.ui.Configurator;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-12-15.
|
* Created by Ziver on 2015-12-15.
|
||||||
*/
|
*/
|
||||||
@DBBean.DBTable("event")
|
@DBBean.DBTable("event")
|
||||||
public class Event extends AbstractDevice<HalEvent>{
|
public class Event extends AbstractDevice<HalEventData>{
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
package se.hal.struct;
|
|
||||||
|
|
||||||
import se.hal.intf.HalSensor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Ziver on 2015-12-03.
|
|
||||||
*/
|
|
||||||
public interface PowerConsumptionSensor extends HalSensor {
|
|
||||||
}
|
|
||||||
9
src/se/hal/struct/PowerConsumptionSensorData.java
Executable file
9
src/se/hal/struct/PowerConsumptionSensorData.java
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package se.hal.struct;
|
||||||
|
|
||||||
|
import se.hal.intf.HalSensorData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ziver on 2015-12-03.
|
||||||
|
*/
|
||||||
|
public interface PowerConsumptionSensorData extends HalSensorData {
|
||||||
|
}
|
||||||
|
|
@ -1,31 +1,22 @@
|
||||||
package se.hal.struct;
|
package se.hal.struct;
|
||||||
|
|
||||||
import se.hal.HalContext;
|
import se.hal.HalContext;
|
||||||
import se.hal.intf.HalSensor;
|
import se.hal.intf.HalSensorData;
|
||||||
import se.hal.intf.HalSensorController;
|
import se.hal.intf.HalSensorController;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.bean.DBBean;
|
import zutil.db.bean.DBBean;
|
||||||
import zutil.db.bean.DBBeanSQLResultHandler;
|
import zutil.db.bean.DBBeanSQLResultHandler;
|
||||||
import zutil.db.handler.SimpleSQLResult;
|
import zutil.db.handler.SimpleSQLResult;
|
||||||
import zutil.io.StringInputStream;
|
|
||||||
import zutil.io.StringOutputStream;
|
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
import zutil.parser.json.JSONObjectInputStream;
|
|
||||||
import zutil.parser.json.JSONObjectOutputStream;
|
|
||||||
import zutil.parser.json.JSONParser;
|
|
||||||
import zutil.parser.json.JSONWriter;
|
|
||||||
import zutil.ui.Configurator;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
@DBBean.DBTable(value="sensor", superBean=true)
|
@DBBean.DBTable(value="sensor", superBean=true)
|
||||||
public class Sensor extends AbstractDevice<HalSensor>{
|
public class Sensor extends AbstractDevice<HalSensorData>{
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
private long external_id = -1;
|
private long external_id = -1;
|
||||||
|
|
@ -88,7 +79,7 @@ public class Sensor extends AbstractDevice<HalSensor>{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HalSensor.AggregationMethod getAggregationMethod(){
|
public HalSensorData.AggregationMethod getAggregationMethod(){
|
||||||
return getDeviceData().getAggregationMethod();
|
return getDeviceData().getAggregationMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@
|
||||||
|
|
||||||
package se.hal.struct;
|
package se.hal.struct;
|
||||||
|
|
||||||
import se.hal.intf.HalEvent;
|
import se.hal.intf.HalEventData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-05-07.
|
* Created by Ziver on 2015-05-07.
|
||||||
*/
|
*/
|
||||||
public interface SwitchEvent extends HalEvent {
|
public interface SwitchEventData extends HalEventData {
|
||||||
|
|
||||||
boolean isOn();
|
boolean isOn();
|
||||||
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package se.hal.struct;
|
package se.hal.struct;
|
||||||
|
|
||||||
import se.hal.intf.HalSensor;
|
import se.hal.intf.HalSensorData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-12-03.
|
* Created by Ziver on 2015-12-03.
|
||||||
*/
|
*/
|
||||||
public interface TemperatureSensor extends HalSensor {
|
public interface TemperatureSensorData extends HalSensorData {
|
||||||
|
|
||||||
double getTemperature();
|
double getTemperature();
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package se.hal.plugin.tellstick;
|
package se.hal.plugin.tellstick;
|
||||||
|
|
||||||
import se.hal.HalContext;
|
import se.hal.HalContext;
|
||||||
import se.hal.intf.HalSensor;
|
import se.hal.intf.HalSensorData;
|
||||||
import se.hal.intf.HalSensorReportListener;
|
import se.hal.intf.HalSensorReportListener;
|
||||||
import se.hal.plugin.tellstick.protocols.Oregon0x1A2D;
|
import se.hal.plugin.tellstick.protocols.Oregon0x1A2D;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
|
|
@ -32,7 +32,7 @@ public class TelstickSerialCommTest {
|
||||||
TellstickSerialComm comm = new TellstickSerialComm();
|
TellstickSerialComm comm = new TellstickSerialComm();
|
||||||
comm.setListener(new HalSensorReportListener() {
|
comm.setListener(new HalSensorReportListener() {
|
||||||
@Override
|
@Override
|
||||||
public void reportReceived(HalSensor s) {
|
public void reportReceived(HalSensorData s) {
|
||||||
if(s instanceof Oregon0x1A2D){
|
if(s instanceof Oregon0x1A2D){
|
||||||
logger.info("Power used: "+ ((Oregon0x1A2D)s).getTemperature() +" pulses");
|
logger.info("Power used: "+ ((Oregon0x1A2D)s).getTemperature() +" pulses");
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue