class PCPEasy::PMAPI::PmUnits

Public Class Methods

new(pm_units) click to toggle source

Decodes a 32bit integer into the correct fields of pmUnits. This implementation assumes little-endian encoding

# File lib/pcp_easy/pmapi/pm_units.rb, line 8
def initialize(pm_units)
  @pm_units = pm_units
end

Public Instance Methods

==(other) click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 40
def ==(other)
  self.class == other.class && \
  dim_space == other.dim_space && \
  dim_time == other.dim_time && \
  dim_count == other.dim_count && \
  scale_space == other.scale_space && \
  scale_time == other.scale_time && \
  scale_count == other.scale_count
end
dim_count() click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 20
def dim_count
  signed_4_bit(@pm_units >> 20)
end
dim_space() click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 12
def dim_space
  signed_4_bit(@pm_units >> 28)
end
dim_time() click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 16
def dim_time
  signed_4_bit(@pm_units >> 24)
end
inspect() click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 36
def inspect
  "<#{self.class.to_s}:#{object_id} @pm_units=#{@pm_units} {#{dim_space},#{dim_time},#{dim_count},#{scale_space},#{scale_time},#{scale_count}}>"
end
scale_count() click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 32
def scale_count
  signed_4_bit(@pm_units >> 8)
end
scale_space() click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 24
def scale_space
  unsigned_4_bit(@pm_units >> 16)
end
scale_time() click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 28
def scale_time
  unsigned_4_bit(@pm_units >> 12)
end

Private Instance Methods

signed_4_bit(lowest_4_bits) click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 52
def signed_4_bit(lowest_4_bits)
  lowest_4_bits & 0x8 == 0 ? lowest_4_bits & 0xf : -((~lowest_4_bits & 0xf) + 1)
end
unsigned_4_bit(lowest_4_bits) click to toggle source
# File lib/pcp_easy/pmapi/pm_units.rb, line 56
def unsigned_4_bit(lowest_4_bits)
  lowest_4_bits & 0xf
end