Beispiel #1
0
    def __init__(self, options, show_tabs=False):

        prefsfile = os.path.abspath(options.preferences)
        messagesfile = os.path.abspath(options.messages)
        settingsfile = os.path.abspath(options.settings)
        plugindir = os.path.abspath(options.plugin_dir)
        disable_plugins = options.disable_plugins

        if not os.path.exists(messagesfile):
            message_dialog("Could not find messages.xml", None, secondary=gs.CONFIG_DIR)
            sys.exit(1)
        if not os.path.exists(settingsfile):
            message_dialog("Could not find settings.xml", None, secondary=gs.CONFIG_DIR)
            sys.exit(1)

        LOG.info("Groundstation loading")
        LOG.info("Restored preferences: %s" % prefsfile)
        LOG.info("Messages file: %s" % messagesfile)
        LOG.info("Settings file: %s" % settingsfile)

        self._messagesfile = MessagesFile(path=messagesfile, debug=False)
        self._messagesfile.parse()

        self._settingsfile = SettingsFile(path=settingsfile)

        self._config = Config(filename=prefsfile)
        ConfigurableIface.__init__(self, self._config)
        self.autobind_config("command_button","enabled_plugins")

        self._source = UAVSource(self._config, self._messagesfile, options)
        self._tm = TabletGraphManager(self._config, self._source, self._messagesfile, self)

        self._plugin_manager = PluginManager(plugindir, plugin_whitelist=self._enabled_plugins)
        if not disable_plugins:
            self._plugin_manager.initialize_plugins(self._config, self._source, self._messagesfile, self._settingsfile, self)

        self._in_fullscreen = False

        if HILDON_AVAILABLE:
            self._win = hildon.Window()
            self._win.fullscreen()
            self._win.connect("key-press-event", self._on_hildon_key_press)
        else:
            self._win = gtk.Window()
            self._win.set_default_size(800, 480)

        self._win.set_title("Wasp Groundstation")
        self._win.connect("window-state-event", self._on_window_state_change)
        self._win.connect("destroy", self._on_close)

        vb = gtk.VBox(spacing=5)
        self._notebook = gtk.Notebook()
        if not show_tabs:
            self._notebook.set_show_tabs(False)

        self._bb = gtk.HBox()

        vb.pack_start(self._notebook, expand=True, fill=True)
        vb.pack_start(self._bb, expand=False, fill=True)
        self._win.add(vb)

        self.add_page(
                "Status",
                self.make_status_page(show_uav_info=True, show_build=True, show_comm_status=True))
        self.add_page(
                "Telemetry",
                self.make_telemetry_page())

        self._configurable = [
            self._source,
            self._tm,
        ]
        for c in self._configurable:
            if c:
                c.update_state_from_config()

        gobject.timeout_add(2000, lambda: self._source.connect_to_uav())
        gobject.timeout_add(3000, lambda: self._source.refresh_uav_info())

        self._win.show_all()
