Exemplo n.º 1
0
class qa_threshold_to_message (gr_unittest.TestCase):

    def setUp (self):
        self.tb = gr.top_block ()
        self.pdf = Pdf_class(self.id().split(".")[1])

    def tearDown (self):
        self.tb = None
        self.pdf.finalize_pdf()

    def test_001_t (self):
        """test_001_t: without repetition"""
        print('do you see me?')
        data_src = (-1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1)
        expected_data = (0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1)


        data_out = test_spl(self, data_src)

        plot(self, data_out, data_src)

        self.assertAlmostEqual(data_out, expected_data)
        print ("- Data correctly encoded.")


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_threshold_to_message)
    runner = runner.HTMLTestRunner(output='../TestResults', template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 2
0
class qa_fixed_point_math (gr_unittest.TestCase):

    def setUp (self):
        self.tb = gr.top_block ()

    def tearDown (self):
        self.tb = None

    def test_001_t (self):
        """test_001_t: fractional"""
        src_data = np.arange(-2, 2, 0.01)
        expected_result = (-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -0.9375, -0.9375, -0.9375, -0.9375, -0.9375, -0.9375, -0.875, -0.875, -0.875, -0.875, -0.875, -0.875, -0.8125, -0.8125, -0.8125, -0.8125, -0.8125, -0.8125, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.75, -0.6875, -0.6875, -0.6875, -0.6875, -0.6875, -0.6875, -0.625, -0.625, -0.625, -0.625, -0.625, -0.625, -0.5625, -0.5625, -0.5625, -0.5625, -0.5625, -0.5625, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.4375, -0.4375, -0.4375, -0.4375, -0.4375, -0.4375, -0.375, -0.375, -0.375, -0.375, -0.375, -0.375, -0.3125, -0.3125, -0.3125, -0.3125, -0.3125, -0.3125, -0.25, -0.25, -0.25, -0.25, -0.25, -0.25, -0.25, -0.1875, -0.1875, -0.1875, -0.1875, -0.1875, -0.1875, -0.125, -0.125, -0.125, -0.125, -0.125, -0.125, -0.0625, -0.0625, -0.0625, -0.0625, -0.0625, -0.0625, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.1875, 0.1875, 0.1875, 0.1875, 0.1875, 0.1875, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.3125, 0.3125, 0.3125, 0.3125, 0.3125, 0.3125, 0.375, 0.375, 0.375, 0.375, 0.375, 0.375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.4375, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5625, 0.5625, 0.5625, 0.5625, 0.5625, 0.5625, 0.625, 0.625, 0.625, 0.625, 0.625, 0.625, 0.6875, 0.6875, 0.6875, 0.6875, 0.6875, 0.6875, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.8125, 0.8125, 0.8125, 0.8125, 0.8125, 0.8125, 0.875, 0.875, 0.875, 0.875, 0.875, 0.875, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375,0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375, 0.9375)

        src = blocks.vector_source_f(src_data)
        dst = blocks.vector_sink_f()
        fixed_point_math_conv = flaress.fixed_point_math_ff(1, 1, 4)

        self.tb.connect(src, fixed_point_math_conv, dst)
        self.tb.run()

        result_data = dst.data()

        # print result_data
        self.assertEqual(expected_result, result_data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_fixed_point_math)
    runner = runner.HTMLTestRunner(output='../TestResults',template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 3
0
        """test_002_t: precision test"""
        param = namedtuple('param', 'samp_rate items N min_value max_value')
        param.N = 4
        param.samp_rate = 4096 * 4
        param.items = param.samp_rate / 2
        param.max_value = 2 * math.pi
        param.min_value = -2 * math.pi

        print_parameters(param)

        data_pc = test_ramp(self, param)
        plot(self,data_pc)

        src_slope = (param.max_value - param.min_value) / param.items

        pc_min_step, pc_slope = check_integer_phase(data_pc.out, param.N , param.items)
        precision = math.pow(2,(- (param.N - 1))) * math.pi

        self.assertGreaterEqual(pc_min_step, precision)
        self.assertAlmostEqual(pc_slope, src_slope, 5)

        print ("-Output Slope : %f rad/s;" % (pc_slope * param.samp_rate))
        print ("-Output Min step : %f rad." % pc_min_step)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_phase_converter)
    runner = runner.HTMLTestRunner(output='Results', template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 4
0
        )

        param.f_central = 0
        param.bw = 1000
        param.average = False
        param.cutoff = 1000
        param.samp_rate = 4096 * 8
        param.items = param.samp_rate
        param.freq = 0
        param.threshold = 10
        param.noise = 1
        param.fft_size = 4096
        param.decimation = 1

        print_parameters(param)

        data_sine = test_sine(self, param)

        self.assertGreaterEqual(len(data_sine.src), len(data_sine.out))
        self.assertGreater(len(data_sine.out), 0)
        self.assertGreaterEqual(len(data_sine.tags), 1)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(
        qa_signal_search_fft_v)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_2')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 5
0
        result_data = dst.data()

        # print result_data
        self.assertEqual(expected_result, result_data)

    def test_002_t(self):
        """test_002_t: long input"""
        src_data = np.arange(-10, 10, 1)
        expected_result = (-8, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3,
                           4, 5, 6, 7, 7, 7)

        src = flaress.vector_source_int64(src_data)
        dst = flaress.vector_sink_int64()
        integer_point_math_conv = flaress.integer_math_ll(1, 4)

        self.tb.connect(src, integer_point_math_conv, dst)
        self.tb.run()

        result_data = dst.data()

        # print result_data
        self.assertEqual(expected_result, result_data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_integer_math)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 6
0
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)

    def test_002_double_2 (self):
        """test_002_double_2: add const double version with 2 inputs"""

        src_data1 = [float(x) for x in range(16)]
        expected_result_temp = []

        const = 10
        for i in range(0, len(src_data1)): 
            expected_result_temp.append(const + src_data1[i])
        expected_result = tuple(expected_result_temp)

        src1 = flaress.vector_source_double(src_data1)
        dst = flaress.vector_sink_double()

        op = flaress.add_const_double(const, 1)

        self.tb.connect(src1, (op, 0))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
      
