Merge pull request #58 from RickCarlino/master

Add home_* methods back in, Phase out more global var usage ($bot_hardware, $dbaccess), NullDatabase stub class
pull/62/head
Tim Evers 2015-03-11 21:49:48 +01:00
commit a57219f946
28 changed files with 278 additions and 274 deletions

View File

@ -21,7 +21,6 @@ $db_write_sync = Mutex.new
print 'database '
require 'active_record'
require_relative 'lib/database/dbaccess'
$bot_dbaccess = DbAccess.new('development')
puts 'OK'
print 'synchronization '
@ -33,7 +32,7 @@ if $hardware_type != nil
print 'hardware '
require_relative 'lib/controller'
require_relative $hardware_type
$bot_hardware = HardwareInterface.new(false)
HardwareInterface.current = HardwareInterface.new(false)
else
$hardware_sim = 1
end

View File

@ -21,7 +21,6 @@ $db_write_sync = Mutex.new
print 'database '
require 'active_record'
require_relative 'lib/database/dbaccess'
$bot_dbaccess = DbAccess.new('development')
puts 'OK'
print 'synchronization '

View File

@ -9,7 +9,7 @@ class Controller
def initialize
@star_char = 0
@bot_dbaccess = $bot_dbaccess
@bot_dbaccess = DbAccess.current
@last_hw_check = Time.now
@command = nil
@ -62,16 +62,16 @@ class Controller
print 'arduino '
sleep 1
$bot_hardware.read_device_version() if $hardware_sim == 0
HardwareInterface.current.read_device_version() if $hardware_sim == 0
puts $status.device_version
$status.info_status = 'synchronizing arduino parameters'
print 'parameters '
$bot_hardware.check_parameters if $hardware_sim == 0
$bot_hardware.check_parameters if $hardware_sim == 0
HardwareInterface.current.check_parameters if $hardware_sim == 0
HardwareInterface.current.check_parameters if $hardware_sim == 0
if $hardware_sim == 0
if $bot_hardware.ramps_param.params_in_sync
if HardwareInterface.current.ramps_param.params_in_sync
puts 'OK'
else
puts 'ERROR'
@ -80,8 +80,8 @@ class Controller
puts "SIM"
end
#$bot_hardware.read_end_stops()
#$bot_hardware.read_postition()
#HardwareInterface.current.read_end_stops()
#HardwareInterface.current.read_postition()
read_hw_status()
@bot_dbaccess.write_to_log(1,'Controller running')
@ -179,9 +179,9 @@ class Controller
def check_hardware()
if (Time.now - @last_hw_check) > 0.5 and $hardware_sim == 0
$bot_hardware.check_parameters
$bot_hardware.read_end_stops()
$bot_hardware.read_postition()
HardwareInterface.current.check_parameters
HardwareInterface.current.read_end_stops()
HardwareInterface.current.read_postition()
read_hw_status()
@last_hw_check = Time.now

View File

