Class: Sappho::Heatmiser::Proxy::HeatmiserStatus
- Inherits:
-
Object
- Object
- Sappho::Heatmiser::Proxy::HeatmiserStatus
- Includes:
- LogUtilities, Singleton
- Defined in:
- lib/sappho-heatmiser-proxy/heatmiser_status.rb
Defined Under Namespace
Classes: Schedule, TimedTemperature
Instance Attribute Summary collapse
-
#dayOfWeek ⇒ Object
readonly
Returns the value of attribute dayOfWeek.
-
#deviceTimeOffset ⇒ Object
readonly
Returns the value of attribute deviceTimeOffset.
-
#frostProtectOn ⇒ Object
readonly
Returns the value of attribute frostProtectOn.
-
#heatOn ⇒ Object
readonly
Returns the value of attribute heatOn.
-
#keyLockOn ⇒ Object
readonly
Returns the value of attribute keyLockOn.
-
#requestedTemperature ⇒ Object
readonly
Returns the value of attribute requestedTemperature.
-
#sampleTime ⇒ Object
readonly
Returns the value of attribute sampleTime.
-
#schedule ⇒ Object
readonly
Returns the value of attribute schedule.
-
#sensedTemperature ⇒ Object
readonly
Returns the value of attribute sensedTemperature.
-
#timeSinceLastValid ⇒ Object
readonly
Returns the value of attribute timeSinceLastValid.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize ⇒ HeatmiserStatus
constructor
A new instance of HeatmiserStatus.
- #invalidate ⇒ Object
- #raw ⇒ Object
- #set(raw, timestamp, sampleTime) ⇒ Object
Constructor Details
#initialize ⇒ HeatmiserStatus
Returns a new instance of HeatmiserStatus.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 60 def initialize @mutex = Mutex.new @log = Sappho::ApplicationAutoFlushLog.instance @valid = false @raw = [] @timestamp = Time.now @sampleTime = 0.0 @timeSinceLastValid = 0.0 @sensedTemperature = 0.0 @requestedTemperature = 0 @holidayReturnTime = Time.now @holdMinutes = 0 @heatOn = false @keyLockOn = false @frostProtectOn = false @holidayOn = false @deviceTimeOffset = 0.0 @dayOfWeek = 0 @schedule = {} end |
Instance Attribute Details
#dayOfWeek ⇒ Object (readonly)
Returns the value of attribute dayOfWeek.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def dayOfWeek @dayOfWeek end |
#deviceTimeOffset ⇒ Object (readonly)
Returns the value of attribute deviceTimeOffset.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def deviceTimeOffset @deviceTimeOffset end |
#frostProtectOn ⇒ Object (readonly)
Returns the value of attribute frostProtectOn.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def frostProtectOn @frostProtectOn end |
#heatOn ⇒ Object (readonly)
Returns the value of attribute heatOn.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def heatOn @heatOn end |
#keyLockOn ⇒ Object (readonly)
Returns the value of attribute keyLockOn.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def keyLockOn @keyLockOn end |
#requestedTemperature ⇒ Object (readonly)
Returns the value of attribute requestedTemperature.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def requestedTemperature @requestedTemperature end |
#sampleTime ⇒ Object (readonly)
Returns the value of attribute sampleTime.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def sampleTime @sampleTime end |
#schedule ⇒ Object (readonly)
Returns the value of attribute schedule.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def schedule @schedule end |
#sensedTemperature ⇒ Object (readonly)
Returns the value of attribute sensedTemperature.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def sensedTemperature @sensedTemperature end |
#timeSinceLastValid ⇒ Object (readonly)
Returns the value of attribute timeSinceLastValid.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def timeSinceLastValid @timeSinceLastValid end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def @timestamp end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
18 19 20 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 18 def valid @valid end |
Instance Method Details
#get ⇒ Object
85 86 87 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 85 def get @mutex.synchronize { yield } end |
#invalidate ⇒ Object
128 129 130 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 128 def invalidate @mutex.synchronize { @valid = false } end |
#raw ⇒ Object
81 82 83 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 81 def raw @raw.dup end |
#set(raw, timestamp, sampleTime) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/sappho-heatmiser-proxy/heatmiser_status.rb', line 89 def set raw, , sampleTime @mutex.synchronize do @valid = true begin @raw = raw.dup @sensedTemperature = ((raw[44] & 0xFF) | ((raw[45] << 8) & 0xFF00)) / 10.0 @holdMinutes = (raw[38] & 0xFF) | ((raw[39] << 8) & 0xFF00) @heatOn = raw[47] == 1 @keyLockOn = raw[29] == 1 @frostProtectOn = raw[30] == 1 @holidayOn = raw[37] == 1 @holidayReturnTime = Time.local(2000 + (raw[32] & 0xFF), raw[33], raw[34], raw[35], raw[36], 0) @requestedTemperature = @frostProtectOn ? raw[24] & 0xFF : raw[25] & 0xFF @deviceTimeOffset = Time.local(2000 + (raw[48] & 0xFF), raw[49], raw[50], raw[52], raw[53], raw[54]) - dayOfWeek = raw[51] @dayOfWeek = dayOfWeek == 7 ? 0 : dayOfWeek @schedule = { :weekday => Schedule.new(@raw, 55), :weekend => Schedule.new(@raw, 67) } @timeSinceLastValid = - @timestamp @timestamp = @sampleTime = sampleTime if @log.debug? @log.debug "#{hexString raw}" @log.debug "#{@requestedTemperature} #{@holdMinutes / 60}:#{@holdMinutes % 60} #{@sensedTemperature} #{@heatOn} #{@keyLockOn} #{@frostProtectOn} #{@timeSinceLastValid} #{@dayOfWeek} #{@deviceTimeOffset} #{sampleTime} #{@holidayOn} #{@holidayReturnTime}" @log.debug "weekday: #{@schedule[:weekday].description} weekend: #{@schedule[:weekend].description}" else @log.info "received status: heating is #{@heatOn ? "on" : "off"} because required temperature is #{@requestedTemperature} and actual is #{@sensedTemperature}" end yield rescue => error @log.error error @valid = false end end end |