Skip to content

Commit

Permalink
Remove duplicated functions resulted from SWIG update
Browse files Browse the repository at this point in the history
  • Loading branch information
fenrir-naru committed Mar 28, 2024
1 parent a34340c commit a40e873
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 80 deletions.
73 changes: 0 additions & 73 deletions lib/gps_pvt/receiver/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,79 +60,6 @@ def attach_online_ephemeris(uri_template = [nil])

module GPS

# These ephemeris helper functions will be removed
# when native functions are available in GPS.i
class Ephemeris
URA_TABLE = [
2.40, 3.40, 4.85, 6.85, 9.65, 13.65, 24.00, 48.00,
96.00, 192.00, 384.00, 768.00, 1536.00, 3072.00, 6144.00]
def URA_index=(idx)
send(:URA=, (idx >= URA_TABLE.size) ? (URA_TABLE[-1] * 2) : (idx < 0 ? -1 : URA_TABLE[idx]))
end
def URA_index
ura = send(:URA)
(ura < 0) ? -1 : URA_TABLE.find_index{|v| ura <= v}
end
proc{
orig = instance_method(:fit_interval=)
define_method(:fit_interval=){|args|
args = case args
when Array
flag, iodc, sys = args
hr = case (sys ||= :GPS)
when :GPS, :gps
(flag == 0) ? 4 : case iodc
when 240..247; 8
when 248..255, 496; 14
when 497..503; 26
when 504..510; 50
when 511, 752..756; 74
when 757..763; 98
when 764..767, 1088..1010; 122
when 1011..1020; 146
else; 6
end
when :QZSS, :qzss
raise unless flag == 0 # TODO how to treat fit_interval > 2 hrs
2
else; raise
end
hr * 60 * 60
else
args
end
orig.bind(self).call(args)
}
}.call
end
class Ephemeris_SBAS
URA_TABLE = [ # Table 2-3 in DO-229E
2.0, 2.8, 4.0, 5.7, 8.0, 11.3, 16.0, 32.0,
64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0]
def URA_index=(idx)
send(:URA=, (idx >= URA_TABLE.size) ? (URA_TABLE[-1] * 2) : (idx < 0 ? -1 : URA_TABLE[idx]))
end
def URA_index
ura = send(:URA)
(ura < 0) ? -1 : URA_TABLE.find_index{|v| ura <= v}
end
end
class Ephemeris_GLONASS
F_T_TABLE = [ # Table 4.4 in ICD 5.1
1, 2, 2.5, 4, 5, 7, 10, 12, 14, 16, 32, 64, 128, 256, 512, 1024]
def F_T_index=(idx)
send(:F_T=, (idx >= F_T_TABLE.size) ? (F_T_TABLE[-1] * 2) : (idx < 0 ? -1 : F_T_TABLE[idx]))
end
def F_T_index
f_t = send(:F_T)
(f_t < 0) ? -1 : F_T_TABLE.find_index{|v| f_t <= v}
end
def NA
# based on TimeProperties::date2raw
self.day_of_year + [1, 367, 732, 1097][(self.year - 1996) % 4]
end
end

[
Ionospheric_UTC_Parameters,
Ephemeris, Ephemeris_SBAS, Ephemeris_GLONASS,
Expand Down
8 changes: 4 additions & 4 deletions lib/gps_pvt/rtcm3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def message_number
103 => 1,
104 => 1,
105 => 1,
106 => [2, proc{|v| [0, 30, 45, 60][v] * 60}], # [s]
106 => 2,
107 => [12, proc{|v|
hh, mm, ss = [v >> 7, (v & 0x7E) >> 1, (v & 0x1) > 0 ? 30 : 0]
hh * 3600 + mm * 60 + ss # [sec]
Expand Down Expand Up @@ -314,7 +314,7 @@ module GPS_Ephemeris
def params
# TODO WN is truncated to 0-1023
res = Hash[*(KEY2IDX.collect{|k, i| [k, self[i][0]]}.flatten(1))]
res[:fit_interval] = [self[29][0], res[:iodc]]
res[:fit_interval] = (self[29][0] != 0)
res
end
end
Expand All @@ -334,7 +334,7 @@ def params
# TODO insufficient: :n => ?(String4); extra: :P3
# TODO generate time with t_b, N_T, NA, N_4
# TODO GPS.i is required to modify to generate EPhemeris_with_GPS_Time
k_i = {:svid => 1, :freq_ch => 2, :P1 => 5, :t_k => 6, :B_n => 7, :P2 => 8, :t_b => 9,
k_i = {:svid => 1, :freq_ch => 2, :P1_index => 5, :t_k => 6, :B_n => 7, :P2 => 8, :t_b => 9,
:xn_dot => 10, :xn => 11, :xn_ddot => 12,
:yn_dot => 13, :yn => 14, :yn_ddot => 15,
:zn_dot => 16, :zn => 17, :zn_ddot => 18,
Expand Down Expand Up @@ -362,7 +362,7 @@ module QZSS_Ephemeris
def params
# TODO PRN = svid + 192, WN is truncated to 0-1023
res = Hash[*(KEY2IDX.collect{|k, i| [k, self[i][0]]}.flatten(1))]
res[:fit_interval] = [self[29][0], res[:iodc], :QZSS]
res[:fit_interval] = (self[29][0] != 0)
res
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/gps_pvt/supl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def attach_rrlp(msg)
eph.WN -= 1
end
eph.iode = eph.iodc & 0xFF
eph.fit_interval = [eph_src[:ephemFitFlag], eph.iodc]
eph.fit_interval = (eph_src[:ephemFitFlag] != 0)
eph
}
}
Expand Down Expand Up @@ -403,7 +403,7 @@ def attach_rrlp(msg)
:zn => [:Z, Rational(1000, 1 << 11)], :zn_dot => [:Zdot, Rational(1000, 1 << 20)], :zn_ddot => [:Zdotdot, Rational(1000, 1 << 30)],
:tau_n => [:Tau, Rational(1, 1 << 30)],
:gamma_n => [:Gamma, Rational(1, 1 << 40)],
:M => :M, :P1 => [:P1, proc{|v| [0, 30, 45, 60][v] * 60}], :P2 => :P2, :E_n => :En,
:M => :M, :P1_index => :P1, :P2 => :P2, :E_n => :En,
}.collect{|dst_k, (src_k, sf)|
["#{dst_k}=".to_sym, ["glo#{src_k}".to_sym, sf || 1]]
}.flatten(1))]
Expand Down Expand Up @@ -480,7 +480,7 @@ def attach_lpp(msg)
elsif delta_sec < -GPS::Time::Seconds_week / 2 then
eph.WN -= 1
end
eph.fit_interval = [eph_src[:navFitFlag], eph.iodc, sys]
eph.fit_interval = (eph_src[:navFitFlag] != 0)
eph
}
}
Expand Down

0 comments on commit a40e873

Please sign in to comment.