Class: ModBus::Client Abstract
- Inherits:
-
Object
- Object
- ModBus::Client
- Defined in:
- lib/rmodbus/client.rb,
lib/rmodbus/client/slave.rb
Overview
This class is abstract.
Defined Under Namespace
Classes: Slave
Instance Attribute Summary
Attributes included from Options
#raise_exception_on_mismatch, #read_retries, #read_retry_timeout
Attributes included from Debug
#logger, #raise_exception_on_mismatch, #read_retries, #read_retry_timeout
Instance Method Summary collapse
-
#close ⇒ Object
Close connections.
-
#closed? ⇒ Boolean
Check connections.
-
#initialize(*args) { ... } ⇒ Client
constructor
Initialized client (alias :connect).
-
#with_slave(uid) ⇒ Slave
Given slave object.
Constructor Details
#initialize(*args) { ... } ⇒ Client
Initialized client (alias :connect)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rmodbus/client.rb', line 20 def initialize(*args) # Defaults @logger = nil @raise_exception_on_mismatch = false @read_retry_timeout = 1 @read_retries = 1 @io = open_connection(*args) if block_given? begin yield self ensure close end else self end end |
Instance Method Details
#close ⇒ Object
Close connections
72 73 74 |
# File 'lib/rmodbus/client.rb', line 72 def close @io.close unless @io.closed? end |
#closed? ⇒ Boolean
Check connections
67 68 69 |
# File 'lib/rmodbus/client.rb', line 67 def closed? @io.closed? end |
#with_slave(uid) ⇒ Slave
Given slave object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rmodbus/client.rb', line 52 def with_slave(uid) slave = get_slave(uid, @io) slave.logger = logger slave.raise_exception_on_mismatch = raise_exception_on_mismatch slave.read_retries = read_retries slave.read_retry_timeout = read_retry_timeout if block_given? yield slave else slave end end |