Пример #1
0
def get_module_info():
    print "\n***detailed module info***"
    t.add(u"\n\n***detailed module info***")
    module_id = 270526858
    #module_id = 270526860
    positioning.select_module(module_id)
    print "module_info(270526858):", positioning.module_info(module_id)
    t.add( unicode( "\n\nmodule_info(270526858): " + str(positioning.module_info(module_id)) ) )
def set_module():
    modules = positioning.modules()
    positioning.select_module(modules[2]["id"])
    print "Starting position feed again- withspecific module."
    print positioning.position(course=1,
                               satellites=1,
                               callback=cb,
                               interval=1000000,
                               partial=1)
Пример #3
0
def get_position():
    positioning.select_module(270526858)
    pos=positioning.position()['position']
    ret="latitude=",pos['latitude'], "&longitude=", pos['longitude']
    return ret


    
    
Пример #4
0
 def __initgps(self):
     try:
         import positioning as gps
         gps.select_module(gps.default_module())
         gps.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
         gps.position(course=1,satellites=0,callback=self.__gps_cb, interval=5000000,partial=0)#intervall at 5 seconds atm
         e32.ao_sleep(3)
     except ImportError:
         self.gps_result="Error"
Пример #5
0
def get_module_info():
    print "\n***detailed module info***"
    t.add(u"\n\n***detailed module info***")
    module_id = 270526858
    #module_id = 270526860
    positioning.select_module(module_id)
    print "module_info(270526858):", positioning.module_info(module_id)
    t.add(
        unicode("\n\nmodule_info(270526858): " +
                str(positioning.module_info(module_id))))
Пример #6
0
 def StartGPS():
     positioning.select_module(positioning.default_module())
     positioning.set_requestors([{
         "type":"service",
         "format":"application",
         "data":"test_app"
         }])
     positioning.position(course=1,satellites=1,
                          callback=S60DataProvider.CallBack,
                          interval=S60DataProvider.interval,
                          partial=1)
Пример #7
0
 def Update(self):
     positioning.select_module(positioning.default_module())
     positioning.set_requestors([{"type":"service", 
                          "format":"application",
                          "data":"GpsLocProvider"}])  
     
     # open log file
     if(self.logmode):
         self.FILE = open(self.logpath, "w+")
         self.FILE.write("LOGFILE START:\r")
         self.FILE.write("GPS Modules detected:\r")
         self.FILE.write(str(positioning.modules()))
         self.FILE.write("Using default: " + str(positioning.default_module()) + "\r")
    
     global keep_scanning
     
     while keep_scanning: 
         # get current location, compare to old current location
         newLoc = self.getCurrentLocation()
         if newLoc['lat'] != newLoc['lat']: # if we got a "NaN" response from positioning, this will abort and try again
         	continue
         # if no(or little) change, don't do anything
         #latDif = math.fabs(newLoc["lat"] - self.current_location["lat"])
         #lngDif = math.fabs(newLoc["lng"] - self.current_location["lng"])
         # if latDif < 0.0001 or lngDif < .001:
         #     print "Haven't moved far enough.  Cancelling update."
         #self.current_location = newLoc
         
         #self.nearbyLock.signal()
         self.addPOIs(self.get_nearby_locations(self.current_location["lat"], self.current_location["lng"]))
            
         self.actives = self.get_active_list()
         if len(self.actives) != 0:
             self.newActives = 1
         else:
         	self.newActives = 0
             	
    #     for poi in actives:
     #        self.GUI.location_cache.appendLocation(poi)       
      #       self.GUI.notifyOfNewLocation(poi["name"])
             
       #  print "Update in :" + str(time.clock() - initialTime) + " ms."       
                        
         if self.logmode:                 
         	self.FILE.flush()
         e32.ao_yield()
         e32.ao_sleep(5)
     
     if self.logmode:
     	self.FILE.write("Total GPS scans performed: " + str(self.total_scans) + "\r")
     	self.FILE.write("Avg time per scan: " + str(self.total_scan_time / self.total_scans) + "\r")
     	self.FILE.close()
     print "Update thread done."