Beispiel #2
0
    def __init__(self, options):
        
        prefsfile = os.path.abspath(options.preferences)
        messagesfile = os.path.abspath(options.messages)
        settingsfile = os.path.abspath(options.settings)
        plugindir = os.path.abspath(options.plugin_dir)
        disable_plugins = options.disable_plugins

        if not os.path.exists(messagesfile):
            message_dialog("Could not find messages.xml", None, secondary="%s does not exist." % messagesfile)
            sys.exit(1)
        if not os.path.exists(settingsfile):
            message_dialog("Could not find settings.xml", None, secondary="%s does not exist." % settingsfile)
            sys.exit(1)
    
        #connect our log buffer to the python logging subsystem
        self._logbuffer = LogBuffer()
        handler = logging.StreamHandler(self._logbuffer)
        defaultFormatter = logging.Formatter(self._logbuffer.FORMAT)
        handler.setFormatter(defaultFormatter)
        logging.root.addHandler(handler)

        LOG.info("Groundstation loading")
        LOG.info("Restored preferences: %s" % prefsfile)
        LOG.info("Messages file: %s" % messagesfile)
        LOG.info("Settings file: %s" % settingsfile)
        LOG.info("Installed: %d" % gs.IS_INSTALLED)
        LOG.info("Windows: %d" % gs.IS_WINDOWS)

        try:
            GtkBuilderWidget.__init__(self, "groundstation.ui")
        except Exception:
            LOG.critical("Error loading ui file", exc_info=True)
            sys.exit(1)

        icon = get_icon_pixbuf("rocket.svg")
        gtk.window_set_default_icon(icon)

        self._tried_to_connect = False
        self._home_lat = self.CONFIG_LAT_DEFAULT
        self._home_lon = self.CONFIG_LON_DEFAULT
        self._home_zoom = self.CONFIG_ZOOM_DEFAULT

        self.window = self.get_resource("main_window")
        self.window.set_title(gs.NAME)

        self._config = Config(filename=prefsfile)
        ConfigurableIface.__init__(self, self._config)

        self._messagesfile = MessagesFile(path=messagesfile, debug=False)
        self._messagesfile.parse()

        self._settingsfile = SettingsFile(path=settingsfile)

        self._source = UAVSource(self._config, self._messagesfile, options)
        self._source.connect("source-connected", self._on_source_connected)
        self._source.connect("uav-selected", self._on_uav_selected)

        #track the UAVs we have got data from
        self._source.connect("uav-detected", self._on_uav_detected)
        self._uav_detected_model = gtk.ListStore(str,int)
        self._uav_detected_model.append( ("All UAVs", wasp.ACID_ALL) )

        #track the state of a few key variables received from the plane
        self._state = {}
        self._source.register_interest(self._on_gps, 2, "GPS_LLH")

        #All the menus in the UI. Get them the first time a plugin tries to add a submenu
        #to the UI to save startup time.
        self._menus = {
                "File"      :   None,
                "Window"    :   None,
                "Map"       :   None,
                "UAV"       :   None,
                "Help"      :   None,
        }

        self._map = Map(self._config, self._source)
        self._msgarea = MsgAreaController()
        self._sb = StatusBar(self._source)
        self._info = InfoBox(self._source, self._settingsfile)
        self._statusicon = StatusIcon(icon, self._source)

        #raise the window when the status icon clicked
        self._statusicon.connect("activate", lambda si, win: win.present(), self.window)

        self.get_resource("main_left_vbox").pack_start(self._info.widget, False, False)
        self.get_resource("window_vbox").pack_start(self._msgarea, False, False)
        self.get_resource("window_vbox").pack_start(self._sb, False, False)

        #The telemetry tab page
        self.telemetrycontroller = TelemetryController(self._config, self._source, self._messagesfile, self.window)
        self.get_resource("telemetry_hbox").pack_start(self.telemetrycontroller.widget, True, True)

        #The settings tab page
        self.settingscontroller = SettingsController(self._source, self._settingsfile, self._messagesfile)
        self.get_resource("settings_hbox").pack_start(self.settingscontroller.widget, True, True)

        #The command and control tab page
        self.commandcontroller = CommandController(self._source, self._messagesfile, self._settingsfile)
        self.get_resource("command_hbox").pack_start(self.commandcontroller.widget, False, True)
        self.controlcontroller = ControlController(self._source, self._messagesfile, self._settingsfile)
        self.get_resource("control_hbox").pack_start(self.controlcontroller.widget, True, True)
        #Track ok/failed command messages
        self._source.connect("command-ok", self._on_command_ok)
        self._source.connect("command-fail", self._on_command_fail)
        #Track logging of source
        self._source.connect("logging-started", self._on_logging_started)

        #Lazy initialize the following when first needed
        self._plane_view = None
        self._horizon_view = None
        self._prefs_window = None

        #create the map
        self.get_resource("map_holder").add(self._map.get_widget())
        self._map.connect("notify::auto-center", self.on_map_autocenter_property_change)
        self._map.connect("notify::show-trip-history", self.on_map_show_trip_history_property_change)

        #initialize the plugins
        self._plugin_manager = PluginManager(plugindir)
        if not disable_plugins:
            self._plugin_manager.initialize_plugins(self._config, self._source, self._messagesfile, self._settingsfile, self)
    
        #Setup those items which are configurable, or depend on configurable
        #information, and implement config.ConfigurableIface
        self._configurable = [
            self,
            self._source,
            self._map,
            self.telemetrycontroller.graphmanager,
        ]
        #Add those plugins that can also be configured
        self._configurable += self._plugin_manager.get_plugins_implementing_interface(ConfigurableIface)

        for c in self._configurable:
            if c:
                c.update_state_from_config()

        self.get_resource("menu_item_disconnect").set_sensitive(False)
        self.get_resource("menu_item_autopilot_disable").set_sensitive(False)
        self.builder_connect_signals()

        self.window.show_all()
