class Plc::Emulator::EmuDevice

Attributes

in_value[R]
out_value[R]

Public Class Methods

new(a, b = nil) click to toggle source
Calls superclass method
# File lib/plc/emulator/emu_device.rb, line 34
def initialize a, b = nil
  super
  @lock = Mutex.new
  @in_value = 0
  @out_value = 0
end

Public Instance Methods

bool(kind=nil) click to toggle source
# File lib/plc/emulator/emu_device.rb, line 53
def bool kind=nil
  v = value kind
  case v
  when nil, false, 0
    false
  else
    true
  end
end
bool=(value) click to toggle source
Calls superclass method
# File lib/plc/emulator/emu_device.rb, line 63
def bool= value
  @lock.synchronize { super }
end
reset() click to toggle source
Calls superclass method
# File lib/plc/emulator/emu_device.rb, line 41
def reset
  @lock.synchronize {
    super
    @in_value = nil
    @out_value = 0
  }
end
set_value(value, kind=nil) click to toggle source
# File lib/plc/emulator/emu_device.rb, line 90
def set_value value, kind=nil
  @lock.synchronize {
    case kind
    when :in
      @in_value = value
    when :out
      @out_value = value
    else
      @value = value
    end
  }
end
sync_input() click to toggle source
# File lib/plc/emulator/emu_device.rb, line 103
def sync_input
  @lock.synchronize {
    unless @in_value.nil?
      @value = @in_value
      @in_value = nil
    end
  }
end
sync_output() click to toggle source
# File lib/plc/emulator/emu_device.rb, line 112
def sync_output
  @lock.synchronize {
    @out_value = @value
  }
end
value(kind=nil) click to toggle source
# File lib/plc/emulator/emu_device.rb, line 77
def value kind=nil
  @lock.synchronize {
    case kind
    when :in
      @in_value
    when :out
      @out_value
    else
      @value
    end
  }
end
value=(value) click to toggle source
# File lib/plc/emulator/emu_device.rb, line 49
def value= value
  set_value value
end
word(kind=nil) click to toggle source
# File lib/plc/emulator/emu_device.rb, line 67
def word kind=nil
  value kind
end
word=(value) click to toggle source
Calls superclass method
# File lib/plc/emulator/emu_device.rb, line 71
def word= value
  @lock.synchronize {
    super
  }
end