Пример #8
0
 def use_module(self, module_id):
     if module_id is None: raise "must specify valid module ID"
     if self.module_id != module_id:
         isact = self.active
         if isact:
             self.stop()
         try:
             positioning.select_module(module_id)
             self.module_id = module_id
             ut.report("selected GPS module %d (%s)" % (self.module_id, self.module_gui_name()))
         finally:
             if isact:
                 self.start()
Пример #9
0
 def StartGps(self):
     Log("ngps", "NativeGps::StartGps()")
     import positioning
     positioning.select_module(positioning.default_module())
     positioning.set_requestors([{
         "type": "service",
         "format": "application",
         "data": "tracker-py"
     }])
     positioning.position(course=1,
                          satellites=1,
                          callback=self.CallBack,
                          interval=500000,
                          partial=1)
Пример #10
0
def getCoordinates():
    positioning.select_module(positioning.default_module())
    positioning.set_requestors([{
        'type': 'service',
        'format': 'application',
        'data': 'position'
    }])
    try:
        sys.stdout.write('Retrieving GPS co-ordinates ...\n')
        data = positioning.position(course=1, satellites=1)
    except:
        sys.stdout.write('Could not retrieve GPS co-ordinates\n\n\n')
        sys.exit(-1)
    else:
        sys.stdout.write('GPS co-ordinates retrieved\n')
    return (data['position']['latitude'], data['position']['longitude'])
Пример #11
0
def gps_init():
	#This function will start the updating of global variable (dictionary) 'gps_data' every 0.2 sec.
	#0.2 sec comes form 'interval = 200000' set according to your needs
	#This function uses callback funtion gps
	global gps_data
	#First this fills the gps_data with 0.0 so that there is something before the first gps update
	gps_data = {
	'satellites': {'horizontal_dop': 0.0, 'used_satellites': 0, 'vertical_dop': 0.0, 'time': 0.0,'satellites': 0, 'time_dop':0.0}, 
	'position': {'latitude': 0.0, 'altitude': 0.0, 'vertical_accuracy': 0.0, 'longitude': 0.0, 'horizontal_accuracy': 0.0}, 
	'course': {'speed': 0.0, 'heading': 0.0, 'heading_accuracy': 0.0, 'speed_accuracy': 0.0}
	}
	try:
		positioning.select_module(positioning.default_module())
		positioning.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
		positioning.position(course=1,satellites=1,callback=gps, interval=200000,partial=0)
		e32.ao_sleep(3)
	except:
		appuifw.note(u'Problem with GPS','error')
Пример #12
0
  def open(self, id=None):

    self.id       = id

    if id == None:
      id = positioning.default_module()
    self.id       = id
    self.info = positioning.module_info(self.id)
    self.name = PositioningProvider.name + " using " + self.info["name"]
    # HACK ALERT: undocumented, but otherwise bluetooth stays open!
    if e32.pys60_version < '1.4.5':
      positioning._positioner=positioning._pos_serv.positioner(self.id)
    else:
      positioning.select_module(self.id)

    positioning.set_requestors([{"type":"service",
                                 "format":"application",
                                 "data":"test_app"}])
    positioning.position(course=True, satellites=True, callback=self.__callback,
                         interval=int(self.interval*1.0E6), partial=True)
    self.ok = True
Пример #13
0
 def get_position(self):
     positioning.select_module(270526860) # A-GPS -- you need at least a working GPRS connection
     positioning.set_requestors([{"type":"service","format":"application","data":"iamhere"}])
     sys.stdout.write(u"Retrieving position ...\n")
     return positioning.position()['position']
Пример #14
0
import positioning,appuifw,time,e32

positioning.select_module(positioning.default_module())
positioning.set_requestors([{"type":"service",
                             "format":"application",
                             "data":"test_app"}])

