Moved PC to a plugin directory

This commit is contained in:
Ziver Koc 2020-06-26 00:56:56 +02:00
parent fccc6a3609
commit 47afc78ee4
12 changed files with 226 additions and 90 deletions

View file

@ -15,10 +15,13 @@
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-mqtt/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-nutups/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-netscan/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-powerchallenge/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-powerchallenge/resource" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-mqtt/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-netscan/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-nutups/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-powerchallenge/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-raspberry/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-tellstick/build" />
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-zigbee/build" />

View file

@ -8,6 +8,7 @@
<property name="srcDir" value="${root}/src" />
<property name="testDir" value="${root}/test" />
<property name="libDir" value="${root}/lib" />
<property name="resourceDir" value="${root}/resource" />
<property name="buildRoot" value="${root}/build" />
<property name="compileDir" value="${buildRoot}/production" />
@ -153,8 +154,8 @@
<copy todir="${releaseDir}/lib">
<fileset dir="${libDir}" excludes="junit-*.jar,hamcrest-*.jar" />
</copy>
<copy todir="${releaseDir}/resource/web">
<fileset dir="resource/web" />
<copy todir="${releaseDir}/resource">
<fileset dir="${resourceDir}" />
</copy>
<jar destfile="${releaseDir}/${releaseJar}" basedir="${compileDir}" />
</target>
@ -175,6 +176,12 @@
<include name="*/lib/**"/>
</fileset>
</copy>
<!-- Copy plugin resources -->
<copy todir="${releaseDir}/resources" includeEmptyDirs="false">
<fileset dir="plugins/">
<include name="*/resources/**"/>
</fileset>
</copy>
</target>
<!-- ________________________ UTILITY TARGETS ________________________ -->

View file

@ -94,6 +94,9 @@
</target>
<target name="package" depends="build">
<copy todir="${releaseDir}/resource" failonerror="false">
<fileset dir="${resourceDir}" />
</copy>
<jar destfile="${releaseDir}/${releaseJar}" basedir="${compileDir}" />
</target>

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Hal-Power;Challenge Plugin" >
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
<!--plugin specific properties-->
<property name="releaseJar" value="hal-powerchallenge.jar" />
<!--common properties-->
<property name="root" value="." />
<property name="srcDir" value="${root}/src" />
<property name="testDir" value="${root}/test" />
<property name="libDir" value="${root}/lib" />
<property name="resourceDir" value="${root}/resource" />
<property name="buildRoot" value="${root}/build" />
<property name="compileDir" value="${buildRoot}/production" />
<property name="compileTestDir" value="${buildRoot}/test" />
<property name="releaseDir" value="${buildRoot}/release" />
<property name="reportsDir" value="../../${buildRoot}/reports" /> <!-- Use Hal reports folder -->
<!-- ________________________ TARGETS ________________________ -->
<import file="../../build_plugin.xml"/>
</project>

View file

@ -1,10 +1,34 @@
package se.hal.daemon;
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Ziver Koc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package se.hal.plugin.powerchallenge.daemon;
import se.hal.HalContext;
import se.hal.daemon.PCDataSynchronizationDaemon.PeerDataRspDTO;
import se.hal.daemon.PCDataSynchronizationDaemon.SensorDTO;
import se.hal.daemon.PCDataSynchronizationDaemon.SensorDataDTO;
import se.hal.daemon.PCDataSynchronizationDaemon.SensorDataListDTO;
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.page.HalAlertManager.AlertTTL;

View file

@ -1,8 +1,32 @@
package se.hal.daemon;
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Ziver Koc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package se.hal.plugin.powerchallenge.daemon;
import se.hal.HalContext;
import se.hal.daemon.PCDataSynchronizationClient.PeerDataReqDTO;
import se.hal.daemon.PCDataSynchronizationClient.SensorDataReqDTO;
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;

View file

