Exemplo n.º 1
0
 def measurement_state_callback(self, sbp_msg, **metadata):
     self._at_least_one_track_received = True
     with self.CN0_lock:
         codes_that_came = []
         t = monotonic() - self.t_init
         self.time.append(t)
         # first we loop over all the SIDs / channel keys we have stored and set 0 in for CN0
         for i, s in enumerate(sbp_msg.states):
             if code_is_glo(s.mesid.code):
                 # for Glonass satellites, store in two dictionaries FCN and SLOT
                 # so that they can both be retrieved when displaying the channel
                 if (s.mesid.sat > 90):
                     self.glo_fcn_dict[i] = s.mesid.sat - 100
                 sat = self.glo_fcn_dict.get(i, 0)
                 if (s.mesid.sat <= 90):
                     self.glo_slot_dict[sat] = s.mesid.sat
             else:
                 sat = s.mesid.sat
             key = (s.mesid.code, sat)
             codes_that_came.append(key)
             if s.cn0 != 0:
                 self.CN0_dict[key].append(s.cn0 / 4.0)
                 self.CN0_age[key] = t
             received_code_list = getattr(self, "received_codes", [])
             if s.mesid.code not in received_code_list:
                 received_code_list.append(s.mesid.code)
                 self.received_codes = received_code_list
         for key, cno_array in list(self.CN0_dict.items()):
             if key not in codes_that_came:
                 cno_array.append(0)
         self.clean_cn0(t)
     self.update_scheduler.schedule_update('update_plot', self.update_plot)
Exemplo n.º 2
0
 def tracking_state_callback(self, sbp_msg, **metadata):
     self._at_least_one_track_received = True
     with self.CN0_lock:
         codes_that_came = []
         t = monotonic() - self.t_init
         self.time.append(t)
         # first we loop over all the SIDs / channel keys we have stored and set 0 in for CN0
         # for each SID, an array of size MAX PLOT with the history of CN0's stored
         # If there is no CN0 or not tracking for an epoch, 0 will be used
         # each array can be plotted against host_time, t
         for i, s in enumerate(sbp_msg.states):
             if code_is_glo(s.sid.code):
                 if (s.sid.sat > 90):
                     sat = s.sid.sat - 100
                 else:
                     sat = s.fcn - GLO_FCN_OFFSET
                 self.glo_slot_dict[sat] = s.sid.sat
             else:
                 sat = s.sid.sat
             key = (s.sid.code, sat)
             codes_that_came.append(key)
             if s.cn0 != 0:
                 self.CN0_dict[key].append(s.cn0 / 4.0)
                 self.CN0_age[key] = t
             received_code_list = getattr(self, "received_codes", [])
             if s.sid.code not in received_code_list:
                 received_code_list.append(s.sid.code)
                 self.received_codes = received_code_list
         for key, cno_array in list(self.CN0_dict.items()):
             if key not in codes_that_came:
                 cno_array.append(0)
         self.clean_cn0(t)
     self.update_scheduler.schedule_update('update_plot', self.update_plot)
Exemplo n.º 3
0
 def measurement_state_callback(self, sbp_msg, **metadata):
     codes_that_came = []
     t = time.time() - self.t_init
     self.time.append(t)
     self.CN0_lock.acquire()
     # first we loop over all the SIDs / channel keys we have stored and set 0 in for CN0
     for i, s in enumerate(sbp_msg.states):
         if code_is_glo(s.mesid.code):
             # for Glonass satellites, store in two dictionaries FCN and SLOT
             # so that they can both be retrieved when displaying the channel
             if (s.mesid.sat > 90):
                 self.glo_fcn_dict[i] = s.mesid.sat - 100
             else:
                 self.glo_slot_dict[i] = s.mesid.sat
             sat = self.glo_fcn_dict.get(i, 0)
         else:
             sat = s.mesid.sat
         key = (s.mesid.code, sat, i)
         codes_that_came.append(key)
         if s.cn0 != 0:
             self.CN0_dict[key].append(s.cn0 / 4.0)
         received_code_list = getattr(self, "received_codes", [])
         if s.mesid.code not in received_code_list:
             received_code_list.append(s.mesid.code)
             self.received_codes = received_code_list
     for key, cno_array in self.CN0_dict.items():
         if key not in codes_that_came:
             cno_array.append(0)
     self.CN0_lock.release()
     GUI.invoke_later(self.update_plot)
