Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Add timout to ARC16 scrape.
Browse files Browse the repository at this point in the history
See issue #57.
  • Loading branch information
mmanguno committed Sep 12, 2016
1 parent a09f9ec commit dff192a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/controllers/air/transmitter_log_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ def index

# scrape the power readings page
begin
doc = Nokogiri::XML(open('http://opdesk.wrek.org/engineering/arc16xml.php'))
@plate_current = doc.at_css('Channel[name="PLTCUR"]')[:value]
@plate_voltage = doc.at_css('Channel[name="PLTVLT"]')[:value]
@power_out = doc.at_css('Channel[name="PWROUT"]')[:value]
timout(5) do
doc = Nokogiri::XML(open('http://opdesk.wrek.org/engineering/arc16xml.php'))
@plate_current = doc.at_css('Channel[name="PLTCUR"]')[:value]
@plate_voltage = doc.at_css('Channel[name="PLTVLT"]')[:value]
@power_out = doc.at_css('Channel[name="PWROUT"]')[:value]
end
rescue
@plate_current = "?"
@plate_voltage = "?"
Expand Down Expand Up @@ -63,4 +65,4 @@ def transmitter_log_entry_params
params.require(:transmitter_log_entry).permit(:sign_in, :automation_in, :automation_out, :sign_out)
end

end
end

0 comments on commit dff192a

Please sign in to comment.