Class: IRTelemetry::DataPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/ir_telemetry/data_point.rb

Constant Summary collapse

VAR_TYPES_MAPPING =
{
  1 => {
    size: 1,
    type: :irsdk_bool,
    handler: BinData::Bit8
  },
  2 => {
    size: 4,
    type: :irsdk_int,
    handler: BinData::Int32le
  },
  3 => {
    size: 4,
    type: :irsdk_bit_field,
    handler: BinData::Int32le
  },
  4 => {
    size: 4,
    type: :irsdk_float,
    handler: BinData::FloatLe
  },
  5 => {
    size: 8,
    type: :irsdk_double,
    handler: BinData::DoubleLe
  }
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(buffer, dataset) ⇒ DataPoint

Returns a new instance of DataPoint.



33
34
35
36
# File 'lib/ir_telemetry/data_point.rb', line 33

def initialize(buffer, dataset)
  @buffer = buffer
  @dataset = dataset
end

Instance Method Details

#[](variable_name) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/ir_telemetry/data_point.rb', line 38

def [](variable_name)
  variable = @dataset.variables[variable_name]
  type = VAR_TYPES_MAPPING[variable.var_type]

  type[:handler].read(
    @buffer.byteslice(variable.offset, type[:size])
  )
end