Exemplo n.º 4
0
 def tracking_state_callback(self, sbp_msg, **metadata):
     codes_that_came = []
     self.CN0_lock.acquire()
     t = time.time() - self.t_init
     self.time.append(t)
     # first we loop over all the SIDs / channel keys we have stored and set 0 in for CN0
     # for each SID, an array of size MAX PLOT with the history of CN0's stored
     # If there is no CN0 or not tracking for an epoch, 0 will be used
     # each array can be plotted against host_time, t
     for i, s in enumerate(sbp_msg.states):
         if code_is_glo(s.sid.code):
             sat = s.fcn - GLO_FCN_OFFSET
             self.glo_slot_dict[i] = s.sid.sat
         else:
             sat = s.sid.sat
         key = (s.sid.code, sat, i)
         codes_that_came.append(key)
         if s.cn0 != 0:
             self.CN0_dict[key].append(s.cn0 / 4.0)
         received_code_list = getattr(self, "received_codes", [])
         if s.sid.code not in received_code_list:
             received_code_list.append(s.sid.code)
             self.received_codes = received_code_list
     for key, cno_array in self.CN0_dict.items():
         if key not in codes_that_came:
             cno_array.append(0)
     self.CN0_lock.release()
     GUI.invoke_later(self.update_plot)
Exemplo n.º 5
0
    def tracking_state_callback(self, sbp_msg, **metadata):
        t = time.time() - self.t_init
        self.time[0:-1] = self.time[1:]
        self.time[-1] = t
        # first we loop over all the SIDs / channel keys we have stored and set 0 in for CN0
        for key, cno_array in self.CN0_dict.items():
            # p
            if (cno_array == 0).all():
                self.CN0_dict.pop(key)
            else:
                new_arr = np.roll(cno_array, -1)
                new_arr[-1] = 0
                self.CN0_dict[key] = new_arr

        # If the whole array is 0 we remove it
        # for each satellite, we have a (code, prn, channel) keyed dict
        # for each SID, an array of size MAX PLOT with the history of CN0's stored
        # If there is no CN0 or not tracking for an epoch, 0 will be used
        # each array can be plotted against host_time, t
        for i, s in enumerate(sbp_msg.states):
            if code_is_gps(s.sid.code):
                sat = s.sid.sat
            elif code_is_glo(s.sid.code):
                sat = s.fcn - GLO_FCN_OFFSET
                self.glo_slot_dict[sat] = s.sid.sat

            key = (s.sid.code, sat, i)
            if s.cn0 != 0:
                self.CN0_dict[key][-1] = s.cn0 / 4.0

        GUI.invoke_later(self.update_plot)
Exemplo n.º 6
0
    def tracking_state_callback(self, sbp_msg, **metadata):
        t = time.time() - self.t_init
        self.time[0:-1] = self.time[1:]
        self.time[-1] = t
        # first we loop over all the SIDs / channel keys we have stored and set 0 in for CN0
        for key, cno_array in self.CN0_dict.items():
            # p
            if (cno_array == 0).all():
                self.CN0_dict.pop(key)
            else:
                new_arr = np.roll(cno_array, -1)
                new_arr[-1] = 0
                self.CN0_dict[key] = new_arr

        # If the whole array is 0 we remove it
        # for each satellite, we have a (code, prn, channel) keyed dict
        # for each SID, an array of size MAX PLOT with the history of CN0's stored
        # If there is no CN0 or not tracking for an epoch, 0 will be used
        # each array can be plotted against host_time, t
        for i, s in enumerate(sbp_msg.states):
            if code_is_glo(s.sid.code):
                sat = s.fcn - GLO_FCN_OFFSET
                self.glo_slot_dict[i] = s.sid.sat
            else:
                sat = s.sid.sat
            key = (s.sid.code, sat, i)
            if s.cn0 != 0:
                self.CN0_dict[key][-1] = s.cn0 / 4.0
            received_code_list = getattr(self, "received_codes", [])
            if s.sid.code not in received_code_list:
                received_code_list.append(s.sid.code)
                self.received_codes = received_code_list
        GUI.invoke_later(self.update_plot)
