Moved PowerChallenge into Hal
Former-commit-id: 34665800518933f0b92723378601a3bafc53fdb0
This commit is contained in:
parent
5b2dffeb43
commit
4428824061
14 changed files with 35 additions and 30 deletions
|
|
@ -44,7 +44,7 @@
|
|||
</target>
|
||||
|
||||
<target name="run-main-server" depends="">
|
||||
<java fork="true" failonerror="true" classname="se.hal.PowerChallenge">
|
||||
<java fork="true" failonerror="true" classname="se.hal.HalServer">
|
||||
<classpath>
|
||||
<pathelement path="${buildDir}/hal.jar"/> <!--wildcard may not be platform independent, ok?-->
|
||||
<pathelement path="${libDir}/*"/> <!--wildcard may not be platform independent, ok?-->
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package se.hal;
|
||||
|
||||
|
||||
import se.hal.deamon.DataAggregatorDaemon;
|
||||
import se.hal.deamon.DataCleanupDaemon;
|
||||
import se.hal.deamon.DataSynchronizationClient;
|
||||
import se.hal.deamon.DataSynchronizationDaemon;
|
||||
import se.hal.deamon.SensorDataAggregatorDaemon;
|
||||
import se.hal.deamon.SensorDataCleanupDaemon;
|
||||
import se.hal.deamon.PCDataSynchronizationClient;
|
||||
import se.hal.deamon.PCDataSynchronizationDaemon;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.intf.HalHttpPage;
|
||||
import se.hal.page.PCConfigureHttpPage;
|
||||
import se.hal.page.SensorConfigHttpPage;
|
||||
import se.hal.page.PCHeatMapHttpPage;
|
||||
import se.hal.page.PCOverviewHttpPage;
|
||||
import se.hal.struct.Event;
|
||||
|
|
@ -26,7 +26,7 @@ import java.util.logging.Level;
|
|||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
public class PowerChallenge {
|
||||
public class HalServer {
|
||||
|
||||
private static HalDaemon[] daemons;
|
||||
private static HalHttpPage[] pages;
|
||||
|
|
@ -58,10 +58,10 @@ public class PowerChallenge {
|
|||
|
||||
// init daemons
|
||||
daemons = new HalDaemon[]{
|
||||
new DataAggregatorDaemon(),
|
||||
new DataSynchronizationDaemon(),
|
||||
new DataSynchronizationClient(),
|
||||
new DataCleanupDaemon()
|
||||
new SensorDataAggregatorDaemon(),
|
||||
new PCDataSynchronizationDaemon(),
|
||||
new PCDataSynchronizationClient(),
|
||||
new SensorDataCleanupDaemon()
|
||||
};
|
||||
// We set only one thread for easier troubleshooting
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
|
|
@ -74,7 +74,7 @@ public class PowerChallenge {
|
|||
pages = new HalHttpPage[]{
|
||||
new PCOverviewHttpPage(),
|
||||
new PCHeatMapHttpPage(),
|
||||
new PCConfigureHttpPage()
|
||||
new SensorConfigHttpPage()
|
||||
};
|
||||
HttpServer http = new HttpServer(HalContext.getIntegerProperty("http_port"));
|
||||
http.setDefaultPage(new HttpFilePage(FileUtil.find("web-resource/")));
|
||||
|
|
@ -19,7 +19,7 @@ import java.util.regex.Pattern;
|
|||
* Date: 2013-12-17
|
||||
* Time: 10:59
|
||||
*/
|
||||
public class HalClient {
|
||||
public class HalSpeechClient {
|
||||
private static HashMap<String, SwitchEvent> switches = new HashMap<String, SwitchEvent>();
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package se.hal.deamon;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.deamon.DataSynchronizationDaemon.*;
|
||||
import se.hal.deamon.PCDataSynchronizationDaemon.*;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.struct.Sensor;
|
||||
import se.hal.struct.User;
|
||||
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DataSynchronizationClient implements HalDaemon {
|
||||
public class PCDataSynchronizationClient implements HalDaemon {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
private static final long SYNC_INTERVAL = 5 * 60 * 1000; // 5 min
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package se.hal.deamon;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.deamon.DataSynchronizationClient.*;
|
||||
import se.hal.deamon.PCDataSynchronizationClient.*;
|
||||
import se.hal.intf.HalDaemon;
|
||||
import se.hal.struct.Sensor;
|
||||
import se.hal.struct.User;
|
||||
|
|
@ -25,11 +25,11 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DataSynchronizationDaemon extends ThreadedTCPNetworkServer implements HalDaemon {
|
||||
public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implements HalDaemon {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
|
||||
public DataSynchronizationDaemon() {
|
||||
public PCDataSynchronizationDaemon() {
|
||||
super(HalContext.getIntegerProperty("sync_port"));
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DataAggregatorDaemon implements HalDaemon {
|
||||
public class SensorDataAggregatorDaemon implements HalDaemon {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
public void initiate(ScheduledExecutorService executor){
|
||||
|
|
@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DataCleanupDaemon implements HalDaemon {
|
||||
public class SensorDataCleanupDaemon implements HalDaemon {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
public void initiate(ScheduledExecutorService executor){
|
||||
|
|
@ -7,6 +7,8 @@ import zutil.parser.Templator;
|
|||
import java.util.Map;
|
||||
|
||||
public class PCHeatMapHttpPage extends HalHttpPage {
|
||||
private static final String TEMPLATE = "web-resource/pc_heatmap.tmpl";
|
||||
|
||||
|
||||
public PCHeatMapHttpPage() {
|
||||
super("Heatmap", "map");
|
||||
|
|
@ -19,7 +21,7 @@ public class PCHeatMapHttpPage extends HalHttpPage {
|
|||
Map<String, String> request)
|
||||
throws Exception{
|
||||
|
||||
Templator tmpl = new Templator(FileUtil.find("web-resource/heatmap.tmpl"));
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
return tmpl;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ import java.util.ArrayList;
|
|||
import java.util.Map;
|
||||
|
||||
public class PCOverviewHttpPage extends HalHttpPage {
|
||||
private static final String TEMPLATE = "web-resource/pc_overview.tmpl";
|
||||
|
||||
public PCOverviewHttpPage() {
|
||||
super("Overview", "overview");
|
||||
super("Power;Challenge", "powerChallenge");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -80,7 +81,7 @@ public class PCOverviewHttpPage extends HalHttpPage {
|
|||
ArrayList<PowerData> dayDataList = DBConnection.exec(stmt, new SQLPowerDataBuilder());
|
||||
|
||||
|
||||
Templator tmpl = new Templator(FileUtil.find("web-resource/overview.tmpl"));
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
tmpl.set("minData", minDataList);
|
||||
tmpl.set("hourData", hourDataList);
|
||||
tmpl.set("dayData", dayDataList);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ import zutil.ui.Configurator.*;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
public class PCConfigureHttpPage extends HalHttpPage {
|
||||
public class SensorConfigHttpPage extends HalHttpPage {
|
||||
private static final String TEMPLATE = "web-resource/sensor_config.tmpl";
|
||||
|
||||
private class SensorDataParams{
|
||||
public Class clazz;
|
||||
public ConfigurationParam[] params;
|
||||
|
|
@ -21,7 +23,7 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
|||
private SensorDataParams[] sensorConfigurations;
|
||||
|
||||
|
||||
public PCConfigureHttpPage() {
|
||||
public SensorConfigHttpPage() {
|
||||
super("Configuration", "config");
|
||||
|
||||
sensorConfigurations = new SensorDataParams[
|
||||
|
|
@ -118,7 +120,7 @@ public class PCConfigureHttpPage extends HalHttpPage {
|
|||
}
|
||||
|
||||
// Output
|
||||
Templator tmpl = new Templator(FileUtil.find("web-resource/configure.tmpl"));
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
tmpl.set("user", localUser);
|
||||
tmpl.set("localSensors", Sensor.getLocalSensors(db));
|
||||
tmpl.set("localSensorConf", sensorConfigurations);
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<title>Power;Challenge</title>
|
||||
<title>HAL</title>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">Power;Challenge</a>
|
||||
<a class="navbar-brand" href="#">HAL</a>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@
|
|||
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default drop-shadow">
|
||||
<div class="panel-heading">External Users</div>
|
||||
<div class="panel-heading">Power;Challenge External Users</div>
|
||||
<div class="panel-body">
|
||||
<p>Add or remove users that you want to synchronized data with.</p>
|
||||
|
||||
|
|
@ -161,7 +161,7 @@
|
|||
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default drop-shadow">
|
||||
<div class="panel-heading">External Sensors</div>
|
||||
<div class="panel-heading">Power;Challenge External Sensors</div>
|
||||
<div class="panel-body">
|
||||
<p>This is a read only list of synchronized sensors from external users.</p>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue