Updated with new Configurator changes and cleaned up imports
This commit is contained in:
parent
6109f66ea0
commit
e1618604c9
66 changed files with 297 additions and 198 deletions
|
|
@ -6,13 +6,13 @@ import se.hal.util.HalDeviceUtil;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.plugin.PluginManager;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.Configurator.PostConfigurationActionListener;
|
||||
import zutil.ui.Configurator.PreConfigurationActionListener;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,13 @@ import zutil.log.LogUtil;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package se.hal;
|
||||
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.page.*;
|
||||
import se.hal.intf.HalAbstractControllerManager;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.intf.HalJsonPage;
|
||||
import se.hal.intf.HalWebPage;
|
||||
import se.hal.page.HalAlertManager;
|
||||
import se.hal.struct.PluginConfig;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.io.file.FileUtil;
|
||||
|
|
@ -14,7 +17,9 @@ import zutil.plugin.PluginData;
|
|||
import zutil.plugin.PluginManager;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.logging.Level;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@ import se.hal.util.HalDeviceUtil;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.plugin.PluginManager;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.Configurator.PostConfigurationActionListener;
|
||||
import zutil.ui.Configurator.PreConfigurationActionListener;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import se.hal.HalContext;
|
|||
import se.hal.intf.HalAction;
|
||||
import se.hal.intf.HalEventData;
|
||||
import se.hal.struct.Event;
|
||||
import se.hal.util.ConfigEventValueProvider;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
|
@ -18,8 +19,8 @@ import java.util.logging.Logger;
|
|||
public class SendEventAction implements HalAction {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
@Configurator.Configurable("Event Device ID")
|
||||
private int eventId;
|
||||
@Configurator.Configurable(value = "Event Device", valueProvider = ConfigEventValueProvider.class)
|
||||
private Event event;
|
||||
@Configurator.Configurable("Data to Send")
|
||||
private double data;
|
||||
|
||||
|
|
@ -28,7 +29,6 @@ public class SendEventAction implements HalAction {
|
|||
public void execute() {
|
||||
try {
|
||||
DBConnection db = HalContext.getDB();
|
||||
Event event = Event.getEvent(db, eventId);
|
||||
if (event != null) {
|
||||
HalEventData dataObj = (HalEventData) event.getDeviceConfig().getDeviceDataClass().newInstance();
|
||||
dataObj.setData(data);
|
||||
|
|
@ -37,7 +37,7 @@ public class SendEventAction implements HalAction {
|
|||
EventControllerManager.getInstance().send(event);
|
||||
}
|
||||
else
|
||||
logger.warning("Unable to find event with id: "+ eventId);
|
||||
logger.warning("Unable to find event with id: "+ event.getId());
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, null, e);
|
||||
}
|
||||
|
|
@ -45,11 +45,8 @@ public class SendEventAction implements HalAction {
|
|||
|
||||
|
||||
public String toString(){
|
||||
DBConnection db = HalContext.getDB();
|
||||
Event event = null;
|
||||
try{ event = Event.getEvent(db, eventId); } catch (Exception e){} //ignore exception
|
||||
return "Send event: "+ eventId +
|
||||
return "Send event: " + event.getId() +
|
||||
" (" + (event!=null ? event.getName() : null) + ")" +
|
||||
" with data: "+ data;
|
||||
" with data: " + data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ import zutil.db.SQLResultHandler;
|
|||
import zutil.db.handler.SimpleSQLResult;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.UserMessageManager;
|
||||
import zutil.ui.UserMessageManager.*;
|
||||
import zutil.ui.UserMessageManager.MessageTTL;
|
||||
import zutil.ui.UserMessageManager.UserMessage;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import zutil.ClassUtil;
|
|||
import zutil.log.LogUtil;
|
||||
import zutil.plugin.PluginManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import zutil.db.bean.DBBean;
|
|||
import zutil.log.LogUtil;
|
||||
import zutil.parser.json.JSONParser;
|
||||
import zutil.parser.json.JSONWriter;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import zutil.net.http.HttpHeader;
|
|||
import zutil.net.http.HttpPage;
|
||||
import zutil.net.http.HttpPrintStream;
|
||||
import zutil.parser.Templator;
|
||||
import zutil.parser.json.JSONWriter;
|
||||
import zutil.ui.Navigation;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ import zutil.db.DBConnection;
|
|||
import zutil.io.file.FileUtil;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.parser.Templator;
|
||||
import zutil.ui.UserMessageManager.*;
|
||||
import zutil.ui.UserMessageManager.MessageLevel;
|
||||
import zutil.ui.UserMessageManager.MessageTTL;
|
||||
import zutil.ui.UserMessageManager.UserMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import zutil.ui.UserMessageManager;
|
|||
import zutil.ui.UserMessageManager.UserMessage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package se.hal.page;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.HalJsonPage;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import se.hal.intf.HalJsonPage;
|
||||
import se.hal.struct.Event;
|
||||
import se.hal.struct.Sensor;
|
||||
import zutil.db.DBConnection;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ package se.hal.page;
|
|||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.HalWebPage;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.io.file.FileUtil;
|
||||
import zutil.parser.Templator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class PropertyConfigWebPage extends HalWebPage {
|
||||
private static final String TEMPLATE = HalContext.RESOURCE_WEB_ROOT + "/property_config.tmpl";
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import se.hal.util.UTCTimeUtility;
|
|||
import zutil.ArrayUtil;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.net.http.HttpHeader;
|
||||
import zutil.net.http.HttpPrintStream;
|
||||
import zutil.parser.DataNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import zutil.io.file.FileUtil;
|
|||
import zutil.parser.Templator;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import zutil.db.DBConnection;
|
|||
import zutil.io.file.FileUtil;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.parser.Templator;
|
||||
import zutil.ui.UserMessageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import zutil.db.DBConnection;
|
|||
import zutil.io.file.FileUtil;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.parser.Templator;
|
||||
import zutil.ui.UserMessageManager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,11 @@
|
|||
package se.hal.struct;
|
||||
|
||||
import se.hal.intf.HalAction;
|
||||
import se.hal.intf.HalTrigger;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
import zutil.db.bean.DBBeanObjectDSO;
|
||||
import zutil.db.bean.DBBeanSQLResultHandler;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Defines a action that will be executed
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package se.hal.struct;
|
||||
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.Configurator.ConfigurationParam;
|
||||
import zutil.ui.conf.Configurator;
|
||||
import zutil.ui.conf.Configurator.ConfigurationParam;
|
||||
|
||||
/**
|
||||
* A Data class used by the dynamic class configuration pages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package se.hal.struct;
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalEventData;
|
||||
import se.hal.util.DeviceDataSqlResult;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,8 @@ import se.hal.intf.HalTrigger;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
import zutil.db.bean.DBBeanObjectDSO;
|
||||
import zutil.db.bean.DBBeanSQLResultHandler;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A class that declares a trigger/condition that
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ package se.hal.trigger;
|
|||
|
||||
import se.hal.intf.HalTrigger;
|
||||
import zutil.CronTimer;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.Configurator.PreConfigurationActionListener;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
|
||||
public class DateTimeTrigger implements HalTrigger,Configurator.PostConfigurationActionListener {
|
||||
|
||||
@Configurator.Configurable("Minute (Cron format)")
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package se.hal.trigger;
|
||||
|
||||
import se.hal.TriggerManager;
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalDeviceData;
|
||||
import se.hal.intf.HalDeviceReportListener;
|
||||
import se.hal.intf.HalTrigger;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.Configurator.PostConfigurationActionListener;
|
||||
import zutil.ui.Configurator.PreConfigurationActionListener;
|
||||
import se.hal.intf.*;
|
||||
import zutil.ui.conf.Configurator;
|
||||
import zutil.ui.conf.Configurator.PostConfigurationActionListener;
|
||||
import zutil.ui.conf.Configurator.PreConfigurationActionListener;
|
||||
|
||||
/**
|
||||
* An abstract class that implements generic device data logic
|
||||
|
|
@ -18,8 +14,6 @@ public abstract class DeviceTrigger implements HalTrigger,
|
|||
PostConfigurationActionListener,
|
||||
HalDeviceReportListener<HalDeviceConfig,HalDeviceData> {
|
||||
|
||||
@Configurator.Configurable("Device ID")
|
||||
protected int deviceId = -1;
|
||||
@Configurator.Configurable("Trigger only on change")
|
||||
protected boolean triggerOnChange = true;
|
||||
@Configurator.Configurable("Data to compare to")
|
||||
|
|
@ -31,14 +25,14 @@ public abstract class DeviceTrigger implements HalTrigger,
|
|||
|
||||
@Override
|
||||
public void preConfigurationAction(Configurator configurator, Object obj) {
|
||||
HalAbstractDevice device = getDevice(deviceId);
|
||||
HalAbstractDevice device = getDevice();
|
||||
if (device != null)
|
||||
device.removeReportListener(this);
|
||||
reset();
|
||||
}
|
||||
@Override
|
||||
public void postConfigurationAction(Configurator configurator, Object obj) {
|
||||
HalAbstractDevice device = getDevice(deviceId);
|
||||
HalAbstractDevice device = getDevice();
|
||||
if (device != null)
|
||||
device.addReportListener(this);
|
||||
}
|
||||
|
|
@ -67,5 +61,5 @@ public abstract class DeviceTrigger implements HalTrigger,
|
|||
|
||||
|
||||
|
||||
protected abstract HalAbstractDevice getDevice(long id);
|
||||
protected abstract HalAbstractDevice getDevice();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
package se.hal.trigger;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.struct.Event;
|
||||
import se.hal.util.ConfigEventValueProvider;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class EventTrigger extends DeviceTrigger{
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
@Configurator.Configurable(value = "Event", valueProvider = ConfigEventValueProvider.class)
|
||||
protected Event device;
|
||||
|
||||
|
||||
@Override
|
||||
protected Event getDevice(long id) {
|
||||
try {
|
||||
if (id >= 0)
|
||||
return Event.getEvent(HalContext.getDB(), id);
|
||||
} catch (SQLException e){ logger.log(Level.SEVERE, null, e);}
|
||||
return null;
|
||||
protected Event getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
Event event = getDevice(deviceId);
|
||||
Event event = getDevice();
|
||||
return "Trigger " + (triggerOnChange ? "on" : "when") +
|
||||
" event: "+ deviceId +" ("+(event != null ? event.getName() : null) + ")" +
|
||||
" == "+ expectedData;
|
||||
" event: " + device.getId() + " (" + (event != null ? event.getName() : null) + ")" +
|
||||
" == " + expectedData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +1,30 @@
|
|||
package se.hal.trigger;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.struct.Event;
|
||||
import se.hal.struct.Sensor;
|
||||
import se.hal.util.ConfigSensorValueProvider;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SensorTrigger extends DeviceTrigger{
|
||||
public class SensorTrigger extends DeviceTrigger {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
@Configurator.Configurable(value = "Sensor", valueProvider = ConfigSensorValueProvider.class)
|
||||
protected Sensor device;
|
||||
|
||||
|
||||
@Override
|
||||
protected Sensor getDevice(long id) {
|
||||
try {
|
||||
if (id >= 0)
|
||||
return Sensor.getSensor(HalContext.getDB(), id);
|
||||
} catch (SQLException e){ logger.log(Level.SEVERE, null, e);}
|
||||
return null;
|
||||
protected Sensor getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
Sensor sensor = getDevice(deviceId);
|
||||
Sensor sensor = getDevice();
|
||||
return "Trigger " + (triggerOnChange ? "on" : "when") +
|
||||
" sensor: "+ deviceId +" ("+(sensor != null ? sensor.getName() : null) + ")" +
|
||||
" == "+ expectedData;
|
||||
" sensor: " + sensor.getId() +" (" + (sensor != null ? sensor.getName() : null) + ")" +
|
||||
" == " + expectedData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package se.hal.trigger;
|
|||
|
||||
import se.hal.intf.HalTrigger;
|
||||
import zutil.Timer;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
public class TimerTrigger implements HalTrigger {
|
||||
|
||||
|
|
|
|||
55
hal-core/src/se/hal/util/ConfigEventValueProvider.java
Normal file
55
hal-core/src/se/hal/util/ConfigEventValueProvider.java
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
package se.hal.util;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.struct.Event;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A value provider that will give all Enum values
|
||||
*/
|
||||
public class ConfigEventValueProvider implements Configurator.ConfigValueProvider<Event> {
|
||||
private Event currentValue;
|
||||
private Map<String, Event> events = new HashMap<>();
|
||||
|
||||
|
||||
public ConfigEventValueProvider(Class<Enum> fieldType, Object fieldValue) {
|
||||
this.currentValue = (Event) fieldValue;
|
||||
|
||||
try {
|
||||
DBConnection db = HalContext.getDB();
|
||||
|
||||
for (Event event : Event.getLocalEvents(db)) {
|
||||
events.put(getValue(event), event);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("Unable to collect Event objects.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getValue(Event event) {
|
||||
return event.getName() + " (id: " + event.getId() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentValue() {
|
||||
return getValue(currentValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
return new ArrayList<String>(events.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event getObject(String value) {
|
||||
return events.get(value);
|
||||
}
|
||||
}
|
||||
55
hal-core/src/se/hal/util/ConfigSensorValueProvider.java
Normal file
55
hal-core/src/se/hal/util/ConfigSensorValueProvider.java
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
package se.hal.util;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.struct.Sensor;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A value provider that will give all Enum values
|
||||
*/
|
||||
public class ConfigSensorValueProvider implements Configurator.ConfigValueProvider<Sensor> {
|
||||
private Sensor currentValue;
|
||||
private Map<String, Sensor> sensors = new HashMap<>();
|
||||
|
||||
|
||||
public ConfigSensorValueProvider(Class<Enum> fieldType, Object fieldValue) {
|
||||
this.currentValue = (Sensor) fieldValue;
|
||||
|
||||
try {
|
||||
DBConnection db = HalContext.getDB();
|
||||
|
||||
for (Sensor sensor : Sensor.getLocalSensors(db)) {
|
||||
sensors.put(getValue(sensor), sensor);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("Unable to collect Event objects.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getValue(Sensor sensor) {
|
||||
return sensor.getName() + " (id: " + sensor.getId() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentValue() {
|
||||
return getValue(currentValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPossibleValues() {
|
||||
return new ArrayList<String>(sensors.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sensor getObject(String value) {
|
||||
return sensors.get(value);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package se.hal.util;
|
||||
|
||||
import se.hal.intf.HalDeviceData;
|
||||
import zutil.ClassUtil;
|
||||
import zutil.db.SQLResultHandler;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import se.hal.HalServer;
|
|||
import se.hal.intf.HalAbstractControllerManager;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import se.hal.struct.devicedata.TemperatureSensorData;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class SensorControllerManagerTest {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ import se.hal.struct.TriggerFlow;
|
|||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
package se.hal.daemon;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.util.UTCTimeUtility;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.DBUpgradeHandler;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
public class SensorDataAggregationDaemonTest {
|
||||
private static final String DEFAULT_DB_FILE = "resource/resource/hal-default.db";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package se.hal.test;
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import se.hal.daemon.SensorDataAggregatorDaemon.AggregationPeriodLength;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import se.hal.daemon.SensorDataAggregatorDaemon.AggregationPeriodLength;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -18,8 +17,8 @@ import static org.junit.Assert.assertTrue;
|
|||
@RunWith(Parameterized.class)
|
||||
public class TimeUtilityTest {
|
||||
private final long currentTime_UTC;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param timestamp
|
||||
|
|
@ -27,7 +26,7 @@ public class TimeUtilityTest {
|
|||
public TimeUtilityTest(long timestamp){
|
||||
this.currentTime_UTC = timestamp;
|
||||
}
|
||||
|
||||
|
||||
@Parameters
|
||||
public static Collection<Object[]> data(){
|
||||
return Arrays.asList(new Object[][] {
|
||||
|
|
@ -50,15 +49,15 @@ public class TimeUtilityTest {
|
|||
{Long.MAX_VALUE-(60*UTCTimeUtility.WEEK_IN_MS)}, //max time - 60w
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes year
|
||||
@Test
|
||||
public void testYear_UTC(){
|
||||
public void testYear_UTC(){
|
||||
System.out.println("Testing year with timestamp " + currentTime_UTC + " " + UTCTimeUtility.getDateString(currentTime_UTC));
|
||||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.YEAR, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.YEAR, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" year start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("perdiod start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -80,18 +79,18 @@ public class TimeUtilityTest {
|
|||
assertEquals("period end day is wrong", 31, UTCTimeUtility.getDayOfMonthFromTimestamp(thisPeriodEndedAt));
|
||||
assertEquals("period end month is wrong", Calendar.DECEMBER, UTCTimeUtility.getMonthOfYearFromTimestamp(thisPeriodEndedAt));
|
||||
assertEquals("period end year is wrong", UTCTimeUtility.getYearFromTimestamp(currentTime_UTC), UTCTimeUtility.getYearFromTimestamp(thisPeriodEndedAt));
|
||||
|
||||
|
||||
//verify that start and end values are reasonable
|
||||
assertTrue("start is zero", thisPeriodStartedAt != 0);
|
||||
assertTrue("end is zero", thisPeriodEndedAt != 0);
|
||||
assertTrue("start is not before end", thisPeriodStartedAt < thisPeriodEndedAt );
|
||||
assertTrue("start and end are equal", thisPeriodStartedAt != thisPeriodEndedAt );
|
||||
|
||||
|
||||
//verify that the period start and end is in the same period
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.YEAR, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.YEAR, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes month
|
||||
@Test
|
||||
public void testMonth_UTC(){
|
||||
|
|
@ -101,7 +100,7 @@ public class TimeUtilityTest {
|
|||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MONTH, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MONTH, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" month start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("perdiod start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -129,12 +128,12 @@ public class TimeUtilityTest {
|
|||
assertTrue("end is zero", thisPeriodEndedAt != 0);
|
||||
assertTrue("start is not before end", thisPeriodStartedAt < thisPeriodEndedAt );
|
||||
assertTrue("start and end are equal", thisPeriodStartedAt != thisPeriodEndedAt );
|
||||
|
||||
|
||||
//verify that the period start and end is in the same period
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MONTH, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MONTH, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes week
|
||||
@Test
|
||||
public void testWeek_UTC(){
|
||||
|
|
@ -142,7 +141,7 @@ public class TimeUtilityTest {
|
|||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.WEEK, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.WEEK, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" week start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -175,8 +174,8 @@ public class TimeUtilityTest {
|
|||
//verify that the period start and end is in the same period
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.WEEK, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.WEEK, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes day
|
||||
@Test
|
||||
public void testDay_UTC(){
|
||||
|
|
@ -184,7 +183,7 @@ public class TimeUtilityTest {
|
|||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.DAY, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.DAY, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" day start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -218,7 +217,7 @@ public class TimeUtilityTest {
|
|||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.DAY, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.DAY, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes hour
|
||||
@Test
|
||||
public void testHour_UTC(){
|
||||
|
|
@ -226,7 +225,7 @@ public class TimeUtilityTest {
|
|||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.HOUR, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.HOUR, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" hour start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -260,7 +259,7 @@ public class TimeUtilityTest {
|
|||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.HOUR, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.HOUR, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes 15-minute period
|
||||
@Test
|
||||
public void testFifteenMinute_UTC(){
|
||||
|
|
@ -268,7 +267,7 @@ public class TimeUtilityTest {
|
|||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIFTEEN_MINUTES, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIFTEEN_MINUTES, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" 15-min start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -305,15 +304,15 @@ public class TimeUtilityTest {
|
|||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIFTEEN_MINUTES, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIFTEEN_MINUTES, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes 5-minute period
|
||||
@Test
|
||||
public void testFiveMinute_UTC(){
|
||||
System.out.println("Testing 5-min with timestamp " + currentTime_UTC + " " + UTCTimeUtility.getDateString(currentTime_UTC));
|
||||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIVE_MINUTES, currentTime_UTC);
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIVE_MINUTES, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIVE_MINUTES, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" 5-min start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -350,7 +349,7 @@ public class TimeUtilityTest {
|
|||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIVE_MINUTES, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIVE_MINUTES, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes minute
|
||||
@Test
|
||||
public void testMinute_UTC(){
|
||||
|
|
@ -358,7 +357,7 @@ public class TimeUtilityTest {
|
|||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MINUTE, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MINUTE, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" minute start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -391,7 +390,7 @@ public class TimeUtilityTest {
|
|||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MINUTE, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MINUTE, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
|
||||
// Test flooring & ceiling UTC time to the closes second
|
||||
@Test
|
||||
public void testSecond_UTC(){
|
||||
|
|
@ -399,7 +398,7 @@ public class TimeUtilityTest {
|
|||
|
||||
long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.SECOND, currentTime_UTC);
|
||||
long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.SECOND, currentTime_UTC);
|
||||
|
||||
|
||||
//verify period start is correct
|
||||
System.out.println(" second start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt));
|
||||
assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC);
|
||||
|
|
@ -432,9 +431,9 @@ public class TimeUtilityTest {
|
|||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.SECOND, thisPeriodEndedAt));
|
||||
assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.SECOND, thisPeriodStartedAt));
|
||||
}
|
||||
|
||||
|
||||
// Test printing converting milliseconds to text
|
||||
@Test
|
||||
@Test
|
||||
public void testMsToString(){
|
||||
//low values
|
||||
assertEquals("00:00:00.000", UTCTimeUtility.timeInMsToString(0));
|
||||
|
|
@ -452,23 +451,23 @@ public class TimeUtilityTest {
|
|||
assertEquals("00:59:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.MINUTE_IN_MS*59));
|
||||
assertEquals("23:00:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.HOUR_IN_MS*23));
|
||||
assertEquals("52w+5d+00:00:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.DAY_IN_MS*369));
|
||||
|
||||
|
||||
//high overflow values
|
||||
assertEquals("00:00:01.999", UTCTimeUtility.timeInMsToString(1999));
|
||||
assertEquals("00:02:39.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.SECOND_IN_MS*159));
|
||||
assertEquals("02:39:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.MINUTE_IN_MS*159));
|
||||
assertEquals("5d+03:00:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.HOUR_IN_MS*123));
|
||||
|
||||
|
||||
//combinations
|
||||
assertEquals("142w+5d+23:59:59.999", UTCTimeUtility.timeInMsToString((UTCTimeUtility.WEEK_IN_MS*142) + (UTCTimeUtility.DAY_IN_MS*5) + (UTCTimeUtility.HOUR_IN_MS*23) + (UTCTimeUtility.MINUTE_IN_MS*59) + (UTCTimeUtility.SECOND_IN_MS*59) + 999));
|
||||
assertEquals("6d+23:59:59.999", UTCTimeUtility.timeInMsToString(UTCTimeUtility.WEEK_IN_MS-1));
|
||||
}
|
||||
|
||||
|
||||
// Test printing converting milliseconds to text for a negative time
|
||||
@Test(expected=NumberFormatException.class)
|
||||
public void testMsToStringForNegativeArgument(){
|
||||
//low values
|
||||
UTCTimeUtility.timeInMsToString(-1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,6 @@
|
|||
|
||||
package se.hal.plugin.assistant.google;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.actions.api.smarthome.*;
|
||||
import com.google.auth.oauth2.AccessToken;
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
|
|
@ -38,6 +33,11 @@ import zutil.db.DBConnection;
|
|||
import zutil.log.LogUtil;
|
||||
import zutil.net.http.page.oauth.OAuth2Registry.TokenRegistrationListener;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class SmartHomeImpl extends SmartHomeApp implements TokenRegistrationListener {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
|
|
|||
|
|
@ -24,21 +24,17 @@
|
|||
|
||||
package se.hal.plugin.assistant.google;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.actions.api.smarthome.SmartHomeApp;
|
||||
import se.hal.plugin.assistant.google.SmartHomeImpl;
|
||||
import zutil.io.IOUtil;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.net.http.HttpHeader;
|
||||
import zutil.net.http.HttpPage;
|
||||
import zutil.net.http.HttpPrintStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Handles Google SMartHome request received via HTTP POST.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import se.hal.intf.*;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class DummyController implements HalSensorController, HalEventController, Runnable, HalDaemon {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package se.hal.plugin.dummy;
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalDeviceData;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.struct.devicedata.HumiditySensorData;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package se.hal.plugin.dummy;
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalDeviceData;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalEventData;
|
||||
import se.hal.struct.devicedata.OnOffEventData;
|
||||
|
||||
public class DummySwitchEvent implements DummyDevice, HalEventConfig {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package se.hal.plugin.dummy;
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalDeviceData;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
|
||||
package se.hal.plugin.mqtt.device;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalEventData;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package se.hal.plugin.netscan;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalEventData;
|
||||
import se.hal.struct.devicedata.OnOffEventData;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
public class NetworkDevice implements HalEventConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,10 @@
|
|||
package se.hal.plugin.nutups;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalAutoScannableController;
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalDeviceReportListener;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.osal.linux.app.NutUPSClient;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,13 +48,12 @@
|
|||
|
||||
package se.hal.plugin.nutups;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
||||
import zutil.osal.linux.app.NutUPSClient;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
public class NutUpsDevice implements HalSensorConfig{
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,9 @@
|
|||
|
||||
package se.hal.plugin.nvr.rtsp;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalDeviceData;
|
||||
import se.hal.plugin.nvr.intf.HalCameraController;
|
||||
import se.hal.plugin.nvr.intf.HalCameraConfig;
|
||||
import se.hal.plugin.nvr.intf.HalCameraController;
|
||||
|
||||
public class RTSPCameraConfig implements HalCameraConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
package se.hal.plugin.nvr.struct;
|
||||
|
||||
import se.hal.intf.HalAbstractController;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import se.hal.plugin.nvr.intf.HalCameraConfig;
|
||||
import se.hal.plugin.nvr.intf.HalCameraData;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,18 +25,17 @@
|
|||
package se.hal.plugin.powerchallenge.daemon;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.page.HalAlertManager;
|
||||
import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.PeerDataRspDTO;
|
||||
import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.SensorDTO;
|
||||
import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.SensorDataDTO;
|
||||
import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.SensorDataListDTO;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.page.HalAlertManager;
|
||||
import se.hal.struct.Sensor;
|
||||
import se.hal.struct.User;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.parser.json.JSONParser;
|
||||
import zutil.ui.UserMessageManager;
|
||||
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
package se.hal.plugin.powerchallenge.daemon;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationClient.PeerDataReqDTO;
|
||||
import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationClient.SensorDataReqDTO;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.struct.Sensor;
|
||||
import se.hal.struct.User;
|
||||
import zutil.db.DBConnection;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package se.hal.plugin.raspberry;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
public class RPiPowerConsumptionSensor implements HalSensorConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package se.hal.plugin.raspberry;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
public class RPiTemperatureSensor implements HalSensorConfig {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
package se.hal.plugin.tellstick.device;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalEventData;
|
||||
|
|
@ -31,7 +30,7 @@ import se.hal.plugin.tellstick.TellstickDeviceGroup;
|
|||
import se.hal.plugin.tellstick.TellstickSerialComm;
|
||||
import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol;
|
||||
import se.hal.struct.devicedata.OnOffEventData;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-02-18.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
package se.hal.plugin.tellstick.device;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalEventData;
|
||||
|
|
@ -30,7 +29,7 @@ import se.hal.plugin.tellstick.TellstickDevice;
|
|||
import se.hal.plugin.tellstick.TellstickSerialComm;
|
||||
import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol;
|
||||
import se.hal.struct.devicedata.DimmerEventData;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-02-18.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package se.hal.plugin.tellstick.device;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
|
|
@ -12,7 +11,7 @@ import se.hal.struct.devicedata.LightSensorData;
|
|||
import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
||||
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.Configurator;
|
||||
import zutil.ui.conf.Configurator;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ package se.hal.plugin.tellstick.protocol;
|
|||
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventData;
|
||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||
import se.hal.plugin.tellstick.cmd.TellstickCmd;
|
||||
import se.hal.plugin.tellstick.cmd.TellstickCmdExtendedSend;
|
||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||
import se.hal.plugin.tellstick.device.NexaSelfLearning;
|
||||
import se.hal.plugin.tellstick.device.NexaSelfLearningDimmer;
|
||||
import se.hal.struct.devicedata.DimmerEventData;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package se.hal.plugin.tellstick;
|
|||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalDeviceReportListener;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventData;
|
||||
import se.hal.plugin.tellstick.test.TestEventDevice;
|
||||
import se.hal.plugin.tellstick.test.TestProtocol;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package se.hal.plugin.tellstick;
|
|||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalDeviceReportListener;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.plugin.tellstick.test.TestProtocol;
|
||||
import se.hal.plugin.tellstick.test.TestSensorDevice;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package se.hal.plugin.tellstick.test;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalEventData;
|
||||
import se.hal.plugin.tellstick.TellstickDevice;
|
||||
import se.hal.plugin.tellstick.TellstickSerialCommEventTest;
|
||||
|
||||
public class TestEventDevice implements TellstickDevice, HalEventConfig {
|
||||
public int testData;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package se.hal.plugin.tellstick.test;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.plugin.tellstick.TellstickDevice;
|
||||
import se.hal.plugin.tellstick.TellstickSerialCommSensorTest;
|
||||
|
||||
public class TestSensorDevice implements HalSensorConfig, TellstickDevice {
|
||||
public int testData;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ package se.hal.plugin.zigbee.deconz.zigbee.deconz.rest;
|
|||
import zutil.net.ws.WSInterface.WSPath;
|
||||
import zutil.net.ws.WSInterface.WSRequestType;
|
||||
|
||||
import static zutil.net.ws.WSInterface.RequestType.*;
|
||||
import static zutil.net.ws.WSInterface.RequestType.DELETE;
|
||||
import static zutil.net.ws.WSInterface.RequestType.GET;
|
||||
|
||||
/**
|
||||
* Rules provide the ability to trigger actions of lights or groups when a specific sensor condition is met.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ package se.hal.plugin.zigbee.deconz.zigbee.deconz.rest;
|
|||
import zutil.net.ws.WSInterface.WSPath;
|
||||
import zutil.net.ws.WSInterface.WSRequestType;
|
||||
|
||||
import static zutil.net.ws.WSInterface.RequestType.*;
|
||||
import static zutil.net.ws.WSInterface.RequestType.GET;
|
||||
import static zutil.net.ws.WSInterface.RequestType.POST;
|
||||
|
||||
/**
|
||||
* The touchlink endpoint allows to communicate with near by located devices.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package se.hal.plugin.zigbee;
|
|||
|
||||
|
||||
import com.zsmartsystems.zigbee.*;
|
||||
import com.zsmartsystems.zigbee.app.basic.ZigBeeBasicServerExtension;
|
||||
import com.zsmartsystems.zigbee.app.discovery.ZigBeeDiscoveryExtension;
|
||||
import com.zsmartsystems.zigbee.app.iasclient.ZigBeeIasCieExtension;
|
||||
import com.zsmartsystems.zigbee.app.otaserver.ZigBeeOtaUpgradeExtension;
|
||||
|
|
@ -12,20 +11,19 @@ import com.zsmartsystems.zigbee.dongle.xbee.ZigBeeDongleXBee;
|
|||
import com.zsmartsystems.zigbee.security.ZigBeeKey;
|
||||
import com.zsmartsystems.zigbee.serialization.DefaultDeserializer;
|
||||
import com.zsmartsystems.zigbee.serialization.DefaultSerializer;
|
||||
import com.zsmartsystems.zigbee.transport.*;
|
||||
import com.zsmartsystems.zigbee.transport.TransportConfig;
|
||||
import com.zsmartsystems.zigbee.transport.TransportConfigOption;
|
||||
import com.zsmartsystems.zigbee.transport.ZigBeePort;
|
||||
import com.zsmartsystems.zigbee.transport.ZigBeeTransportTransmit;
|
||||
import com.zsmartsystems.zigbee.zcl.clusters.*;
|
||||
import com.zsmartsystems.zigbee.zdo.command.NetworkAddressRequest;
|
||||
import com.zsmartsystems.zigbee.zdo.field.NodeDescriptor;
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import java.nio.channels.Channel;
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,12 +24,11 @@
|
|||
|
||||
package se.hal.plugin.zigbee;
|
||||
|
||||
import com.fazecast.jSerialComm.SerialPort;
|
||||
import com.zsmartsystems.zigbee.transport.ZigBeePort;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fazecast.jSerialComm.SerialPort;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package se.hal.plugin.zwave;
|
|||
import org.zwave4j.*;
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalAbstractDevice;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import static groovy.io.FileType.*
|
||||
import static groovy.io.FileType.DIRECTORIES
|
||||
|
||||
rootProject.name = "Hal"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue