#!/usr/local/bin/ruby # data = { # SID1 => { # FREQ1 => {'Power' => [power], 'Max' => [val, index]}, # FREQ2 => {'Power' => [power], 'Max' => [val, index]}, ... # }, # SID2 => { # FREQ1 => {'Power' => [power], 'Max' => [val, index]}, # FREQ2 => {'Power' => [power], 'Max' => [val, index]}, ... # }, # ... # } class ProcessLog POWER = 'power' MAX = 'max' def ProcessLog::log2hash(target, full_analysis = false) data = {} current_sat = nil current_freq = nil current_power = nil target.each{|line| if full_analysis and line =~ /^\d+\.?\d*/ then current_power << $&.to_f next end if line =~ /^SID: (.+)/ then data[$1.to_i] = current_sat = {} elsif line =~ /^FREQ index: (.+?); FREQ: (.+)/ current_sat[$2.to_f] = current_freq = {} current_power = current_freq[POWER] = [] elsif line =~ /^Max: (.+) at (.+?)\./ current_freq[MAX] = [$1.to_f, $2.to_i] end } return data end end if __FILE__ == $0 then $stdout << Marshal::dump(ProcessLog::log2hash($stdin)) end