def getmyposition():
    print 'Reading GPS. Wait...'
    result = positioning.position()
    print 'all gps data: ', result    
    coordinates=result["position"]
    mylatitude = coordinates["latitude"]
    mylongitude = coordinates["longitude"]
    browserApp ='BrowserNG.exe'
    url = 'http://www.marinetraffic.com/ais/m/mob_map.aspx?&zoom=12&centerx='+str(mylongitude)+'&centery='+str(mylatitude)
    e32.start_exe(browserApp, ' "4 %s"' %url, 1)
    appuifw.app.set_exit()

getmyposition()
Пример #15
0
 def test_select_module(self):
     positioning.select_module(270526858)
     # Check whether selecting a module changes the default module too.
     self.failUnlessEqual(positioning.default_module(),
                          gps_data['default_module'],
                          "Default module not set properly")
             font='normal')
    img.text((40, 94), u'Spd: ' + str(int(spd)), 0xff0000, font='normal')
    img.text((40, 124), u'Snd: ' + str(sndtime), 0xff0000, font='normal')
    handle_redraw(())


canvas = appuifw.Canvas(event_callback=None)
appuifw.app.body = canvas
appuifw.app.title = u"Data logger"
w, h = canvas.size
img = graphics.Image.new((w, h))

startrecording()

positioning.set_requestors([{
    "type": "service",
    "format": "application",
    "data": "test_app"
}])
positioning.select_module(270526860)
positioning.position(course=1,
                     satellites=1,
                     callback=cb,
                     interval=1000000,
                     partial=1)

app_lock = e32.Ao_lock()
app_lock.wait()

stoprecording()
Пример #17
0
if not os.path.exists(log_dir):
    os.makedirs(log_dir)
logfile = os.path.join(log_dir, 'fpp_RawData_CMRI_'+date+'.csv')
fout = open(logfile, 'a')

media = "e:\\videos\\noti.mid"
try:
    snd = aud.Sound.open(media) 
    #print 'Sound ready!'
except:
    print 'Oops! NOT available: %s!' % media

print
print 'IMEI:%s\nUserAgent:%s' % (imei, uagent)
mod = pos.default_module() # A-GPS as first time fixer
pos.select_module(mod) 
modinfo = pos.module_info(mod)
print '%s:%s,QoD:%s' % (modinfo['name'],modinfo['id'],modinfo['status']['data_quality'])
try:
    # set_requestors() must follows select_module()
    pos.set_requestors([{"type":"service","format":"application","data":"test_app"}])
    gpsdict = pos.position(satellites=True)
except:
    print 'Oops! GPS failed!'
    pos.stop_position()
    sys.exit(1)


mod -= 2
pos.select_module(mod)  # Built-in GPS
modinfo = pos.module_info(mod)
Пример #18
0
 def __init__(self, moduleID=positioning.default_module()):
     self.callbacks = []
     positioning.select_module(moduleID)
     positioning.set_requestors([{"type":"service", \
                                  "format":"application", \
                                  "data":"test_app"}])
Пример #19
0
if not os.path.exists(log_dir):
    os.makedirs(log_dir)
logfile = os.path.join(log_dir, 'fpp_RawData_CMRI_' + date + '.csv')
fout = open(logfile, 'a')

media = "e:\\videos\\noti.mid"
try:
    snd = aud.Sound.open(media)
    #print 'Sound ready!'
except:
    print 'Oops! NOT available: %s!' % media

print
print 'IMEI:%s\nUserAgent:%s' % (imei, uagent)
mod = pos.default_module()  # A-GPS as first time fixer
pos.select_module(mod)
modinfo = pos.module_info(mod)
print '%s:%s,QoD:%s' % (modinfo['name'], modinfo['id'],
                        modinfo['status']['data_quality'])
try:
    # set_requestors() must follows select_module()
    pos.set_requestors([{
        "type": "service",
        "format": "application",
        "data": "test_app"
    }])
    gpsdict = pos.position(satellites=True)
except:
    print 'Oops! GPS failed!'
    pos.stop_position()
    sys.exit(1)
Пример #20
0
 def __init__(self, moduleID = positioning.default_module()):
     self.callbacks = []
     positioning.select_module(moduleID)
     positioning.set_requestors([{"type":"service", \
                                  "format":"application", \
                                  "data":"test_app"}])