Piotr Krysik | 2164b9b | 2017-09-13 09:33:27 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | # @file |
| 4 | # @author Piotr Krysik <ptrkrysik@gmail.com> |
| 5 | # @section LICENSE |
| 6 | # |
| 7 | # Gr-gsm is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 3, or (at your option) |
| 10 | # any later version. |
| 11 | # |
| 12 | # Gr-gsm is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with gr-gsm; see the file COPYING. If not, write to |
| 19 | # the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | # Boston, MA 02110-1301, USA. |
| 21 | # |
| 22 | # |
| 23 | |
| 24 | from gnuradio import gr, gr_unittest |
| 25 | from gnuradio import blocks |
| 26 | from txtime_bursts_tagger import txtime_bursts_tagger |
Piotr Krysik | 27f0032 | 2017-09-19 08:05:28 +0200 | [diff] [blame] | 27 | #from transmitter.txtime_bursts_tagger import txtime_bursts_tagger |
| 28 | from pmt import * |
| 29 | |
| 30 | def make_time_hint_msg(time_hint): |
| 31 | return cons( dict_add(make_dict(), intern("time_hint"), from_double(time_hint)),PMT_NIL) |
| 32 | |
| 33 | def make_fn_time_msg(fn_ref, time_ref): |
| 34 | return cons( dict_add(make_dict(), intern("fn_time"), cons(from_uint64(fn_ref), from_double(time_ref))),PMT_NIL) |
Piotr Krysik | 2164b9b | 2017-09-13 09:33:27 +0200 | [diff] [blame] | 35 | |
| 36 | class qa_txtime_bursts_tagger (gr_unittest.TestCase): |
| 37 | |
| 38 | def setUp (self): |
| 39 | self.tb = gr.top_block () |
| 40 | |
| 41 | def tearDown (self): |
| 42 | self.tb = None |
| 43 | |
| 44 | def test_001_t (self): |
Piotr Krysik | 27f0032 | 2017-09-19 08:05:28 +0200 | [diff] [blame] | 45 | tb = self.tb |
| 46 | time_ref = 0 |
| 47 | fn_ref = 0 |
| 48 | dut = txtime_bursts_tagger(fn_ref, time_ref) |
| 49 | |
| 50 | framenumbers_input = [1259192, 1076346, 1076242, 235879, 1259218] |
| 51 | timeslots_input = [6, 3, 4, 3, 5] |
| 52 | bursts_input = [ |
| 53 | "0001100001000111100111101111100101000100101011000010011110011101001111101100010100111111100000110100011111101011101100100111110011000100010001010000", |
| 54 | "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000", |
| 55 | "0001001101101101000111001000101011001101001110110001001100111101001111101100010100111111111001001010011010011111010010010101011001001011011100110000", |
| 56 | "0000010010100000001001101010100001011100010001101100111111101101001111101100010100111111101101001110100010101110010110101111100010010000110010110000", |
| 57 | ] |
| 58 | |
| 59 | src = grgsm.burst_source(framenumbers_input, timeslots_input, bursts_input) |
| 60 | sink = grgsm.burst_sink() |
| 61 | |
| 62 | self.tb.msg_connect(src, "out", dut, "bursts") |
| 63 | self.tb.msg_connect(dut, "bursts", sink, "in") |
| 64 | |
| 65 | tb.start() |
| 66 | tb.wait() |
| 67 | print "Dupa" |
| 68 | print sink |
| 69 | |
| 70 | |
| 71 | # msg1 = make_msg(1,"lol1") |
| 72 | # msg2 = make_msg(1,"lol2") |
| 73 | # msg3 = make_msg(2,"lol1") |
| 74 | # msg4 = make_msg(2,"lol1") |
| 75 | # |
| 76 | # port = intern("msgs") |
| 77 | |
| 78 | # tb.msg_connect(g,"msgs",dbg,"store") |
| 79 | # #tb.msg_connect(g,"msgs",dbg,"print_pdu") |
| 80 | |
| 81 | # tb.start() |
| 82 | |
| 83 | # g.to_basic_block()._post(port, msg1) |
| 84 | # g.to_basic_block()._post(port, msg3) |
| 85 | # g.to_basic_block()._post(port, msg2) |
| 86 | # g.to_basic_block()._post(port, msg4) |
| 87 | |
| 88 | |
| 89 | |
| 90 | # while dbg.num_messages() < 4: |
| 91 | # time.sleep(0.1) |
| 92 | |
| 93 | # tb.stop() |
| 94 | # tb.wait() |
| 95 | # print dbg.get_message(0) |
| 96 | # print get_id(dbg.get_message(0)) |
| 97 | # |
| 98 | # self.assertEqual(get_id(dbg.get_message(0)),1) |
| 99 | # self.assertEqual(get_id(dbg.get_message(1)),1) |
| 100 | # self.assertEqual(get_id(dbg.get_message(2)),2) |
| 101 | # self.assertEqual(get_id(dbg.get_message(3)),2) |
| 102 | |
Piotr Krysik | 2164b9b | 2017-09-13 09:33:27 +0200 | [diff] [blame] | 103 | |
| 104 | |
| 105 | if __name__ == '__main__': |
| 106 | gr_unittest.run(qa_txtime_bursts_tagger, "qa_txtime_bursts_tagger.xml") |