forked from rsposton/monitor-temperature
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecord_temp.rb
35 lines (29 loc) · 1.11 KB
/
record_temp.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env ruby
require_relative('thermometer')
require_relative('functions')
require('open-uri')
puts "\n*** Initializing Setup ***"
puts "Time: #{Time.now}"
t=Thermometer.new
command_line_arguments = check_args
puts "Endpoint details:"
puts "host: #{command_line_arguments[:endpoint].host}"
puts "path: #{command_line_arguments[:endpoint].path}"
puts "port: #{command_line_arguments[:endpoint].port}"
puts "user: #{command_line_arguments[:endpoint].user}"
puts "pswd: #{command_line_arguments[:endpoint].password}"
puts "\n*** Finding Sensor ***"
t.find_sensor(command_line_arguments)
puts "\n*** Checking Thermometer File ***"
readings = t.read
readings.each do |reading|
puts "Reading in celcius: "+reading.to_celcius.to_s
puts "Reading in fahrenheit: "+reading.to_fahrenheit.to_s
end
puts "\n*** Recording Temperature to Endpoint ***"
readings.each do |reading|
puts "recording location: #{command_line_arguments[:location]}"
fahrenheit = reading.to_fahrenheit
puts "temperature recorded: #{fahrenheit}"
#record_temp(command_line_arguments[:endpoint],command_line_arguments[:location],fahrenheit)
end