8 conf = config.Configuration()
10 class ReplayScanner ( gobject.GObject ) :
12 def __init__ ( self ) :
13 gobject.GObject.__init__( self )
16 # Values specific to replaying
17 self._file = os.path.join( conf.homedir , "wiscan_gui.info" )
22 # Values to be set by GPSDevice changed events
23 self.info = None, 0, 0, None, None, None, None
24 self.satellites = None
28 # Values to be set by wireless scans
34 # Values from the Scanner object
37 def start ( self , timeout=5000 ) :
38 self.scan_timeout = timeout
39 self._fd = open( self._file )
40 self._current = self._fd.readline().split()
48 if not self.scan_timeout :
51 next = self._fd.readline().split()
52 delta = float(next[0]) - float(self._current[0])
53 gobject.timeout_add( int(1000 / self._speed * delta) , self.scan )
55 self.info = self._current[1:8]
56 if self.info[0] == "FIX" :
61 self.tstamp = float(self._current[0])
62 for n in range(11, len(self._current), 2) :
64 self.scanlist[ self._current[n] ] = int(self._current[n+1])
69 return "%d gps\t%d scan\t%d fp\t%d ap\t%d total ap" % ( self.ngps , self.nscan , self.nfp , self.newap , -1 )
72 gobject.type_register(ReplayScanner)
74 if __name__ == "__main__" :
75 loop = gobject.MainLoop()
76 sample = ReplayScanner()
77 def show_scan(wifiscanner):
78 gobject.timeout_add( 5000 , show_scan , sample )
79 print "scan results %s" % wifiscanner.report()
80 print " tstamp %s" % wifiscanner.tstamp
82 for k,v in wifiscanner.scanlist.iteritems() :
84 print " %s %s" % ( k , v )
91 gobject.timeout_add( 5100 , show_scan , sample )