diff --git a/Hal.iml b/Hal.iml index 2a2619c3..b1470533 100755 --- a/Hal.iml +++ b/Hal.iml @@ -15,10 +15,13 @@ + + + diff --git a/build.xml b/build.xml index 2d10a629..c4111d91 100755 --- a/build.xml +++ b/build.xml @@ -8,6 +8,7 @@ + @@ -153,8 +154,8 @@ - - + + @@ -175,6 +176,12 @@ + + + + + + diff --git a/build_plugin.xml b/build_plugin.xml index 4c7ba9f5..229481ce 100755 --- a/build_plugin.xml +++ b/build_plugin.xml @@ -94,6 +94,9 @@ + + + diff --git a/plugins/hal-powerchallenge/build.xml b/plugins/hal-powerchallenge/build.xml new file mode 100644 index 00000000..e601ffd6 --- /dev/null +++ b/plugins/hal-powerchallenge/build.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/se/hal/daemon/PCDataSynchronizationClient.java b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationClient.java old mode 100755 new mode 100644 similarity index 84% rename from src/se/hal/daemon/PCDataSynchronizationClient.java rename to plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationClient.java index 5af5b33b..aa53d175 --- a/src/se/hal/daemon/PCDataSynchronizationClient.java +++ b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationClient.java @@ -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; diff --git a/src/se/hal/daemon/PCDataSynchronizationDaemon.java b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationDaemon.java similarity index 85% rename from src/se/hal/daemon/PCDataSynchronizationDaemon.java rename to plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationDaemon.java index c8e57e5e..5c4715d4 100644 --- a/src/se/hal/daemon/PCDataSynchronizationDaemon.java +++ b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationDaemon.java @@ -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; diff --git a/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/page/PCHeatMapWebPage.java b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/page/PCHeatMapWebPage.java new file mode 100644 index 00000000..e9a3d712 --- /dev/null +++ b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/page/PCHeatMapWebPage.java @@ -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 session, + Map cookie, + Map request) + throws Exception{ + + Templator tmpl = new Templator(FileUtil.find(TEMPLATE)); + return tmpl; + } + +} diff --git a/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/page/PCOverviewWebPage.java b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/page/PCOverviewWebPage.java new file mode 100644 index 00000000..1c0b39bf --- /dev/null +++ b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/page/PCOverviewWebPage.java @@ -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 session, + Map cookie, + Map request) + throws Exception { + + DBConnection db = HalContext.getDB(); + List sensors = Sensor.getSensors(db); + + Templator tmpl = new Templator(FileUtil.find(TEMPLATE)); + tmpl.set("users", User.getUsers(db)); + tmpl.set("sensors", sensors); + + return tmpl; + } + + +} diff --git a/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/plugin.json b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/plugin.json new file mode 100644 index 00000000..9c8c587d --- /dev/null +++ b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/plugin.json @@ -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"} + ] +} \ No newline at end of file diff --git a/src/se/hal/page/PCHeatMapWebPage.java b/src/se/hal/page/PCHeatMapWebPage.java deleted file mode 100644 index 8831e047..00000000 --- a/src/se/hal/page/PCHeatMapWebPage.java +++ /dev/null @@ -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 session, - Map cookie, - Map request) - throws Exception{ - - Templator tmpl = new Templator(FileUtil.find(TEMPLATE)); - return tmpl; - } - -} diff --git a/src/se/hal/page/PCOverviewWebPage.java b/src/se/hal/page/PCOverviewWebPage.java deleted file mode 100644 index aac6ed5e..00000000 --- a/src/se/hal/page/PCOverviewWebPage.java +++ /dev/null @@ -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 session, - Map cookie, - Map request) - throws Exception { - - DBConnection db = HalContext.getDB(); - List sensors = Sensor.getSensors(db); - - Templator tmpl = new Templator(FileUtil.find(TEMPLATE)); - tmpl.set("users", User.getUsers(db)); - tmpl.set("sensors", sensors); - - return tmpl; - } - - -} diff --git a/src/se/hal/plugin/powerchallenge/plugin.json b/src/se/hal/plugin/powerchallenge/plugin.json deleted file mode 100755 index 26a63e94..00000000 --- a/src/se/hal/plugin/powerchallenge/plugin.json +++ /dev/null @@ -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"} - ] -} \ No newline at end of file