Beispiel #3
0
    def __init__(self, options, show_tabs=False):

        prefsfile = os.path.abspath(options.preferences)
        messagesfile = os.path.abspath(options.messages)
        settingsfile = os.path.abspath(options.settings)
        plugindir = os.path.abspath(options.plugin_dir)
        disable_plugins = options.disable_plugins

        if not os.path.exists(messagesfile):
            message_dialog("Could not find messages.xml",
                           None,
                           secondary=gs.CONFIG_DIR)
            sys.exit(1)
        if not os.path.exists(settingsfile):
            message_dialog("Could not find settings.xml",
                           None,
                           secondary=gs.CONFIG_DIR)
            sys.exit(1)

        LOG.info("Groundstation loading")
        LOG.info("Restored preferences: %s" % prefsfile)
        LOG.info("Messages file: %s" % messagesfile)
        LOG.info("Settings file: %s" % settingsfile)

        self._messagesfile = MessagesFile(path=messagesfile, debug=False)
        self._messagesfile.parse()

        self._settingsfile = SettingsFile(path=settingsfile)

        self._config = Config(filename=prefsfile)
        ConfigurableIface.__init__(self, self._config)
        self.autobind_config("command_button", "enabled_plugins")

        self._source = UAVSource(self._config, self._messagesfile, options)
        self._tm = TabletGraphManager(self._config, self._source,
                                      self._messagesfile, self)

        self._plugin_manager = PluginManager(
            plugindir, plugin_whitelist=self._enabled_plugins)
        if not disable_plugins:
            self._plugin_manager.initialize_plugins(self._config, self._source,
                                                    self._messagesfile,
                                                    self._settingsfile, self)

        self._in_fullscreen = False

        if HILDON_AVAILABLE:
            self._win = hildon.Window()
            self._win.fullscreen()
            self._win.connect("key-press-event", self._on_hildon_key_press)
        else:
            self._win = gtk.Window()
            self._win.set_default_size(800, 480)

        self._win.set_title("Wasp Groundstation")
        self._win.connect("window-state-event", self._on_window_state_change)
        self._win.connect("destroy", self._on_close)

        vb = gtk.VBox(spacing=5)
        self._notebook = gtk.Notebook()
        if not show_tabs:
            self._notebook.set_show_tabs(False)

        self._bb = gtk.HBox()

        vb.pack_start(self._notebook, expand=True, fill=True)
        vb.pack_start(self._bb, expand=False, fill=True)
        self._win.add(vb)

        self.add_page(
            "Status",
            self.make_status_page(show_uav_info=True,
                                  show_build=True,
                                  show_comm_status=True))
        self.add_page("Telemetry", self.make_telemetry_page())

        self._configurable = [
            self._source,
            self._tm,
        ]
        for c in self._configurable:
            if c:
                c.update_state_from_config()

        gobject.timeout_add(2000, lambda: self._source.connect_to_uav())
        gobject.timeout_add(3000, lambda: self._source.refresh_uav_info())

        self._win.show_all()