⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 garmin.py

📁 gps pygarmin-0[1].6.tgz
💻 PY
📖 第 1 页 / 共 4 页
字号:
                                            self.cmdproto.Cmnd_Transfer_Trk,                                            self.link.Pid_Trk_Data)class A301(MultiTransferProtocol):   "Track Log Transfer Protocol"   def getData(self):      return MultiTransferProtocol.getData(self,                                           self.cmdproto.Cmnd_Transfer_Trk,                                           self.link.Pid_Trk_Hdr,                                           self.link.Pid_Trk_Data)class A400(SingleTransferProtocol):   "Proximity Waypoint Transfer Protocol"   def getData(self):      return SingleTransferProtocol.getData(self,                                            self.cmdproto.Cmnd_Transfer_Prx,                                            self.link.Pid_Prx_Wpt_Data)class A500(SingleTransferProtocol):   "Almanac Transfer Protocol"   def getData(self):      return SingleTransferProtocol.getData(self,                                            self.cmdproto.Cmnd_Transfer_Alm,                                            self.link.Pid_Prx_Alm_Data)class A600(TransferProtocol):   "Waypoint Date & Time Initialization Protocol"   def getData(self):      self.link.sendPacket(self.link.Pid_Command_Data,                           self.cmdproto.Cmnd_Transfer_Time)      data = self.link.expectPacket(self.link.Pid_Date_Time_Data)      d = D600()      d.unpack(data)      return dclass A700(TransferProtocol):   "Position Initialisation Protocol"   passclass A800(TransferProtocol):   "PVT Data Protocol"   # Live Position, Velocity and Time, similar to that provided by NMEA   def dataOn(self):      self.link.sendPacket(self.link.Pid_Command_Data,                           self.cmdproto.Cmnd_Start_Pvt_Data)    def dataOff(self):      self.link.sendPacket(self.link.Pid_Command_Data,                           self.cmdproto.Cmnd_Stop_Pvt_Data)   def getData(self):      data = self.link.expectPacket(self.link.Pid_Pvt_Data)      d = D800()      d.unpack(data)      return d   passclass A900(TransferProtocol):   "Used by GPS III+, no documentation as of 2000-09-18"   passclass A902(TransferProtocol):   "Used by etrex, no documentation as of 2001-05-30"   passclass A903(TransferProtocol):   "Used by etrex, no documentation as of 2001-05-30"   pass# Most of the following subclasses have a fmt member which is a format# string as understood by the struct module, detailing how the class# is transmitted on the wire, and a 'parts' member, listing the# atrributes that are serialized.class DataPoint:   parts = ()   fmt = ""   # Generic serialization stuff. If this looks complex, try it in   # any other language!   def pack(self):      arg = (self.fmt,)      for i in self.parts:         try:            # I imagine this is faster, but it only works            # if attribute 'i' has been assigned to. Otherwise            # it's only in the class, not in the instance.            v = self.__dict__[i]         except KeyError:            v = eval('self.'+i)         arg = arg + (v,)       return apply(struct.pack, arg)      def unpack(self, bytes):      # print struct.calcsize(self.fmt), self.fmt      # print len(bytes), repr(bytes)      try:         bits = struct.unpack(self.fmt, bytes)         for i in range(len(self.parts)):            self.__dict__[self.parts[i]] = bits[i]      except Exception, e:         print e         print "Format: <" + self.fmt   + ">"         print "Parts:  <" + string.join(self.parts, ", ") + ">"         print "Input:  <" + string.join(bytes, "><") + ">"	 raise Exception, e# Waypoints  ---------------------------------------------------# Different products store different info in their waypoints# Internally, waypoints store latitude and longitude in 'semicircle'# coordinates. Here's the conversion:def degrees(semi):   return semi * 180.0 / (1L<<31)def semi(deg):   return long(deg * ((1L<<31) / 180))class Waypoint(DataPoint):   parts = ("ident", "slat", "slon", "unused", "cmnt")   fmt = "< 6s l l L 40s"   def __init__(self, ident="", slat=0L, slon=0L, cmnt=""):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon             self.cmnt = cmnt           # comment (must be upper case)      self.unused = 0L         def __repr__(self):      return "<Waypoint %s (%3.5f, %3.5f) (at %x)>" % (self.ident,                                                       degrees(self.slat),                                                       degrees(self.slon),                                                       id(self))   def __str__(self):      return "%s (%3.5f, %3.5f)" % (self.ident,                                    degrees(self.slat),                                    degrees(self.slon))   def getDict(self):      self.data = {'name': self.ident,                'comment': self.cmnt,                'latitude': self.slat,                'longitude': self.slon                }      return self.data   class D100(Waypoint):   passclass D101(Waypoint):   parts = Waypoint.parts + ("dst", "smbl")   fmt = "< 6s l l L 40s f b"   dst = 0.0                  # proximity distance (m)   smbl = 0                   # symbol_type id (0-255)   def __init__(self, ident="", slat=0L, slon=0L, cmnt="", dst=0L, smbl=0L):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon             self.cmnt = cmnt           # comment (must be upper case)      self.unused = 0L      self.dst = dst      self.smbl = smbl      self.data = {}   def __repr__(self):      return "<Waypoint %s (%3.5f, %3.5f) (at %x)>" % (self.ident,                                                       degrees(self.slat),                                                       degrees(self.slon),                                                       id(self))   def __str__(self):      return "%s (%3.5f, %3.5f)" % (self.ident,                                    degrees(self.slat),                                    degrees(self.slon))   def getDict(self):      self.data = {'name': self.ident,                   'comment': stripnull(self.cmnt),                   'latitude': self.slat,                   'longitude': self.slon,                   'distance': self.dst,                   'symbol': self.smbl,                    }      return self.dataclass D102(Waypoint):   parts = Waypoint.parts + ("dst", "smbl")   fmt = "< 6s l l L 40s f h"   dst = 0.0                  # proximity distance (m)   smbl = 0                   # symbol_type id   def __init__(self, ident="", slat=0L, slon=0L, cmnt="", dst=0L, smbl=0L):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon             self.cmnt = cmnt           # comment (must be upper case)      self.unused = 0L      self.dst = dst      self.smbl = smbl      self.data = {}   def __repr__(self):      return "<Waypoint %s (%3.5f, %3.5f) (at %x)>" % (self.ident,                                                       degrees(self.slat),                                                       degrees(self.slon),                                                       id(self))   def __str__(self):      return "%s (%3.5f, %3.5f)" % (self.ident,                                    degrees(self.slat),                                    degrees(self.slon))   def getDict(self):      self.data = {'name': self.ident,                   'comment': stripnull(self.cmnt),                   'latitude': self.slat,                   'longitude': self.slon,                   'distance': self.dst,                   'symbol': self.smbl                   }      return self.dataclass D103(Waypoint):   parts = Waypoint.parts + ("smbl","dspl")   fmt = "<6s l l L 40s b b"   smbl = 0                   # D103 symbol id   dspl = 0                   # D103 display option   def __init__(self, ident="", slat=0L, slon=0L, cmnt="", dspl=0L, smbl=0L):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon             self.cmnt = cmnt           # comment (must be upper case)      self.unused = 0L      self.dspl = dspl      self.smbl = smbl      self.data = {}   def __repr__(self):      return "<Waypoint %s (%3.5f, %3.5f) (at %x)>" % (self.ident,                                                       degrees(self.slat),                                                       degrees(self.slon),                                                       id(self))   def __str__(self):      return "%s (%3.5f, %3.5f)" % (self.ident,                                    degrees(self.slat),                                    degrees(self.slon))   def getDict(self):      self.data = {'name': self.ident,                   'comment': stripnull(self.cmnt),                   'latitude': self.slat,                   'longitude': self.slon,                   'display': self.dspl,                   'symbol': self.smbl                   }      return self.data   class D104(Waypoint):   parts = Waypoint.parts + ("dst", "smbl", "dspl")   fmt = "<6s l l L 40s f h b"   dst = 0.0                  # proximity distance (m)   smbl = 0                   # symbol_type id   dspl = 0                   # D104 display option   def __init__(self, ident="", slat=0L, slon=0L, cmnt="",                dst=0L, smbl=0L, dspl=0L):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon             self.cmnt = cmnt           # comment (must be upper case)      self.unused = 0L      self.dst = dst             # proximity distance (m)      self.smbl = smbl           # symbol_type id      self.dspl = dspl           # D104 display option   def __repr__(self):      return "<Waypoint %s (%3.5f, %3.5f) (at %x)>" % (self.ident,                                                       degrees(self.slat),                                                       degrees(self.slon),                                                       id(self))   def __str__(self):      return "%s (%3.5f, %3.5f)" % (self.ident,                                    degrees(self.slat),                                    degrees(self.slon))   def getDict(self):      self.data = {'name': self.ident,                   'comment': stripnull(self.cmnt),                   'latitude': self.slat,                   'longitude': self.slon,                   'distance': self.dst,                   'symbol': self.smbl,                    'display': self.dspl                   }      return self.dataclass D105(Waypoint):   parts = ("slat", "slon", "smbl", "ident")   fmt = "<l l h s"   smbl = 0   def __init__(self, ident="", slat=0L, slon=0L, smbl=0L):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon             self.unused = 0L      self.smbl = smbl   def __repr__(self):      return "<Waypoint %s (%3.5f, %3.5f) (at %x)>" % (self.ident,                                                       degrees(self.slat),                                                       degrees(self.slon),                                                       id(self))   def __str__(self):      return "%s (%3.5f, %3.5f)" % (self.ident,                                    degrees(self.slat),                                    degrees(self.slon))   def getDict(self):      self.data = {'name': self.ident,                   'latitude': self.slat,                   'longitude': self.slon,                   'symbol': self.smbl                   }      return self.dataclass D106(Waypoint):   parts = ("wpt_class", "subclass", "slat", "slon", "smbl", "ident", "lnk_ident")   fmt = "<b 13s l l h s s"   wpt_class = 0   subclass = ""   smbl = 0   lnk_ident = ""   def __init__(self, ident="", slat=0L, slon=0L, subclass="",                wpt_class=0L, lnk_ident="", smbl=0L):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon             self.wpt_class = wpt_class         self.unused = 0L      self.subclass = subclass                self.lnk_ident = lnk_ident      self.smbl = smbl   def __repr__(self):      return "<Waypoint %s (%3.5f, %3.5f) (at %x)>" % (self.ident,                                                       degrees(self.slat),                                                       degrees(self.slon),                                                       id(self))   def __str__(self):      return "%s (%3.5f, %3.5f)" % (self.ident,                                    degrees(self.slat),                                    degrees(self.slon))   def getDict(self):      self.data = {'name': self.ident,                   'class': self.wpt_class,                   'subclass': self.subclass,                   'latitude': self.slat,                   'longitude': self.slon,                   'link': self.lnk_ident,                   'symbol': self.smbl                   }      return self.dataclass D107(Waypoint):   parts = Waypoint.parts + ("smbl", "dspl", "dst", "color")   fmt = "<6s l l L 40s b b f b"   smbl = 0                   # D103 symbol id   dspl = 0                   # D103 display option   dst = 0.0   color = 0   def __init__(self, ident="", slat=0L, slon=0L, cmnt="",                dst=0L, smbl=0L, dspl=0L, color=0L):      self.ident = ident         # text identidier (upper case)      self.slat = slat           # lat & long in semicircle terms      self.slon = slon       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -