Class: LadderDrive::Protocol::Keyence::KvDevice

Inherits:
LadderDrive::PlcDevice show all
Defined in:
lib/ladder_drive/protocol/keyence/kv_device.rb

Constant Summary

Constants inherited from LadderDrive::PlcDevice

LadderDrive::PlcDevice::ESC_SUFFIXES, LadderDrive::PlcDevice::NUMBER_TYPE_DEC, LadderDrive::PlcDevice::NUMBER_TYPE_DEC_HEX, LadderDrive::PlcDevice::NUMBER_TYPE_HEX

Instance Attribute Summary

Attributes inherited from LadderDrive::PlcDevice

#number, #suffix, #value

Instance Method Summary collapse

Methods inherited from LadderDrive::PlcDevice

#bit_device?, #bool, #bool=, #device_by_suffix_number, #device_code, #input?, #name, #next_device, program_area_device, #reset, #set_text, status_from_plc_device, status_to_plc_device, #text, #text=

Constructor Details

#initialize(a, b = nil) ⇒ KvDevice

Returns a new instance of KvDevice.



30
31
32
33
# File 'lib/ladder_drive/protocol/keyence/kv_device.rb', line 30

def initialize a, b = nil
  super
  @suffix = "R" if @suffix.nil? || @suffix.length == 0
end

Instance Method Details

#+(value) ⇒ Object



35
36
37
# File 'lib/ladder_drive/protocol/keyence/kv_device.rb', line 35

def + value
  self.class.new self.suffix, self.number + value
end

#-(value) ⇒ Object



39
40
41
# File 'lib/ladder_drive/protocol/keyence/kv_device.rb', line 39

def - value
  self.class.new self.suffix, [self.number - value, 0].max
end