Class: EmuPower::Types::InstantaneousDemand
- Inherits:
-
Notification
- Object
- Notification
- EmuPower::Types::InstantaneousDemand
- Defined in:
- lib/emu_power/types.rb
Constant Summary
Constants inherited from Notification
Notification::UNIX_TIME_OFFSET
Instance Attribute Summary collapse
-
#digits_left ⇒ Object
Returns the value of attribute digits_left.
-
#digits_right ⇒ Object
Returns the value of attribute digits_right.
-
#divisor ⇒ Object
Returns the value of attribute divisor.
-
#multiplier ⇒ Object
Returns the value of attribute multiplier.
-
#raw_demand ⇒ Object
Returns the value of attribute raw_demand.
-
#suppress_leading_zeroes ⇒ Object
Returns the value of attribute suppress_leading_zeroes.
Attributes inherited from Notification
#device_mac, #meter_mac, #raw, #timestamp
Instance Method Summary collapse
- #build(hash) ⇒ Object
-
#demand ⇒ Object
Return computed demand in KW.
Methods inherited from Notification
#initialize, #parse_bool, #parse_hex, #parse_timestamp, root_name, subclasses
Constructor Details
This class inherits a constructor from EmuPower::Types::Notification
Instance Attribute Details
#digits_left ⇒ Object
Returns the value of attribute digits_left.
125 126 127 |
# File 'lib/emu_power/types.rb', line 125 def digits_left @digits_left end |
#digits_right ⇒ Object
Returns the value of attribute digits_right.
124 125 126 |
# File 'lib/emu_power/types.rb', line 124 def digits_right @digits_right end |
#divisor ⇒ Object
Returns the value of attribute divisor.
123 124 125 |
# File 'lib/emu_power/types.rb', line 123 def divisor @divisor end |
#multiplier ⇒ Object
Returns the value of attribute multiplier.
122 123 124 |
# File 'lib/emu_power/types.rb', line 122 def multiplier @multiplier end |
#raw_demand ⇒ Object
Returns the value of attribute raw_demand.
121 122 123 |
# File 'lib/emu_power/types.rb', line 121 def raw_demand @raw_demand end |
#suppress_leading_zeroes ⇒ Object
Returns the value of attribute suppress_leading_zeroes.
126 127 128 |
# File 'lib/emu_power/types.rb', line 126 def suppress_leading_zeroes @suppress_leading_zeroes end |
Instance Method Details
#build(hash) ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/emu_power/types.rb', line 128 def build(hash) self.raw_demand = parse_hex('Demand') self.multiplier = parse_hex('Multiplier') self.divisor = parse_hex('Divisor') self.digits_right = parse_hex('DigitsRight') self.digits_left = parse_hex('DigitsLeft') self.suppress_leading_zeroes = parse_bool('SuppressLeadingZero') end |
#demand ⇒ Object
Return computed demand in KW. This may return nil if data is missing.
138 139 140 141 142 |
# File 'lib/emu_power/types.rb', line 138 def demand return 0 if self.divisor == 0 return nil if self.multiplier.nil? || self.raw_demand.nil? || self.divisor.nil? return self.multiplier * self.raw_demand / Float(self.divisor) end |