Merge branch 'master' of http://repo.koc.se/hal

Former-commit-id: 9a0f546853b78d3780d00a27ef77a70a3849ac2f
This commit is contained in:
Ziver Koc 2016-01-14 17:30:12 +01:00
commit 5f55b5da65
2 changed files with 3 additions and 1 deletions

View file

@ -26,7 +26,7 @@
<target name="run-local-sensor" depends=""> <target name="run-local-sensor" depends="">
<java fork="true" failonerror="true" classname="se.hal.plugin.localsensor.ImpulseTracker"> <java fork="true" failonerror="true" classname="se.hal.plugin.localsensor.RPiImpulseCountSensor">
<classpath> <classpath>
<pathelement path="${buildDir}/hal.jar"/> <!--wildcard may not be platform independent, ok?--> <pathelement path="${buildDir}/hal.jar"/> <!--wildcard may not be platform independent, ok?-->
<pathelement path="${libDir}/*"/> <!--wildcard may not be platform independent, ok?--> <pathelement path="${libDir}/*"/> <!--wildcard may not be platform independent, ok?-->

View file

@ -56,6 +56,7 @@ public class RPiImpulseCountSensor implements Runnable {
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) { public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
if(event.getState() == PinState.LOW){ //low = light went on if(event.getState() == PinState.LOW){ //low = light went on
//System.out.println("IR LED turned ON"); //System.out.println("IR LED turned ON");
//logger.log(Level.INFO, "IR LED turned on");
synchronized(impulseCount){ synchronized(impulseCount){
impulseCount++; impulseCount++;
} }
@ -132,6 +133,7 @@ public class RPiImpulseCountSensor implements Runnable {
executorPool.execute(new Runnable(){ executorPool.execute(new Runnable(){
@Override @Override
public void run() { public void run() {
logger.log(Level.INFO, "Saving data to DB. timestamp_end="+timestamp_end+", data="+data);
try { try {
db.exec("INSERT INTO sensor_data_raw(timestamp, sensor_id, data) VALUES("+timestamp_end+", "+RPiImpulseCountSensor.this.sensorId+", "+data+")"); db.exec("INSERT INTO sensor_data_raw(timestamp, sensor_id, data) VALUES("+timestamp_end+", "+RPiImpulseCountSensor.this.sensorId+", "+data+")");
} catch (SQLException e) { } catch (SQLException e) {