示例#1
0
    def test_someSatellitesUsed(self):
        """
        Tests a beacon information with a bunch of satellites, some of
        them used in computing a fix.
        """
        bi = base.BeaconInformation()

        for prn in range(1, 10):
            satellite = base.Satellite(identifier=prn, **self.satelliteKwargs)
            bi.seenBeacons.add(satellite)
            if prn % 2:
                bi.usedBeacons.add(satellite)

        self.assertEqual(len(bi.seenBeacons), 9)
        self.assertEqual(len(bi.usedBeacons), 5)

        self.assertEqual(
            repr(bi), "<BeaconInformation (used beacons (5): ["
            "<Satellite (1), azimuth: 1, elevation: 1, snr: 1.0>, "
            "<Satellite (3), azimuth: 1, elevation: 1, snr: 1.0>, "
            "<Satellite (5), azimuth: 1, elevation: 1, snr: 1.0>, "
            "<Satellite (7), azimuth: 1, elevation: 1, snr: 1.0>, "
            "<Satellite (9), azimuth: 1, elevation: 1, snr: 1.0>], "
            "unused beacons: ["
            "<Satellite (2), azimuth: 1, elevation: 1, snr: 1.0>, "
            "<Satellite (4), azimuth: 1, elevation: 1, snr: 1.0>, "
            "<Satellite (6), azimuth: 1, elevation: 1, snr: 1.0>, "
            "<Satellite (8), azimuth: 1, elevation: 1, snr: 1.0>])>")
示例#2
0
    def _fixGSV(self):
        """
        Parses partial visible satellite information from a GSV sentence.
        """
        # To anyone who knows NMEA, this method's name should raise a chuckle's
        # worth of schadenfreude. 'Fix' GSV? Hah! Ludicrous.
        beaconInformation = base.BeaconInformation()
        self._sentenceData["_partialBeaconInformation"] = beaconInformation

        keys = "satellitePRN", "azimuth", "elevation", "signalToNoiseRatio"
        for index in range(4):
            prn, azimuth, elevation, snr = [
                getattr(self.currentSentence, attr)
                for attr in ("%s_%i" % (key, index) for key in keys)
            ]

            if prn is None or snr is None:
                # The peephole optimizer optimizes the jump away, meaning that
                # coverage.py thinks it isn't covered. It is. Replace it with
                # break, and watch the test case fail.
                # ML thread about this issue: http://goo.gl/1KNUi
                # Related CPython bug: http://bugs.python.org/issue2506
                continue

            satellite = base.Satellite(prn, azimuth, elevation, snr)
            beaconInformation.seenBeacons.add(satellite)
示例#3
0
    def test_minimal(self):
        """
        Tests a minimal satellite that only has a known PRN.

        Tests that the azimuth, elevation and signal to noise ratios
        are L{None} and verifies the repr.
        """
        s = base.Satellite(1)
        self.assertEqual(s.identifier, 1)
        self.assertIsNone(s.azimuth)
        self.assertIsNone(s.elevation)
        self.assertIsNone(s.signalToNoiseRatio)
        self.assertEqual(repr(s), "<Satellite (1), azimuth: None, "
                                   "elevation: None, snr: None>")
示例#4
0
    def test_simple(self):
        """
        Tests a minimal satellite that only has a known PRN.

        Tests that the azimuth, elevation and signal to noise ratios
        are correct and verifies the repr.
        """
        s = base.Satellite(
            identifier=1, azimuth=270.0, elevation=30.0, signalToNoiseRatio=25.0
        )

        self.assertEqual(s.identifier, 1)
        self.assertEqual(s.azimuth, 270.0)
        self.assertEqual(s.elevation, 30.0)
        self.assertEqual(s.signalToNoiseRatio, 25.0)
        self.assertEqual(
            repr(s), "<Satellite (1), azimuth: 270.0, " "elevation: 30.0, snr: 25.0>"
        )
示例#5
0
 def _buildSatellite(**kw):
     kwargs = dict(self.satelliteKwargs)
     kwargs.update(kw)
     return base.Satellite(**kwargs)