Exemplo n.º 7
0
    def measurement_state_callback(self, sbp_msg, **metadata):
        t = time.time() - self.t_init
        self.time[0:-1] = self.time[1:]
        self.time[-1] = t
        # first we loop over all the SIDs / channel keys we have stored and set 0 in for CN0
        for key, cno_array in self.CN0_dict.items():
            # p
            if (cno_array == 0).all():
                self.CN0_dict.pop(key)
            else:
                new_arr = np.roll(cno_array, -1)
                new_arr[-1] = 0
                self.CN0_dict[key] = new_arr

        for i, s in enumerate(sbp_msg.states):
            if code_is_glo(s.mesid.code):
                # for Glonass satellites, store in two dictionaries FCN and SLOT
                # so that they can both be retrieved when displaying the channel
                if (s.mesid.sat > 90):
                    self.glo_fcn_dict[i] = s.mesid.sat - 100
                else:
                    self.glo_slot_dict[i] = s.mesid.sat
                sat = self.glo_fcn_dict.get(i, 0)
            else:
                sat = s.mesid.sat
            key = (s.mesid.code, sat, i)
            if s.cn0 != 0:
                self.CN0_dict[key][-1] = s.cn0 / 4.0
            received_code_list = getattr(self, "received_codes", [])
            if s.mesid.code not in received_code_list:
                received_code_list.append(s.mesid.code)
                self.received_codes = received_code_list
        GUI.invoke_later(self.update_plot)
Exemplo n.º 8
0
def get_color(key):
    code, sat, ch = key

    # reuse palatte for glo signals
    if code_is_glo(code):
        code -= 3
        sat += GLO_FCN_OFFSET

    key = str((code, sat % 32))
    color = color_dict.get(key, 0xff0000)
    return color
Exemplo n.º 9
0
def get_color(key):
    code, sat, ch = key

    # reuse palatte for glo signals
    if code_is_glo(code):
        code -= 3
        sat += GLO_FCN_OFFSET

    key = str((code, sat % 32))
    color = color_dict.get(key, 0xff0000)
    return color
Exemplo n.º 10
0
def get_label(key, extra):
    code, sat, ch = key
    lbl = 'Ch {ch:02d}: {code} '.format(ch=ch, code=code_to_str(code))

    if code_is_gps(code):
        lbl += 'PRN {sat:02d}'.format(sat=sat)
    elif code_is_glo(code):
        lbl += 'FCN {sat:0=+3d}'.format(sat=sat)
        if sat in extra:
            lbl += ' Slot: {slot:02d}'.format(slot=extra[sat])

    return lbl
Exemplo n.º 11
0
def get_label(key, extra):
    code, sat, ch = key
    lbl = 'Ch {ch:02d}: {code} '.format(ch=ch, code=code_to_str(code))

    if code_is_gps(code):
        lbl += 'PRN {sat:02d}'.format(sat=sat)
    elif code_is_glo(code):
        lbl += 'FCN {sat:0=+3d}'.format(sat=sat)
        if sat in extra:
            lbl += ' Slot: {slot:02d}'.format(slot=extra[sat])

    return lbl
Exemplo n.º 12
0
def get_color(key):
    code, sat = key

    # reuse palatte for glo signals
    if code_is_glo(code):
        sat += GLO_FCN_OFFSET
    elif code_is_sbas(code):
        sat -= 120
    elif code_is_qzss(code):
        sat -= 193
    if sat > 37:
        sat = sat % 37
    key = str((0, sat))
    color = color_dict.get(key, 0xff0000)
    return color
Exemplo n.º 13
0
def get_label(key, extra):
    code, sat, ch = key
    lbl = 'Ch {ch:02d}: {code} '.format(ch=ch, code=code_to_str(code))

    if code_is_glo(code):
        lbl += 'F{sat:0=+3d}'.format(sat=sat)
        if ch in extra:
            lbl += ' R{slot:02d}'.format(slot=extra[ch])
    elif code_is_sbas(code):
        lbl += 'S{sat:3d}'.format(sat=sat)
    elif code_is_bds2(code):
        lbl += 'C{sat:02d}'.format(sat=sat)
    elif code_is_qzss(code):
        lbl += 'J{sat:3d}'.format(sat=sat)
    else:
        lbl += 'G{sat:02d}'.format(sat=sat)

    return lbl