@ -4,7 +4,7 @@
class ControllerCommandProc
def initialize
@bot_dbaccess = $bot_dbaccess
@bot_dbaccess = DbAccess.current
end
WHITELIST = ['move_absolute','move_relative','home_x','home_y','home_z',
@ -47,64 +47,64 @@ class ControllerCommandProc
end
def move_absolute(command_line)
$bot_hardware.move_absolute(command_line.coord_x, command_line.coord_y, command_line.coord_z)
HardwareInterface.current.move_absolute(command_line.coord_x, command_line.coord_y, command_line.coord_z)
end
def move_relative(command_line)
$bot_hardware.move_relative(command_line.coord_x, command_line.coord_y, command_line.coord_z)
HardwareInterface.current.move_relative(command_line.coord_x, command_line.coord_y, command_line.coord_z)
end
def home_x(command_line)
$bot_hardware.move_home_x
HardwareInterface.current.move_home_x
end
def home_y(command_line)
$bot_hardware.move_home_y
HardwareInterface.current.move_home_y
end
def home_z(command_line)
$bot_hardware.move_home_z
HardwareInterface.current.move_home_z
end
def calibration_x(command_line)
$bot_hardware.calibrate_x
HardwareInterface.current.calibrate_x
end
def calibration_y(command_line)
$bot_hardware.calibrate_y
HardwareInterface.current.calibrate_y
end
def calibration_z(command_line)
$bot_hardware.calibrate_z
HardwareInterface.current.calibrate_z
end
def dose_water(command_line)
$bot_hardware.dose_water(command_line.amount)
HardwareInterface.current.dose_water(command_line.amount)
end
# def set_speed(command_line)
# $bot_hardware.set_speed(command_line.speed)
# HardwareInterface.current.set_speed(command_line.speed)
# end
def pin_write(command_line)
$bot_hardware.pin_std_set_value(command_line.pin_nr, command_line.pin_value_1, command_line.pin_mode)
HardwareInterface.current.pin_std_set_value(command_line.pin_nr, command_line.pin_value_1, command_line.pin_mode)
end
def pin_read(command_line)
$bot_hardware.pin_std_read_value(command_line.pin_nr, command_line.pin_mode, command_line.external_info)
HardwareInterface.current.pin_std_read_value(command_line.pin_nr, command_line.pin_mode, command_line.external_info)
end
def pin_mode(command_line)
$bot_hardware.pin_std_set_mode(command_line.pin_nr, command_line.pin_mode)
HardwareInterface.current.pin_std_set_mode(command_line.pin_nr, command_line.pin_mode)
end
def pin_pulse(command_line)
$bot_hardware.pin_std_pulse(command_line.pin_nr, command_line.pin_value_1,
HardwareInterface.current.pin_std_pulse(command_line.pin_nr, command_line.pin_value_1,
command_line.pin_value_2, command_line.pin_time, command_line.pin_mode)
end
def servo_move(command_line)
$bot_hardware.servo_std_move(command_line.pin_nr, command_line.pin_value_1)
HardwareInterface.current.servo_std_move(command_line.pin_nr, command_line.pin_value_1)
end

View File

@ -15,6 +15,14 @@ require_relative 'dbaccess_measurements.rb'
class DbAccess
class << self
attr_accessor :current
def current
@current ||= self.new("development")
end
end
attr_accessor :max_nr_log_lines
def initialize(environment)
@ -31,6 +39,13 @@ class DbAccess
end
def create_command(*args)
add_command_line(*args)
create_new_command(Time.now,'NOTSET')
add_command_line(*args)
save_new_command
increment_refresh
end
## parameters
def increment_parameters_version

View File

@ -5,10 +5,10 @@ class TestFileHandler
def self.readCommandFile
$bot_dbaccess.clear_schedule()
DbAccess.current.clear_schedule()
if File.file?('testcommands.csv')
$bot_dbaccess.create_new_command(Time.now,'file')
DbAccess.current.create_new_command(Time.now,'file')
f = File.open('testcommands.csv','r')
f.each_line do |line|
if line.length > 5
@ -21,10 +21,10 @@ class TestFileHandler
yCoord = params[2].to_i
zCoord = params[3].to_i
amount = params[4].to_i
$bot_dbaccess.add_command_line(action, xCoord, yCoord, zCoord, 0, amount)
DbAccess.current.add_command_line(action, xCoord, yCoord, zCoord, 0, amount)
end
end
$bot_dbaccess.save_new_command
DbAccess.current.save_new_command
end
end
end

View File

@ -12,13 +12,21 @@ require_relative 'ramps_param.rb'
class HardwareInterface
class << self
attr_accessor :current
def current
@current ||= self.new(true)
end
end
attr_reader :ramps_param, :ramps_main, :ramps_arduino
# initialize the interface
#
def initialize(test_mode)
@bot_dbaccess = $bot_dbaccess
@bot_dbaccess = DbAccess.current
@test_mode = test_mode
# create the sub processing objects
@ -68,7 +76,7 @@ class HardwareInterface
# set pulse on standard pin
#
def pin_std_pulse(pin, value1, value2, time, mode)
@ramps_arduino.execute_command("F44 P#{pin} V#{value1} W#{value2} T#{time} M#{mode}", false, @status_debug_msg)
@ramps_arduino.execute_command("F44 P#{pin} V#{value1} W#{value2} T#{time} M#{mode}", false, @status_debug_msg)
end
# dose an amount of water (in ml)

View File

@ -20,7 +20,7 @@ class HardwareInterfaceArduino
#
def initialize(test_mode)
@bot_dbaccess = $bot_dbaccess
@bot_dbaccess = DbAccess.current
@status_debug_msg = $status_debug_msg
@ -30,7 +30,7 @@ class HardwareInterfaceArduino
# connect to arduino
connect_board()
@external_info = ""
end
@ -42,12 +42,12 @@ class HardwareInterfaceArduino
#
def connect_board
parameters =
parameters =
{
"baud" => 115200,
"data_bits" => 8,
"stop_bits" => 1,
"parity" => SerialPort::NONE,
"parity" => SerialPort::NONE,
"flow_control" => SerialPort::SOFT
}
@ -59,7 +59,7 @@ class HardwareInterfaceArduino
# write a command to the robot
#
def execute_command(text, log, onscreen)
begin
begin
write_status = create_write_status(text, log, onscreen)
prepare_serial_port(write_status)
@ -101,7 +101,7 @@ class HardwareInterfaceArduino
end
def log_result_of_execution(write_status)
# log things if needed
if write_status.done == 1
puts 'ST: done' if write_status.onscreen and @test_mode == false
@ -160,7 +160,7 @@ class HardwareInterfaceArduino
case write_status.code
# command received by arduino
when 'R01'
when 'R01'
write_status.timeout = 90
# command is finished
@ -217,7 +217,7 @@ class HardwareInterfaceArduino
# if there is an emergency stop, immediately write it to the arduino
#
def check_emergency_stop
def check_emergency_stop
if ($status.emergency_stop)
serial_port_write( "E\n" )
end
@ -240,7 +240,7 @@ class HardwareInterfaceArduino
# depending on the report code, process the values
# this is done by reading parameter names and their values
# and respong on it as needed
# and respong on it as needed
process_value_process_param_list(params,code)
process_value_process_named_params(params,code)
@ -265,7 +265,7 @@ class HardwareInterfaceArduino
params.load_parameter(par_code, par_value)
end
end
def process_value_process_param_list(params,code)
@ -289,7 +289,7 @@ class HardwareInterfaceArduino
end
# Process report parameter value and save to database
#
#
def process_value_R23(params,code)
if code == 'R23'
param = @ramps_param.get_param_by_id(params.p)
@ -315,7 +315,7 @@ class HardwareInterfaceArduino
# Process report end stops
#
def process_value_R81(params,code)
if code == 'R81'
if code == 'R81'
$status.info_end_stop_x_a = (params.xa == 1)
$status.info_end_stop_x_b = (params.xb == 1)
$status.info_end_stop_y_a = (params.ya == 1)
@ -327,7 +327,7 @@ class HardwareInterfaceArduino
# Process report position
def process_value_R82(params,code)
if code == 'R82'
if code == 'R82'
$status.info_current_x_steps = params.x
$status.info_current_x = params.x / @ramps_param.axis_x_steps_per_unit
@ -344,7 +344,7 @@ class HardwareInterfaceArduino
def process_value_process_text(code,text)
process_value_process_R83(code,text)
process_value_process_R99(code,text)
end
end
# Process report software version
#
@ -352,7 +352,7 @@ class HardwareInterfaceArduino
if code == 'R83'
$status.device_version = text
end
end
end
# Process report of a debug comment
#
@ -360,7 +360,7 @@ class HardwareInterfaceArduino
if code == 'R99'
puts ">#{text}<" if @test_mode == false
end
end
end
## additional pin function

View File

@ -27,7 +27,7 @@ class HardwareInterfaceParam
# init database and parameters
@bot_dbaccess = $bot_dbaccess
@bot_dbaccess = DbAccess.current
@params = Array.new
@external_info = ""
@param_version_db = 0
@ -107,7 +107,7 @@ class HardwareInterfaceParam
# get the parameter object by name
#
def get_param_by_name(name)
def get_param_by_name(name)
param = nil
@params.each do |p|
if p['name'] == name
@ -146,10 +146,10 @@ class HardwareInterfaceParam
# read parameter value from memory
#
#def get_param_value_by_id(name_or_id, by_name_or_id, from_device_or_db, default_value)
# value = default_value
#
#
# param = get_param(id, by_name_or_id)
# if param != nil and from_device_or_db == :from_device
# value = param['value_ar']

View File

@ -11,12 +11,6 @@ require_relative 'messagehandler_schedule.rb'
require_relative 'messagehandler_status.rb'
require_relative 'messagehandler_message'
class NullDatabase
def method_missing(*)
self
end
end
# Get the JSON command, received through skynet, and send it to the farmbot
# command queue Parses JSON messages received through SkyNet.
class MessageHandler
@ -28,7 +22,7 @@ class MessageHandler
def initialize
#@dbaccess = DbAccess.new
@dbaccess = $dbaccess || NullDatabase.new
@dbaccess = DbAccess.current
@last_time_stamp = ''
@message_handlers = Array.new

View File

@ -11,7 +11,7 @@ class MessageHandlerBase
## general handling messages
def initialize
@dbaccess = $bot_dbaccess
@dbaccess = DbAccess.current
@last_time_stamp = ''
end

View File

@ -42,8 +42,8 @@ class MessageHandlerMessage
def move_relative(message)
inputs = message.payload["command"] || {}
# {"action"=>"MOVE RELATIVE", "x"=>0, "y"=>0, "z"=>0, "speed"=>100, "delay"=>0}
args = [
'MOVE RELATIVE', # action
DbAccess.current.create_command *[
'MOVE RELATIVE', # action
inputs['x'] || 0, # x
inputs['y'] || 0, # y
inputs['z'] || 0, # z
@ -56,24 +56,20 @@ class MessageHandlerMessage
0, # time
0, # external_info
]
$bot_dbaccess.create_new_command(Time.now,'menu')
$bot_dbaccess.add_command_line(*args)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
rescue => e
puts e.message, e.backtrace.first
end
def home_x(*)
raise 'Not implemented yet.'
HardwareInterface.current.move_home_x
end
def home_y(*)
raise 'Not implemented yet.'
HardwareInterface.current.move_home_y
end
def home_z(*)
raise 'Not implemented yet.'
HardwareInterface.current.move_home_z
end
def calibrate_x(*)

View File

@ -21,7 +21,7 @@ class MessageHandlerScheduleCmdLine
attr_accessor :ext_info
def initialize
@dbaccess = $bot_dbaccess
@dbaccess = DbAccess.current
end
@ -29,8 +29,8 @@ class MessageHandlerScheduleCmdLine
@delay = (command.has_key? 'delay' ) ? command['delay' ] : 0
@action = (command.has_key? 'action') ? command['action' ] : 'NOP'
@x = (command.has_key? 'x' ) ? command['x' ] : 0
@y = (command.has_key? 'y' ) ? command['y' ] : 0
@z = (command.has_key? 'z' ) ? command['z' ] : 0
@y = (command.has_key? 'y' ) ? command['y' ] : 0
@z = (command.has_key? 'z' ) ? command['z' ] : 0
@speed = (command.has_key? 'speed' ) ? command['speed' ] : 0
@amount = (command.has_key? 'amount') ? command['amount' ] : 0
@delay = (command.has_key? 'delay' ) ? command['delay' ] : 0

119
menu.rb
View File

@ -9,16 +9,11 @@ $db_write_sync = Mutex.new
#require './lib/controller.rb'
#require "./lib/hardware/ramps.rb"
#$bot_control = Control.new
#$bot_hardware = HardwareInterface.new
db = DbAccess.current
$shutdown = 0
# just a little menu for testing
puts 'connecting to database'
$bot_dbaccess = DbAccess.new('development')
$move_size = 10
$command_delay = 0
@ -91,75 +86,75 @@ while $shutdown == 0 do
# read the file
#TestFileHandler.readCommandFile
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('CALIBRATE X', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('CALIBRATE X', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
db.save_new_command
db.increment_refresh
when "K" # Move Servo
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('SERVO MOVE', 0, 0, 0, 0, 0, $pin_nr, $servo_angle, 0, 0, 0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('SERVO MOVE', 0, 0, 0, 0, 0, $pin_nr, $servo_angle, 0, 0, 0)
db.save_new_command
db.increment_refresh
when "I" # Set Pin Off
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('PIN WRITE', 0, 0, 0, 0, 0, $pin_nr, 0, 0, 0, 0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('PIN WRITE', 0, 0, 0, 0, 0, $pin_nr, 0, 0, 0, 0)
db.save_new_command
db.increment_refresh
when "U" # Set Pin On
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('PIN WRITE', 0, 0, 0, 0, 0, $pin_nr, 1, 0, 0, 0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('PIN WRITE', 0, 0, 0, 0, 0, $pin_nr, 1, 0, 0, 0)
db.save_new_command
db.increment_refresh
when "Y" # Dose water
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('DOSE WATER', 0, 0, 0, 0, 15, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('DOSE WATER', 0, 0, 0, 0, 15, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "Z" # Move to home
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('HOME Z', 0, 0, 0, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('HOME Z', 0, 0, 0, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "X" # Move to home
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('HOME X', 0, 0, 0, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('HOME X', 0, 0, 0, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "C" # Move to home
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('HOME Y',0 ,0 ,-$move_size, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('HOME Y',0 ,0 ,-$move_size, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "W" # Move forward
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('MOVE RELATIVE',0,$move_size, 0, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('MOVE RELATIVE',0,$move_size, 0, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "S" # Move back
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('MOVE RELATIVE',0,-$move_size, 0, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('MOVE RELATIVE',0,-$move_size, 0, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "A" # Move left
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('MOVE RELATIVE', -$move_size, 0, 0, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('MOVE RELATIVE', -$move_size, 0, 0, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "D" # Move right
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('MOVE RELATIVE', $move_size, 0, 0, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('MOVE RELATIVE', $move_size, 0, 0, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "R" # Move up
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line('MOVE RELATIVE', 0, 0, $move_size, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line('MOVE RELATIVE', 0, 0, $move_size, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
when "F" # Move down
$bot_dbaccess.create_new_command(Time.now + $command_delay,'menu')
$bot_dbaccess.add_command_line("MOVE RELATIVE", 0, 0, -$move_size, 0, 0, 0,0,0,0,0)
$bot_dbaccess.save_new_command
$bot_dbaccess.increment_refresh
db.create_new_command(Time.now + $command_delay,'menu')
db.add_command_line("MOVE RELATIVE", 0, 0, -$move_size, 0, 0, 0,0,0,0,0)
db.save_new_command
db.increment_refresh
end
end

View File

@ -10,14 +10,14 @@ describe ControllerCommandProc do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
$bot_hardware = HardwareInterface.new(true)
@ramps = $bot_hardware
HardwareInterface.current = HardwareInterface.new(true)
@ramps = HardwareInterface.current
@controller = ControllerCommandProc.new
@ -169,7 +169,7 @@ describe ControllerCommandProc do
command_line.pin_nr = pin
command_line.pin_value_1 = value
command_line.pin_mode = mode
@controller.pin_write(command_line)
expect(@ramps.ramps_arduino.test_serial_write).to eq("F41 P#{pin} V#{value} M#{mode}\n")

View File

@ -8,9 +8,9 @@ describe HardwareInterfaceArduino do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -39,10 +39,10 @@ describe HardwareInterfaceArduino do
it "create write status" do
text = rand(9999999).to_s
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = true
write_status = @ramps.create_write_status(text, log, onscreen)
expect(write_status.text ).to eq(text )
@ -59,10 +59,10 @@ describe HardwareInterfaceArduino do
it "log result of execution" do
text = rand(9999999).to_s
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = true
write_status = @ramps.create_write_status(text, log, onscreen)
@ramps.log_result_of_execution(write_status)
@ -75,7 +75,7 @@ describe HardwareInterfaceArduino do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
@ramps.test_serial_read = "R02\n"
write_status = @ramps.create_write_status(text, log, onscreen)
@ -85,7 +85,7 @@ describe HardwareInterfaceArduino do
@ramps.process_feedback(write_status)
@ramps.process_feedback(write_status)
@ramps.process_feedback(write_status)
expect(write_status.done).to eq(1)
end
@ -95,7 +95,7 @@ describe HardwareInterfaceArduino do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
write_status = @ramps.create_write_status(text, log, onscreen)
@ramps.add_and_process_characters(write_status, 'R')
@ -111,11 +111,11 @@ describe HardwareInterfaceArduino do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
onscreen = false
write_status = @ramps.create_write_status(text, log, onscreen)
write_status.code = "R01"
timeout = write_status.timeout
timeout = write_status.timeout
@ramps.process_code_and_params(write_status)
@ -127,7 +127,7 @@ describe HardwareInterfaceArduino do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
onscreen = false
write_status = @ramps.create_write_status(text, log, onscreen)
write_status.code = "R02"
@ -142,7 +142,7 @@ describe HardwareInterfaceArduino do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
onscreen = false
write_status = @ramps.create_write_status(text, log, onscreen)
write_status.code = "R03"
@ -156,11 +156,11 @@ describe HardwareInterfaceArduino do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
onscreen = false
write_status = @ramps.create_write_status(text, log, onscreen)
write_status.code = "R04"
timeout = write_status.timeout
timeout = write_status.timeout
time = Time.now
@ramps.process_code_and_params(write_status)
@ -174,7 +174,7 @@ describe HardwareInterfaceArduino do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
onscreen = false
par = rand(9999999).to_s
write_status = @ramps.create_write_status(text, log, onscreen)
@ -184,14 +184,14 @@ describe HardwareInterfaceArduino do
@ramps.process_code_and_params(write_status)
expect($status.device_version).to eq(write_status.params)
end
it "prepare serial port" do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
onscreen = false
write_status = @ramps.create_write_status(text, log, onscreen)
@ -229,7 +229,7 @@ describe HardwareInterfaceArduino do
it "log incoming text" do
text = rand(9999999).to_s
log = rand(9999999).to_s
onscreen = false
onscreen = false
write_status = @ramps.create_write_status(text, log, onscreen)
@ -238,7 +238,7 @@ describe HardwareInterfaceArduino do
end
it "process value split two letters" do
params = HardwareInterfaceArduinoValuesReceived.new
code = "R81"
text = "ZA1 ZB2 XA3 XB4 YA5 YB6"
@ -253,7 +253,7 @@ describe HardwareInterfaceArduino do
end
it "process value split one letters" do
params = HardwareInterfaceArduinoValuesReceived.new
code = "R99"
text = "P1 V2 X3 Y4 Z5"
@ -268,7 +268,7 @@ describe HardwareInterfaceArduino do
end
it "process value R21" do
param = 1
value = rand(999).to_i
@ -282,11 +282,11 @@ describe HardwareInterfaceArduino do
par_obj = @ramps_param.get_param_by_id(param)
expect(par_obj['value_ar']).to eq(value)
end
it "process value R23" do
param = 1
value = rand(999).to_i
@ -300,11 +300,11 @@ describe HardwareInterfaceArduino do
par_obj = @ramps_param.get_param_by_id(param)
expect(par_obj['value_db']).to eq(value)
end
it "process value R41" do
pinnr = rand(9999999).to_i
value = rand(9999999).to_i
exinf = rand(9999999).to_i
@ -319,16 +319,16 @@ describe HardwareInterfaceArduino do
@ramps.process_value_R41(params,code)
pin_value = 0
list = $dbaccess.read_measurement_list()
list = DbAccess.current.read_measurement_list()
list.each do |meas|
if meas['ext_info'].to_s == exinf.to_s
pin_value = meas['value']
end
end
expect(pin_value.to_i).to eq(value.to_i)
end
it "process value R81 XA" do
@ -345,7 +345,7 @@ describe HardwareInterfaceArduino do
expect($status.info_end_stop_y_b).to eq(false)
expect($status.info_end_stop_z_a).to eq(false)
expect($status.info_end_stop_z_b).to eq(false)
end
it "process value R81 XB" do
@ -362,7 +362,7 @@ describe HardwareInterfaceArduino do
expect($status.info_end_stop_y_b).to eq(false)
expect($status.info_end_stop_z_a).to eq(false)
expect($status.info_end_stop_z_b).to eq(false)
end
it "process value R81 YA" do
@ -379,7 +379,7 @@ describe HardwareInterfaceArduino do
expect($status.info_end_stop_y_b).to eq(false)
expect($status.info_end_stop_z_a).to eq(false)
expect($status.info_end_stop_z_b).to eq(false)
end
it "process value R81 YB" do
@ -396,7 +396,7 @@ describe HardwareInterfaceArduino do
expect($status.info_end_stop_y_b).to eq(true)
expect($status.info_end_stop_z_a).to eq(false)
expect($status.info_end_stop_z_b).to eq(false)
end
it "process value R81 ZA" do
@ -413,7 +413,7 @@ describe HardwareInterfaceArduino do
expect($status.info_end_stop_y_b).to eq(false)
expect($status.info_end_stop_z_a).to eq(true)
expect($status.info_end_stop_z_b).to eq(false)
end
it "process value R81 ZB" do
@ -430,7 +430,7 @@ describe HardwareInterfaceArduino do
expect($status.info_end_stop_y_b).to eq(false)
expect($status.info_end_stop_z_a).to eq(false)
expect($status.info_end_stop_z_b).to eq(true)
end
it "process value R82" do
@ -452,7 +452,7 @@ describe HardwareInterfaceArduino do
expect($status.info_current_x ).to eq(x / @ramps_param.axis_x_steps_per_unit)
expect($status.info_current_y ).to eq(y / @ramps_param.axis_y_steps_per_unit)
expect($status.info_current_z ).to eq(z / @ramps_param.axis_z_steps_per_unit)
end
it "process value R83" do
@ -474,7 +474,7 @@ describe HardwareInterfaceArduino do
end
it "save pin value" do
pinnr = rand(9999999).to_i
value = rand(9999999).to_i
exinf = rand(9999999).to_i
@ -483,21 +483,21 @@ describe HardwareInterfaceArduino do
@ramps.save_pin_value(pinnr, value)
pin_value = 0
list = $dbaccess.read_measurement_list()
list = DbAccess.current.read_measurement_list()
list.each do |meas|
if meas['ext_info'].to_s == exinf.to_s
pin_value = meas['value']
end
end
expect(pin_value.to_i).to eq(value.to_i)
expect(pin_value.to_i).to eq(value.to_i)
end
it "process value process param list 1" do
# "process value R21"
param = 1
value = rand(999).to_i
@ -516,7 +516,7 @@ describe HardwareInterfaceArduino do
it "process value process param list 2" do
# "process value R23"
param = 1
value = rand(999).to_i
@ -534,9 +534,9 @@ describe HardwareInterfaceArduino do
end
it "process value process param list 3" do
# "process value R41"
pinnr = rand(9999999).to_i
value = rand(9999999).to_i
exinf = rand(9999999).to_i
@ -551,14 +551,14 @@ describe HardwareInterfaceArduino do
@ramps.process_value_process_param_list(params,code)
pin_value = 0
list = $dbaccess.read_measurement_list()
list = DbAccess.current.read_measurement_list()
list.each do |meas|
if meas['ext_info'].to_s == exinf.to_s
pin_value = meas['value']
end
end
end
it "process value process text 1" do
@ -588,7 +588,7 @@ describe HardwareInterfaceArduino do
it "process value 1" do
# "process value R21"
param = 1
value = rand(999).to_i

View File

@ -7,9 +7,9 @@ describe HardwareInterfaceArduinoValuesReceived do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new

View File

@ -7,9 +7,9 @@ describe HardwareInterfaceArduinoWriteStatus do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -18,13 +18,13 @@ describe HardwareInterfaceArduinoWriteStatus do
end
it "is busy 1" do
@ramps.done = 0
busy = @ramps.is_busy
expect(busy).to eq(true)
end
it "is busy 2" do
@ramps.done = 1

View File

@ -8,9 +8,9 @@ describe HardwareInterfaceArduino do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -31,9 +31,9 @@ describe HardwareInterfaceArduino do
y_per_unit = rand(9999999).to_i
z_per_unit = rand(9999999).to_i
$dbaccess.write_parameter('MOVEMENT_STEPS_PER_UNIT_X', x_per_unit )
$dbaccess.write_parameter('MOVEMENT_STEPS_PER_UNIT_Y', y_per_unit )
$dbaccess.write_parameter('MOVEMENT_STEPS_PER_UNIT_Z', z_per_unit )
DbAccess.current.write_parameter('MOVEMENT_STEPS_PER_UNIT_X', x_per_unit )
DbAccess.current.write_parameter('MOVEMENT_STEPS_PER_UNIT_Y', y_per_unit )
DbAccess.current.write_parameter('MOVEMENT_STEPS_PER_UNIT_Z', z_per_unit )
@ramps_param.load_config_from_database()
@ramps_param.load_param_values_non_arduino()
@ -41,7 +41,7 @@ describe HardwareInterfaceArduino do
expect(@ramps_param.axis_x_steps_per_unit).to eq(x_per_unit)
expect(@ramps_param.axis_y_steps_per_unit).to eq(y_per_unit)
expect(@ramps_param.axis_z_steps_per_unit).to eq(z_per_unit)
end
# def load_config_from_database
@ -51,7 +51,7 @@ describe HardwareInterfaceArduino do
x_per_unit = rand(9999999).to_i
name = 'MOVEMENT_STEPS_PER_UNIT_X'
$dbaccess.write_parameter(name, x_per_unit )
DbAccess.current.write_parameter(name, x_per_unit )
@ramps_param.load_config_from_database()
x_per_unit_retrieved = 0
@ -101,7 +101,7 @@ describe HardwareInterfaceArduino do
end
# def get_param_by_name(name)
# def get_param_by_name(name)
it "get param by name" do
name = rand(9999999).to_s
@ -171,12 +171,12 @@ describe HardwareInterfaceArduino do
@ramps_param.param_name_add(name, id, default)
@ramps_param.save_param_value(id, :by_id, :from_device, value)
param = @ramps_param.get_param(id, :by_id)
expect(param['name']).to eq(name)
expect(param['id']).to eq(id)
expect(param['default']).to eq(default)
expect(param['value_ar']).to eq(value)
end
it "save param value (by name, by device)" do
@ -188,12 +188,12 @@ describe HardwareInterfaceArduino do
@ramps_param.param_name_add(name, id, default)
@ramps_param.save_param_value(name, :by_name, :from_device, value)
param = @ramps_param.get_param(name, :by_name)
expect(param['name']).to eq(name)
expect(param['id']).to eq(id)
expect(param['default']).to eq(default)
expect(param['value_ar']).to eq(value)
end
it "save param value (by id, by database)" do
@ -205,12 +205,12 @@ describe HardwareInterfaceArduino do
@ramps_param.param_name_add(name, id, default)
@ramps_param.save_param_value(id, :by_id, :from_db, value)
param = @ramps_param.get_param(id, :by_id)
expect(param['name']).to eq(name)
expect(param['id']).to eq(id)
expect(param['default']).to eq(default)
expect(param['value_db']).to eq(value)
end
it "save param value (by name, by database)" do
@ -222,12 +222,12 @@ describe HardwareInterfaceArduino do
@ramps_param.param_name_add(name, id, default)
@ramps_param.save_param_value(name, :by_name, :from_db, value)
param = @ramps_param.get_param(name, :by_name)
expect(param['name']).to eq(name)
expect(param['id']).to eq(id)
expect(param['default']).to eq(default)
expect(param['value_db']).to eq(value)
end
# def read_parameter_from_device(id)
@ -241,7 +241,7 @@ describe HardwareInterfaceArduino do
@ramps.test_serial_write = ""
@ramps.test_serial_read = "R21 P#{id} V#{value}\n"
@ramps_param.read_parameter_from_device(id)
param = @ramps_param.get_param(id, :by_id)
expect(param['id']).to eq(id)
@ -263,7 +263,7 @@ describe HardwareInterfaceArduino do
@ramps.test_serial_read = "R01\nR02\n"
@ramps_param.write_parameter_to_device(id, value)
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value}\n")
end
@ -322,7 +322,7 @@ describe HardwareInterfaceArduino do
value = rand(9999999).to_i
value2 = rand(9999999).to_i
$bot_dbaccess.write_parameter(name,value)
DbAccess.current.write_parameter(name,value)
param = @ramps_param.get_param(id, :by_id)
@ramps.test_serial_write = ""
@ -341,7 +341,7 @@ describe HardwareInterfaceArduino do
value = rand(9999999).to_i
value2 = rand(9999999).to_i
$bot_dbaccess.write_parameter(name,value)
DbAccess.current.write_parameter(name,value)
param = @ramps_param.get_param(id, :by_id)
@ramps.test_serial_write = ""
@ -366,7 +366,7 @@ describe HardwareInterfaceArduino do
value3 = rand(9999999).to_i
value4 = rand(9999999).to_i
$bot_dbaccess.write_parameter(name,value0)
DbAccess.current.write_parameter(name,value0)
@ramps_param.param_version_db = value3
@ramps_param.param_version_ar = value4
@ -425,7 +425,7 @@ describe HardwareInterfaceArduino do
@ramps_param.param_version_db = value
@ramps_param.param_version_ar = value - 1
$bot_dbaccess.write_parameter('PARAM_VERSION',@ramps_param.param_version_db)
DbAccess.current.write_parameter('PARAM_VERSION',@ramps_param.param_version_db)
@ramps.test_serial_write = ""
@ramps.test_serial_read = ""
@ -446,15 +446,15 @@ describe HardwareInterfaceArduino do
db_version = rand(9999999).to_i
$bot_dbaccess.write_parameter('PARAM_VERSION',db_version)
DbAccess.current.write_parameter('PARAM_VERSION',db_version)
@ramps.test_serial_write = ""
@ramps.test_serial_read = "R21 P0 V#{db_version}\n"
@ramps_param.check_parameters()
expect(@ramps_param.params_in_sync).to eq(true)
end
it "check parameter, different" do
@ -469,9 +469,9 @@ describe HardwareInterfaceArduino do
value1 = rand(9999999).to_i
value2 = rand(9999999).to_i
$bot_dbaccess.write_parameter(name,value0)
$bot_dbaccess.write_parameter('PARAM_VERSION',db_version)
DbAccess.current.write_parameter(name,value0)
DbAccess.current.write_parameter('PARAM_VERSION',db_version)
@ramps.test_serial_write = ""
@ramps.test_serial_read = "R21 P0 V#{ar_version}\n"
@ -492,7 +492,7 @@ describe HardwareInterfaceArduino do
expect(@ramps_param.params_in_sync).to eq(false)
expect(@ramps.test_serial_write).to eq("F22 P#{id} V#{value0}\n")
end
end

View File

@ -7,9 +7,9 @@ describe HardwareInterface do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -56,14 +56,14 @@ describe HardwareInterface do
@ramps.pin_std_read_value(pin, mode, ext_info)
pin_value = 0
list = $dbaccess.read_measurement_list()
list = DbAccess.current.read_measurement_list()
list.each do |meas|
if meas['ext_info'].to_s == ext_info.to_s
pin_value = meas['value']
end
end
expect(pin_value.to_i).to eq(value.to_i)
expect(@ramps.ramps_arduino.test_serial_write).to eq("F42 P#{pin} M#{mode}\n")
end
@ -330,8 +330,8 @@ describe HardwareInterface do
db_version = rand(9999999).to_i
$bot_dbaccess.write_parameter('PARAM_VERSION',db_version)
DbAccess.current.write_parameter('PARAM_VERSION',db_version)
@ramps.ramps_arduino.test_serial_write = ""
@ramps.ramps_arduino.test_serial_read = "R21 P0 V#{db_version}\n"
@ramps.check_parameters()
@ -339,5 +339,5 @@ describe HardwareInterface do
expect(@ramps.ramps_arduino.test_serial_write).to eq("F21 P0\n")
end
end

View File

@ -8,13 +8,13 @@ describe MessageHandlerEmergencyStop do
before do
#$db_write_sync = Mutex.new
#$dbaccess = DbAccess.new('development')
#DbAccess.current = DbAccess.new('development')
#@msg = MessageHandler.new
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new

View File

@ -8,9 +8,9 @@ describe MessageHandlerLog do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -36,8 +36,8 @@ describe MessageHandlerLog do
log_module_1 = 99
log_module_2 = 98
$dbaccess.write_to_log( log_module_1, log_text_1 )
$dbaccess.write_to_log( log_module_2, log_text_2 )
DbAccess.current.write_to_log( log_module_1, log_text_1 )
DbAccess.current.write_to_log( log_module_2, log_text_2 )
# get the logs in a message

View File

@ -8,9 +8,9 @@ describe MessageHandlerMeasurement do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -33,7 +33,7 @@ describe MessageHandlerMeasurement do
# write a measurement
measurement_value = rand(9999999).to_i
measurement_text = rand(9999999).to_s
$dbaccess.write_measurements(measurement_value, measurement_text)
DbAccess.current.write_measurements(measurement_value, measurement_text)
message = MessageHandlerMessage.new
message.handled = false
@ -59,11 +59,11 @@ describe MessageHandlerMeasurement do
# write two measurements
measurement_value_1 = rand(9999999).to_i
measurement_text_1 = rand(9999999).to_s
$dbaccess.write_measurements(measurement_value_1, measurement_text_1)
DbAccess.current.write_measurements(measurement_value_1, measurement_text_1)
measurement_value_2 = rand(9999999).to_i
measurement_text_2 = rand(9999999).to_s
$dbaccess.write_measurements(measurement_value_2, measurement_text_2)
DbAccess.current.write_measurements(measurement_value_2, measurement_text_2)
# check if the measurements are in the database and get the id
found_in_list_1 = false
@ -72,7 +72,7 @@ describe MessageHandlerMeasurement do
found_in_list_2_after = false
id_1 = 0
id_2 = 0
return_list = $dbaccess.read_measurement_list()
return_list = DbAccess.current.read_measurement_list()
return_list.each do |item|
if item['value'] == measurement_value_1 and item['ext_info'] == measurement_text_1
@ -97,7 +97,7 @@ describe MessageHandlerMeasurement do
# check if the measurements are still in the database and get the id
found_in_list_1_after = false
found_in_list_2_after = false
return_list = $dbaccess.read_measurement_list()
return_list = DbAccess.current.read_measurement_list()
return_list.each do |item|
if item['value'] == measurement_value_1 and item['ext_info'] == measurement_text_1

View File

@ -8,9 +8,9 @@ describe MessageHandlerParameter do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -33,11 +33,11 @@ describe MessageHandlerParameter do
# write a few parameters
parameter_value_1 = rand(9999999).to_i
parameter_name_1 = rand(9999999).to_s
$dbaccess.write_parameter(parameter_name_1, parameter_value_1)
DbAccess.current.write_parameter(parameter_name_1, parameter_value_1)
parameter_value_2 = rand(9999999).to_i
parameter_name_2 = rand(9999999).to_s
$dbaccess.write_parameter(parameter_name_2, parameter_value_2)
DbAccess.current.write_parameter(parameter_name_2, parameter_value_2)
# get the list of parameters that the system will send
@ -98,8 +98,8 @@ describe MessageHandlerParameter do
# check if the parameters in the database have the right values
value_read_1 = $dbaccess.read_parameter(parameter_name_1)
value_read_2 = $dbaccess.read_parameter(parameter_name_2)
value_read_1 = DbAccess.current.read_parameter(parameter_name_1)
value_read_2 = DbAccess.current.read_parameter(parameter_name_2)
# check expectations

View File

@ -11,9 +11,9 @@ describe MessageHandlerSchedule do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new
@ -74,9 +74,9 @@ describe MessageHandlerSchedule do
command_obj = MessageHandlerScheduleCmdLine.new
command_obj.split_command_line( command )
$dbaccess.create_new_command(sched_time,crop_id)
DbAccess.current.create_new_command(sched_time,crop_id)
@handler.save_command_line(command_obj)
$dbaccess.save_new_command
DbAccess.current.save_new_command
# get the data back from the database

View File

@ -5,7 +5,7 @@ describe MessageHandler do
before do
$db_write_sync = Mutex.new
$dbaccess = DbAccess.new('development')
DbAccess.current = DbAccess.new('development')
@msg = MessageHandler.new
end
@ -16,7 +16,7 @@ describe MessageHandler do
end
# it "create new command" do
# crop_id = rand(9999999).to_i
# crop_id = rand(9999999).to_i
# scheduled_time = Time.now
#
# @db.create_new_command(scheduled_time, crop_id)

View File

@ -16,9 +16,9 @@ describe MessageHandlerStatus do
before do
$db_write_sync = Mutex.new
$bot_dbaccess = DbAccess.new('development')
$dbaccess = $bot_dbaccess
$dbaccess.disable_log_to_screen()
DbAccess.current = DbAccess.new('development')
DbAccess.current = DbAccess.current
DbAccess.current.disable_log_to_screen()
$status = Status.new

View File

@ -6,14 +6,12 @@ $db_write_sync = Mutex.new
require 'active_record'
require_relative 'lib/database/dbaccess'
$bot_dbaccess = DbAccess.new
puts 'connected to database'
puts 'writing settings'
def write(name, value)
puts "#{name} = #{value}"
$bot_dbaccess.write_parameter(name, value)
DbAccess.current.write_parameter(name, value)
end