if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_add_const_xx)
    runner = runner.HTMLTestRunner(output='../TestResults', template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 7
0
        throttle = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        head = blocks.head(gr.sizeof_float, int (items))

        # throttle.set_max_noutput_items (samp_rate)
        # throttle.set_min_noutput_items (samp_rate)

        tb.connect(src, throttle)
        tb.connect(throttle, head)
        tb.connect(head, debug)

        _probe_func_thread.start()
        tb.run()

        data = debug.data()

        self.assertEqual(len(data), 2)
        self.assertLessEqual(data[0], samp_rate * 2)
        self.assertGreaterEqual(data[0], samp_rate)
        self.assertLessEqual(data[1], samp_rate * 3)
        self.assertGreaterEqual(data[1], samp_rate * 2)

        print ("-Set function received at the moment: %f s." % (data[0] * (1.0 / samp_rate)))
        print ("-Set function received at the moment: %f s." % (data[1] * (1.0 / samp_rate)))


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_debug_func_probe)
    runner = runner.HTMLTestRunner(output='../TestResults',template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 8
0
        print_parameters(param)

        data_pe, data_fft = test_accumulator_gain(self, param)

        plot(self, data_pe)
        plot_fft(self, data_fft)

        phase = check_phase(
            data_pe.out[1:])  #to consider the delay of gain phase accumulator

        #check frequency
        self.assertAlmostEqual(((param.freq * param.downlink / param.uplink) *
                                (2 * math.pi) / param.samp_rate),
                               np.mean(phase))
        print "-Frequency measured= %f Hz;" % (np.mean(phase) /
                                               (2 * math.pi) * param.samp_rate)

        #check phase error
        self.assertAlmostEqual(np.var(phase), 0)
        print "-No phase jump found."


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(
        qa_coherent_phase_modulator)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_2')
    runner.run(suite)
    # gr_unittest.TestProgram()
Exemplo n.º 9
0
    def test_002_double_2(self):
        """test_002_double_2: multiply const double version with 2 inputs"""

        src_data1 = [float(x) for x in range(16)]
        expected_result_temp = []

        const = 10
        for i in range(0, len(src_data1)):
            expected_result_temp.append(const * src_data1[i])
        expected_result = tuple(expected_result_temp)

        src1 = flaress.vector_source_double(src_data1)
        dst = flaress.vector_sink_double()

        op = flaress.multiply_const_double(const, 1)

        self.tb.connect(src1, (op, 0))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(
        qa_multiply_const_xx)
    runner = runner.HTMLTestRunner(output='../TestResults',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 10
0
            stdout = p.communicate()[0]
            log.debug(stdout)

            # Should fail only on the last iteration of the loop
            try:
                self.assertEqual(stdout.count("Got event code underflow message."), 1,
                    "TX underflows could not be requested async")
            except AssertionError, e:
                self.failures.append(str(e))
                pass
        finally:
            timer.cancel()

if __name__ == '__main__':

    crimson_test_suite  = gr_unittest.TestSuite()

    # Flag for test development
    IS_DEV = False

    if IS_DEV:
        # Runs only the specified test in isolation
        crimson_test_suite.addTest(qa_crimson_loopback('test_000_t'))
    else:
        crimson_test_suite  = gr_unittest.TestLoader().loadTestsFromTestCase(qa_crimson_loopback)

    print "Test results availible in test_results.log"

    #gr_unittest.TextTestRunner(verbosity=2).run(crimson_test_suite)
    gr_unittest.TextTestRunner().run(crimson_test_suite)
Exemplo n.º 11
0
        """test_002_double_2: divide double version with 2 inputs"""

        src_data1 = [float(x) for x in range(1, 16)]
        src_data2 = [float(x) for x in range(1, 16)]
        expected_result_temp = []

        for i in range(0, len(src_data1)):
            expected_result_temp.append(src_data1[i] / src_data2[i])
        expected_result = tuple(expected_result_temp)

        src1 = flaress.vector_source_double(src_data1)
        src2 = flaress.vector_source_double(src_data2)
        dst = flaress.vector_sink_double()

        op = flaress.divide_double(1)

        self.tb.connect(src1, (op, 0))
        self.tb.connect(src2, (op, 1))
        self.tb.connect(op, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_divide_xx)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 12
0
        self.tb.connect(src, conv, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)

    def test_005(self):
        """test_005: set_repeat"""

        src_data = [int(x) for x in range(16)]
        src_data_int = [int(x) for x in range(16)]
        expected_result = tuple(src_data_int)

        src = blocks.vector_source_i(src_data, True)
        dst = flaress.vector_sink_int64()
        src.set_repeat(False)
        conv = flaress.int_to_int64()

        self.tb.connect(src, conv, dst)
        # will timeout if set_repeat does not work
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_int_to_int64)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 13
0
        conv = flaress.float_to_int64()

        self.tb.connect(src, conv, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)

    def test_005(self):
        """test_005: set_repeat"""

        src_data = [float(x) for x in range(16)]
        expected_result = tuple(src_data)

        src = blocks.vector_source_f(src_data, True)
        dst = flaress.vector_sink_int64()
        src.set_repeat(False)
        conv = flaress.float_to_int64()

        self.tb.connect(src, conv, dst)
        # will timeout if set_repeat does not work
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_float_to_double)
    runner = runner.HTMLTestRunner(output='../TestResults',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 14
0
        adder = blocks.add_vcc(1)

        tb.connect(src, (adder, 1))
        tb.connect(noise, (adder, 0))
        tb.connect(src, bpf_signal)
        tb.connect(bpf_signal, dst_src)
        tb.connect(noise, bpf_noise)
        tb.connect(bpf_noise, dst_noise)
        tb.connect(adder, head1)
        tb.connect(head1, snr)
        tb.connect(snr, dst_out)

        tb.run()

        data_src = dst_src.data()
        data_noise = dst_noise.data()
        # data_input = dst_input.data()
        data_out = dst_out.data()

        print("SNR evaluated variance:",
              10 * math.log10(np.var(data_src) / np.var(data_noise)))
        print("SNR estimated:", np.mean(data_out))


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_snr_estimator)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_2')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 15
0
        print_parameters(param)

        time_error_measure = 0.05
        error = 0.05

        data_sine = test_sine(self, param)
        data_transient = transient_evaluation(self, data_sine, param, error,
                                              time_error_measure)

        self.assertLessEqual(data_transient.settling_time, 100)
        self.assertGreaterEqual(data_transient.settling_time, 10)
        self.assertEqual(data_transient.stable_start, True)
        self.assertLessEqual(data_transient.error_percentage_mean_start,
                             (error + param.noise) * 100)
        self.assertLessEqual(data_transient.error_percentage_mean_end,
                             (error + param.noise) * 100)
        print("-Settling time: %.3f ms" % data_transient.settling_time)
        print("-Output error after swing: %.3f%%" %
              data_transient.error_percentage_mean_start)
        print("-Output error before swing: %.3f%%" %
              data_transient.error_percentage_mean_end)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_agc)
    runner = runner.HTMLTestRunner(output='../TestResults',
                                   template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 16
0
        print(
            "-Set function received at the moment (of the simulation): %.2f s;"
            % (switch[0] * (1.0 / param.samp_rate)))

        #check the value after reset
        self.assertEqual(data_gain.src[switch[0]], data_gain.out[switch[0]])

        #check slope
        src_min_step, src_slope = check_integer_phase(data_gain.src, param.N,
                                                      10)
        gain_min_step, gain_slope = check_integer_phase(
            data_gain.out, param.N, 10)
        tar = (param.downlink * 1.0 / param.uplink)  #turn around ratio

        self.assertAlmostEqual((tar * src_slope), gain_slope, 2)
        self.assertAlmostEqual((tar * src_min_step), gain_min_step, 2)
        print("-Input Slope : %f rad/s;" % (src_slope * param.samp_rate))
        print("-Input Min step : %f rad;" % src_min_step)
        print("-Turn Around Ration : %f;" % tar)
        print("-Output Slope : %f rad/s;" % (gain_slope * param.samp_rate))
        print("-Output Min step : %f rad." % gain_min_step)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(
        qa_gain_phase_accumulator)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 17
0
        param.t1, param.t2, param.samp_rate)
        
        print("Coefficents: ")
        print((loop_filter_3rd_order))
        reference = (4.542760205688479, 0.013480000495910645, 1.0000000447034852e-05)
        self.assertEqual(loop_filter_3rd_order, reference)

    def test_003_t (self):
        """test_003_t: test 3rd order coefficient generation with unstable time constants"""
        param = namedtuple('param', 'order samp_rate natural_freq t1 t2')

        param.order = "3rd"
        param.samp_rate = 200000
        param.natural_freq = 10
        param.t1 = 0.01
        param.t2 = 0.00674

        to_print = "/pr!Order: %s<br> Sample Rate: %d<br> Natural Frequency: %.0f Hz<br> Time constant 1: %.3f s<br> Time constant 2: %.3f s<br>/pr!" \
            %(param.order, param.samp_rate, param.natural_freq, param.t1, param.t2)
        print (to_print)
        
        self.assertRaises(RuntimeError, ecss.loop_filter.coefficients3rdorder, param.natural_freq,
        param.t1, param.t2, param.samp_rate)
        print("RuntimeError raised")
                
