From e4112db40f31167aa5c860b70e2cd804639ac5d4 Mon Sep 17 00:00:00 2001 From: TimEvWw Date: Wed, 5 Mar 2014 07:44:16 -0100 Subject: [PATCH] fixing test file execution --- lib/database/filehandler.rb | 8 ++++---- lib/hardware/ramps.rb | 6 +++--- menu.rb | 6 +++--- testcommands.csv | 10 ++++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/database/filehandler.rb b/lib/database/filehandler.rb index 8e43bdff..32d4dc05 100644 --- a/lib/database/filehandler.rb +++ b/lib/database/filehandler.rb @@ -1,11 +1,11 @@ -require_relative '../database/controlcommand' +require_relative 'dbaccess' # read the test file and convert it into one command class TestFileHandler def self.readCommandFile if File.file?('testcommands.csv') - $bot_dbaccess.createNewCommand(Time.now) + $bot_dbaccess.create_new_command(Time.now) f = File.open('testcommands.csv','r') f.each_line do |line| if line.length > 5 @@ -17,10 +17,10 @@ class TestFileHandler xCoord = params[1].to_i yCoord = params[2].to_i zCoord = params[3].to_i - $bot_dbaccess.addCommandLine('HOME Z', 0, 0, 0, 0, 0) + $bot_dbaccess.add_command_line(action, xCoord, yCoord, zCoord, 0, 0) end end - $bot_dbaccess.saveNewCommand + $bot_dbaccess.save_new_command end end end diff --git a/lib/hardware/ramps.rb b/lib/hardware/ramps.rb index 4a3eeaf1..21454851 100644 --- a/lib/hardware/ramps.rb +++ b/lib/hardware/ramps.rb @@ -320,9 +320,9 @@ class HardwareInterface # calculate the number of steps for the motors to do - steps_x = (coord_x - @axis_x.pos_x) * @axis_x.steps_per_unit_x - steps_y = (coord_y - @axis_y.pos_y) * @axis_y.steps_per_unit_y - steps_z = (coord_z - @axis_z.pos_z) * @axis_z.steps_per_unit_z + steps_x = (coord_x - @axis_x.pos) * @axis_x.steps_per_unit + steps_y = (coord_y - @axis_y.pos) * @axis_y.steps_per_unit + steps_z = (coord_z - @axis_z.pos) * @axis_z.steps_per_unit puts "x steps #{steps_x}" puts "y steps #{steps_y}" diff --git a/menu.rb b/menu.rb index cfa7b0a1..070c0429 100644 --- a/menu.rb +++ b/menu.rb @@ -2,7 +2,7 @@ puts '[FarmBot Controller Menu]' puts 'starting up' require './lib/database/dbaccess.rb' -#require './lib/database/filehandler.rb' +require './lib/database/filehandler.rb' #require './lib/controller.rb' #require "./lib/hardware/ramps.rb" @@ -29,7 +29,7 @@ while $shutdown == 0 do puts '[FarmBot Controller Menu]' puts '' puts 'p - stop' -# puts 't - execute test file' + puts 't - execute test file' puts '' puts "move size = #{$move_size}" puts "command delay = #{$command_delay}" @@ -69,7 +69,7 @@ while $shutdown == 0 do $command_delay = command_delay_temp.to_i if command_delay_temp.to_i > 0 when "T" # Execute test file # read the file - #TestFileHandler.readCommandFile + TestFileHandler.readCommandFile when "Z" # Move to home $bot_dbaccess.create_new_command(Time.now + $command_delay) $bot_dbaccess.add_command_line('HOME Z', 0, 0, 0, 0, 0) diff --git a/testcommands.csv b/testcommands.csv index 7e47de86..8cb84929 100644 --- a/testcommands.csv +++ b/testcommands.csv @@ -1,7 +1,9 @@ - - -MOVE ABSOLUTE,15,20,0 -MOVE RELATIVE,2,3,1 +MOVE ABSOLUTE, 0, 50, 0 +MOVE ABSOLUTE, 50, 50, 0 +MOVE ABSOLUTE, 50,100, 0 +MOVE ABSOLUTE,150,100, 0 +MOVE ABSOLUTE,150, 50, 0 +MOVE RELATIVE,0,0,0 HOME Z,0,0,0 HOME Y,0,0,0 HOME X,0,0,0