Moved the smaller plugins to separate folders.
This commit is contained in:
parent
fc11ae264f
commit
edd5d0d083
18 changed files with 233 additions and 74 deletions
2
Hal.iml
2
Hal.iml
|
|
@ -14,8 +14,10 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/plugins/hal-zwave/test" isTestSource="true" />
|
||||
<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" />
|
||||
<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-raspberry/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/plugins/hal-tellstick/build" />
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--plugin specific properties-->
|
||||
<property name="releaseJar" value="hal-mqtt.jar" />
|
||||
|
||||
<!--common properties-->
|
||||
<property name="root" value="." />
|
||||
<property name="srcDir" value="${root}/src" />
|
||||
|
|
@ -13,7 +16,6 @@
|
|||
<property name="compileDir" value="${buildRoot}/production" />
|
||||
<property name="compileTestDir" value="${buildRoot}/test" />
|
||||
<property name="releaseDir" value="${buildRoot}/release" />
|
||||
<property name="releaseJar" value="hal-mqtt.jar" />
|
||||
<property name="reportsDir" value="../../${buildRoot}/reports" /> <!-- Use Hal reports folder -->
|
||||
|
||||
<!-- ________________________ TARGETS ________________________ -->
|
||||
|
|
|
|||
25
plugins/hal-netscan/build.xml
Normal file
25
plugins/hal-netscan/build.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="Hal MQTT Plugin" >
|
||||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--plugin specific properties-->
|
||||
<property name="releaseJar" value="hal-netscan.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="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>
|
||||
0
src/se/hal/plugin/netscan/NetScanController.java → plugins/hal-netscan/src/se/hal/plugin/netscan/NetScanController.java
Executable file → Normal file
0
src/se/hal/plugin/netscan/NetScanController.java → plugins/hal-netscan/src/se/hal/plugin/netscan/NetScanController.java
Executable file → Normal file
0
src/se/hal/plugin/netscan/NetworkDevice.java → plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java
Executable file → Normal file
0
src/se/hal/plugin/netscan/NetworkDevice.java → plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java
Executable file → Normal file
2
src/se/hal/plugin/netscan/plugin.json → plugins/hal-netscan/src/se/hal/plugin/netscan/plugin.json
Executable file → Normal file
2
src/se/hal/plugin/netscan/plugin.json → plugins/hal-netscan/src/se/hal/plugin/netscan/plugin.json
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": 1.0,
|
||||
"name": "Network Scanner",
|
||||
"name": "Hal-Network Scanner",
|
||||
"interfaces": [
|
||||
{"se.hal.intf.HalAutoScannableController": "se.hal.plugin.netscan.NetScanController"},
|
||||
{"se.hal.intf.HalEventConfig": "se.hal.plugin.netscan.NetworkDevice"}
|
||||
25
plugins/hal-nutups/build.xml
Normal file
25
plugins/hal-nutups/build.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="Hal MQTT Plugin" >
|
||||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--plugin specific properties-->
|
||||
<property name="releaseJar" value="hal-nutups.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="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>
|
||||
50
src/se/hal/plugin/nutups/NutUpsController.java → plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsController.java
Executable file → Normal file
50
src/se/hal/plugin/nutups/NutUpsController.java → plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsController.java
Executable file → Normal file
|
|
@ -1,3 +1,51 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.nutups;
|
||||
|
||||
import se.hal.HalContext;
|
||||
|
|
@ -19,7 +67,7 @@ public class NutUpsController implements HalSensorController, HalAutoScannableCo
|
|||
public static Logger logger = LogUtil.getLogger();
|
||||
private static final int SYNC_INTERVAL = 60 * 1000;
|
||||
|
||||
private HashMap<String,NutUpsDevice> registeredDevices = new HashMap<>();
|
||||
private HashMap<String, NutUpsDevice> registeredDevices = new HashMap<>();
|
||||
private NutUPSClient client;
|
||||
private ScheduledExecutorService executor;
|
||||
private HalSensorReportListener listener;
|
||||
112
plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java
Normal file
112
plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.nutups;
|
||||
|
||||
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;
|
||||
|
||||
public class NutUpsDevice implements HalSensorConfig{
|
||||
|
||||
@Configurator.Configurable("UPS id")
|
||||
private String upsId;
|
||||
|
||||
|
||||
public NutUpsDevice(){}
|
||||
|
||||
protected NutUpsDevice(NutUPSClient.UPSDevice ups){
|
||||
this.upsId = ups.getId();
|
||||
}
|
||||
|
||||
|
||||
protected HalSensorData read(NutUPSClient.UPSDevice ups){
|
||||
PowerConsumptionSensorData data = new PowerConsumptionSensorData();
|
||||
data.setTimestamp(System.currentTimeMillis());
|
||||
data.setData(ups.getPowerUsage() * 1/60.0); // convert watt min to watt hour
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public String getUpsId(){
|
||||
return upsId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getDataInterval(){
|
||||
return 60*1000; // 1 min
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if (obj instanceof NutUpsDevice)
|
||||
return upsId != null && upsId.equals(((NutUpsDevice)obj).upsId);
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "upsId: "+ upsId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregationMethod getAggregationMethod() {
|
||||
return AggregationMethod.SUM;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends HalSensorController> getSensorControllerClass() {
|
||||
return NutUpsController.class;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends HalSensorData> getSensorDataClass() {
|
||||
return PowerConsumptionSensorData.class;
|
||||
}
|
||||
}
|
||||
2
src/se/hal/plugin/nutups/plugin.json → plugins/hal-nutups/src/se/hal/plugin/nutups/plugin.json
Executable file → Normal file
2
src/se/hal/plugin/nutups/plugin.json → plugins/hal-nutups/src/se/hal/plugin/nutups/plugin.json
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": 1.0,
|
||||
"name": "NutUps",
|
||||
"name": "Hal-NutUps",
|
||||
"interfaces": [
|
||||
{"se.hal.intf.HalAutoScannableController": "se.hal.plugin.nutups.NutUpsController"},
|
||||
{"se.hal.intf.HalSensorConfig": "se.hal.plugin.nutups.NutUpsDevice"}
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--plugin specific properties-->
|
||||
<property name="releaseJar" value="hal-raspberry.jar" />
|
||||
|
||||
<!--common properties-->
|
||||
<property name="root" value="." />
|
||||
<property name="srcDir" value="${root}/src" />
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--plugin specific properties-->
|
||||
<property name="releaseJar" value="hal-tellstick.jar" />
|
||||
|
||||
<!--common properties-->
|
||||
<property name="root" value="." />
|
||||
<property name="srcDir" value="${root}/src" />
|
||||
|
|
@ -13,7 +16,6 @@
|
|||
<property name="compileDir" value="${buildRoot}/production" />
|
||||
<property name="compileTestDir" value="${buildRoot}/test" />
|
||||
<property name="releaseDir" value="${buildRoot}/release" />
|
||||
<property name="releaseJar" value="hal-tellstick.jar" />
|
||||
<property name="reportsDir" value="../../${buildRoot}/reports" /> <!-- Use Hal reports folder -->
|
||||
|
||||
<!-- ________________________ TARGETS ________________________ -->
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--plugin specific properties-->
|
||||
<property name="releaseJar" value="hal-zigbee.jar" />
|
||||
|
||||
<!--common properties-->
|
||||
<property name="root" value="." />
|
||||
<property name="srcDir" value="${root}/src" />
|
||||
|
|
@ -13,7 +16,6 @@
|
|||
<property name="compileDir" value="${buildRoot}/production" />
|
||||
<property name="compileTestDir" value="${buildRoot}/test" />
|
||||
<property name="releaseDir" value="${buildRoot}/release" />
|
||||
<property name="releaseJar" value="hal-zigbee.jar" />
|
||||
<property name="reportsDir" value="../../${buildRoot}/reports" /> <!-- Use Hal reports folder -->
|
||||
|
||||
<!-- ________________________ TARGETS ________________________ -->
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--plugin specific properties-->
|
||||
<property name="releaseJar" value="hal-zwave.jar" />
|
||||
|
||||
<!--common properties-->
|
||||
<property name="root" value="." />
|
||||
<property name="srcDir" value="${root}/src" />
|
||||
|
|
@ -37,7 +40,6 @@
|
|||
<property name="compileDir" value="${buildRoot}/production" />
|
||||
<property name="compileTestDir" value="${buildRoot}/test" />
|
||||
<property name="releaseDir" value="${buildRoot}/release" />
|
||||
<property name="releaseJar" value="hal-zwave.jar" />
|
||||
<property name="reportsDir" value="../../${buildRoot}/reports" /> <!-- Use Hal reports folder -->
|
||||
|
||||
<!-- ________________________ TARGETS ________________________ -->
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default drop-shadow">
|
||||
<div class="panel-heading">Local Events</div>
|
||||
<div class="panel-heading">Active plugins</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<table class="table table-hover table-condensed">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default drop-shadow">
|
||||
<div class="panel-heading">Local Events</div>
|
||||
<div class="panel-heading">Registered properties</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<table class="table table-hover table-condensed">
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class PluginConfigWebPage extends HalWebPage {
|
|||
|
||||
public PluginConfigWebPage(){
|
||||
super("plugins");
|
||||
super.getRootNav().createSubNav("Settings").createSubNav(this.getId(), "Plugins").setWeight(100);
|
||||
super.getRootNav().createSubNav("Settings").createSubNav(this.getId(), "Plugins").setWeight(500);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
package se.hal.plugin.nutups;
|
||||
|
||||
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;
|
||||
|
||||
public class NutUpsDevice implements HalSensorConfig{
|
||||
|
||||
@Configurator.Configurable("UPS id")
|
||||
private String upsId;
|
||||
|
||||
|
||||
public NutUpsDevice(){}
|
||||
|
||||
protected NutUpsDevice(NutUPSClient.UPSDevice ups){
|
||||
this.upsId = ups.getId();
|
||||
}
|
||||
|
||||
|
||||
protected HalSensorData read(NutUPSClient.UPSDevice ups){
|
||||
PowerConsumptionSensorData data = new PowerConsumptionSensorData();
|
||||
data.setTimestamp(System.currentTimeMillis());
|
||||
data.setData(ups.getPowerUsage() * 1/60.0); // convert watt min to watt hour
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public String getUpsId(){
|
||||
return upsId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getDataInterval(){
|
||||
return 60*1000; // 1 min
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if (obj instanceof NutUpsDevice)
|
||||
return upsId != null && upsId.equals(((NutUpsDevice)obj).upsId);
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "upsId: "+ upsId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregationMethod getAggregationMethod() {
|
||||
return AggregationMethod.SUM;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends HalSensorController> getSensorControllerClass() {
|
||||
return NutUpsController.class;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends HalSensorData> getSensorDataClass() {
|
||||
return PowerConsumptionSensorData.class;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue