Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fenrir-naru committed Oct 26, 2023
1 parent 331eaef commit 1457f6b
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions tool/misc/receiver_debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,25 +318,31 @@ def make_critical(fname)
end

GPS::Measurement.class_eval{
proc{
key2sym = []
GPS::Measurement.constants.each{|k|
i = GPS::Measurement.const_get(k)
key2sym[i] = k if i.kind_of?(Integer)
}
define_method(:to_a2){
to_a.collect{|prn, k, v| [prn, key2sym[k] || k, v]}
}
define_method(:to_hash2){
Hash[*(to_hash.collect{|prn, k_v|
[prn, Hash[*(k_v.collect{|k, v| [key2sym[k] || k, v]}.flatten(1))]]
}.flatten(1))]
}
}.call
add_orig = instance_method(:add)
define_method(:add){|prn, key, value|
add_orig.bind(self).call(prn, key.kind_of?(Symbol) ? GPS::Measurement.const_get(key) : key, value)
}
key2sym = GPS::Measurement.constants.inject([]){|res, k|
res[GPS::Measurement.const_get(k)] = k if /^L\d/ =~ k.to_s
res
}
define_method(:to_a2){
collect{|prn, k, v| [prn, key2sym[k] || k, v]}
}
cl_hash2 = Class::new(Hash){
define_method(:to_meas){
GPS::Measurement::new.tap{|res|
each{|prn, k_v|
k_v.each{|k, v| res.add(prn, k, v)}
}
}
}
}
define_method(:to_hash2){
cl_hash2::new.tap{|res|
each{|prn, k, v| (res[prn] ||= {})[key2sym[k] || k] = v}
}
}
}

def run(meas, t_meas, ref_pos = @base_station)
Expand Down

0 comments on commit 1457f6b

Please sign in to comment.