Module: GPS_PVT

Defined in:
lib/gps_pvt/ubx.rb,
lib/gps_pvt.rb,
lib/gps_pvt/pvt.rb,
lib/gps_pvt/supl.rb,
lib/gps_pvt/util.rb,
lib/gps_pvt/ntrip.rb,
lib/gps_pvt/rtcm3.rb,
lib/gps_pvt/version.rb,
lib/gps_pvt/asn1/per.rb,
lib/gps_pvt/receiver.rb,
lib/gps_pvt/asn1/asn1.rb,
lib/gps_pvt/receiver/agps.rb,
lib/gps_pvt/receiver/rtcm3.rb,
lib/gps_pvt/receiver/almanac.rb,
lib/gps_pvt/receiver/extension.rb,
ext/gps_pvt/SylphideMath/SylphideMath_wrap.cxx,
ext/gps_pvt/Coordinate/Coordinate_wrap.cxx,
ext/gps_pvt/GPS/GPS_wrap.cxx

Overview

Receiver extension

Defined Under Namespace

Modules: Coordinate, GPS, PER, SylphideMath, Util Classes: Error, Ntrip, RTCM3, Receiver, SUPL_Client, UBX

Constant Summary collapse

UPL =

UPL: User Plane Location ULP: UserPlane Location Protocol

Module::new{
define_method(:generate_skeleton){|k_cmd, *args|
  opts = args[0] || {}
  ver = case [2, 0xFF, 0xFF].zip([opts[:version]].flatten || []) \
      .inject(0){|sum, (v1, v2)| (sum * 0x100) + (v2 || v1)}
    when 0x020006..0x02FFFF; [2, 0, 6]
    #when 0x020000..0x02FFFF; [2, 0, 0]
    else; raise
  end
  res = ASN1::generate_skeleton(upl[:ULP][:"ULP-PDU"])
  [:maj, :min, :servind].zip(ver).each{|k, v|
    res[:version][k] = v
  }
  res[:message].reject!{|k, v|
    "ms#{k_cmd}".to_sym != k
  }
  res.define_singleton_method(:all_keys){
    (iter = proc{|hash|
      hash.collect{|k, v|
        v.kind_of?(Hash) ? {k => iter.call(v)} : k
      }
    }).call(self)
  }
  res
}
define_method(:encode){|cmd|
  buf = ASN1::encode_per(upl[:ULP][:"ULP-PDU"], cmd).scan(/.{1,8}/)
  buf[-1] += "0" * (8 - buf[-1].length)
  (buf.length.divmod(1 << 8) + buf[2..-1].collect{|str| str.to_i(2)}).pack("C*")
} 
define_method(:decode){|str|
  ASN1::decode_per(upl[:ULP][:"ULP-PDU"], str.unpack("C*").collect{|v| "%08b" % [v]}.join)
}
module_function(:generate_skeleton, :encode, :decode)
}
VERSION =
"0.10.4"
ASN1 =
Module::new{
define_method(:resolve_tree, &resolve_tree)
define_method(:generate_skeleton){|tree, *data|
  generate_skeleton.call(tree, *data)
}
define_method(:encode_per, &encode)
define_method(:decode_per){|*args| decode.call(args)}
define_method(:dig, &dig)
define_method(:read_json){|*src_list|
  require 'json'
  resolve_tree(src_list.inject({}){|res, src|
    res.merge(JSON::parse(
        (src.respond_to?(:read) ? src : open(src)).read,
        {:symbolize_names => true}))
  })
}
decode_orig = decode
define_method(:debug=){|bool|
  if bool then
    debug_decode.call
  else
    debug = decode_orig
  end
  bool
}
module_function(*instance_methods(false))
}

Class Method Summary collapse

Class Method Details

.version_compare(a, b) ⇒ Object



6
7
8
# File 'lib/gps_pvt/version.rb', line 6

def GPS_PVT.version_compare(a, b)
  Gem::Version::new(a) <=> Gem::Version::new(b)
end