if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_loop_filter)
    runner = runner.HTMLTestRunner(output='../TestResults', template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
        src.set_data(src_data)

        self.tb.connect(src, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)

    def test_007(self):
        """test_007: set_repeat"""

        src_data = [int(x) for x in range(16)]
        expected_result = tuple(src_data)

        src = flaress.vector_source_int64(src_data, True)
        dst = flaress.vector_sink_int64()
        src.set_repeat(False)

        self.tb.connect(src, dst)
        # will timeout if set_repeat does not work
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(expected_result, result_data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(
        qa_vector_sink_source_int64)
    runner = runner.HTMLTestRunner(output='../TestResults',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 19
0
        blocks_file_source_0 = blocks.file_source(
            gr.sizeof_float * 1,
            os.path.join(srcdir, "test_files",
                         "phase_error_PLL_datasw150kHz_swr32kHz-s_tc4kbps_mi"),
            False)
        blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        dst_output = blocks.vector_sink_f()

        ##################################################
        # Connections
        ##################################################
        tb.connect((blocks_file_source_0, 0), (blocks_throttle_0, 0))
        tb.connect((blocks_throttle_0, 0), (dst_output, 0))

        self.tb.run()

        data.phase_output = dst_output.data()
        data.time = np.linspace(0, (len(data.phase_output) * 1.0 / samp_rate),
                                len(data.phase_output),
                                endpoint=False)

        plot(self, data)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_demodulator)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 20
0
        head = blocks.head(flaress.sizeof_long, 100)
        dst = flaress.null_sink(flaress.sizeof_long)

        self.tb.connect(src, head, dst)
        self.tb.run()

    def test_006(self):
        """test_006: with Float64 (Double)"""
        src = flaress.null_source(gr.sizeof_double)
        head = blocks.head(gr.sizeof_double, 100)
        dst = flaress.null_sink(gr.sizeof_double)

        self.tb.connect(src, head, dst)
        self.tb.run()

    def test_007(self):
        """test_007: with Complex"""
        src = flaress.null_source(gr.sizeof_gr_complex)
        head = blocks.head(gr.sizeof_gr_complex, 100)
        dst = flaress.null_sink(gr.sizeof_gr_complex)

        self.tb.connect(src, head, dst)
        self.tb.run()


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_null_source_sink)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 21
0
        step_phase = 3.0
        frequency = step_phase * samp_rate / (2 * math.pi)

        # Blocks
        sine_debug_0 = sine_debug()
        dst_out = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_gr_complex, items)
        sig_source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                         frequency, 1, 0)

        # Connections
        tb.connect(sig_source, head)
        tb.connect(head, sine_debug_0)
        tb.connect(sine_debug_0, dst_out)

        self.tb.run()

        result_data = dst_out.data()

        self.assertAlmostEqual(np.mean(result_data), step_phase, 4)
        self.assertAlmostEqual(np.var(result_data), 0, 3)
        print(np.mean(result_data), np.var(result_data))


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_sine_debug)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    gr_unittest.TestProgram()
Exemplo n.º 22
0
        tb.connect((blocks_complex_to_arg_0, 0), (dst_output, 0))

        self.tb.run()

        data_tar.phase_source = dst_source.data()
        data_tar.phase_output = dst_output.data()
        data_tar.tar = dst_tar.data()
        data_tar.time = np.linspace(
            0, (len(data_tar.phase_output) * 1.0 / samp_rate),
            len(data_tar.phase_output),
            endpoint=False)

        print(len(data_tar.phase_output), len(data_tar.phase_source))

        # for i in range(len(data_tar.phase_output)):
        #     if data_tar.phase_output[i] != 0:
        #         print i
        #         break

        plot(self, data_tar)
        # self.assertAlmostEqual(np.mean(data_tar.tar[127000:]), (240.0/221.0),6)
        # self.assertAlmostEqual(np.var(data_tar.tar[127000:]), 0.0)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_validation_test)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 23
