Moved raspberry pi plugin into its own plugin folder
This commit is contained in:
parent
26ed8584c8
commit
eab6c72800
21 changed files with 471 additions and 436 deletions
12
Hal.iml
12
Hal.iml
|
|
@ -9,7 +9,9 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/plugins/zwave/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/plugins/tellstick/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/plugins/tellstick/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/plugins/raspberry/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/plugins/raspberry/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/plugins/tellstick/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/plugins/zwave/build" />
|
||||
</content>
|
||||
|
|
@ -49,6 +51,16 @@
|
|||
<jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="lib Raspberry">
|
||||
<CLASSES>
|
||||
<root url="file://$MODULE_DIR$/plugins/raspberry/lib" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
<jarDirectory url="file://$MODULE_DIR$/plugins/raspberry/lib" recursive="false" />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library" scope="TEST">
|
||||
<library name="JUnit4">
|
||||
<CLASSES>
|
||||
|
|
|
|||
212
build.xml
212
build.xml
|
|
@ -1,31 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="Hal" >
|
||||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--common properties-->
|
||||
<property name="root" value="." />
|
||||
<property name="srcDir" value="${root}/src" />
|
||||
<property name="testDir" value="${root}/test" />
|
||||
<property name="libDir" value="${root}/lib" />
|
||||
<!--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" />
|
||||
<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" />
|
||||
<property name="releaseJar" value="hal.jar" />
|
||||
|
||||
|
||||
<!-- ________________________ CLASSPATH ________________________ -->
|
||||
<!-- ________________________ CLASSPATH ________________________ -->
|
||||
|
||||
<!--define standard arguments for javac-->
|
||||
<presetdef name="javac">
|
||||
<javac includeantruntime="false" />
|
||||
</presetdef>
|
||||
<!--define standard arguments for javac-->
|
||||
<presetdef name="javac">
|
||||
<javac includeantruntime="false" />
|
||||
</presetdef>
|
||||
|
||||
<!--classpath included when building-->
|
||||
<path id="classpath.build">
|
||||
<!--classpath included when building-->
|
||||
<path id="classpath.build">
|
||||
<fileset dir="${libDir}">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
|
|
@ -53,111 +53,111 @@
|
|||
<target name="debug-remote" depends="package">
|
||||
<java fork="true" failonerror="true" classname="se.hal.HalServer">
|
||||
<jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" />
|
||||
<classpath>
|
||||
<pathelement path="${releaseDir}/${releaseJar}"/>
|
||||
<pathelement path="${libDir}/*"/> <!--wildcard may not be platform independent, ok?-->
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
<classpath>
|
||||
<pathelement path="${releaseDir}/${releaseJar}"/>
|
||||
<pathelement path="${libDir}/*"/> <!--wildcard may not be platform independent, ok?-->
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Test targets -->
|
||||
<target name="test-all" depends="test,test-plugins" />
|
||||
|
||||
<target name="test" depends="build-test">
|
||||
<mkdir dir="${reportsDir}" />
|
||||
<junit printsummary="yes" haltonfailure="false" fork="true">
|
||||
<classpath refid="classpath.test" />
|
||||
<formatter type="plain" usefile="false" /> <!-- to screen -->
|
||||
<formatter type="xml" /> <!-- to file -->
|
||||
<target name="test" depends="build-test">
|
||||
<mkdir dir="${reportsDir}" />
|
||||
<junit printsummary="yes" haltonfailure="false" fork="true">
|
||||
<classpath refid="classpath.test" />
|
||||
<formatter type="plain" usefile="false" /> <!-- to screen -->
|
||||
<formatter type="xml" /> <!-- to file -->
|
||||
|
||||
<batchtest todir="${reportsDir}" skipNonTests="true">
|
||||
<fileset dir="${compileTestDir}" includes="**/*Test*.class" />
|
||||
</batchtest>
|
||||
</junit>
|
||||
</target>
|
||||
<batchtest todir="${reportsDir}" skipNonTests="true">
|
||||
<fileset dir="${compileTestDir}" includes="**/*Test*.class" />
|
||||
</batchtest>
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test-plugins" depends="build-test">
|
||||
<subant target="test" verbose="true">
|
||||
<fileset dir="plugins/" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
<!-- ________________________ BUILD TARGETS ________________________ -->
|
||||
<!-- ________________________ BUILD TARGETS ________________________ -->
|
||||
|
||||
<!-- clean all build paths -->
|
||||
<target name="clean">
|
||||
<delete includeemptydirs="true" failonerror="false">
|
||||
<fileset dir="${buildRoot}" includes="**/*"/>
|
||||
</delete>
|
||||
<!-- clean all build paths -->
|
||||
<target name="clean">
|
||||
<delete includeemptydirs="true" failonerror="false">
|
||||
<fileset dir="${buildRoot}" includes="**/*"/>
|
||||
</delete>
|
||||
<!-- clean plugins -->
|
||||
<subant target="clean" verbose="true">
|
||||
<fileset dir="plugins/" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- build product code -->
|
||||
<!-- build product code -->
|
||||
<target name="build-all" depends="build,build-plugins" />
|
||||
|
||||
<target name="build" depends="build-dependencies">
|
||||
<mkdir dir="${compileDir}" />
|
||||
<javac srcdir="${srcDir}" destdir="${compileDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
|
||||
<classpath refid="classpath.build" />
|
||||
<include name="**/*.java" />
|
||||
<exclude name="se/hal/tts/GoogleTTSClient.java" />
|
||||
</javac>
|
||||
<copy todir="${compileDir}">
|
||||
<fileset dir="${srcDir}"
|
||||
excludes="**/*.java" />
|
||||
</copy>
|
||||
</target>
|
||||
<target name="build" depends="build-dependencies">
|
||||
<mkdir dir="${compileDir}" />
|
||||
<javac srcdir="${srcDir}" destdir="${compileDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
|
||||
<classpath refid="classpath.build" />
|
||||
<include name="**/*.java" />
|
||||
<exclude name="se/hal/tts/GoogleTTSClient.java" />
|
||||
</javac>
|
||||
<copy todir="${compileDir}">
|
||||
<fileset dir="${srcDir}"
|
||||
excludes="**/*.java" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="build-dependencies">
|
||||
<mkdir dir="${compileDir}" />
|
||||
<get src="http://ci.koc.se/jenkins/job/Zutil/147/artifact/build/release/Zutil.jar"
|
||||
dest="${libDir}" verbose="true" usetimestamp="true"/>
|
||||
</target>
|
||||
<target name="build-dependencies">
|
||||
<mkdir dir="${compileDir}" />
|
||||
<get src="http://ci.koc.se/jenkins/job/Zutil/147/artifact/build/release/Zutil.jar"
|
||||
dest="${libDir}" verbose="true" usetimestamp="true"/>
|
||||
</target>
|
||||
|
||||
<target name="build-plugins" depends="build">
|
||||
<subant target="build" verbose="true">
|
||||
<fileset dir="plugins/" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
<target name="build-plugins" depends="build">
|
||||
<subant target="build" verbose="true">
|
||||
<fileset dir="plugins/" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="build-test" depends="build">
|
||||
<mkdir dir="${compileTestDir}" />
|
||||
<javac srcdir="${testDir}" destdir="${compileTestDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
|
||||
<classpath refid="classpath.test" />
|
||||
<include name="**/*.java" />
|
||||
</javac>
|
||||
<copy todir="${compileTestDir}">
|
||||
<fileset dir="${testDir}"
|
||||
excludes="**/*.java" />
|
||||
</copy>
|
||||
</target>
|
||||
<target name="build-test" depends="build">
|
||||
<mkdir dir="${compileTestDir}" />
|
||||
<javac srcdir="${testDir}" destdir="${compileTestDir}" debug="yes" debugLevel="lines,vars,source" fork="yes">
|
||||
<classpath refid="classpath.test" />
|
||||
<include name="**/*.java" />
|
||||
</javac>
|
||||
<copy todir="${compileTestDir}">
|
||||
<fileset dir="${testDir}"
|
||||
excludes="**/*.java" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- generate release packages -->
|
||||
<target name="package-all" depends="package,package-plugins" />
|
||||
|
||||
<target name="package" depends="build">
|
||||
<copy todir="${releaseDir}" >
|
||||
<fileset file="${root}/hal.conf.example" />
|
||||
<fileset file="${root}/hal-default.db" />
|
||||
<fileset file="${root}/logging.properties" />
|
||||
<fileset file="${root}/run.sh" />
|
||||
</copy>
|
||||
<copy todir="${releaseDir}/lib">
|
||||
<fileset dir="${libDir}" excludes="junit-*.jar,hamcrest-*.jar" />
|
||||
</copy>
|
||||
<copy todir="${releaseDir}/resource/web">
|
||||
<fileset dir="resource/web" />
|
||||
</copy>
|
||||
<jar destfile="${releaseDir}/${releaseJar}" basedir="${compileDir}" />
|
||||
</target>
|
||||
<target name="package" depends="build">
|
||||
<copy todir="${releaseDir}" >
|
||||
<fileset file="${root}/hal.conf.example" />
|
||||
<fileset file="${root}/hal-default.db" />
|
||||
<fileset file="${root}/logging.properties" />
|
||||
<fileset file="${root}/run.sh" />
|
||||
</copy>
|
||||
<copy todir="${releaseDir}/lib">
|
||||
<fileset dir="${libDir}" excludes="junit-*.jar,hamcrest-*.jar" />
|
||||
</copy>
|
||||
<copy todir="${releaseDir}/resource/web">
|
||||
<fileset dir="resource/web" />
|
||||
</copy>
|
||||
<jar destfile="${releaseDir}/${releaseJar}" basedir="${compileDir}" />
|
||||
</target>
|
||||
|
||||
<target name="package-plugins" depends="package">
|
||||
<subant target="package" verbose="true">
|
||||
<fileset dir="plugins/" includes="*/build.xml"/>
|
||||
</subant>
|
||||
<target name="package-plugins" depends="package">
|
||||
<subant target="package" verbose="true">
|
||||
<fileset dir="plugins/" includes="*/build.xml"/>
|
||||
</subant>
|
||||
<!-- Copy plugin jars -->
|
||||
<copy todir="${releaseDir}/plugins" flatten="true" includeEmptyDirs="false">
|
||||
<fileset dir="plugins/">
|
||||
|
|
@ -170,19 +170,19 @@
|
|||
<include name="*/lib/**"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</target>
|
||||
|
||||
<!-- ________________________ UTILITY TARGETS ________________________ -->
|
||||
<!-- ________________________ UTILITY TARGETS ________________________ -->
|
||||
|
||||
<target name="clear-aggr-data-from-db" depends="">
|
||||
<exec executable="sqlite3">
|
||||
<arg line="hal.db 'DELETE FROM sensor_data_aggr'" />
|
||||
</exec>
|
||||
<target name="clear-aggr-data-from-db" depends="">
|
||||
<exec executable="sqlite3">
|
||||
<arg line="hal.db 'DELETE FROM sensor_data_aggr'" />
|
||||
</exec>
|
||||
|
||||
<!-- update all internal sensors aggregation version to indicate for peers that they need to re-sync all data -->
|
||||
<exec executable="sqlite3">
|
||||
<arg line="hal.db 'UPDATE sensor SET aggr_version = (aggr_version+1) WHERE id = (SELECT sensor.id FROM user, sensor WHERE user.external == 0 AND sensor.user_id = user.id)'" />
|
||||
</exec>
|
||||
</target>
|
||||
<!-- update all internal sensors aggregation version to indicate for peers that they need to re-sync all data -->
|
||||
<exec executable="sqlite3">
|
||||
<arg line="hal.db 'UPDATE sensor SET aggr_version = (aggr_version+1) WHERE id = (SELECT sensor.id FROM user, sensor WHERE user.external == 0 AND sensor.user_id = user.id)'" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
23
plugins/raspberry/build.xml
Executable file
23
plugins/raspberry/build.xml
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="RaspberryPi Plugin" >
|
||||
|
||||
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
|
||||
|
||||
<!--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="releaseJar" value="raspberry.jar" />
|
||||
<property name="reportsDir" value="../../${buildRoot}/reports" /> <!-- Use Hal reports folder -->
|
||||
|
||||
<!-- ________________________ TARGETS ________________________ -->
|
||||
|
||||
<import file="../../build_plugin.xml"/>
|
||||
|
||||
</project>
|
||||
98
plugins/raspberry/src/se/hal/plugin/raspberry/RPiController.java
Executable file
98
plugins/raspberry/src/se/hal/plugin/raspberry/RPiController.java
Executable file
|
|
@ -0,0 +1,98 @@
|
|||
package se.hal.plugin.raspberry;
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.plugin.raspberry.hardware.RPiDS18B20;
|
||||
import se.hal.plugin.raspberry.hardware.RPiInteruptPulseFlankCounter;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RPiController implements HalSensorController {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
private HashMap<String, RPiSensor> pinToSensorMap = new HashMap<>();
|
||||
private HalSensorReportListener sensorListener;
|
||||
|
||||
public RPiController(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(HalSensorConfig sensor) {
|
||||
if(sensor instanceof RPiPowerConsumptionSensor){
|
||||
RPiPowerConsumptionSensor powerConsumptionSensor = (RPiPowerConsumptionSensor) sensor;
|
||||
int gpioPin = powerConsumptionSensor.getGpioPin();
|
||||
if(!pinToSensorMap.containsKey("GPIO_"+gpioPin)){
|
||||
RPiInteruptPulseFlankCounter impulseCounter = new RPiInteruptPulseFlankCounter(gpioPin, this);
|
||||
pinToSensorMap.put("GPIO_"+gpioPin, impulseCounter);
|
||||
}else{
|
||||
logger.warning("Cannot create a RPiPowerConsumptionSensor on GPIO pin " + gpioPin + " since is already is in use by another sensor.");
|
||||
}
|
||||
} else if(sensor instanceof RPiTemperatureSensor){
|
||||
RPiTemperatureSensor temperatureSensor = (RPiTemperatureSensor) sensor;
|
||||
String w1Address = temperatureSensor.get1WAddress();
|
||||
if(!pinToSensorMap.containsKey("W1_"+w1Address)){
|
||||
RPiDS18B20 ds12b20 = new RPiDS18B20(w1Address, this);
|
||||
pinToSensorMap.put("W1_"+w1Address, ds12b20);
|
||||
}else{
|
||||
logger.warning("Cannot create a RPi1WireTemperatureSensor on 1-Wire address " + w1Address + " since is already is in use by another sensor.");
|
||||
}
|
||||
}else{
|
||||
logger.warning("Cannot register a non-supported sensor");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deregister(HalSensorConfig sensor) {
|
||||
if(sensor instanceof RPiPowerConsumptionSensor){
|
||||
RPiPowerConsumptionSensor powerConsumprtionSensor = (RPiPowerConsumptionSensor) sensor;
|
||||
RPiSensor sensorToDeregister = pinToSensorMap.remove("GPIO_"+powerConsumprtionSensor.getGpioPin());
|
||||
if(sensorToDeregister != null){
|
||||
sensorToDeregister.close();
|
||||
}
|
||||
} else if(sensor instanceof RPiTemperatureSensor){
|
||||
RPiTemperatureSensor temperatureSensor = (RPiTemperatureSensor) sensor;
|
||||
RPiSensor sensorToDeregister = pinToSensorMap.remove("W1_"+temperatureSensor.get1WAddress());
|
||||
if(sensorToDeregister != null){
|
||||
sensorToDeregister.close();
|
||||
}
|
||||
}else{
|
||||
logger.warning("Cannot deregister a non-supported sensor");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return pinToSensorMap.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(HalSensorReportListener listener) {
|
||||
sensorListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
for(String key : this.pinToSensorMap.keySet()){
|
||||
pinToSensorMap.get(key).close();
|
||||
pinToSensorMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendDataReport(HalSensorConfig sensorConfig, HalSensorData sensorData){
|
||||
if(sensorListener != null){
|
||||
sensorListener.reportReceived(sensorConfig, sensorData);
|
||||
}else{
|
||||
logger.log(Level.WARNING, "Could not report data. No registered listener");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,15 +7,15 @@ import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
|||
import zutil.ui.Configurator;
|
||||
|
||||
public class RPiPowerConsumptionSensor implements HalSensorConfig {
|
||||
|
||||
@Configurator.Configurable("GPIO-Pin")
|
||||
|
||||
@Configurator.Configurable("GPIO-Pin")
|
||||
private int gpioPin = -1;
|
||||
|
||||
|
||||
public RPiPowerConsumptionSensor(){ } //need to be empty for the framework to create an instance
|
||||
public RPiPowerConsumptionSensor(int gpioPin) {
|
||||
this.gpioPin = gpioPin;
|
||||
}
|
||||
|
||||
public RPiPowerConsumptionSensor(){ } //need to be empty for the framework to create an instance
|
||||
public RPiPowerConsumptionSensor(int gpioPin) {
|
||||
this.gpioPin = gpioPin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -41,14 +41,14 @@ public class RPiPowerConsumptionSensor implements HalSensorConfig {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(obj instanceof RPiPowerConsumptionSensor)
|
||||
return ((RPiPowerConsumptionSensor)obj).gpioPin == gpioPin;
|
||||
return false;
|
||||
if(obj instanceof RPiPowerConsumptionSensor)
|
||||
return ((RPiPowerConsumptionSensor)obj).gpioPin == gpioPin;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getGpioPin() {
|
||||
return gpioPin;
|
||||
}
|
||||
public int getGpioPin() {
|
||||
return gpioPin;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "gpioPin:" + gpioPin;
|
||||
2
src/se/hal/plugin/raspberry/RPiSensor.java → plugins/raspberry/src/se/hal/plugin/raspberry/RPiSensor.java
Normal file → Executable file
2
src/se/hal/plugin/raspberry/RPiSensor.java → plugins/raspberry/src/se/hal/plugin/raspberry/RPiSensor.java
Normal file → Executable file
|
|
@ -2,6 +2,6 @@ package se.hal.plugin.raspberry;
|
|||
|
||||
public interface RPiSensor {
|
||||
|
||||
void close();
|
||||
void close();
|
||||
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@ import se.hal.struct.devicedata.TemperatureSensorData;
|
|||
import zutil.ui.Configurator;
|
||||
|
||||
public class RPiTemperatureSensor implements HalSensorConfig {
|
||||
|
||||
@Configurator.Configurable("1-Wire Address")
|
||||
|
||||
@Configurator.Configurable("1-Wire Address")
|
||||
private String w1Address;
|
||||
|
||||
|
||||
|
|
@ -41,13 +41,13 @@ public class RPiTemperatureSensor implements HalSensorConfig {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(obj instanceof RPiTemperatureSensor && w1Address != null)
|
||||
return this.get1WAddress().equals(((RPiTemperatureSensor) obj).w1Address);
|
||||
return false;
|
||||
if(obj instanceof RPiTemperatureSensor && w1Address != null)
|
||||
return this.get1WAddress().equals(((RPiTemperatureSensor) obj).w1Address);
|
||||
return false;
|
||||
}
|
||||
|
||||
public String get1WAddress() {
|
||||
return w1Address;
|
||||
}
|
||||
public String get1WAddress() {
|
||||
return w1Address;
|
||||
}
|
||||
|
||||
}
|
||||
75
plugins/raspberry/src/se/hal/plugin/raspberry/RPiUtility.java
Executable file
75
plugins/raspberry/src/se/hal/plugin/raspberry/RPiUtility.java
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
package se.hal.plugin.raspberry;
|
||||
|
||||
import com.pi4j.io.gpio.Pin;
|
||||
import com.pi4j.io.gpio.RaspiPin;
|
||||
|
||||
public class RPiUtility {
|
||||
|
||||
public static Pin getPin(int gpioPin){
|
||||
switch(gpioPin){
|
||||
case 0:
|
||||
return RaspiPin.GPIO_00;
|
||||
case 1:
|
||||
return RaspiPin.GPIO_01;
|
||||
case 2:
|
||||
return RaspiPin.GPIO_02;
|
||||
case 3:
|
||||
return RaspiPin.GPIO_03;
|
||||
case 4:
|
||||
return RaspiPin.GPIO_04;
|
||||
case 5:
|
||||
return RaspiPin.GPIO_05;
|
||||
case 6:
|
||||
return RaspiPin.GPIO_06;
|
||||
case 7:
|
||||
//used by 1-wire divices
|
||||
case 8:
|
||||
//used by I2C devices
|
||||
case 9:
|
||||
//used by I2C devices
|
||||
case 10:
|
||||
//used by SPI devices
|
||||
case 11:
|
||||
//used by SPI devices
|
||||
case 12:
|
||||
//used by SPI devices
|
||||
case 13:
|
||||
//used by SPI devices
|
||||
case 14:
|
||||
//used by SPI devices
|
||||
case 15:
|
||||
//used by Serial devices
|
||||
case 16:
|
||||
//used by Serial devices
|
||||
case 17:
|
||||
//reserved for future use
|
||||
case 18:
|
||||
//reserved for future use
|
||||
case 19:
|
||||
//reserved for future use
|
||||
case 20:
|
||||
//reserved for future use
|
||||
case 21:
|
||||
//reserved for future use
|
||||
case 22:
|
||||
//reserved for future use
|
||||
case 23:
|
||||
//reserved for future use
|
||||
case 24:
|
||||
//reserved for future use
|
||||
case 25:
|
||||
//reserved for future use
|
||||
case 26:
|
||||
//reserved for future use
|
||||
case 27:
|
||||
//reserved for future use
|
||||
case 28:
|
||||
//reserved for future use
|
||||
case 29:
|
||||
//reserved for future use
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
68
plugins/raspberry/src/se/hal/plugin/raspberry/hardware/RPiDS18B20.java
Executable file
68
plugins/raspberry/src/se/hal/plugin/raspberry/hardware/RPiDS18B20.java
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
package se.hal.plugin.raspberry.hardware;
|
||||
|
||||
import com.pi4j.component.temperature.TemperatureSensor;
|
||||
import com.pi4j.io.w1.W1Master;
|
||||
import com.pi4j.temperature.TemperatureScale;
|
||||
import se.hal.plugin.raspberry.RPiController;
|
||||
import se.hal.plugin.raspberry.RPiSensor;
|
||||
import se.hal.plugin.raspberry.RPiTemperatureSensor;
|
||||
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RPiDS18B20 implements RPiSensor, Runnable {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
private final String DEGREE_SIGN = "\u00b0";
|
||||
|
||||
private RPiController controller;
|
||||
private String w1Address;
|
||||
private ScheduledExecutorService scheduler;
|
||||
private W1Master w1Mater;
|
||||
|
||||
public RPiDS18B20(String w1Address, RPiController controller){
|
||||
this.controller = controller;
|
||||
this.w1Address = w1Address;
|
||||
|
||||
scheduler = Executors.newScheduledThreadPool(1);
|
||||
|
||||
w1Mater = new W1Master();
|
||||
|
||||
//print out all sensors found
|
||||
for(TemperatureSensor device : w1Mater.getDevices(TemperatureSensor.class)){
|
||||
logger.info(String.format("1-Wire temperature sensor divice found: %-20s: %3.1f"+DEGREE_SIGN+"C\n", device.getName(), device.getTemperature(TemperatureScale.CELSIUS)));
|
||||
}
|
||||
|
||||
//schedule job
|
||||
scheduler.scheduleAtFixedRate(this, 10, 60, TimeUnit.SECONDS); //wait 10s and run every 60s
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
scheduler.shutdown();
|
||||
try {
|
||||
scheduler.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
//noop
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(TemperatureSensor device : w1Mater.getDevices(TemperatureSensor.class)){
|
||||
if(device.getName().equals(w1Address)){
|
||||
controller.sendDataReport(
|
||||
new RPiTemperatureSensor(w1Address),
|
||||
new TemperatureSensorData(
|
||||
device.getTemperature(TemperatureScale.CELSIUS),
|
||||
System.currentTimeMillis()
|
||||
));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,74 +17,74 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
public class RPiInteruptPulseFlankCounter implements Runnable, GpioPinListenerDigital, RPiSensor {
|
||||
private static final int REPORT_TIMEOUT = 60_000; //one minute
|
||||
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
private RPiController controller;
|
||||
private ExecutorService executorPool;
|
||||
private long nanoSecondsSleep = REPORT_TIMEOUT * 1_000_000L;
|
||||
private volatile Integer impulseCount = 0;
|
||||
private GpioPinDigitalInput irLightSensor;
|
||||
private final int gpioPin;
|
||||
|
||||
public RPiInteruptPulseFlankCounter(int gpioPin, RPiController controller){
|
||||
this.controller = controller;
|
||||
this.gpioPin = gpioPin;
|
||||
|
||||
// setup a thread pool for executing jobs
|
||||
private static final int REPORT_TIMEOUT = 60_000; //one minute
|
||||
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
private RPiController controller;
|
||||
private ExecutorService executorPool;
|
||||
private long nanoSecondsSleep = REPORT_TIMEOUT * 1_000_000L;
|
||||
private volatile Integer impulseCount = 0;
|
||||
private GpioPinDigitalInput irLightSensor;
|
||||
private final int gpioPin;
|
||||
|
||||
public RPiInteruptPulseFlankCounter(int gpioPin, RPiController controller){
|
||||
this.controller = controller;
|
||||
this.gpioPin = gpioPin;
|
||||
|
||||
// setup a thread pool for executing jobs
|
||||
this.executorPool = Executors.newCachedThreadPool();
|
||||
|
||||
//Enable non privileged access to the GPIO pins (no sudo required from now)
|
||||
GpioUtil.enableNonPrivilegedAccess();
|
||||
//Enable non privileged access to the GPIO pins (no sudo required from now)
|
||||
GpioUtil.enableNonPrivilegedAccess();
|
||||
|
||||
// create gpio controller
|
||||
GpioController gpio = null;
|
||||
try{
|
||||
gpio = GpioFactory.getInstance();
|
||||
}catch(IllegalArgumentException e){
|
||||
logger.log(Level.SEVERE, "", e);
|
||||
throw e;
|
||||
}catch(UnsatisfiedLinkError e){
|
||||
logger.log(Level.SEVERE, "", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// provision gpio pin as an input pin with its internal pull up resistor enabled
|
||||
irLightSensor = gpio.provisionDigitalInputPin(RPiUtility.getPin(gpioPin), PinPullResistance.PULL_UP);
|
||||
// create gpio controller
|
||||
GpioController gpio = null;
|
||||
try{
|
||||
gpio = GpioFactory.getInstance();
|
||||
}catch(IllegalArgumentException e){
|
||||
logger.log(Level.SEVERE, "", e);
|
||||
throw e;
|
||||
}catch(UnsatisfiedLinkError e){
|
||||
logger.log(Level.SEVERE, "", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// provision gpio pin as an input pin with its internal pull up resistor enabled
|
||||
irLightSensor = gpio.provisionDigitalInputPin(RPiUtility.getPin(gpioPin), PinPullResistance.PULL_UP);
|
||||
|
||||
// create and register gpio pin listener. May require the program to be run as sudo if the GPIO pin has not been exported
|
||||
irLightSensor.addListener(this);
|
||||
|
||||
//start a daemon thread to save the impulse count every minute
|
||||
//start a daemon thread to save the impulse count every minute
|
||||
Thread thread = new Thread(this);
|
||||
thread.setDaemon(false);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
irLightSensor.removeListener(this);
|
||||
executorPool.shutdown();
|
||||
irLightSensor.removeListener(this);
|
||||
executorPool.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* GpioPinListenerDigital interface
|
||||
*/
|
||||
@Override
|
||||
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
|
||||
if(event.getState() == PinState.LOW){ //low = light went on
|
||||
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
|
||||
if(event.getState() == PinState.LOW){ //low = light went on
|
||||
//System.out.println("IR LED turned ON");
|
||||
//logger.log(Level.INFO, "IR LED turned on");
|
||||
synchronized(impulseCount){
|
||||
impulseCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long startTime = System.nanoTime();
|
||||
synchronized(impulseCount){
|
||||
@Override
|
||||
public void run() {
|
||||
long startTime = System.nanoTime();
|
||||
synchronized(impulseCount){
|
||||
impulseCount = 0; //reset the impulse count
|
||||
}
|
||||
while(!executorPool.isShutdown()) {
|
||||
|
|
@ -103,19 +103,19 @@ public class RPiInteruptPulseFlankCounter implements Runnable, GpioPinListenerDi
|
|||
nanoSecondsSleep -= nanoSecondsTooMany / 3; //divide by constant to take into account varaiations im loop time
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
}
|
||||
|
||||
/**
|
||||
* Sleep for [ns] nanoseconds
|
||||
* @param ns
|
||||
*/
|
||||
private void sleepNano(long ns){
|
||||
//System.out.println("will go to sleep for " + ns + "ns");
|
||||
try{
|
||||
Thread.sleep(ns/1000000L, (int)(ns%1000000L));
|
||||
}catch(InterruptedException e){
|
||||
//ignore
|
||||
}
|
||||
try{
|
||||
Thread.sleep(ns/1000000L, (int)(ns%1000000L));
|
||||
}catch(InterruptedException e){
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,18 +128,18 @@ public class RPiInteruptPulseFlankCounter implements Runnable, GpioPinListenerDi
|
|||
* @param data
|
||||
*/
|
||||
private void save(final long timestamp_end, final int data){
|
||||
//offload the timed loop by not doing the db interaction in this thread.
|
||||
executorPool.execute(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
logger.log(Level.INFO, "Reporting data. timestamp_end="+timestamp_end+", data="+data);
|
||||
controller.sendDataReport(
|
||||
new RPiPowerConsumptionSensor(gpioPin),
|
||||
//offload the timed loop by not doing the db interaction in this thread.
|
||||
executorPool.execute(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
logger.log(Level.INFO, "Reporting data. timestamp_end="+timestamp_end+", data="+data);
|
||||
controller.sendDataReport(
|
||||
new RPiPowerConsumptionSensor(gpioPin),
|
||||
new PowerConsumptionSensorData(
|
||||
timestamp_end, data
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
8
plugins/raspberry/src/se/hal/plugin/raspberry/plugin.json
Executable file
8
plugins/raspberry/src/se/hal/plugin/raspberry/plugin.json
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"version": 1.1,
|
||||
"name": "Raspberry Pi Sensors",
|
||||
"interfaces": [
|
||||
{"se.hal.intf.HalSensorConfig": "se.hal.plugin.raspberry.RPiPowerConsumptionSensor"},
|
||||
{"se.hal.intf.HalSensorConfig": "se.hal.plugin.raspberry.RPiTemperatureSensor"}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
package se.hal.plugin.raspberry;
|
||||
|
||||
import se.hal.intf.*;
|
||||
import se.hal.plugin.raspberry.hardware.RPiDS18B20;
|
||||
import se.hal.plugin.raspberry.hardware.RPiInteruptPulseFlankCounter;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RPiController implements HalSensorController {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
private HashMap<String, RPiSensor> pinToSensorMap = new HashMap<>();
|
||||
private HalSensorReportListener sensorListener;
|
||||
|
||||
public RPiController(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(HalSensorConfig sensor) {
|
||||
if(sensor instanceof RPiPowerConsumptionSensor){
|
||||
RPiPowerConsumptionSensor powerConsumptionSensor = (RPiPowerConsumptionSensor) sensor;
|
||||
int gpioPin = powerConsumptionSensor.getGpioPin();
|
||||
if(!pinToSensorMap.containsKey("GPIO_"+gpioPin)){
|
||||
RPiInteruptPulseFlankCounter impulseCounter = new RPiInteruptPulseFlankCounter(gpioPin, this);
|
||||
pinToSensorMap.put("GPIO_"+gpioPin, impulseCounter);
|
||||
}else{
|
||||
logger.warning("Cannot create a RPiPowerConsumptionSensor on GPIO pin " + gpioPin + " since is already is in use by another sensor.");
|
||||
}
|
||||
} else if(sensor instanceof RPiTemperatureSensor){
|
||||
RPiTemperatureSensor temperatureSensor = (RPiTemperatureSensor) sensor;
|
||||
String w1Address = temperatureSensor.get1WAddress();
|
||||
if(!pinToSensorMap.containsKey("W1_"+w1Address)){
|
||||
RPiDS18B20 ds12b20 = new RPiDS18B20(w1Address, this);
|
||||
pinToSensorMap.put("W1_"+w1Address, ds12b20);
|
||||
}else{
|
||||
logger.warning("Cannot create a RPi1WireTemperatureSensor on 1-Wire address " + w1Address + " since is already is in use by another sensor.");
|
||||
}
|
||||
}else{
|
||||
logger.warning("Cannot register a non-supported sensor");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deregister(HalSensorConfig sensor) {
|
||||
if(sensor instanceof RPiPowerConsumptionSensor){
|
||||
RPiPowerConsumptionSensor powerConsumprtionSensor = (RPiPowerConsumptionSensor) sensor;
|
||||
RPiSensor sensorToDeregister = pinToSensorMap.remove("GPIO_"+powerConsumprtionSensor.getGpioPin());
|
||||
if(sensorToDeregister != null){
|
||||
sensorToDeregister.close();
|
||||
}
|
||||
} else if(sensor instanceof RPiTemperatureSensor){
|
||||
RPiTemperatureSensor temperatureSensor = (RPiTemperatureSensor) sensor;
|
||||
RPiSensor sensorToDeregister = pinToSensorMap.remove("W1_"+temperatureSensor.get1WAddress());
|
||||
if(sensorToDeregister != null){
|
||||
sensorToDeregister.close();
|
||||
}
|
||||
}else{
|
||||
logger.warning("Cannot deregister a non-supported sensor");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return pinToSensorMap.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(HalSensorReportListener listener) {
|
||||
sensorListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
for(String key : this.pinToSensorMap.keySet()){
|
||||
pinToSensorMap.get(key).close();
|
||||
pinToSensorMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendDataReport(HalSensorConfig sensorConfig, HalSensorData sensorData){
|
||||
if(sensorListener != null){
|
||||
sensorListener.reportReceived(sensorConfig, sensorData);
|
||||
}else{
|
||||
logger.log(Level.WARNING, "Could not report data. No registered listener");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
package se.hal.plugin.raspberry;
|
||||
|
||||
import com.pi4j.io.gpio.Pin;
|
||||
import com.pi4j.io.gpio.RaspiPin;
|
||||
|
||||
public class RPiUtility {
|
||||
|
||||
public static Pin getPin(int gpioPin){
|
||||
switch(gpioPin){
|
||||
case 0:
|
||||
return RaspiPin.GPIO_00;
|
||||
case 1:
|
||||
return RaspiPin.GPIO_01;
|
||||
case 2:
|
||||
return RaspiPin.GPIO_02;
|
||||
case 3:
|
||||
return RaspiPin.GPIO_03;
|
||||
case 4:
|
||||
return RaspiPin.GPIO_04;
|
||||
case 5:
|
||||
return RaspiPin.GPIO_05;
|
||||
case 6:
|
||||
return RaspiPin.GPIO_06;
|
||||
case 7:
|
||||
//used by 1-wire divices
|
||||
case 8:
|
||||
//used by I2C devices
|
||||
case 9:
|
||||
//used by I2C devices
|
||||
case 10:
|
||||
//used by SPI devices
|
||||
case 11:
|
||||
//used by SPI devices
|
||||
case 12:
|
||||
//used by SPI devices
|
||||
case 13:
|
||||
//used by SPI devices
|
||||
case 14:
|
||||
//used by SPI devices
|
||||
case 15:
|
||||
//used by Serial devices
|
||||
case 16:
|
||||
//used by Serial devices
|
||||
case 17:
|
||||
//reserved for future use
|
||||
case 18:
|
||||
//reserved for future use
|
||||
case 19:
|
||||
//reserved for future use
|
||||
case 20:
|
||||
//reserved for future use
|
||||
case 21:
|
||||
//reserved for future use
|
||||
case 22:
|
||||
//reserved for future use
|
||||
case 23:
|
||||
//reserved for future use
|
||||
case 24:
|
||||
//reserved for future use
|
||||
case 25:
|
||||
//reserved for future use
|
||||
case 26:
|
||||
//reserved for future use
|
||||
case 27:
|
||||
//reserved for future use
|
||||
case 28:
|
||||
//reserved for future use
|
||||
case 29:
|
||||
//reserved for future use
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
package se.hal.plugin.raspberry.hardware;
|
||||
|
||||
import com.pi4j.component.temperature.TemperatureSensor;
|
||||
import com.pi4j.io.w1.W1Master;
|
||||
import com.pi4j.temperature.TemperatureScale;
|
||||
import se.hal.plugin.raspberry.RPiController;
|
||||
import se.hal.plugin.raspberry.RPiSensor;
|
||||
import se.hal.plugin.raspberry.RPiTemperatureSensor;
|
||||
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RPiDS18B20 implements RPiSensor, Runnable {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
private final String DEGREE_SIGN = "\u00b0";
|
||||
|
||||
private RPiController controller;
|
||||
private String w1Address;
|
||||
private ScheduledExecutorService scheduler;
|
||||
private W1Master w1Mater;
|
||||
|
||||
public RPiDS18B20(String w1Address, RPiController controller){
|
||||
this.controller = controller;
|
||||
this.w1Address = w1Address;
|
||||
|
||||
scheduler = Executors.newScheduledThreadPool(1);
|
||||
|
||||
w1Mater = new W1Master();
|
||||
|
||||
//print out all sensors found
|
||||
for(TemperatureSensor device : w1Mater.getDevices(TemperatureSensor.class)){
|
||||
logger.info(String.format("1-Wire temperature sensor divice found: %-20s: %3.1f"+DEGREE_SIGN+"C\n", device.getName(), device.getTemperature(TemperatureScale.CELSIUS)));
|
||||
}
|
||||
|
||||
//schedule job
|
||||
scheduler.scheduleAtFixedRate(this, 10, 60, TimeUnit.SECONDS); //wait 10s and run every 60s
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
scheduler.shutdown();
|
||||
try {
|
||||
scheduler.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
//noop
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(TemperatureSensor device : w1Mater.getDevices(TemperatureSensor.class)){
|
||||
if(device.getName().equals(w1Address)){
|
||||
controller.sendDataReport(
|
||||
new RPiTemperatureSensor(w1Address),
|
||||
new TemperatureSensorData(
|
||||
device.getTemperature(TemperatureScale.CELSIUS),
|
||||
System.currentTimeMillis()
|
||||
));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"version": 1.1,
|
||||
"name": "Raspberry Pi Sensors",
|
||||
"interfaces": [
|
||||
{"se.hal.intf.HalSensorConfig": "se.hal.plugin.raspberry.RPiPowerConsumptionSensor"},
|
||||
{"se.hal.intf.HalSensorConfig": "se.hal.plugin.raspberry.RPiTemperatureSensor"}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue