Changeset 05062c9 for de.wigbels.ruby/hothotread
- Timestamp:
- 02/19/2017 11:23:59 AM (8 years ago)
- Branches:
- master
- Children:
- 8d49a2d
- Parents:
- 2c75e95
- Location:
- de.wigbels.ruby/hothotread
- Files:
-
- 4 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
de.wigbels.ruby/hothotread/hothotpiper_water.rb
r2c75e95 r05062c9 7 7 8 8 mypath = File.expand_path(File.dirname(__FILE__)) 9 trigger_step = 0.0 19 trigger_step = 0.001 10 10 trigger_watch = 0 11 11 counter = 0.0 … … 26 26 end 27 27 28 watch :pin => 9, :trigger => :falling do 29 #puts "Pin changed from #{pin.last_value} to #{pin.value}" 28 watch :pin => 9, :trigger => :rising, :pull => :up do 30 29 puts('triggered watch to 1') 31 30 trigger_watch = 1 … … 33 32 34 33 35 rrdpath = mypath + "/ gasneu.rrd"34 rrdpath = mypath + "/water.rrd" 36 35 counter = last_rrd_count(rrdpath) 37 36 puts('Counter restored to: ' + counter.to_s) 38 #PiPiper::Pin.new(:pin => 24, :direction => :in)39 37 40 38 EventMachine.run do … … 42 40 if trigger_watch == 1 then 43 41 counter = counter + trigger_step 44 #system("rrdtool update #{rrdpath} N:#{counter}:#{trigger_step}")42 system("rrdtool update #{rrdpath} N:#{counter}:#{trigger_step}") 45 43 puts('Counter updated to: ' + counter.to_s) 46 44 timestamp = Time.now.to_i 47 45 trigger_watch = 0 48 46 elsif Time.now.to_i - timestamp > 3600 49 #system("rrdtool update #{rrdpath} N:#{counter}:0")47 system("rrdtool update #{rrdpath} N:#{counter}:0") 50 48 timestamp = Time.now.to_i 51 49 end
Note:
See TracChangeset
for help on using the changeset viewer.