fixing test file execution

pull/2/head
TimEvWw 2014-03-05 07:44:16 -01:00
parent 64aeedc9b9
commit e4112db40f
4 changed files with 16 additions and 14 deletions

View File

@ -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

View File

@ -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}"

View File

@ -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)

View File

@ -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

1 MOVE ABSOLUTE 15 0 20 50 0
2 MOVE RELATIVE MOVE ABSOLUTE 2 1 50 3 50 0
3 HOME Z MOVE ABSOLUTE 0 0 50 0 100 0
4 HOME Y MOVE ABSOLUTE 0 0 150 0 100 0
5 MOVE ABSOLUTE 150 50 0
6 MOVE RELATIVE 0 0 0
7 HOME X HOME Z 0 0 0 0 0
8 HOME Y 0 0 0
9 HOME X 0 0 0