fixing issue with refreshes
parent
ef73a88121
commit
bb2fd3f0f5
|
@ -63,21 +63,24 @@ class Controller
|
|||
|
||||
print 'arduino '
|
||||
sleep 1
|
||||
$bot_hardware.read_device_version()
|
||||
$bot_hardware.read_device_version() if $hardware_sim == 0
|
||||
puts $status.device_version
|
||||
|
||||
$status.info_status = 'synchronizing arduino parameters'
|
||||
print 'parameters '
|
||||
$bot_hardware.check_parameters
|
||||
$bot_hardware.check_parameters
|
||||
$bot_hardware.check_parameters if $hardware_sim == 0
|
||||
$bot_hardware.check_parameters if $hardware_sim == 0
|
||||
|
||||
if $bot_hardware.ramps_param.params_in_sync
|
||||
puts 'OK'
|
||||
if $hardware_sim == 0
|
||||
if $bot_hardware.ramps_param.params_in_sync
|
||||
puts 'OK'
|
||||
else
|
||||
puts 'ERROR'
|
||||
end
|
||||
else
|
||||
puts 'ERROR'
|
||||
puts "SIM"
|
||||
end
|
||||
|
||||
|
||||
#$bot_hardware.read_end_stops()
|
||||
#$bot_hardware.read_postition()
|
||||
read_hw_status()
|
||||
|
@ -105,6 +108,7 @@ class Controller
|
|||
$status.info_status = 'executing command'
|
||||
#show_info()
|
||||
|
||||
|
||||
$status.info_nr_of_commands = $status.info_nr_of_commands + 1
|
||||
|
||||
process_command( @command )
|
||||
|
@ -123,7 +127,7 @@ class Controller
|
|||
wait_start_time = Time.now
|
||||
|
||||
# wait until the scheduled time has arrived, or wait for a minute or
|
||||
#until a refresh it set in the database as a sign new data has arrived
|
||||
# until a refresh it set in the database as a sign new data has arrived
|
||||
|
||||
while Time.now < wait_start_time + 60 and @command.scheduled_time > Time.now - 1 and refresh_received == false
|
||||
|
||||
|
@ -160,7 +164,8 @@ class Controller
|
|||
|
||||
check_hardware()
|
||||
|
||||
refresh_received = check_refresh or @bot_dbaccess.check_refresh
|
||||
refresh_received = true if @bot_dbaccess.check_refresh
|
||||
refresh_received = true if check_refresh
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -176,7 +181,7 @@ class Controller
|
|||
|
||||
def check_hardware()
|
||||
|
||||
if (Time.now - @last_hw_check) > 0.5
|
||||
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()
|
||||
|
@ -240,7 +245,7 @@ class Controller
|
|||
refreshed = true
|
||||
@cmd_last_refresh = $status.command_refresh
|
||||
else
|
||||
refreshed = false;
|
||||
refreshed = false
|
||||
end
|
||||
refreshed
|
||||
end
|
||||
|
|
|
@ -19,8 +19,6 @@ class ControllerCommandProc
|
|||
|
||||
if cmd != nil
|
||||
cmd.command_lines.each do |command_line|
|
||||
#$status.info_movement = "#{command_line.action.downcase} xyz=#{command_line.coord_x} #{command_line.coord_y} #{command_line.coord_z} amt=#{command_line.amount} spd=#{command_line.speed}"
|
||||
@bot_dbaccess.write_to_log(1,@info_movement)
|
||||
send_command(command_line)
|
||||
end
|
||||
else
|
||||
|
@ -32,13 +30,18 @@ class ControllerCommandProc
|
|||
end
|
||||
|
||||
def send_command(command_line)
|
||||
function = command_line.action.downcase.sub(' ','_')
|
||||
check_whitelist(function)
|
||||
|
||||
if $hardware_sim == 0
|
||||
function = command_line.action.downcase.sub(' ','_')
|
||||
check_whitelist(function)
|
||||
send(function, command_line)
|
||||
else
|
||||
@bot_dbaccess.write_to_log(1,'>simulating hardware<')
|
||||
sleep 2
|
||||
#$status.info_movement =
|
||||
@info_movement = "#{command_line.action.downcase} xyz=#{command_line.coord_x} #{command_line.coord_y} #{command_line.coord_z} amt=#{command_line.amount} spd=#{command_line.speed} pin=#{command_line.pin_nr}"
|
||||
puts "simulating: #{@info_movement}"
|
||||
#@bot_dbaccess.write_to_log(1,@info_movement)
|
||||
#@bot_dbaccess.write_to_log(1,"simulating hardware: #{function}")
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,9 +81,9 @@ class ControllerCommandProc
|
|||
$bot_hardware.dose_water(command_line.amount)
|
||||
end
|
||||
|
||||
def set_speed(command_line)
|
||||
$bot_hardware.set_speed(command_line.speed)
|
||||
end
|
||||
# def set_speed(command_line)
|
||||
# $bot_hardware.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)
|
||||
|
|
|
@ -15,16 +15,20 @@ require_relative 'dbaccess_measurements.rb'
|
|||
|
||||
class DbAccess
|
||||
|
||||
attr_accessor :max_nr_log_lines
|
||||
|
||||
def initialize(environment)
|
||||
config = YAML::load(File.open('./config/database.yml'))
|
||||
ActiveRecord::Base.establish_connection(config[environment])
|
||||
|
||||
@commands = DbAccessCommands.new
|
||||
@refreshes = DbAccessRefreshes.new
|
||||
@logs = DbAccessLogs.new
|
||||
@logs = DbAccessLogs.new(self)
|
||||
@parameters = DbAccessParameters.new
|
||||
@measurements = DbAccessMeasurements.new
|
||||
|
||||
@max_nr_log_lines = 1000
|
||||
|
||||
end
|
||||
|
||||
## parameters
|
||||
|
|
|
@ -12,10 +12,11 @@ require_relative '../../app/models/log.rb'
|
|||
class DbAccessLogs
|
||||
|
||||
attr_writer :dbaccess
|
||||
attr_accessor :log_to_screen
|
||||
|
||||
def initialize
|
||||
def initialize(db)
|
||||
@dbaccess = db
|
||||
@log_to_screen = true
|
||||
@max_nr_log_lines = 10000
|
||||
end
|
||||
|
||||
## logs
|
||||
|
@ -24,9 +25,7 @@ class DbAccessLogs
|
|||
#
|
||||
def write_to_log(module_id,text)
|
||||
|
||||
if @log_to_screen
|
||||
puts "[LOG] #{text}"
|
||||
end
|
||||
puts "[LOG] #{text}" if @log_to_screen
|
||||
|
||||
log = Log.new
|
||||
log.text = text
|
||||
|
@ -37,11 +36,13 @@ class DbAccessLogs
|
|||
end
|
||||
|
||||
# clean up old logs
|
||||
Log.where("created_at < (?)", 2.days.ago).find_each do |log|
|
||||
|
||||
if Log.count > @dbaccess.max_nr_log_lines
|
||||
$db_write_sync.synchronize do
|
||||
log.delete
|
||||
Log.delete(Log.order("created_at asc").first(Log.count - @dbaccess.max_nr_log_lines))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# read all logs from the log file
|
||||
|
|
|
@ -23,7 +23,7 @@ class DbAccessRefreshes
|
|||
def check_refresh
|
||||
r = Refresh.find_or_create_by(name: 'FarmBotControllerSchedule')
|
||||
@refresh_value_new = (r == nil ? 0 : r.value.to_i)
|
||||
return @refresh_value_new != @refresh_value
|
||||
@refresh_value_new != @refresh_value
|
||||
end
|
||||
|
||||
def save_refresh
|
||||
|
|
|
@ -216,7 +216,7 @@ class HardwareInterfaceParam
|
|||
@params_in_sync = true
|
||||
end
|
||||
end
|
||||
puts @params_in_sync
|
||||
|
||||
def parameters_different
|
||||
differences_found_total = false
|
||||
params.each do |p|
|
||||
|
|
|
@ -18,7 +18,7 @@ class MessageHandlerBase
|
|||
# A list of MessageHandler methods (as strings) that a Skynet User may access.
|
||||
#
|
||||
def whitelist
|
||||
[]
|
||||
['test']
|
||||
end
|
||||
|
||||
# Handle the message received from skynet
|
||||
|
@ -32,4 +32,7 @@ class MessageHandlerBase
|
|||
|
||||
end
|
||||
|
||||
def test(message)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -62,7 +62,7 @@ class MessageHandlerParameter < MessageHandlerBase
|
|||
end
|
||||
message.handler.send_confirmation(message.sender, message.time_stamp)
|
||||
else
|
||||
message.handler.send_error(sender, time_stamp, 'no paramer list in message')
|
||||
message.handler.send_error(message.sender, message.time_stamp, 'no paramer list in message')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class MessageHandlerSchedule < MessageHandlerBase
|
|||
|
||||
else
|
||||
|
||||
message.handler.send_error(sender, time_stamp, 'no command in message')
|
||||
message.handler.send_error(message.sender, message.time_stamp, 'no command in message')
|
||||
|
||||
end
|
||||
|
||||
|
@ -40,6 +40,7 @@ class MessageHandlerSchedule < MessageHandlerBase
|
|||
@dbaccess.create_new_command(Time.now + delay.to_i,'single_command')
|
||||
save_command_line(command)
|
||||
@dbaccess.save_new_command
|
||||
@dbaccess.increment_refresh
|
||||
end
|
||||
|
||||
def save_command_line(command)
|
||||
|
@ -81,6 +82,7 @@ class MessageHandlerSchedule < MessageHandlerBase
|
|||
end
|
||||
|
||||
@dbaccess.save_new_command
|
||||
@dbaccess.increment_refresh
|
||||
end
|
||||
|
||||
end
|
||||
|
|
15
menu.rb
15
menu.rb
|
@ -94,59 +94,72 @@ while $shutdown == 0 do
|
|||
$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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$status_debug_msg = false
|
||||
$hardware_sim = 0
|
||||
#$hardware_type = "lib/hardware/firmata/ramps"
|
||||
$hardware_type = "lib/hardware/gcode/ramps"
|
||||
#$hardware_type = nil
|
||||
#$hardware_type = "lib/hardware/gcode/ramps"
|
||||
$hardware_type = nil
|
||||
|
||||
$controller_disable = 0
|
||||
|
|
|
@ -263,6 +263,14 @@ describe ControllerCommandProc do
|
|||
@controller.send_command(command_line)
|
||||
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
|
||||
$hardware_sim = 1
|
||||
|
||||
@ramps.ramps_arduino.test_serial_write = ""
|
||||
@controller.send_command(command_line)
|
||||
expect(@ramps.ramps_arduino.test_serial_write).to eq("")
|
||||
|
||||
$hardware_sim = 0
|
||||
end
|
||||
|
||||
# def process_command( cmd )
|
||||
|
@ -285,6 +293,12 @@ describe ControllerCommandProc do
|
|||
expect(@ramps.ramps_arduino.test_serial_write).to eq("F61 P#{pin} V#{value}\n")
|
||||
end
|
||||
|
||||
# def process_command( cmd )
|
||||
|
||||
it "process command when command is nil" do
|
||||
@controller.process_command( nil )
|
||||
end
|
||||
|
||||
# def set_speed(command_line)
|
||||
|
||||
end
|
||||
|
|
|
@ -4,8 +4,9 @@ require './lib/database/dbaccess.rb'
|
|||
describe DbAccess do
|
||||
|
||||
before do
|
||||
$db_write_sync = Mutex.new
|
||||
@db = DbAccess.new('development')
|
||||
$db_write_sync = Mutex.new
|
||||
@db = DbAccess.new('development')
|
||||
#@db.max_nr_log_lines = 10
|
||||
end
|
||||
|
||||
## logs
|
||||
|
@ -20,6 +21,30 @@ describe DbAccess do
|
|||
expect(logs.count).to eq(1)
|
||||
end
|
||||
|
||||
it "write to log and clean log" do
|
||||
|
||||
@db.disable_log_to_screen()
|
||||
|
||||
# write 15 lines
|
||||
|
||||
# fill up the logging db if not filled to capacity
|
||||
|
||||
while Log.count < @db.max_nr_log_lines
|
||||
log_text = rand(9999999).to_s
|
||||
@db.write_to_log(99,log_text)
|
||||
end
|
||||
|
||||
# add a couple more
|
||||
|
||||
15.times do
|
||||
log_text = rand(9999999).to_s
|
||||
@db.write_to_log(99,log_text)
|
||||
end
|
||||
|
||||
# check if there are eventually just enough log lines still in the database
|
||||
expect(Log.count).to eq(@db.max_nr_log_lines)
|
||||
end
|
||||
|
||||
it "read_logs_all" do
|
||||
log_text = rand(9999999).to_s
|
||||
return_list = @db.read_logs_all
|
||||
|
|
|
@ -304,97 +304,33 @@ describe DbAccess do
|
|||
param_name = 'TEST_VALUE_0'
|
||||
param_value = 432
|
||||
|
||||
@db.write_parameter_with_type(param_name, 1, param_value)
|
||||
|
||||
return_val = @db.read_parameter_with_default(param_name, param_value)
|
||||
|
||||
expect(return_val).to eq(param_value)
|
||||
end
|
||||
|
||||
it "read parameter with default, value is nil" do
|
||||
# write a parameter of type int
|
||||
param_name = 'TEST_VALUE_0'
|
||||
param_value = 0
|
||||
|
||||
## measurements
|
||||
param = Parameter.find_or_create_by(name: param_name)
|
||||
param.valuetype = 1
|
||||
|
||||
# def write_measurements(value, external_info)
|
||||
# @measurements.write_measurements(value, external_info)
|
||||
# end
|
||||
param.valueint = nil;
|
||||
param.valuefloat = nil;
|
||||
param.valuestring = nil;
|
||||
param.valuebool = nil;
|
||||
|
||||
# def read_measurement_list()
|
||||
# @measurements.read_measurement_list()
|
||||
# end
|
||||
|
||||
# def delete_measurement(id)
|
||||
# @measurements.delete_measurement(id)
|
||||
# end
|
||||
|
||||
## logs
|
||||
|
||||
# def write_to_log(module_id,text)
|
||||
# @logs.write_to_log(module_id,text)
|
||||
# end
|
||||
|
||||
# def read_logs_all()
|
||||
# @logs.read_logs_all()
|
||||
# end
|
||||
|
||||
# def retrieve_log(module_id, nr_of_lines)
|
||||
# @logs.retrieve_log(module_id, nr_of_lines)
|
||||
# end
|
||||
|
||||
## commands
|
||||
|
||||
# def create_new_command(scheduled_time, crop_id)
|
||||
# @commands.create_new_command(scheduled_time, crop_id)
|
||||
# end
|
||||
|
||||
# def add_command_line(action, x = 0, y = 0, z = 0, speed = 0, amount = 0, pin_nr = 0, value1 = 0, value2 = 0, mode = 0, time = 0, external_info = "")
|
||||
# @commands.add_command_line(action, x, y, z, speed, amount, pin_nr, value1, value2, mode, time, external_info)
|
||||
# end
|
||||
|
||||
# def fill_in_command_line_coordinates(line, action, x, y, z, speed)
|
||||
# @commands.fill_in_command_line_coordinates(line, action, x, y, z, speed)
|
||||
# end
|
||||
|
||||
# def fill_in_command_line_pins(line, pin_nr, value1, value2, mode, time)
|
||||
# @commands.fill_in_command_line_pins(line, pin_nr, value1, value2, mode, time)
|
||||
# end
|
||||
|
||||
# def fill_in_command_line_extra(line, amount = 0, external_info = "")
|
||||
# @commands.fill_in_command_line_extra(line, amount = 0, external_info = "")
|
||||
# end
|
||||
|
||||
# def save_new_command
|
||||
# @commands.save_new_command
|
||||
# @refreshes.increment_refresh
|
||||
# end
|
||||
|
||||
# def clear_schedule
|
||||
# @commands.clear_schedule
|
||||
# end
|
||||
|
||||
# def clear_crop_schedule(crop_id)
|
||||
# @commands.clear_crop_schedule(crop_id)
|
||||
# end
|
||||
|
||||
# def get_command_to_execute
|
||||
# @commands.get_command_to_execute
|
||||
# end
|
||||
|
||||
# def set_command_to_execute_status(new_status)
|
||||
# @commands.set_command_to_execute_status(new_status)
|
||||
# end
|
||||
|
||||
## refreshes
|
||||
|
||||
# def check_refresh
|
||||
# @refreshes.check_refresh
|
||||
# end
|
||||
|
||||
# def save_refresh
|
||||
# @refresh_value = @refresh_value_new
|
||||
# end
|
||||
|
||||
# def increment_refresh
|
||||
# @refreshes.increment_refresh
|
||||
# end
|
||||
$db_write_sync.synchronize do
|
||||
param.save
|
||||
end
|
||||
|
||||
return_val = @db.read_parameter_with_default(param_name, param_value)
|
||||
|
||||
expect(return_val).to eq(param_value)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -96,6 +96,9 @@ describe HardwareInterfaceArduino do
|
|||
expect(param['id']).to eq(id)
|
||||
expect(param['default']).to eq(default)
|
||||
|
||||
# repeat again so the part where the param already exists is ran too
|
||||
@ramps_param.param_name_add(name, id, default)
|
||||
|
||||
end
|
||||
|
||||
# def get_param_by_name(name)
|
||||
|
@ -408,6 +411,32 @@ describe HardwareInterfaceArduino do
|
|||
expect(@ramps_param.params_in_sync).to eq(true)
|
||||
end
|
||||
|
||||
it "compare and write paramters, different version, all parameters identical" do
|
||||
|
||||
name = 'TESTING'
|
||||
id = 1
|
||||
|
||||
value = rand(9999999).to_i
|
||||
|
||||
@ramps_param.params.each do |p|
|
||||
p['value_ar'] = p['value_db']
|
||||
end
|
||||
|
||||
@ramps_param.param_version_db = value
|
||||
@ramps_param.param_version_ar = value - 1
|
||||
|
||||
$bot_dbaccess.write_parameter('PARAM_VERSION',@ramps_param.param_version_db)
|
||||
|
||||
@ramps.test_serial_write = ""
|
||||
@ramps.test_serial_read = ""
|
||||
|
||||
@ramps_param.compare_and_write_parameters()
|
||||
|
||||
expect(@ramps.test_serial_write).to eq("F22 P0 V#{value}\n")
|
||||
expect(@ramps_param.params_in_sync).to eq(true)
|
||||
end
|
||||
|
||||
|
||||
# def check_parameters
|
||||
|
||||
it "check parameter, no difference" do
|
||||
|
|
|
@ -16,4 +16,13 @@ describe MessageHandlerBase do
|
|||
expect(message.handled).to eq(false)
|
||||
end
|
||||
|
||||
it "hanlde message test message" do
|
||||
message = MessageHandlerMessage.new
|
||||
message.message_type = 'test'
|
||||
message.handled = false
|
||||
@handler.handle_message(message)
|
||||
expect(message.handled).to eq(true)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -27,6 +27,10 @@ describe MessageHandlerEmergencyStop do
|
|||
|
||||
## messaging
|
||||
|
||||
it "white list" do
|
||||
list = @handler.whitelist
|
||||
expect(list.count).to eq(2)
|
||||
end
|
||||
|
||||
it "message handler emergency stop" do
|
||||
message = MessageHandlerMessage.new
|
||||
|
@ -39,8 +43,6 @@ describe MessageHandlerEmergencyStop do
|
|||
expect($messaging.message[:message_type]).to eq('confirmation')
|
||||
end
|
||||
|
||||
|
||||
|
||||
it "message handler emergency stop reset" do
|
||||
message = MessageHandlerMessage.new
|
||||
message.handled = false
|
||||
|
|
|
@ -23,6 +23,11 @@ describe MessageHandlerLog do
|
|||
|
||||
## logs
|
||||
|
||||
it "white list" do
|
||||
list = @handler.whitelist
|
||||
expect(list.count).to eq(1)
|
||||
end
|
||||
|
||||
it "read logs" do
|
||||
|
||||
# write a few lines in the log
|
||||
|
|
|
@ -23,6 +23,10 @@ describe MessageHandlerMeasurement do
|
|||
|
||||
## measurements
|
||||
|
||||
it "white list" do
|
||||
list = @handler.whitelist
|
||||
expect(list.count).to eq(2)
|
||||
end
|
||||
|
||||
it "read measurements" do
|
||||
|
||||
|
|
|
@ -23,7 +23,11 @@ describe MessageHandlerParameter do
|
|||
|
||||
## measurements
|
||||
|
||||
|
||||
it "white list" do
|
||||
list = @handler.whitelist
|
||||
expect(list.count).to eq(2)
|
||||
end
|
||||
|
||||
it "read parameters" do
|
||||
|
||||
# write a few parameters
|
||||
|
@ -66,7 +70,6 @@ describe MessageHandlerParameter do
|
|||
expect($messaging.message[:message_type]).to eq('read_parameters_response')
|
||||
end
|
||||
|
||||
|
||||
it "write parameters" do
|
||||
|
||||
# write a few parameters
|
||||
|
@ -106,5 +109,18 @@ describe MessageHandlerParameter do
|
|||
|
||||
end
|
||||
|
||||
it "write parameters empty command" do
|
||||
|
||||
|
||||
message = MessageHandlerMessage.new
|
||||
message.handled = false
|
||||
message.handler = @main_handler
|
||||
message.payload = {}
|
||||
|
||||
@handler.write_parameters(message)
|
||||
|
||||
expect($messaging.message[:message_type]).to eq('error')
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -26,11 +26,11 @@ describe MessageHandlerSchedule do
|
|||
|
||||
## commands / scheduling
|
||||
|
||||
#def single_command(message)
|
||||
#def save_single_command(command, delay)
|
||||
#def save_command_line(command)
|
||||
#def crop_schedule_update(message)
|
||||
#def save_command_with_lines(command)
|
||||
it "white list" do
|
||||
list = @handler.whitelist
|
||||
expect(list.count).to eq(2)
|
||||
end
|
||||
|
||||
|
||||
it "save command line" do
|
||||
|
||||
|
@ -239,6 +239,25 @@ describe MessageHandlerSchedule do
|
|||
|
||||
end
|
||||
|
||||
it "handle empty command" do
|
||||
|
||||
# create a message
|
||||
|
||||
message = MessageHandlerMessage.new
|
||||
message.handled = false
|
||||
message.handler = @main_handler
|
||||
message.payload = {}
|
||||
|
||||
# execute the message
|
||||
|
||||
@handler.single_command(message)
|
||||
|
||||
# do the checks
|
||||
|
||||
expect($messaging.message[:message_type]).to eq('error')
|
||||
|
||||
end
|
||||
|
||||
# save_command_with_lines
|
||||
|
||||
it "save command with lines" do
|
||||
|
|
|
@ -31,6 +31,12 @@ describe MessageHandlerStatus do
|
|||
@main_handler = MessageHandler.new
|
||||
end
|
||||
|
||||
it "white list" do
|
||||
list = @handler.whitelist
|
||||
expect(list.count).to eq(1)
|
||||
end
|
||||
|
||||
|
||||
it "read status" do
|
||||
|
||||
# create new status data
|
||||
|
|
Loading…
Reference in New Issue