Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minor changes.. moving to new PC

  • Loading branch information...
commit aa9286742a173a93d7ea41b8d537c45315f3cf6c 1 parent 900085a
Tallak Tveide authored
View
8 lib/machines/io/act_as_modbus_slave.rb → lib/machines/io/act_as_modbus_client.rb
@@ -9,7 +9,7 @@ module IO
# Performing requests are done in private threads and when the results
# are ready, they are added to the queue of scheduled tasks in the
# Scheduler
- class ActAsModbusSlave
+ class ActAsModbusClient
extend Notify
ModbusEntry = Struct.new :signal, :format, :scangroup, :length
@@ -45,7 +45,7 @@ def start
# Start the background threads
@stopping = false
@threads = (1..@opts[:threads]).collect do
- Thread.start do
+ Thread.new do
communication_thread_start
end
end
@@ -249,8 +249,10 @@ def type_from_address(address)
end
def communication_thread_start
+ puts 'thread started'
begin
- connection = RModbus::TCPClient.new @opts[:host], @opts[:port], @opts[:slave_address]
+ puts 'calling :new'
+ connection = ModBus::TCPClient.new @opts[:host], @opts[:port], @opts[:slave_address]
@tasks[:queue].synchronize do
@tasks[:cond].wait_while { @tasks[:queue].empty? && !@stopping}
begin
View
7 spec/act_as_modbus_slave_spec.rb
@@ -10,13 +10,12 @@
it 'should create a RModbus connection with parametered address, port, slave id' do
ModBus::TCPClient.should_receive(:new).with('test_addr', 99, 5)
m = ActAsModbusSlave.new :address => 'test_addr', :port => 99, :slave_id => 5, :threads => 1
- m.start
- m.stop
+ m.start.stop
end
it 'should start the correct number of threads according to paramter' do
- Thread.should_receive(:start).twice
- ActAsModbusSlave.new(:threads => 2).start.stop
+ Thread.should_receive(:new).twice.and_return(mock 'thread', :null_object => true)
+ ActAsModbusClient.new(:threads => 2).start.stop
end
it 'should update a input bool' do
Please sign in to comment.
Something went wrong with that request. Please try again.