Class: BWA::Messages::ControlConfigurationRequest

Inherits:
BWA::Message
  • Object
show all
Defined in:
lib/bwa/messages/control_configuration_request.rb

Constant Summary collapse

MESSAGE_TYPE =
"\xbf\x22".b
MESSAGE_LENGTH =
3

Instance Attribute Summary collapse

Attributes inherited from BWA::Message

#raw_data, #src

Instance Method Summary collapse

Methods inherited from BWA::Message

format_duration, format_time, inherited, #log?, parse

Constructor Details

#initialize(type = 1) ⇒ ControlConfigurationRequest

Returns a new instance of ControlConfigurationRequest.



11
12
13
14
# File 'lib/bwa/messages/control_configuration_request.rb', line 11

def initialize(type = 1)
  super()
  self.type = type
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/bwa/messages/control_configuration_request.rb', line 9

def type
  @type
end

Instance Method Details

#inspectObject



35
36
37
# File 'lib/bwa/messages/control_configuration_request.rb', line 35

def inspect
  "#<BWA::Messages::ControlConfigurationRequest #{type}>"
end

#parse(data) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/bwa/messages/control_configuration_request.rb', line 16

def parse(data)
  self.type = case data
              when "\x02\x00\x00" then 1
              when "\x00\x00\x01" then 2
              when "\x01\x00\x00" then 3
              else 0
              end
end

#serializeObject



25
26
27
28
29
30
31
32
33
# File 'lib/bwa/messages/control_configuration_request.rb', line 25

def serialize
  data = case type
         when 1 then "\x02\x00\x00"
         when 2 then "\x00\x00\x01"
         when 3 then "\x01\x00\x00"
         else "\x00\x00\x00"
         end
  super(data)
end