0
        self.assertFloatTuplesAlmostEqual(data_out, expected_data)
        print ("- Data correctly encoded.")

    def test_006_t (self):
        """test_006_t: square wave with data"""
        param = namedtuple('param', 'data_src bit_rate samp_rate sine freq_sub')

        
        param.bit_rate = 1024
        param.samp_rate = 4096 * 32
        param.sine = False
        param.freq_sub = 256
        param.data_src = (0,0,1,0,0,0,1,0,1,0,1,1,1,1,1,0,0,0,0,1,0,1)
        expected_data = (-1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1)

        print_parameters(param)

        data_out = test_nrlz(self, param)

        plot(self, data_out, param.data_src)

        self.assertFloatTuplesAlmostEqual(data_out, expected_data)
        print ("- Data correctly encoded.")


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_nrzl_encoder_subcarrier)
    runner = runner.HTMLTestRunner(output='Results', template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    # gr_unittest.TestProgram()
Exemplo n.º 24
0
            'samp_rate items frequency amplitude offset magnitude phase origin'
        )
        param.samp_rate = 2048
        param.items = param.samp_rate
        param.frequency = 50.0
        param.amplitude = 1.0
        param.offset = 0.0
        param.magnitude = 10.0
        param.phase = -10.0
        param.origin = "TX"

        print_parameters(param)

        data = test_imbalance(self, param)

        all_images = plot(self, data)

        print_all_images(all_images)

        # i,j = np.unravel_index(data.corr.argmax(), data.corr.shape) #get the index of the maximum value of correlation
        # # self.assertAlmostEqual(param.step / (2 * math.pi), data_fft.carrier)
        # print "Time shifting= %.3f ms;" %(data.time_corr[i]*1000)


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_iqbal_gen)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_3')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 25
0
    def setUp(self):
        self.tb = gr.top_block()
        self.pdf = Pdf_class(self.id().split(".")[1])

    def tearDown(self):
        self.tb = None
        self.pdf.finalize_pdf()

    def test_001_t(self):
        """test_001_t: without repetition"""

        data_src = (-1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1,
                    -1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1,
                    -1, 1, -1, 1, 1, -1, -1, 1, 1, -1)
        expected_data = (0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
                         0, 1, 0, 1)

        data_out = test_spl(self, data_src)

        plot(self, data_out, data_src)

        self.assertAlmostEqual(data_out, expected_data)
        print "- Data correctly encoded."


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_spl_decoder)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_1')
    runner.run(suite)
    #gr_unittest.TestProgram()
Exemplo n.º 26
0
        sig_source1 = blocks.vector_source_c(src_data,
                                             repeat=False,
                                             tags=src_tags1)

        # Connections
        tb.connect(sig_source0, (flaress_selector, 0))
        tb.connect(sig_source1, (flaress_selector, 1))
        tb.connect(flaress_selector, dst_out)

        self.tb.run()

        result_data = dst_out.data()
        result_tags = dst_out.tags()

        self.assertFloatTuplesAlmostEqual(expected_result, result_data)
        self.assertEqual(len(result_tags), 4)
        self.assertTrue(compare_tags(expected_tags[0], result_tags[0]))
        self.assertTrue(compare_tags(expected_tags[1], result_tags[1]))
        self.assertTrue(compare_tags(expected_tags[2], result_tags[2]))
        self.assertTrue(compare_tags(expected_tags[3], result_tags[3]))

        print("- Tag received properly")


if __name__ == '__main__':
    suite = gr_unittest.TestLoader().loadTestsFromTestCase(qa_selector)
    runner = runner.HTMLTestRunner(output='Results',
                                   template='DEFAULT_TEMPLATE_2')
    runner.run(suite)
    #gr_unittest.TestProgram()