Class: Proliphix::Network
- Inherits:
-
Object
- Object
- Proliphix::Network
- Defined in:
- lib/pdp/network.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#query ⇒ Object
Returns the value of attribute query.
-
#simulate ⇒ Object
Returns the value of attribute simulate.
-
#squery ⇒ Object
Returns the value of attribute squery.
Instance Method Summary collapse
- #[](reading) ⇒ Object
- #get(name) ⇒ Object
-
#initialize(ip, user, passwd) ⇒ Network
constructor
A new instance of Network.
- #set(name, value) ⇒ Object
Constructor Details
#initialize(ip, user, passwd) ⇒ Network
Returns a new instance of Network.
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 |
# File 'lib/pdp/network.rb', line 11 def initialize(ip, user, passwd) @buffer = "" @debug = false @simulate = false @ip = ip @user = user @passwd = passwd @last = Time.now.to_i - 120 @fetched = {} @sensors = [ ThermHvacMode, ThermHvacState, ThermFanMode, ThermFanState, ThermSetbackHeat, ThermSetbackCool, ThermHeat1Usage, ThermCool1Usage, ThermFanUsage, ThermAverageTemp, ThermSystemTimeSecs, ThermAuxHeatMode, ThermAuxHeatOffset ] end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
9 10 11 |
# File 'lib/pdp/network.rb', line 9 def buffer @buffer end |
#debug ⇒ Object
Returns the value of attribute debug.
9 10 11 |
# File 'lib/pdp/network.rb', line 9 def debug @debug end |
#query ⇒ Object
Returns the value of attribute query.
9 10 11 |
# File 'lib/pdp/network.rb', line 9 def query @query end |
#simulate ⇒ Object
Returns the value of attribute simulate.
9 10 11 |
# File 'lib/pdp/network.rb', line 9 def simulate @simulate end |
#squery ⇒ Object
Returns the value of attribute squery.
9 10 11 |
# File 'lib/pdp/network.rb', line 9 def squery @squery end |
Instance Method Details
#[](reading) ⇒ Object
38 39 40 |
# File 'lib/pdp/network.rb', line 38 def [](reading) return @fetched[reading] end |
#get(name) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/pdp/network.rb', line 42 def get(name) if self[name] and up_to_date return self[name] else fetch_data # TODO: what if we don't manage to return values return self[name] end end |
#set(name, value) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/pdp/network.rb', line 52 def set(name, value) set_data(name, value) if not @simulate sleep 1 end fetch_data end |