@ -0,0 +1,53 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Ziver Koc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package se.hal.plugin.powerchallenge.page;
import se.hal.intf.HalWebPage;
import zutil.io.file.FileUtil;
import zutil.parser.Templator;
import java.util.Map;
public class PCHeatMapWebPage extends HalWebPage {
private static final String TEMPLATE = "resource/web/pc_heatmap.tmpl";
public PCHeatMapWebPage() {
super("pc_heatmap");
super.getRootNav().createSubNav("Sensors").createSubNav(this.getId(), "Heatmap").setWeight(60);
}
@Override
public Templator httpRespond(
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request)
throws Exception{
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
return tmpl;
}
}

View file

@ -0,0 +1,64 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Ziver Koc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package se.hal.plugin.powerchallenge.page;
import se.hal.HalContext;
import se.hal.intf.HalWebPage;
import se.hal.struct.Sensor;
import se.hal.struct.User;
import zutil.db.DBConnection;
import zutil.io.file.FileUtil;
import zutil.parser.Templator;
import java.util.List;
import java.util.Map;
public class PCOverviewWebPage extends HalWebPage {
private static final String TEMPLATE = "resource/web/pc_overview.tmpl";
public PCOverviewWebPage() {
super("pc_overview");
super.getRootNav().createSubNav("Sensors").createSubNav(this.getId(), "Power;Challenge").setWeight(50);
}
@Override
public Templator httpRespond (
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request)
throws Exception {
DBConnection db = HalContext.getDB();
List<Sensor> sensors = Sensor.getSensors(db);
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
tmpl.set("users", User.getUsers(db));
tmpl.set("sensors", sensors);
return tmpl;
}
}

View file

@ -0,0 +1,11 @@
{
"version": 1.0,
"name": "Hal-Power;Challenge",
"interfaces": [
{"se.hal.intf.HalHttpPage": "se.hal.plugin.powerchallenge.page.PCOverviewHttpPage"},
{"se.hal.intf.HalHttpPage": "se.hal.plugin.powerchallenge.page.PCHeatMapHttpPage"},
{"se.hal.intf.HalDaemon": "se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationClient"},
{"se.hal.intf.HalDaemon": "se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon"}
]
}

View file

@ -1,29 +0,0 @@
package se.hal.page;
import se.hal.intf.HalWebPage;
import zutil.io.file.FileUtil;
import zutil.parser.Templator;
import java.util.Map;
public class PCHeatMapWebPage extends HalWebPage {
private static final String TEMPLATE = "resource/web/pc_heatmap.tmpl";
public PCHeatMapWebPage() {
super("pc_heatmap");
super.getRootNav().createSubNav("Sensors").createSubNav(this.getId(), "Heatmap").setWeight(60);
}
@Override
public Templator httpRespond(
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request)
throws Exception{
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
return tmpl;
}
}

View file

@ -1,40 +0,0 @@
package se.hal.page;
import se.hal.HalContext;
import se.hal.intf.HalWebPage;
import se.hal.struct.Sensor;
import se.hal.struct.User;
import zutil.db.DBConnection;
import zutil.io.file.FileUtil;
import zutil.parser.Templator;
import java.util.List;
import java.util.Map;
public class PCOverviewWebPage extends HalWebPage {
private static final String TEMPLATE = "resource/web/pc_overview.tmpl";
public PCOverviewWebPage() {
super("pc_overview");
super.getRootNav().createSubNav("Sensors").createSubNav(this.getId(), "Power;Challenge").setWeight(50);
}
@Override
public Templator httpRespond (
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request)
throws Exception {
DBConnection db = HalContext.getDB();
List<Sensor> sensors = Sensor.getSensors(db);
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
tmpl.set("users", User.getUsers(db));
tmpl.set("sensors", sensors);
return tmpl;
}
}

View file

@ -1,11 +0,0 @@
{
"version": 1.0,
"name": "Hal-Power;Challenge",
"interfaces": [
{"se.hal.intf.HalHttpPage": "se.hal.page.PCOverviewHttpPage"},
{"se.hal.intf.HalHttpPage": "se.hal.page.PCHeatMapHttpPage"},
{"se.hal.intf.HalDaemon": "se.hal.daemon.PCDataSynchronizationClient"},
{"se.hal.intf.HalDaemon": "se.hal.daemon.PCDataSynchronizationDaemon"}
]
}