source: de.wigbels.ruby/hothotread/archiv/hothotpiper_gas.rb@ cb8a295

Last change on this file since cb8a295 was 8cc14b9, checked in by Norbert Wigbels <njw@…>, 9 years ago

Aufraeumen

  • Property mode set to 100644
File size: 818 bytes
Line 
1#!/usr/bin/env ruby
2
3require 'pi_piper'
4include PiPiper
5
6mypath = File.expand_path(File.dirname(__FILE__))
7trigger_step = 0.01
8trigger_watch = 0
9counter = 0
10timestamp = Time.now.to_i
11
12def last_rrd_count(concretepath)
13 val = 0.0
14 handle = IO.popen("rrdtool lastupdate #{concretepath}")
15 handle.each_line do |line|
16 m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
17 if m
18 val = m[1].to_f
19 break
20 end
21 end
22 return val
23end
24
25
26watch :pin => 4, :trigger => :falling do
27 puts('added 10 liter of gas to sensor-database')
28 system("rrdtool update #{mypath}/gas.rrd N:10")
29end
30
31rrdpath = mypath + "/gasneu.rrd"
32counter = last_rrd_count(rrdpath)
33#loop do
34# if trigger_watch == 1 then
35# puts('trigger 1 detected')
36# trigger_watch = 0
37# else
38# puts('trigger 0 detected')
39# end
40# sleep(1)
41#end
42PiPiper.wait
Note: See TracBrowser for help on using the repository browser.