Class: PlcAccess::Protocol::Keyence::KvDevice

Inherits:
PlcAccess::PlcDevice show all
Defined in:
lib/plc_access/protocol/keyence/kv_device.rb

Constant Summary

Constants inherited from PlcAccess::PlcDevice

PlcAccess::PlcDevice::ESC_SUFFIXES, PlcAccess::PlcDevice::NUMBER_TYPE_DEC, PlcAccess::PlcDevice::NUMBER_TYPE_DEC_HEX, PlcAccess::PlcDevice::NUMBER_TYPE_HEX

Instance Attribute Summary

Attributes inherited from PlcAccess::PlcDevice

#number, #suffix, #value

Instance Method Summary collapse

Methods inherited from PlcAccess::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/plc_access/protocol/keyence/kv_device.rb', line 30

def initialize(a, b = nil)
  super
  @suffix = 'R' if @suffix.nil? || @suffix.length.zero?
end

Instance Method Details

#+(other) ⇒ Object



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

def +(other)
  self.class.new suffix, number + other
end

#-(other) ⇒ Object



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

def -(other)
  self.class.new suffix, [number - other, 0].max
end