示例#1
0
    def open(self) -> bool:

        if self._source == "?":
            self._error = "Use snapshot tab to see files available"
            return False

        try:
            # patch up correct filename
            fn = os.path.basename(self._source)
            full_path = pathlib.PurePath(SnapVariables.SNAPSHOT_DIRECTORY, fn)
            full_path = str(full_path)

            # now open the actual file
            file = FileMetaData.FileMetaData(full_path)
            ok, self._file, self._is_wav_file, data_type, sps, cf = file.open()
            self._has_meta_data = file.has_meta_data()

            # only update the following if we managed to recover them on the open()
            if ok:
                self.set_sample_type(data_type)

            # cf and sps can be overridden from ui
            self._centre_frequency_hz = cf
            self._sample_rate_sps = sps

        except ValueError as msg:
            self._error = msg
            logger.error(msg)
            raise ValueError(msg)

        self._connected = True
        return self._connected
示例#2
0
def test_parse_filename_illegal_data_type():
    ok, _, _, _, _ = FileMetaData.parse_filename("test.imag.1000.7f")
    assert not ok
示例#3
0
def test_parse_filename_illegal_sample_rate():
    ok, _, _, _, _ = FileMetaData.parse_filename("test.cplx.twoMhz.8t")
    assert not ok
示例#4
0
def test_parse_filename_unsupported_real():
    ok, _, _, _, _ = FileMetaData.parse_filename("test.real.1000.16tle")
    assert not ok
示例#5
0
def test_parse_filename_illegal_real_complex_type():
    ok, _, _, _, _ = FileMetaData.parse_filename("test.imag.1000.16tle")
    assert not ok
示例#6
0
def test_parse_filename_ignore_too_many_cf_in_filename():
    assert FileMetaData.parse_filename("test.cf.zero.cf1234.cplx.2000.16tbe") == (True, "16tbe", True, 2000.0, 0.0)
示例#7
0
def test_parse_filename_not_enough_fields():
    ok, _, _, _, _ = FileMetaData.parse_filename("test.cplx.1000")
    assert not ok
示例#8
0
def test_parse_filename_centre_frequency_no_decimal_point():
    assert FileMetaData.parse_filename("test.cf1234.cplx.2000.16tbe") == (True, "16tbe", True, 2000.0, 1234e6)
示例#9
0
def test_parse_filename_centre_frequency():
    assert FileMetaData.parse_filename("test.cf1234.1.cplx.2000.16tle") == (True, "16tle", True, 2000.0, 1234.1e6)
示例#10
0
def test_parse_filename_with_bad_cf_number():
    assert FileMetaData.parse_filename("test.cf433.a.cplx.1000.16tle") == (True, "16tle", True, 1000.0, 0.0)
示例#11
0
def test_parse_filename_with_cf():
    assert FileMetaData.parse_filename("test.cf433.5.cplx.1000.16tle") == (True, "16tle", True, 1000.0, 433500000.0)
示例#12
0
def test_parse_filename():
    assert FileMetaData.parse_filename("test.cplx.1000.16tle") == (True, "16tle", True, 1000.0, 0.0)