Exemplo n.º 14
0
 def update_plot(self):
     plot_labels = []
     plots = []
     self.plot_data.set_data('t', self.time)
     # Remove any stale plots that got removed from the dictionary
     for each in self.plot_data.list_data():
         if each not in [str(a)
                         for a in self.CN0_dict.keys()] and each != 't':
             try:
                 self.plot_data.del_data(each)
                 self.plot.delplot(each)
             except KeyError:
                 pass
     for k, cno_array in self.CN0_dict.items():
         if int(k[0]) not in SUPPORTED_CODES:
             continue
         key = str(k)
         # set plot data and create plot for any selected for display
         if (getattr(self, 'show_{}'.format(int(k[0])))):
             self.plot_data.set_data(key, cno_array)
             if key not in self.plot.plots.keys():
                 pl = self.plot.plot(('t', key),
                                     type='line',
                                     color=get_color(k),
                                     name=key)
             else:
                 pl = self.plot.plots[key]
             # if channel is still active:
             if cno_array[-1] != 0:
                 plots.append(pl)
                 svid_label = 'FCN' if code_is_glo(int(k[0])) else 'PRN'
                 plot_labels.append(
                     'Ch %02d (%s%02d (%s))' %
                     (k[2], svid_label, k[1], code_to_str(k[0])))
         # Remove plot data and plots not selected
         else:
             if key in self.plot_data.list_data():
                 self.plot_data.del_data(key)
             if key in self.plot.plots.keys():
                 self.plot.delplot(key)
     plots = dict(zip(plot_labels, plots))
     self.plot.legend.plots = plots
Exemplo n.º 15
0
def get_label(key, extra):
    code, sat = key
    lbl = '{code} '.format(code=code_to_str(code))

    if code_is_glo(code):
        lbl += 'F{sat:0=+3d}'.format(sat=sat)
        if sat in extra:
            lbl += ' R{slot:02d}'.format(slot=extra[sat])
    elif code_is_sbas(code):
        lbl += 'S{sat:3d}'.format(sat=sat)
    elif code_is_bds(code):
        lbl += 'C{sat:02d}'.format(sat=sat)
    elif code_is_qzss(code):
        lbl += 'J{sat:3d}'.format(sat=sat)
    elif code_is_galileo(code):
        lbl += 'E{sat:02d}'.format(sat=sat)
    else:
        lbl += 'G{sat:02d}'.format(sat=sat)

    return lbl
Exemplo n.º 16
0
    def azel_callback(self, sbp_msg, **metadata):
        svazelmsg = MsgSvAzEl(sbp_msg)
        tracked = self._trk_view.get_tracked_sv_labels()

        pending_update = {
            'x_gps': [],
            'x_glo': [],
            'x_gal': [],
            'x_bds': [],
            'x_qzss': [],
            'x_sbas': [],
            'y_gps': [],
            'y_glo': [],
            'y_gal': [],
            'y_bds': [],
            'y_qzss': [],
            'y_sbas': []
        }

        # store new label updates, and display at once
        overlay_update = []

        for azel in svazelmsg.azel:
            sid = azel.sid
            az = azel.az * 2
            el = azel.el

            x, y = self.azel_to_xy(az, el)

            sat_string = ""

            if code_is_gps(sid.code) and self.gps_visible:
                pending_update['x_gps'].append(x)
                pending_update['y_gps'].append(y)
            elif code_is_glo(sid.code) and self.glo_visible:
                pending_update['x_glo'].append(x)
                pending_update['y_glo'].append(y)
            elif code_is_galileo(sid.code) and self.gal_visible:
                pending_update['x_gal'].append(x)
                pending_update['y_gal'].append(y)
            elif code_is_bds(sid.code) and self.bds_visible:
                pending_update['x_bds'].append(x)
                pending_update['y_bds'].append(y)
            elif code_is_qzss(sid.code) and self.qzss_visible:
                pending_update['x_qzss'].append(x)
                pending_update['y_qzss'].append(y)
            elif code_is_sbas(sid.code) and self.sbas_visible:
                pending_update['x_sbas'].append(x)
                pending_update['y_sbas'].append(y)

            sat_string = get_label((sid.code, sid.sat))[2]

            if sat_string in tracked:
                sat_string += TRK_SIGN

            label = DataLabel(component=self.plot,
                              data_point=(x, y),
                              label_text=sat_string,
                              label_position="bottom right",
                              border_visible=False,
                              bgcolor="transparent",
                              marker_visible=False,
                              font='modern 14',
                              arrow_visible=False,
                              show_label_coords=False)
            overlay_update.append(label)

        # display label updates
        self.plot.overlays = (self.axis_overlays + overlay_update +
                              self.default_overlays)

        self.plot_data.update(pending_update)