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 |
|
---|
3 | require 'pi_piper'
|
---|
4 | include PiPiper
|
---|
5 |
|
---|
6 | mypath = File.expand_path(File.dirname(__FILE__))
|
---|
7 | trigger_step = 0.01
|
---|
8 | trigger_watch = 0
|
---|
9 | counter = 0
|
---|
10 | timestamp = Time.now.to_i
|
---|
11 |
|
---|
12 | def 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
|
---|
23 | end
|
---|
24 |
|
---|
25 |
|
---|
26 | watch :pin => 4, :trigger => :falling do
|
---|
27 | puts('added 10 liter of gas to sensor-database')
|
---|
28 | system("rrdtool update #{mypath}/gas.rrd N:10")
|
---|
29 | end
|
---|
30 |
|
---|
31 | rrdpath = mypath + "/gasneu.rrd"
|
---|
32 | counter = 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
|
---|
42 | PiPiper.wait
|
---|
Note:
See
TracBrowser
for help on using the repository browser.