Created
December 4, 2009 22:10
-
-
Save dansimpson/249401 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'pp' | |
require 'logger' | |
$LOAD_PATH << File.dirname(__FILE__) | |
require 'proxy/base' | |
require 'proxy/wibox_proxy' | |
require 'sensors/reading' | |
require 'sensors/sensor' | |
require 'sensors/active_reading' | |
require 'tweeter' | |
Log = Logger.new(File.dirname(__FILE__) + "/processor.log"); | |
#run the eventmachine, which streams data from the wibox | |
#and also tweets status every N minutes | |
EM.run { | |
sensor = Sensor.new | |
proxy = Proxy::WiboxProxy.new({ | |
:host => "192.168.0.2", | |
:port => 8088, | |
:user => "ws", | |
:password => "test", | |
:auto_ack => true | |
}) | |
proxy.on_data do |data| | |
reading = sensor.build_reading(data) | |
reading.save | |
puts reading.to_log_s | |
Log.info reading.to_log_s | |
end | |
proxy.on_announce do |data| | |
puts "ANNOUNCE! #{data}" | |
end | |
proxy.connect | |
#EM.add_periodic_timer(Settings.tweet_interval * 600) do | |
# processor.tweet | |
#end | |
Log.info "Tweeter is running!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment