Class: Modbus::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/modbus/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
# File 'lib/modbus/client.rb', line 11

def initialize(uri)
  @base_polling_interval = 1
  @last_poll_time        = Time.now
  @uri                   = URI uri
end

Instance Method Details

#connectObject



29
30
31
# File 'lib/modbus/client.rb', line 29

def connect
  EM.connect @uri.host, @uri.port, Modbus::Connection::TCPClient, self
end

#connected(conn) ⇒ Object



18
19
20
21
# File 'lib/modbus/client.rb', line 18

def connected(conn)
  @conn = conn
  schedule_next_poll
end

#disconnected(conn) ⇒ Object



24
25
26
# File 'lib/modbus/client.rb', line 24

def disconnected(conn)
  reconnect
end