Class: ModBus::Client Abstract
- Inherits:
-
Object
- Object
- ModBus::Client
- Defined in:
- lib/rmodbus/client.rb
Overview
This class is abstract.
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Options
#raise_exception_on_mismatch, #read_retries, #read_retry_timeout
Attributes included from Debug
#debug, #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, &block) ⇒ Slave
Given slave object.
Constructor Details
#initialize(*args) { ... } ⇒ Client
Initialized client (alias :connect)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rmodbus/client.rb', line 30 def initialize(*args, &block) # Defaults @debug = false @raise_exception_on_mismatch = false @read_retry_timeout = 1 @read_retries = 10 @io = open_connection(*args) if block_given? begin yield self ensure close end else self end end |
Instance Method Details
#close ⇒ Object
Close connections
82 83 84 |
# File 'lib/rmodbus/client.rb', line 82 def close @io.close unless @io.closed? end |
#closed? ⇒ Boolean
Check connections
77 78 79 |
# File 'lib/rmodbus/client.rb', line 77 def closed? @io.closed? end |
#with_slave(uid, &block) ⇒ Slave
Given slave object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rmodbus/client.rb', line 62 def with_slave(uid, &block) slave = get_slave(uid, @io) slave.debug = debug 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 |