Index: de.wigbels.ruby/hothotread/archiv/daemon_run.rb
===================================================================
--- de.wigbels.ruby/hothotread/archiv/daemon_run.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/daemon_run.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'daemons'
+
+mypath = File.expand_path(File.dirname(__FILE__))
+Daemons.run("#{mypath}/hothotpiper.rb")
Index: de.wigbels.ruby/hothotread/archiv/deploy
===================================================================
--- de.wigbels.ruby/hothotread/archiv/deploy	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/deploy	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,1 @@
+scp -P 2342 hothotread.rb root@192.168.14.7:/root/hothotread/hothotread.rb
Index: de.wigbels.ruby/hothotread/archiv/draw_graphs.sh
===================================================================
--- de.wigbels.ruby/hothotread/archiv/draw_graphs.sh	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/draw_graphs.sh	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,57 @@
+#!/bin/bash 
+#DEF:temps9=../hotcoldrain/weather.rrd:temps9:AVERAGE \
+#LINE1:temps9#4e9a06:"Temperatur aussen\n" \
+
+rrdtool graph web/gas_1tag.png \
+-w 800 -h 500 \
+-s 'now - 1 day' -e 'now' \
+--title "Gasverbrauch im Tagesverlauf" \
+--font TITLE:12 --vertical-label="Liter/Stunde" \
+DEF:gas=gas.rrd:gas:AVERAGE \
+CDEF:gash=gas,120,* \
+VDEF:gastotal=gas,TOTAL \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
+LINE2:gash#c17d11:"Gasverbrauch"
+
+rrdtool graph web/gas_1woche.png \
+-w 800 -h 500 \
+-s 'now - 1 week' -e 'now' \
+--title "Gasverbrauch im Wochenverlauf" \
+--font TITLE:12 --vertical-label="Liter/Tag" \
+DEF:gas=gas.rrd:gas:AVERAGE \
+CDEF:gasd=gas,2880,* \
+VDEF:gastotal=gas,TOTAL \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
+LINE2:gasd#c17d11:"Gasverbrauch/Tag"
+
+rrdtool graph web/gas_1monat.png \
+-w 800 -h 500 \
+-s 'now - 1 month' -e 'now' \
+--title "Gasverbrauch im Monatsverlauf" \
+--font TITLE:12 --vertical-label="Liter/Tag" \
+DEF:gas=gas.rrd:gas:AVERAGE \
+CDEF:gasd=gas,2880,* \
+VDEF:gastotal=gas,TOTAL \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
+LINE2:gasd#c17d11:"Gasverbrauch/Tag"
+
+rrdtool graph web/gas_1jahr.png \
+-w 800 -h 500 \
+-s 'now - 1 year' -e 'now' \
+--title "Gasverbrauch im Jahresverlauf" \
+--font TITLE:12 --vertical-label="Liter/Tag" \
+DEF:gas=gas.rrd:gas:AVERAGE \
+CDEF:gasd=gas,2880,* \
+VDEF:gastotal=gas,TOTAL \
+GPRINT:gastotal:"Total %6.0lf Liter Gas" \
+LINE2:gasd#c17d11:"Gasverbrauch/Tag"
+
+
+
+rrdtool graph web/consum_1day.png   -s 'now -1 day' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+rrdtool graph web/consum_1week.png   -s 'now -1 week' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+rrdtool graph web/consum_1month.png   -s 'now -1 month' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+rrdtool graph web/consum_1year.png   -s 'now -1 year' -e 'now'   -Y -A   DEF:consum=power.rrd:consum:AVERAGE   LINE2:consum#00FF00:"Verbrauch [W]"
+
+rrdtool graph web/counter_1week.png   -s 'now -1 week' -e 'now'   -X 0 -Y -A   DEF:counter=power.rrd:counter:LAST   LINE2:counter#000000:"ZÃ€hlerstand [kWh]"
+rrdtool graph web/counter_1month.png   -s 'now -1 month' -e 'now'   -X 0 -Y -A   DEF:counter=power.rrd:counter:LAST   LINE2:counter#000000:"ZÃ€hlerstand [kWh]"
Index: de.wigbels.ruby/hothotread/archiv/hothotpiper.rb
===================================================================
--- de.wigbels.ruby/hothotread/archiv/hothotpiper.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/hothotpiper.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+#
+# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
+#
+# HotHotPiper continously reads the status of a
+# reed contact attached to the Raspberry Pi GPIO
+#
+# The reed measures gas usage.
+#
+# A magig URL is formed and called; the url
+# stores the sensor-data to wigbels.net
+#
+# todo: status-led
+# 
+
+#------------------------------------------
+# Tainted mode 0-4
+$SAFE=0
+
+#------------------------------------------
+require 'pi_piper'
+include PiPiper
+
+$mypath = File.expand_path(File.dirname(__FILE__))
+
+
+def last_rrd_count
+  val = 0.0
+  handle = IO.popen("rrdtool lastupdate #{$mypath}/power.rrd")
+  handle.each_line do |line|
+    m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
+    if m
+      val = m[1].to_f
+      break
+    end
+  end
+  return val
+end
+
+
+watch :pin => 4, :trigger => :falling do 
+  puts('added 10 liter of gas to sensor-database')
+  system("rrdtool update #{$mypath}/gas.rrd N:10")
+end
+
+watch :pin => 11, :trigger => :falling  do
+  puts('updated power consumption')
+  $counter = $counter + $trigger_step
+  trigger_update = $trigger_step * 3600000.0
+  system("rrdtool update #{$mypath}/power.rrd N:#{$counter}:#{trigger_update}")
+end
+
+$trigger_step = 1.0 / 96
+$counter = last_rrd_count
+
+PiPiper.wait
Index: de.wigbels.ruby/hothotread/archiv/hothotpiper_gas.rb
===================================================================
--- de.wigbels.ruby/hothotread/archiv/hothotpiper_gas.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/hothotpiper_gas.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+require 'pi_piper'
+include PiPiper
+
+mypath = File.expand_path(File.dirname(__FILE__))
+trigger_step = 0.01
+trigger_watch = 0
+counter = 0
+timestamp =  Time.now.to_i
+
+def last_rrd_count(concretepath)
+  val = 0.0
+  handle = IO.popen("rrdtool lastupdate #{concretepath}")
+  handle.each_line do |line|
+    m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
+    if m
+      val = m[1].to_f
+      break
+    end
+  end
+  return val
+end
+
+
+watch :pin => 4, :trigger => :falling do 
+  puts('added 10 liter of gas to sensor-database')
+  system("rrdtool update #{mypath}/gas.rrd N:10")
+end
+
+rrdpath = mypath + "/gasneu.rrd"
+counter = last_rrd_count(rrdpath)
+#loop do
+# if trigger_watch == 1 then
+#  puts('trigger 1 detected')
+#  trigger_watch = 0
+# else
+#  puts('trigger 0 detected')
+# end
+# sleep(1)
+#end
+PiPiper.wait
Index: de.wigbels.ruby/hothotread/archiv/lastupdate.rb
===================================================================
--- de.wigbels.ruby/hothotread/archiv/lastupdate.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/lastupdate.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,14 @@
+def last_rrd_count
+  val = 0.0
+  handle = IO.popen("rrdtool lastupdate power.rrd")
+  handle.each_line do |line|
+    m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
+    if m
+      val = m[1].to_f
+      break
+    end
+  end
+  return val
+end
+
+puts last_rrd_count
Index: de.wigbels.ruby/hothotread/archiv/test.rb
===================================================================
--- de.wigbels.ruby/hothotread/archiv/test.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/test.rb	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,19 @@
+require 'pi_piper'
+include PiPiper
+
+trigger_watch = 0
+
+watch :pin => 11, :trigger => :falling  do
+  puts('trigger registered')
+  trigger_watch = 1
+end
+
+loop do
+ if trigger_watch == 1 then
+  puts('trigger 1 detected')
+  trigger_watch = 0
+ else
+  puts('trigger 0 detected')
+ end
+ sleep(5)
+end
Index: de.wigbels.ruby/hothotread/archiv/todo
===================================================================
--- de.wigbels.ruby/hothotread/archiv/todo	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
+++ de.wigbels.ruby/hothotread/archiv/todo	(revision f15e2acd44fd309bc0ff7250b28a78c86040a769)
@@ -0,0 +1,4 @@
+http://www.blackberryforums.com/developer-forum/2730-persistant-tcp-connection.html
+
+nested retry
+restart
