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, 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.
92 93 94 |
# File 'lib/emu_power/types.rb', line 92 def digits_left @digits_left end |
#digits_right ⇒ Object
Returns the value of attribute digits_right.
91 92 93 |
# File 'lib/emu_power/types.rb', line 91 def digits_right @digits_right end |
#divisor ⇒ Object
Returns the value of attribute divisor.
90 91 92 |
# File 'lib/emu_power/types.rb', line 90 def divisor @divisor end |
#multiplier ⇒ Object
Returns the value of attribute multiplier.
89 90 91 |
# File 'lib/emu_power/types.rb', line 89 def multiplier @multiplier end |
#raw_demand ⇒ Object
Returns the value of attribute raw_demand.
88 89 90 |
# File 'lib/emu_power/types.rb', line 88 def raw_demand @raw_demand end |
#suppress_leading_zeroes ⇒ Object
Returns the value of attribute suppress_leading_zeroes.
93 94 95 |
# File 'lib/emu_power/types.rb', line 93 def suppress_leading_zeroes @suppress_leading_zeroes end |
Instance Method Details
#build(hash) ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/emu_power/types.rb', line 95 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.
105 106 107 108 109 |
# File 'lib/emu_power/types.rb', line 105 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 |