class Peak::Plugins::Status
Public Class Methods
new(config, port_map, aprsis)
click to toggle source
# File lib/peak/plugins/status.rb, line 5 def initialize(config, port_map, aprsis) @port_configs = {} @aprsis = aprsis @running = false config.each do |section_name, section_content| if section_name.start_with?('TNC ') tnc_name = section_name.strip.split(' ')[1].strip (1..section_content['port_count']).each do |port_id| port_name = tnc_name + '-' + port_id.to_s port = port_map[port_name] port_section = 'PORT ' + port_name @port_configs[port] = {:status_text => config[port_section]['status_text'], :status_path => config[port_section]['status_path'] } end end end end
Private Class Methods
now()
click to toggle source
# File lib/peak/plugins/status.rb, line 26 def self.now Time.now.to_i end
Public Instance Methods
handle_packet(frame, recv_port)
click to toggle source
# File lib/peak/plugins/status.rb, line 65 def handle_packet(frame, recv_port) end
run()
click to toggle source
# File lib/peak/plugins/status.rb, line 31 def run @running = true # Don't do anything in the first 90 seconds last_trigger = Status::now while @running and Status::now - last_trigger < 90 sleep(1) end # run every 600 second last_trigger = Status::now while @running if Status::now - last_trigger >= 600 last_trigger = Status::now @port_configs.each do |port, port_config| frame = {:source => port.identifier, :destination => 'APRS', :path => port_config[:status_path], :text => port_config[:status_text] } port.write(frame) end else sleep(1) end end end
stop()
click to toggle source
# File lib/peak/plugins/status.rb, line 60 def stop @running = false end