Ignore:
Timestamp:
02/19/2017 11:23:59 AM (8 years ago)
Author:
Norbert Wigbels <frickel@…>
Branches:
master
Children:
8d49a2d
Parents:
2c75e95
Message:

Vorbereitung Wasserzaehler

Location:
de.wigbels.ruby/hothotread
Files:
4 added
1 edited

Legend:

Unmodified
Added
Removed
  • de.wigbels.ruby/hothotread/hothotpiper_water.rb

    r2c75e95 r05062c9  
    77
    88mypath = File.expand_path(File.dirname(__FILE__))
    9 trigger_step = 0.01
     9trigger_step = 0.001
    1010trigger_watch = 0
    1111counter = 0.0
     
    2626end
    2727
    28 watch :pin => 9, :trigger => :falling  do
    29   #puts "Pin changed from #{pin.last_value} to #{pin.value}"
     28watch :pin => 9, :trigger => :rising, :pull => :up  do
    3029  puts('triggered watch to 1')
    3130  trigger_watch = 1
     
    3332
    3433
    35 rrdpath = mypath + "/gasneu.rrd"
     34rrdpath = mypath + "/water.rrd"
    3635counter = last_rrd_count(rrdpath)
    3736puts('Counter restored to: ' + counter.to_s)
    38 #PiPiper::Pin.new(:pin => 24, :direction => :in)
    3937
    4038EventMachine.run do
     
    4240    if trigger_watch == 1 then
    4341      counter = counter + trigger_step
    44       #system("rrdtool update #{rrdpath} N:#{counter}:#{trigger_step}")
     42      system("rrdtool update #{rrdpath} N:#{counter}:#{trigger_step}")
    4543      puts('Counter updated to: ' + counter.to_s)
    4644      timestamp =  Time.now.to_i
    4745      trigger_watch = 0
    4846    elsif Time.now.to_i - timestamp > 3600
    49       #system("rrdtool update #{rrdpath} N:#{counter}:0")
     47      system("rrdtool update #{rrdpath} N:#{counter}:0")
    5048      timestamp = Time.now.to_i
    5149    end
Note: See TracChangeset for help on using the changeset viewer.