Changeset 4fd575d


Ignore:
Timestamp:
04/08/12 20:37:24 (3 years ago)
Author:
Martin Kolman <martin.kolman@…>
Branches:
master
Children:
7adc591
Parents:
51d5699
git-author:
Martin Kolman <martin.kolman@…> (04/08/12 20:37:24)
git-committer:
Martin Kolman <martin.kolman@…> (04/08/12 20:37:24)
Message:
  • don't try to update from a position source if location is disabled
  • code cleanup
Location:
modules/mod_location
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • modules/mod_location/gps_daemon.py

    r3073c84 r4fd575d  
    4343    """stop the GPSD based location update method""" 
    4444    self.GPSDConsumer.shutdown() 
     45    self.connected = False 
    4546    self.status = "No GPSD running" 
    4647 
    4748  def _updateGPSD(self): 
    48     fix = self.GPSDConsumer.getFix() 
    49     if fix: 
    50       """ 
    51       as the GPSD consumer updates its values very often, it probably better to use a simple 
    52       tuple instead of a Fix object and only convert to the Fix object once the position data 
    53       is actually requested 
    54       """ 
    55       (lat,lon,elevation,bearing,speed,timestamp) = fix 
    56       fix = Fix( (lat,lon), 
    57                  elevation, 
    58                  bearing, 
    59                  speed ) 
    60       self.fix = fix 
     49    # only update if connected to GPSD 
     50    if self.connected: 
     51      fix = self.GPSDConsumer.getFix() 
     52      if fix: 
     53        """ 
     54        as the GPSD consumer updates its values very often, it probably better to use a simple 
     55        tuple instead of a Fix object and only convert to the Fix object once the position data 
     56        is actually requested 
     57        """ 
     58        (lat,lon,elevation,bearing,speed,timestamp) = fix 
     59        fix = Fix( (lat,lon), 
     60                   elevation, 
     61                   bearing, 
     62                   speed ) 
     63        self.fix = fix 
    6164 
    6265  def _checkVerbose(self): 
  • modules/mod_location/mod_location.py

    r3b967a6 r4fd575d  
    1919from __future__ import with_statement # for python 2.5 
    2020from base_module import ranaModule 
    21 import threading 
    2221from time import * 
     22from core import gs 
    2323 
    2424def getModule(m,d,i): 
     
    3636    self.set('elevation', None) 
    3737    self.status = "Unknown" 
     38    self.enabled = False 
    3839 
    3940    # check if the device handles location by itself 
     
    6768    TODO: more efficient screen updates""" 
    6869#    print("location: screen update") 
    69     self.provider._updateGPSD() 
    70     fix = self.provider.getFix() 
    71     if fix: 
    72       self.updatePosition(fix) 
    73     else: 
    74       print("location: fix not valid") 
    75       print(fix) 
    7670 
    77     gui = self.modrana.gui 
    78     if gui and gui.getIDString() == "GTK": 
     71    # only try to update position info if 
     72    # location is enabled 
     73    if self.enabled: 
     74      self.provider._updateGPSD() 
     75 
    7976      fix = self.provider.getFix() 
    80       self.updatePosition(fix) 
     77      if fix: 
     78        self.updatePosition(fix) 
     79      else: 
     80        print("location: fix not valid") 
     81        print(fix) 
    8182 
     83      # forced screen update is only needed by the GTK GUI 
    8284      """ 
    8385      the location update method which might run asynchronously in the 
     
    8890      NOTE: this currently applies only to the GTK GUI 
    8991      """ 
    90       sFromLastRequest = time() - gui.getLastFullRedrawRequest() 
     92    if gs.GUIString == "GTK": 
     93      # make sure the screen is updated at least once per second 
     94      sFromLastRequest = time() - self.modrana.gui.getLastFullRedrawRequest() 
    9195      if sFromLastRequest > 0.85: 
    9296        self.set('needRedraw', True) 
     
    155159    else: 
    156160      self.provider.start() 
     161    self.enabled = True 
    157162 
    158163  def stopLocation(self): 
     
    163168    else: 
    164169      self.provider.stop() 
     170    self.enabled = False 
    165171 
    166172  def shutdown(self): 
Note: See TracChangeset for help on using the changeset viewer.