예제 #1
0
파일: source.py 프로젝트: sch17/wasp
    def __init__(self, conf, messages, options, listen_acid=wasp.ACID_ALL):
        gs.config.ConfigurableIface.__init__(self, conf)
        gobject.GObject.__init__(self)

        self._rxts = treeview.MessageTreeStore()

        #dictionary of msgid : [list, of, MessageCb objects]
        self._callbacks = {}

        #for tracking UAVs we have seen and are communicating with
        self._listen_acid = listen_acid
        self._desination_acid = wasp.ACID_ALL
        self._seen_acids = {}

        self._messages_file = messages
        self._transport = transport.Transport(check_crc=True, debug=DEBUG)
        self._groundstation_header = wasp.transport.TransportHeaderFooter(acid=wasp.ACID_GROUNDSTATION)
        self._rm = self._messages_file.get_message_by_name("REQUEST_MESSAGE")
        self._rt = self._messages_file.get_message_by_name("REQUEST_TELEMETRY")

        source_name, comm_klass, cmdline_config = communication.get_source(options.source)
        LOG.info("Source: %s" % comm_klass)
        self.communication = comm_klass(self._transport, self._messages_file, self._groundstation_header)

        #manage commands that expect a reply
        self._command_manager = fms.CommandManager(self.communication)

        #configure the class
        #start with default values
        self._default_config = self.communication.get_configuration_default()
        #replace those with configured values
        self.update_state_from_config()
        #replace those with command line values
        self._default_config.update(cmdline_config)
        LOG.debug("Source config: %s" % self._default_config)
        self.communication.configure_connection(**self._default_config)

        #attach the config UI
        self._config_gui = _SOURCE_CONFIG_GUIS.get(source_name, _SourceConfig)()

        self.communication.connect("message-received", self.on_message_received)
        self.communication.connect("uav-connected", self.on_uav_connected)

        #track how many messages per second
        self._linkok = False
        self._linktimeout = datetime.timedelta(seconds=2)
        self._lastt = datetime.datetime.now()
        self._times = utils.MovingAverage(5, float)
        gobject.timeout_add(2000, self._check_link_status)

        #track the ping time
        self._sendping = None
        self._pingtime = 0
        self._pingmsg = messages.get_message_by_name("PING")
        self.register_interest(self._got_pong, 0, "PONG")
        if options.ping_time > 0:
            gobject.timeout_add(1000*options.ping_time, self._do_ping)
예제 #2
0
파일: source.py 프로젝트: robotang/wasp
    def __init__(self, conf, messages, options, listen_acid=wasp.ACID_ALL):
        config.ConfigurableIface.__init__(self, conf)
        gobject.GObject.__init__(self)

        self._port = self.config_get("serial_port", self.DEFAULT_PORT)
        self._speed = self.config_get("serial_speed", self.DEFAULT_SPEED)
        self._rxts = treeview.MessageTreeStore()

        # dictionary of msgid : [list, of, MessageCb objects]
        self._callbacks = {}

        # for tracking UAVs we have seen and are communicating with
        self._listen_acid = listen_acid
        self._desination_acid = wasp.ACID_ALL
        self._seen_acids = {}

        self._messages_file = messages
        self._transport = transport.Transport(check_crc=True, debug=DEBUG)
        self._groundstation_header = wasp.transport.TransportHeaderFooter(acid=wasp.ACID_GROUNDSTATION)
        self._rm = self._messages_file.get_message_by_name("REQUEST_MESSAGE")
        self._rt = self._messages_file.get_message_by_name("REQUEST_TELEMETRY")

        # initialise the communication class
        connection_configuration = {"serial_port": self._port, "serial_speed": self._speed}

        source_name = options.source
        comm_klass = communication.get_source(source_name)
        LOG.info("Source: %s" % comm_klass)

        self.communication = comm_klass(self._transport, self._messages_file, self._groundstation_header)
        self.communication.configure_connection(**connection_configuration)
        self.communication.connect("message-received", self.on_message_received)
        self.communication.connect("uav-connected", self.on_uav_connected)

        # track how many messages per second
        self._linkok = False
        self._linktimeout = datetime.timedelta(seconds=2)
        self._lastt = datetime.datetime.now()
        self._times = utils.MovingAverage(5, float)
        gobject.timeout_add(2000, self._check_link_status)

        # track the ping time
        self._sendping = None
        self._pingtime = 0
        self._pingmsg = messages.get_message_by_name("PING")
        self.register_interest(self._got_pong, 0, "PONG")
        if options.ping_time > 0:
            gobject.timeout_add(1000 * options.ping_time, self._do_ping)