class Escalator::Protocol::Mitsubishi::QDevice
Constants
- SUFFIXES
- SUFFIX_CODES
Attributes
number[R]
suffix[R]
Public Class Methods
new(a, b = nil)
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 35 def initialize a, b = nil case a when Array case a.size when 4 @suffix = suffix_for_code(a[3]) @number = ((a[2] << 8 | a[1]) << 8) | a[0] end when String if b @suffix = a.upcase @number = b else if a.length == 12 @suffix = [a[0,2].to_i(16), a[2,2].to_i(16)].pack "c*" @suffix.strip! @number = a[4,8].to_i(16) elsif /(X|Y)(.+)/i =~ a @suffix = $1.upcase @number = $2.to_i(p_adic_number) else /(M|L|S|B|F|T|C|D|W|R)(.+)/i =~ a @suffix = $1.upcase @number = $2.to_i(p_adic_number) end end end end
Public Instance Methods
+(value)
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 102 def + value self.class.new self.suffix, self.number + value end
-(value)
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 106 def - value self.class.new self.suffix, [self.number - value, 0].max end
bit_device?()
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 82 def bit_device? case @suffix when "SM", "X", "Y", "M", "L", "F", "V", "B", "TS", "TC", "SS", "SC","CS", "CC", "SB", "S", "DX", "DY" true else false end end
name()
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 73 def name @suffix + @number.to_s(p_adic_number).upcase end
next_device()
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 77 def next_device d = self.class.new @suffix, @number + 1 d end
p_adic_number()
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 64 def p_adic_number case @suffix when "X", "Y", "B", "W", "SB", "SW", "DX", "DY", "ZR" 16 else 10 end end
suffix_code()
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 97 def suffix_code index = SUFFIXES.index suffix index ? SUFFIX_CODES[index] : 0 end
suffix_for_code(code)
click to toggle source
# File lib/escalator/protocol/mitsubishi/qdevice.rb, line 92 def suffix_for_code code index = SUFFIX_CODES.index code index ? SUFFIXES[index] : nil end