Class: Player::Device

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/ruby-player/device.rb

Overview

Basic class for all intrefaces

Direct Known Subclasses

AIO, ActArray, BlobFinder, Client, Gripper, Position2d, Power, Ranger

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addr, client) ⇒ Device

Returns a new instance of Device.



23
24
25
26
# File 'lib/ruby-player/device.rb', line 23

def initialize(addr, client)
  @addr, @client =  addr, client
  @log_level = client.log_level
end

Instance Attribute Details

#addrObject (readonly)

Device address



21
22
23
# File 'lib/ruby-player/device.rb', line 21

def addr
  @addr
end

Instance Method Details

#fill(hdr, msg) ⇒ Object



28
29
30
# File 'lib/ruby-player/device.rb', line 28

def fill(hdr,msg)
  raise_error "Method `fill` isn't implemented for `#{self.class}`"
end

#handle_response(hdr, msg) ⇒ Object



32
33
34
# File 'lib/ruby-player/device.rb', line 32

def handle_response(hdr, msg)
  raise_error "Method `handle_response` isn't implemented for `#{self.class}`"
end

#send_message(type, subtype, msg = "") ⇒ Object



36
37
38
39
40
41
42
# File 'lib/ruby-player/device.rb', line 36

def send_message(type, subtype, msg="")
  @client.send_message_with_hdr( Header.new(
      dev_addr: @addr,
      type: type,
      subtype: subtype,
      size: msg.bytesize), msg)
end