Beispiel #1
0
 def CallBack(point,course,signal,time):
     DataProvider.current = (point,course,signal,time)
     #print point,course,signal,time
     for key in DataProvider.alarmlist.keys():
       try:
         DataProvider.alarmlist[key].Update(point,course,signal,time)
         if DataProvider.alarmlist[key].Condition():
             DataProvider.alarmlist[key].Trigger()
             if DataProvider.alarmlist[key].SingleShot():
                 del DataProvider.alarmlist[key]
       except:
         XStore()
Beispiel #2
0
 def readRefpoint(self,line):
     properties = line.split(",")
     name = properties[0]
     if properties[2].strip()!="":
         try:
             x = eval(properties[2])
             y = eval(properties[3])
             lat = eval(properties[6])+eval(properties[7])/60
             lon = eval(properties[9])+eval(properties[10])/60
             if properties[8]!="N":
                 lat *= -1
             if properties[11]!="E":
                 lon *= -1
             #print "found refpoint", name, x,y,lat,lon
             return Refpoint("",lat,lon,x,y)
         except:
             XStore()
Beispiel #3
0
    def __init__(self):
        global s60locations
        global s60defaults
        global landmarks

        DataStorage.__init__(self)
        DataStorage.instance = self
        try:
            self.config = self.OpenConfig(s60locations,s60defaults)
        except:
            print "Creating data directories"
            # Unable to create config file
            # this probably means that the directory
            # does not currently exist.
            # So, let's create the data directories in c:\data\tracker
            dirs = [
                u"c:\\data\\tracker\\gpx",
                u"c:\\data\\tracker\\maps",
                u"c:\\data\\tracker\\tracks",
                u"c:\\data\\tracker\\routes",
                ]
            try:
                for d in dirs:
                    if not os.path.isdir(d):
                        os.makedirs(d)
                self.config = self.OpenConfig(s60locations,s60defaults)
            except:
                XStore()
                self.config = s60defaults
                self.configfile = "c:"
                print "Unable to create data directories!"

        try:
            import landmarks
            self.lmdb = landmarks.OpenDefaultDatabase()
        except:
            print "Unable to use landmarks module"
            use_landmarks = False
            self.lmdb = None

        try:
            self.InitWaypointList(self.GetDefaultDrive()+self.GetValue("wpt_dir"))
        except:
            XStore()
            print "Unable to read waypoints"

        try:
            self.InitMapList(self.GetDefaultDrive()+self.GetValue("map_dir"))
        except:
            XStore()
            print "Unable to read maps"

        try:
            self.InitTrackList(self.GetDefaultDrive()+self.GetValue("trk_dir"))
        except:
            XStore()
            print "Unable to read tracks"

        try:
            self.InitRouteList(self.GetDefaultDrive()+self.GetValue("rte_dir"))
        except:
            XStore()
            print "Unable to read routes"
Beispiel #4
0
    def InitMapList(self,dir='.'):
        print "InitMapList using directory: ", dir
        selector = FileSelector(dir,".xml")
        self.maps = {}
        for key in selector.files.keys():
            try:
                filename = selector.files[key]
                base,ext = os.path.splitext(filename)
                f = MapFile(filename,"r")
                resolution = f.readResolution()
                refpoints = f.readRefpoints()
                if resolution == None:
                    m = Map(key,base+'.jpg',refpoints)
                else:
                    m = Map(key,base+'.jpg',refpoints,resolution)
                self.maps[m.name]=m
            except:
                XStore()
                print "Unable to parse calibration file ", filename

        selector = FileSelector(dir,".mcx")
        for key in selector.files.keys():
            try:
                filename = selector.files[key]
                base,ext = os.path.splitext(filename)
                f = McxFile(filename,"r")
                resolution = f.readResolution()
                refpoints = f.readRefpoints()
                if resolution == None:
                    m = Map(key,base+'.jpg',refpoints)
                else:
                    m = Map(key,base+'.jpg',refpoints,resolution)
                self.maps[m.name]=m
            except:
                XStore()
                print "Unable to parse calibration file ", filename

        selector = FileSelector(dir,".map")
        for key in selector.files.keys():
            try:
                filename = selector.files[key]
                base,ext = os.path.splitext(filename)
                f = OziFile(filename,"r")
                resolution = f.readResolution()
                refpoints = f.readRefpoints()
                if resolution == None:
                    m = Map(key,base+'.jpg',refpoints)
                else:
                    m = Map(key,base+'.jpg',refpoints,resolution)
                self.maps[m.name]=m
            except:
                XStore()
                print "Unable to parse calibration file ", filename

        selector = FileSelector(dir,".jpg")
        for key in selector.files.keys():
            if key not in self.maps.keys():
                filename = selector.files[key]
                base,ext = os.path.splitext(filename)
                m = Map(key,base+'.jpg',[])
                self.maps[m.name]=m