Refactoring, moved some files and renamed some classes
Former-commit-id: bdba0e95af5560f5e72cf0e45bed257ca29dc4a2
This commit is contained in:
parent
2bc4607ad1
commit
70f9bb1681
19 changed files with 164 additions and 152 deletions
|
|
@ -7,7 +7,7 @@ import se.koc.hal.plugin.tellstick.TellstickChangeListener;
|
||||||
import se.koc.hal.plugin.tellstick.TellstickProtocol;
|
import se.koc.hal.plugin.tellstick.TellstickProtocol;
|
||||||
import se.koc.hal.plugin.tellstick.TellstickSerialComm;
|
import se.koc.hal.plugin.tellstick.TellstickSerialComm;
|
||||||
import se.koc.hal.plugin.tellstick.protocols.NexaSelfLearning;
|
import se.koc.hal.plugin.tellstick.protocols.NexaSelfLearning;
|
||||||
import se.koc.hal.struct.Switch;
|
import se.koc.hal.struct.SwitchEvent;
|
||||||
import se.koc.hal.intf.HalSpeachToText;
|
import se.koc.hal.intf.HalSpeachToText;
|
||||||
import se.koc.hal.stt.ManualSTTClient;
|
import se.koc.hal.stt.ManualSTTClient;
|
||||||
import se.koc.hal.tts.MaryRemoteTTSClient;
|
import se.koc.hal.tts.MaryRemoteTTSClient;
|
||||||
|
|
@ -24,7 +24,7 @@ import java.util.regex.Pattern;
|
||||||
* Time: 10:59
|
* Time: 10:59
|
||||||
*/
|
*/
|
||||||
public class HALClient{
|
public class HALClient{
|
||||||
private static HashMap<String, Switch> switches = new HashMap<String, Switch>();
|
private static HashMap<String, SwitchEvent> switches = new HashMap<String, SwitchEvent>();
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
|
|
@ -57,22 +57,22 @@ public class HALClient{
|
||||||
NexaSelfLearning nexa1 = new NexaSelfLearning();
|
NexaSelfLearning nexa1 = new NexaSelfLearning();
|
||||||
nexa1.setHouse(15087918);
|
nexa1.setHouse(15087918);
|
||||||
nexa1.setUnit(0);
|
nexa1.setUnit(0);
|
||||||
switches.put("livingroom", new Switch("livingroom", nexa1));
|
switches.put("livingroom", new SwitchEvent("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 Switch("bedroom", nexa2));
|
switches.put("bedroom", new SwitchEvent("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 Switch("kitchen", nexa3));
|
switches.put("kitchen", new SwitchEvent("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(Switch s : switches.values()) {
|
for(SwitchEvent 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);
|
||||||
|
|
@ -122,7 +122,7 @@ public class HALClient{
|
||||||
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(Switch s : switches.values())
|
for(SwitchEvent s : switches.values())
|
||||||
s.turnOn();
|
s.turnOn();
|
||||||
return "I've turned everything on for you";
|
return "I've turned everything on for you";
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +136,7 @@ public class HALClient{
|
||||||
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(Switch s : switches.values())
|
for(SwitchEvent s : switches.values())
|
||||||
s.turnOff();
|
s.turnOff();
|
||||||
return "I turned everything off";
|
return "I turned everything off";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import se.koc.hal.deamon.DataAggregatorDaemon;
|
||||||
import se.koc.hal.deamon.DataDeletionDaemon;
|
import se.koc.hal.deamon.DataDeletionDaemon;
|
||||||
import se.koc.hal.deamon.DataSynchronizationClient;
|
import se.koc.hal.deamon.DataSynchronizationClient;
|
||||||
import se.koc.hal.deamon.DataSynchronizationDaemon;
|
import se.koc.hal.deamon.DataSynchronizationDaemon;
|
||||||
import se.koc.hal.deamon.HalDaemon;
|
import se.koc.hal.intf.HalDaemon;
|
||||||
import se.koc.hal.page.HalHttpPage;
|
import se.koc.hal.intf.HalHttpPage;
|
||||||
import se.koc.hal.page.PCConfigureHttpPage;
|
import se.koc.hal.page.PCConfigureHttpPage;
|
||||||
import se.koc.hal.page.PCHeatMapHttpPage;
|
import se.koc.hal.page.PCHeatMapHttpPage;
|
||||||
import se.koc.hal.page.PCOverviewHttpPage;
|
import se.koc.hal.page.PCOverviewHttpPage;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import se.koc.hal.HalContext;
|
import se.koc.hal.HalContext;
|
||||||
import se.koc.hal.struct.Sensor;
|
import se.koc.hal.intf.HalDaemon;
|
||||||
|
import se.koc.hal.struct.HalSensor;
|
||||||
|
import se.koc.hal.util.TimeUtility;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.SQLResultHandler;
|
import zutil.db.SQLResultHandler;
|
||||||
import zutil.db.handler.SimpleSQLResult;
|
import zutil.db.handler.SimpleSQLResult;
|
||||||
|
|
@ -32,8 +34,8 @@ public class DataAggregatorDaemon extends TimerTask implements HalDaemon {
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
try {
|
try {
|
||||||
List<Sensor> sensorList = Sensor.getLocalSensors(HalContext.getDB());
|
List<HalSensor> sensorList = HalSensor.getLocalSensors(HalContext.getDB());
|
||||||
for(Sensor sensor : sensorList){
|
for(HalSensor sensor : sensorList){
|
||||||
logger.fine("Aggregating sensor_id: " + sensor.getId());
|
logger.fine("Aggregating sensor_id: " + sensor.getId());
|
||||||
aggregateSensor(sensor);
|
aggregateSensor(sensor);
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +45,7 @@ public class DataAggregatorDaemon extends TimerTask implements HalDaemon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void aggregateSensor(Sensor sensor) {
|
public void aggregateSensor(HalSensor sensor) {
|
||||||
logger.fine("The sensor is of type: " + sensor.getType());
|
logger.fine("The sensor is of type: " + sensor.getType());
|
||||||
if(sensor.getType().equals("PowerMeter")){
|
if(sensor.getType().equals("PowerMeter")){
|
||||||
logger.fine("aggregating raw data to five minute periods");
|
logger.fine("aggregating raw data to five minute periods");
|
||||||
|
|
@ -154,8 +156,9 @@ public class DataAggregatorDaemon extends TimerTask implements HalDaemon {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
float confidenceSum = 0;
|
float confidenceSum = 0;
|
||||||
int samples = 0;
|
int samples = 0;
|
||||||
long highestSequenceId = Sensor.getHighestSequenceId(sensorId);
|
long highestSequenceId = HalSensor.getHighestSequenceId(sensorId);
|
||||||
PreparedStatement preparedInsertStmt = HalContext.getDB().getPreparedStatement("INSERT INTO sensor_data_aggr(sensor_id, sequence_id, timestamp_start, timestamp_end, data, confidence) VALUES(?, ?, ?, ?, ?, ?)");
|
PreparedStatement preparedInsertStmt = HalContext.getDB().getPreparedStatement(
|
||||||
|
"INSERT INTO sensor_data_aggr(sensor_id, sequence_id, timestamp_start, timestamp_end, data, confidence) VALUES(?, ?, ?, ?, ?, ?)");
|
||||||
while(result.next()){
|
while(result.next()){
|
||||||
if(sensorId != result.getInt("sensor_id")){
|
if(sensorId != result.getInt("sensor_id")){
|
||||||
throw new IllegalArgumentException("found entry for aggregation for the wrong sensorId (expecting: "+sensorId+", but was: "+result.getInt("sensor_id")+")");
|
throw new IllegalArgumentException("found entry for aggregation for the wrong sensorId (expecting: "+sensorId+", but was: "+result.getInt("sensor_id")+")");
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import se.koc.hal.HalContext;
|
import se.koc.hal.HalContext;
|
||||||
import se.koc.hal.struct.Sensor;
|
import se.koc.hal.intf.HalDaemon;
|
||||||
|
import se.koc.hal.struct.HalSensor;
|
||||||
|
import se.koc.hal.util.TimeUtility;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.SQLResultHandler;
|
import zutil.db.SQLResultHandler;
|
||||||
import zutil.db.handler.SimpleSQLResult;
|
import zutil.db.handler.SimpleSQLResult;
|
||||||
|
|
@ -27,8 +29,8 @@ public class DataDeletionDaemon extends TimerTask implements HalDaemon {
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
try {
|
try {
|
||||||
List<Sensor> sensorList = Sensor.getSensors(HalContext.getDB());
|
List<HalSensor> sensorList = HalSensor.getSensors(HalContext.getDB());
|
||||||
for(Sensor sensor : sensorList){
|
for(HalSensor sensor : sensorList){
|
||||||
logger.fine("Deleting old data for sensor id: " + sensor.getId());
|
logger.fine("Deleting old data for sensor id: " + sensor.getId());
|
||||||
cleanupSensor(sensor);
|
cleanupSensor(sensor);
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +40,7 @@ public class DataDeletionDaemon extends TimerTask implements HalDaemon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanupSensor(Sensor sensor) {
|
public void cleanupSensor(HalSensor sensor) {
|
||||||
logger.fine("The sensor is of type: " + sensor.getType());
|
logger.fine("The sensor is of type: " + sensor.getType());
|
||||||
if(sensor.getType().equals("PowerMeter")){
|
if(sensor.getType().equals("PowerMeter")){
|
||||||
//if(sensor.isInternal()){ //TODO
|
//if(sensor.isInternal()){ //TODO
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ import java.util.logging.Logger;
|
||||||
import se.koc.hal.HalContext;
|
import se.koc.hal.HalContext;
|
||||||
import se.koc.hal.deamon.DataSynchronizationDaemon.SensorDataDTO;
|
import se.koc.hal.deamon.DataSynchronizationDaemon.SensorDataDTO;
|
||||||
import se.koc.hal.deamon.DataSynchronizationDaemon.SensorDataListDTO;
|
import se.koc.hal.deamon.DataSynchronizationDaemon.SensorDataListDTO;
|
||||||
import se.koc.hal.struct.Sensor;
|
import se.koc.hal.intf.HalDaemon;
|
||||||
|
import se.koc.hal.struct.HalSensor;
|
||||||
import se.koc.hal.struct.User;
|
import se.koc.hal.struct.User;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
|
|
@ -46,12 +47,12 @@ public class DataSynchronizationClient extends TimerTask implements HalDaemon{
|
||||||
ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
|
ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
|
||||||
ObjectInputStream in = new ObjectInputStream(s.getInputStream());
|
ObjectInputStream in = new ObjectInputStream(s.getInputStream());
|
||||||
|
|
||||||
List<Sensor> sensors = Sensor.getSensors(db, user);
|
List<HalSensor> sensors = HalSensor.getSensors(db, user);
|
||||||
for(Sensor sensor : sensors){
|
for(HalSensor sensor : sensors){
|
||||||
if(sensor.isSynced()) {
|
if(sensor.isSynced()) {
|
||||||
PeerDataReqDTO req = new PeerDataReqDTO();
|
PeerDataReqDTO req = new PeerDataReqDTO();
|
||||||
req.sensorId = sensor.getExternalId();
|
req.sensorId = sensor.getExternalId();
|
||||||
req.offsetSequenceId = Sensor.getHighestSequenceId(sensor.getId());
|
req.offsetSequenceId = HalSensor.getHighestSequenceId(sensor.getId());
|
||||||
out.writeObject(req);
|
out.writeObject(req);
|
||||||
|
|
||||||
SensorDataListDTO dataList = (SensorDataListDTO) in.readObject();
|
SensorDataListDTO dataList = (SensorDataListDTO) in.readObject();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import se.koc.hal.HalContext;
|
import se.koc.hal.HalContext;
|
||||||
import se.koc.hal.deamon.DataSynchronizationClient.PeerDataReqDTO;
|
import se.koc.hal.deamon.DataSynchronizationClient.PeerDataReqDTO;
|
||||||
|
import se.koc.hal.intf.HalDaemon;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.SQLResultHandler;
|
import zutil.db.SQLResultHandler;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package se.koc.hal.deamon;
|
package se.koc.hal.intf;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package se.koc.hal.page;
|
package se.koc.hal.intf;
|
||||||
|
|
||||||
import se.koc.hal.HalContext;
|
import se.koc.hal.HalContext;
|
||||||
import se.koc.hal.struct.Sensor;
|
|
||||||
import se.koc.hal.struct.User;
|
import se.koc.hal.struct.User;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.io.file.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
|
|
@ -11,7 +10,6 @@ import zutil.net.http.HttpPrintStream;
|
||||||
import zutil.parser.Templator;
|
import zutil.parser.Templator;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -3,7 +3,8 @@ package se.koc.hal.page;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import se.koc.hal.HalContext;
|
import se.koc.hal.HalContext;
|
||||||
import se.koc.hal.struct.Sensor;
|
import se.koc.hal.intf.HalHttpPage;
|
||||||
|
import se.koc.hal.struct.HalSensor;
|
||||||
import se.koc.hal.struct.User;
|
import se.koc.hal.struct.User;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.io.file.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
|
|
@ -29,7 +30,7 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
||||||
if(request.containsKey("action")){
|
if(request.containsKey("action")){
|
||||||
String action = request.get("action");
|
String action = request.get("action");
|
||||||
int id = (request.containsKey("id") ? Integer.parseInt(request.get("id")) : -1);
|
int id = (request.containsKey("id") ? Integer.parseInt(request.get("id")) : -1);
|
||||||
Sensor sensor;
|
HalSensor sensor;
|
||||||
User user;
|
User user;
|
||||||
switch(action) {
|
switch(action) {
|
||||||
// Local User
|
// Local User
|
||||||
|
|
@ -41,7 +42,7 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
||||||
|
|
||||||
// Local Sensors
|
// Local Sensors
|
||||||
case "create_local_sensor":
|
case "create_local_sensor":
|
||||||
sensor = new Sensor();
|
sensor = new HalSensor();
|
||||||
sensor.setName(request.get("name"));
|
sensor.setName(request.get("name"));
|
||||||
sensor.setType(request.get("type"));
|
sensor.setType(request.get("type"));
|
||||||
sensor.setConfig(request.get("config"));
|
sensor.setConfig(request.get("config"));
|
||||||
|
|
@ -49,7 +50,7 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
||||||
sensor.setSynced(true);
|
sensor.setSynced(true);
|
||||||
sensor.save(db);
|
sensor.save(db);
|
||||||
case "modify_local_sensor":
|
case "modify_local_sensor":
|
||||||
sensor = Sensor.getSensor(db, id);
|
sensor = HalSensor.getSensor(db, id);
|
||||||
if(sensor != null){
|
if(sensor != null){
|
||||||
sensor.setName(request.get("name"));
|
sensor.setName(request.get("name"));
|
||||||
sensor.setType(request.get("type"));
|
sensor.setType(request.get("type"));
|
||||||
|
|
@ -58,7 +59,7 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "remove_local_sensor":
|
case "remove_local_sensor":
|
||||||
sensor = Sensor.getSensor(db, id);
|
sensor = HalSensor.getSensor(db, id);
|
||||||
if(sensor != null)
|
if(sensor != null)
|
||||||
sensor.delete(db);
|
sensor.delete(db);
|
||||||
break;
|
break;
|
||||||
|
|
@ -87,7 +88,7 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
||||||
|
|
||||||
// External Sensors
|
// External Sensors
|
||||||
case "modify_external_sensor":
|
case "modify_external_sensor":
|
||||||
sensor = Sensor.getSensor(db, id);
|
sensor = HalSensor.getSensor(db, id);
|
||||||
if(sensor != null){
|
if(sensor != null){
|
||||||
sensor.setSynced(Boolean.parseBoolean(request.get("sync")));
|
sensor.setSynced(Boolean.parseBoolean(request.get("sync")));
|
||||||
sensor.save(db);
|
sensor.save(db);
|
||||||
|
|
@ -99,9 +100,9 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
||||||
// Output
|
// Output
|
||||||
Templator tmpl = new Templator(FileUtil.find("web-resource/configure.tmpl"));
|
Templator tmpl = new Templator(FileUtil.find("web-resource/configure.tmpl"));
|
||||||
tmpl.set("user", localUser);
|
tmpl.set("user", localUser);
|
||||||
tmpl.set("localSensor", Sensor.getLocalSensors(db));
|
tmpl.set("localSensor", HalSensor.getLocalSensors(db));
|
||||||
tmpl.set("extUsers", User.getExternalUsers(db));
|
tmpl.set("extUsers", User.getExternalUsers(db));
|
||||||
tmpl.set("extSensor", Sensor.getExternalSensors(db));
|
tmpl.set("extSensor", HalSensor.getExternalSensors(db));
|
||||||
|
|
||||||
return tmpl;
|
return tmpl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
package se.koc.hal.page;
|
package se.koc.hal.page;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import se.koc.hal.intf.HalHttpPage;
|
||||||
import zutil.io.file.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
import zutil.net.http.HttpHeaderParser;
|
|
||||||
import zutil.net.http.HttpPage;
|
|
||||||
import zutil.net.http.HttpPrintStream;
|
|
||||||
import zutil.parser.Templator;
|
import zutil.parser.Templator;
|
||||||
|
|
||||||
public class PCHeatMapHttpPage extends HalHttpPage {
|
public class PCHeatMapHttpPage extends HalHttpPage {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import se.koc.hal.HalContext;
|
import se.koc.hal.HalContext;
|
||||||
import se.koc.hal.deamon.TimeUtility;
|
import se.koc.hal.util.TimeUtility;
|
||||||
|
import se.koc.hal.intf.HalHttpPage;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.SQLResultHandler;
|
import zutil.db.SQLResultHandler;
|
||||||
import zutil.io.file.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
|
|
|
||||||
|
|
@ -25,5 +25,5 @@ package se.koc.hal.struct;
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-05-07.
|
* Created by Ziver on 2015-05-07.
|
||||||
*/
|
*/
|
||||||
public class Dimmer {
|
public class DimmerEvent extends HalEvent{
|
||||||
}
|
}
|
||||||
7
src/se/koc/hal/struct/HalEvent.java
Executable file
7
src/se/koc/hal/struct/HalEvent.java
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
package se.koc.hal.struct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ziver on 2015-12-15.
|
||||||
|
*/
|
||||||
|
public class HalEvent {
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ import zutil.db.bean.DBBeanSQLResultHandler;
|
||||||
import zutil.db.handler.SimpleSQLResult;
|
import zutil.db.handler.SimpleSQLResult;
|
||||||
|
|
||||||
@DBBean.DBTable("sensor")
|
@DBBean.DBTable("sensor")
|
||||||
public class Sensor extends DBBean{
|
public class HalSensor extends DBBean{
|
||||||
// Sensor specific data
|
// Sensor specific data
|
||||||
private String name;
|
private String name;
|
||||||
private String type;
|
private String type;
|
||||||
|
|
@ -25,29 +25,29 @@ public class Sensor extends DBBean{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static List<Sensor> getExternalSensors(DBConnection db) throws SQLException{
|
public static List<HalSensor> getExternalSensors(DBConnection db) throws SQLException{
|
||||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT sensor.* FROM sensor,user WHERE user.external == 1 AND user.id == sensor.user_id" );
|
PreparedStatement stmt = db.getPreparedStatement( "SELECT sensor.* FROM sensor,user WHERE user.external == 1 AND user.id == sensor.user_id" );
|
||||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Sensor.class, db) );
|
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(HalSensor.class, db) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Sensor> getLocalSensors(DBConnection db) throws SQLException{
|
public static List<HalSensor> getLocalSensors(DBConnection db) throws SQLException{
|
||||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT sensor.* FROM sensor,user WHERE user.external == 0 AND user.id == sensor.user_id" );
|
PreparedStatement stmt = db.getPreparedStatement( "SELECT sensor.* FROM sensor,user WHERE user.external == 0 AND user.id == sensor.user_id" );
|
||||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Sensor.class, db) );
|
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(HalSensor.class, db) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Sensor> getSensors(DBConnection db, User user) throws SQLException{
|
public static List<HalSensor> getSensors(DBConnection db, User user) throws SQLException{
|
||||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM sensor WHERE user_id == ?" );
|
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM sensor WHERE user_id == ?" );
|
||||||
stmt.setLong(1, user.getId());
|
stmt.setLong(1, user.getId());
|
||||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Sensor.class, db) );
|
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(HalSensor.class, db) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Sensor> getSensors(DBConnection db) throws SQLException{
|
public static List<HalSensor> getSensors(DBConnection db) throws SQLException{
|
||||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM sensor" );
|
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM sensor" );
|
||||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Sensor.class, db) );
|
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(HalSensor.class, db) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Sensor getSensor(DBConnection db, int id) throws SQLException{
|
public static HalSensor getSensor(DBConnection db, int id) throws SQLException{
|
||||||
return DBBean.load(db, Sensor.class, id);
|
return DBBean.load(db, HalSensor.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,5 +3,5 @@ package se.koc.hal.struct;
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-12-03.
|
* Created by Ziver on 2015-12-03.
|
||||||
*/
|
*/
|
||||||
public class PowerMeterSensor extends Sensor{
|
public class PowerConsumptionSensor extends HalSensor {
|
||||||
}
|
}
|
||||||
|
|
@ -28,12 +28,12 @@ import se.koc.hal.plugin.tellstick.protocols.NexaSelfLearning;
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-05-07.
|
* Created by Ziver on 2015-05-07.
|
||||||
*/
|
*/
|
||||||
public class Switch {
|
public class SwitchEvent extends HalEvent{
|
||||||
private String name;
|
private String name;
|
||||||
private NexaSelfLearning nexa;
|
private NexaSelfLearning nexa;
|
||||||
|
|
||||||
|
|
||||||
public Switch(String name, NexaSelfLearning nexa){
|
public SwitchEvent(String name, NexaSelfLearning nexa){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.nexa = nexa;
|
this.nexa = nexa;
|
||||||
}
|
}
|
||||||
|
|
@ -3,5 +3,5 @@ package se.koc.hal.struct;
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2015-12-03.
|
* Created by Ziver on 2015-12-03.
|
||||||
*/
|
*/
|
||||||
public class TemperatureSensor extends Sensor {
|
public class TemperatureSensor extends HalSensor {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
src/se/koc/hal/deamon/TimeUtility.java → src/se/koc/hal/util/TimeUtility.java
Normal file → Executable file
2
src/se/koc/hal/deamon/TimeUtility.java → src/se/koc/hal/util/TimeUtility.java
Normal file → Executable file
|
|
@ -1,4 +1,4 @@
|
||||||
package se.koc.hal.deamon;
|
package se.koc.hal.util;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
3
test/se/koc/hal/deamon/TimeUtilityTest.java → test/se/koc/hal/util/TimeUtilityTest.java
Normal file → Executable file
3
test/se/koc/hal/deamon/TimeUtilityTest.java → test/se/koc/hal/util/TimeUtilityTest.java
Normal file → Executable file
|
|
@ -1,4 +1,4 @@
|
||||||
package se.koc.hal.deamon;
|
package se.koc.hal.util;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
@ -6,6 +6,7 @@ import java.util.Calendar;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import se.koc.hal.util.TimeUtility;
|
||||||
|
|
||||||
public class TimeUtilityTest {
|
public class TimeUtilityTest {
|
||||||
private long currentTime;
|
private long currentTime;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue