Class: Extface::Driver::EltradeTmU220::Frame

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/extface/driver/eltrade_tm_u220.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ Frame

Returns a new instance of Frame.



343
344
345
346
347
348
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 343

def initialize(buffer)
  if match = buffer.match(/\xAA\x55(.{1})(.{1})(.{1})(.{1})(.*)(.{1})$/nm)
    @frame = match.to_a.first
    @addr, @seq, @cmd, @len, @data, @check_sum = match.captures
  end
end

Instance Attribute Details

#addr ⇒ Object (readonly)

Returns the value of attribute addr.



336
337
338
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 336

def addr
  @addr
end

#check_sum ⇒ Object (readonly)

Returns the value of attribute check_sum.



336
337
338
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 336

def check_sum
  @check_sum
end

#cmd ⇒ Object (readonly)

Returns the value of attribute cmd.



336
337
338
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 336

def cmd
  @cmd
end

#data ⇒ Object (readonly)

Returns the value of attribute data.



336
337
338
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 336

def data
  @data
end

#frame ⇒ Object (readonly)

Returns the value of attribute frame.



336
337
338
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 336

def frame
  @frame
end

#len ⇒ Object (readonly)

Returns the value of attribute len.



336
337
338
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 336

def len
  @len
end

#seq ⇒ Object (readonly)

Returns the value of attribute seq.



336
337
338
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 336

def seq
  @seq
end

Instance Method Details

#busy? ⇒ Boolean

Returns:

  • (Boolean)


354
355
356
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 354

def busy?
  !ready?
end

#ready? ⇒ Boolean

Returns:

  • (Boolean)


350
351
352
# File 'app/models/extface/driver/eltrade_tm_u220.rb', line 350

def ready?
  @ready || true
end