1 # sat_monitor - zavai satellite monitor
3 # Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 from gettext import gettext as _
27 2: _("signal acquired"),
28 3: _("signal unusable"),
30 5: _("code&carrier lock"),
31 6: _("code&carrier lock"),
32 7: _("receiving data")
35 class SatelliteMonitor(gtk.VBox, zavai.Applet):
36 def __init__(self, registry, name, **kw):
37 zavai.Applet.__init__(self, registry, name)
38 gtk.VBox.__init__(self)
40 self.gps = registry.resource("gps")
42 self.store = gtk.ListStore(str, str, str, str, str, str, str, str, str, str, str)
43 self.view = gtk.TreeView(self.store)
45 renderer = gtk.CellRendererText()
46 for idx, name in enumerate((_("CH"), _("ID"), _("SN"), _("ELE"), _("AZI"),
47 _("Used"), _("Diff"), _("Alm"), _("Eph"),
48 _("Bad"), _("Status"))):
49 col = gtk.TreeViewColumn(name)
50 col.pack_start(renderer, False)
51 col.add_attribute(renderer, "text", idx)
52 self.view.append_column(col)
54 self.pack_start(self.view, True, True)
55 self.pack_start(self.make_parent_link(), False, False)
57 def start(self, *args):
58 self.gps.monitor.connect(self.on_ubxdebug_packet)
60 def stop(self, *args):
61 self.gps.monitor.disconnect(self.on_ubxdebug_packet)
63 def on_ubxdebug_packet(self, clid, length, data):
64 # In zhone it is cbUBXDebugPacket
65 #if clid == "NAV-STATUS" and data:
66 # i = ["%s: %d" % (k, data[0][k]) for k in sorted(data[0].keys())]
67 # zavai.info("Status:", " ".join(i))
68 ## if data[0]['TTFF']:
69 ## zavai.info("TTFF: %f", data[0]['TTFF']/1000.0)
70 if clid == "NAV-SVINFO":
71 self.handle_ubx_sat_data(data[1:])
73 # zavai.info("gps got ubxdebug packet", clid)
74 # zavai.info("DATA:", data)
76 def handle_ubx_sat_data(self, ubxinfo):
77 #zavai.info("CH ID SN ELE AZI Used Diff Alm Eph Bad Status")
80 if sv["CNO"] == 0: continue
82 used = sv["Flags"] & 0x01
83 diff = sv["Flags"] & 0x02
84 almoreph = sv["Flags"] & 0x04
85 eph = sv["Flags"] & 0x08
86 bad = sv["Flags"] & 0x10
87 qi = ("%i: " % sv["QI"]) + SAT_QI_NAMES.get(sv["QI"], _("Unknown"))
94 used and "used" or "",
95 diff and "diff" or "",
96 almoreph and "alm" or "",
101 def init(conf = None, registry = None, **kw):
102 registry.register_factory("menu.main.gps.satellite_monitor", SatelliteMonitor, _("Satellite monitor"))