lib/rfbeam/cli.rb in rfbeam-0.4.3 vs lib/rfbeam/cli.rb in rfbeam-0.4.4

- old
+ new

@@ -1,26 +1,28 @@ +# frozen_string_literal: true + require 'thor' require 'rfbeam' require 'tty-table' require 'tty-logger' require 'tty-spinner' require 'io/console' require 'unicode_plot' module RfBeam class CLI < Thor - attr_accessor :radar, :logger + attr_accessor :logger desc 'list', 'List available radar modules' def list logger = TTY::Logger.new devices = RfBeam.connected logger.warning 'No Radar modules found.' unless devices.count.positive? table = TTY::Table.new(header: %w[id Path Version]) - devices.each.with_index { |path, index| table << ["#{index}", path, radar(index).sw_version] } + devices.each.with_index { |path, index| table << [index.to_s, path, radar(index).sw_version] } puts table.render(:ascii) end desc 'config <radar_id>', 'Shows the parameter setting for the Radar module' def config(radar_id) @@ -42,44 +44,44 @@ end desc 'ddat <radar_id>', 'stream any valid detections, stop stream with q and enter' option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device' def ddat(radar_id) - cli = RfBeam::KLD7::CliOutput.new(radar_id) + cli = RfBeam::Kld7::CliOutput.new(radar_id) cli.display(:ddat, stream: options[:stream]) end desc 'pdat <radar_id>', 'Display Tracked Targets' def pdat(radar_id) - cli = RfBeam::KLD7::CliOutput.new(radar_id) + cli = RfBeam::Kld7::CliOutput.new(radar_id) cli.display(:pdat, stream: options[:stream]) end desc 'rfft <radar_id>', 'Display the dopplar radar data as a plot' option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device' option :raw, type: :boolean, aliases: '-r', desc: 'Display raw data' def rfft(radar_id) - plotter = RfBeam::KLD7::CliOutput.new(radar_id) + plotter = RfBeam::Kld7::CliOutput.new(radar_id) if options[:raw] print radar(radar_id).rfft else plotter.plot(:rfft, stream: options[:stream]) end end desc 'tdat <radar_id>', 'Display tracked target data' def tdat(radar_id) - cli = RfBeam::KLD7::CliOutput.new(radar_id) + cli = RfBeam::Kld7::CliOutput.new(radar_id) cli.display(:tdat, stream: options[:stream]) end private def radar(id) devices = RfBeam.connected @logger = TTY::Logger.new return @logger.warning 'No Radar modules found.' unless devices.count.positive? - RfBeam::K_ld7.new(devices[id.to_i]) + RfBeam::KLD7.new(devices[id.to_i]) end end end