Give an order to plugins
authorEnrico Zini <enrico@enricozini.org>
Sun, 14 Jun 2009 05:08:14 +0000 (13:08 +0800)
committerEnrico Zini <enrico@enricozini.org>
Sun, 14 Jun 2009 05:08:14 +0000 (13:08 +0800)
plugins/50_sat_monitor.py [new file with mode: 0644]
plugins/99_debug.py [new file with mode: 0644]
plugins/debug.py [deleted file]
plugins/sat_monitor.py [deleted file]

diff --git a/plugins/50_sat_monitor.py b/plugins/50_sat_monitor.py
new file mode 100644 (file)
index 0000000..af8a24c
--- /dev/null
@@ -0,0 +1,122 @@
+# sat_monitor - zavai satellite monitor
+#
+# Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+import gtk
+import sys
+import gettext
+_ = gettext.gettext
+import zavai
+
+SAT_QI_NAMES = {
+    0: _("idle"),
+    1: _("searching"),
+    2: _("signal acquired"),
+    3: _("signal unusable"),
+    4: _("code lock"),
+    5: _("code&carrier lock"),
+    6: _("code&carrier lock"),
+    7: _("receiving data")
+}
+
+class SatelliteMonitor(gtk.VBox, zavai.Resource):
+    def __init__(self, registry, name, **kw):
+        super(SatelliteMonitor, self).__init__()
+
+        self.gps = registry.resource("gps")
+
+        self.store = gtk.ListStore(str, str, str, str, str, str, str, str, str, str, str)
+        self.view = gtk.TreeView(self.store)
+
+        renderer = gtk.CellRendererText()
+        for idx, name in enumerate((_("CH"), _("ID"), _("SN"), _("ELE"), _("AZI"),
+                     _("Used"), _("Diff"), _("Alm"), _("Eph"),
+                     _("Bad"), _("Status"))):
+            col = gtk.TreeViewColumn(name)
+            col.pack-start(renderer, False)
+            col.add_attribute(rendrer, "text", idx)
+            self.view.append_column(col)
+
+        self.back = registry.menu_link("gps", _("Back"))
+        self.back.connect("clicked", self.stop)
+
+        self.pack_start(self.view, True, True)
+        self.pack_start(self.back, False, False)
+
+    def shutdown(self):
+        self.stop()
+
+    def start(self, args):
+        self.gps.monitor.connect(self.on_ubxdebug_packet)
+
+    def stop(self, args):
+        self.gps.monitor.disconnect(self.on_ubxdebug_packet)
+
+    def on_ubxdebug_packet(self, clid, length, data):
+        # In zhone it is cbUBXDebugPacket
+        #if clid == "NAV-STATUS" and data:
+        #    i = ["%s: %d" % (k, data[0][k]) for k in sorted(data[0].keys())]
+        #    zavai.info("Status:", " ".join(i))
+        ##    if data[0]['TTFF']:
+        ##        zavai.info("TTFF: %f", data[0]['TTFF']/1000.0)
+        if clid == "NAV-SVINFO":
+            self.handle_ubx_sat_data(data[1:])
+        #else:
+        #    zavai.info("gps got ubxdebug packet", clid)
+        #    zavai.info("DATA:", data)
+
+    def handle_ubx_sat_data(self, ubxinfo):
+        #zavai.info("CH ID SN ELE AZI Used Diff Alm Eph Bad Status")
+        self.store.clear()
+        for sv in ubxinfo:
+            if sv["CNO"] == 0: continue
+            svid = sv["SVID"]
+            used = sv["Flags"] & 0x01
+            diff = sv["Flags"] & 0x02
+            almoreph = sv["Flags"] & 0x04
+            eph = sv["Flags"] & 0x08
+            bad = sv["Flags"] & 0x10
+            qi = ("%i: " % sv["QI"]) + SAT_QI_NAMES.get(sv["QI"], _("Unknown"))
+            self.store.append([
+                "%2d" % sv["chn"],
+                "%2d" % sv["SVID"],
+                "%2d" % sv["CNO"],
+                "%3d" % sv["Elev"],
+                "%3d" % sv["Azim"],
+                used and "used" or "",
+                diff and "diff" or "",
+                almoreph and "alm" or "",
+                eph and "eph" or "",
+                bad and "bad" or "",
+                qi])
+
+def start_monitor(registry):
+    monitor = registry.resource("app.satellite_monitor")
+    registry.resource("app").show_widget(monitor)
+    monitor.start()
+
+def init(conf = None, registry = None, **kw):
+    registry.register("app.satellite_monitor", SatelliteMonitor)
+    menu_gps = registry.menu("main.gps")
+
+    monitor = gtk.Button(_("Monitor"))
+    monitor.connect("clicked", lambda *args: start_monitor(registry))
+    menu_gps.add_child(monitor)
+
+    # TODO: automate this in registry
+    registry.menu("main").add_child(registry.menu_link("main.gps", _("GPS")))
+
diff --git a/plugins/99_debug.py b/plugins/99_debug.py
new file mode 100644 (file)
index 0000000..b6458e8
--- /dev/null
@@ -0,0 +1,31 @@
+# debug - zavai debug menus
+#
+# Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+import zavai
+import gtk
+import sys
+
+def init(conf = None, registry = None, **kw):
+    debug = registry.menu("main.debug")
+
+    quit = gtk.Button("Quit")
+    quit.connect("clicked", gtk.main_quit)
+    debug.add_child(quit)
+
+    registry.menu("main").add_child(registry.menu_link("main.debug", "Debug"))
+
diff --git a/plugins/debug.py b/plugins/debug.py
deleted file mode 100644 (file)
index b6458e8..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# debug - zavai debug menus
-#
-# Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-import zavai
-import gtk
-import sys
-
-def init(conf = None, registry = None, **kw):
-    debug = registry.menu("main.debug")
-
-    quit = gtk.Button("Quit")
-    quit.connect("clicked", gtk.main_quit)
-    debug.add_child(quit)
-
-    registry.menu("main").add_child(registry.menu_link("main.debug", "Debug"))
-
diff --git a/plugins/sat_monitor.py b/plugins/sat_monitor.py
deleted file mode 100644 (file)
index af8a24c..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-# sat_monitor - zavai satellite monitor
-#
-# Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-import gtk
-import sys
-import gettext
-_ = gettext.gettext
-import zavai
-
-SAT_QI_NAMES = {
-    0: _("idle"),
-    1: _("searching"),
-    2: _("signal acquired"),
-    3: _("signal unusable"),
-    4: _("code lock"),
-    5: _("code&carrier lock"),
-    6: _("code&carrier lock"),
-    7: _("receiving data")
-}
-
-class SatelliteMonitor(gtk.VBox, zavai.Resource):
-    def __init__(self, registry, name, **kw):
-        super(SatelliteMonitor, self).__init__()
-
-        self.gps = registry.resource("gps")
-
-        self.store = gtk.ListStore(str, str, str, str, str, str, str, str, str, str, str)
-        self.view = gtk.TreeView(self.store)
-
-        renderer = gtk.CellRendererText()
-        for idx, name in enumerate((_("CH"), _("ID"), _("SN"), _("ELE"), _("AZI"),
-                     _("Used"), _("Diff"), _("Alm"), _("Eph"),
-                     _("Bad"), _("Status"))):
-            col = gtk.TreeViewColumn(name)
-            col.pack-start(renderer, False)
-            col.add_attribute(rendrer, "text", idx)
-            self.view.append_column(col)
-
-        self.back = registry.menu_link("gps", _("Back"))
-        self.back.connect("clicked", self.stop)
-
-        self.pack_start(self.view, True, True)
-        self.pack_start(self.back, False, False)
-
-    def shutdown(self):
-        self.stop()
-
-    def start(self, args):
-        self.gps.monitor.connect(self.on_ubxdebug_packet)
-
-    def stop(self, args):
-        self.gps.monitor.disconnect(self.on_ubxdebug_packet)
-
-    def on_ubxdebug_packet(self, clid, length, data):
-        # In zhone it is cbUBXDebugPacket
-        #if clid == "NAV-STATUS" and data:
-        #    i = ["%s: %d" % (k, data[0][k]) for k in sorted(data[0].keys())]
-        #    zavai.info("Status:", " ".join(i))
-        ##    if data[0]['TTFF']:
-        ##        zavai.info("TTFF: %f", data[0]['TTFF']/1000.0)
-        if clid == "NAV-SVINFO":
-            self.handle_ubx_sat_data(data[1:])
-        #else:
-        #    zavai.info("gps got ubxdebug packet", clid)
-        #    zavai.info("DATA:", data)
-
-    def handle_ubx_sat_data(self, ubxinfo):
-        #zavai.info("CH ID SN ELE AZI Used Diff Alm Eph Bad Status")
-        self.store.clear()
-        for sv in ubxinfo:
-            if sv["CNO"] == 0: continue
-            svid = sv["SVID"]
-            used = sv["Flags"] & 0x01
-            diff = sv["Flags"] & 0x02
-            almoreph = sv["Flags"] & 0x04
-            eph = sv["Flags"] & 0x08
-            bad = sv["Flags"] & 0x10
-            qi = ("%i: " % sv["QI"]) + SAT_QI_NAMES.get(sv["QI"], _("Unknown"))
-            self.store.append([
-                "%2d" % sv["chn"],
-                "%2d" % sv["SVID"],
-                "%2d" % sv["CNO"],
-                "%3d" % sv["Elev"],
-                "%3d" % sv["Azim"],
-                used and "used" or "",
-                diff and "diff" or "",
-                almoreph and "alm" or "",
-                eph and "eph" or "",
-                bad and "bad" or "",
-                qi])
-
-def start_monitor(registry):
-    monitor = registry.resource("app.satellite_monitor")
-    registry.resource("app").show_widget(monitor)
-    monitor.start()
-
-def init(conf = None, registry = None, **kw):
-    registry.register("app.satellite_monitor", SatelliteMonitor)
-    menu_gps = registry.menu("main.gps")
-
-    monitor = gtk.Button(_("Monitor"))
-    monitor.connect("clicked", lambda *args: start_monitor(registry))
-    menu_gps.add_child(monitor)
-
-    # TODO: automate this in registry
-    registry.menu("main").add_child(registry.menu_link("main.gps", _("GPS")))
-