def main(options): """ Main function. @param options """ options.my_ip = all_radios_ip[options.my_id] radio = build_radio(options) radio.id = options.my_id radio.set_gain(radios_gain[radio.id]) tb = OpERAFlow('OperaFlow') tb.add_radio(radio, 'radio') tb.start() channel_list = [Channel(ch=0, freq=1.11e9, bw=200e3), Channel(ch=1, freq=1.51e9, bw=400e3), Channel(ch=2, freq=1.7e9, bw=500e3), Channel(ch=3, freq=1.9e9, bw=400e3), ] cognitive_radio_loop(options, radio, channel_list) tb.stop() tb.wait()
def main(options): """ Main function @param options """ options.my_ip = all_radios_ip[options.my_id] radio = build_radio(options) radio.id = options.my_id tb = OpERAFlow('OperaFlow') tb.add_radio(radio, 'radio') tb.start() channel_list = [Channel(ch=0, freq=2.2e9, bw=200e3), ] cognitive_radio_loop(options, radio, channel_list) tb.stop() tb.wait()
class QaEnergyDetector(gr_unittest.TestCase): """ QA related to EnergyDetector class. """ def setUp(self): """ Set globals for all tests. Called before a test is started. """ self.tb = OpERAFlow(name='top') def tear_down(self): """ Destroy globals for all tests. Called right after a test if finished. """ self.tb = None def test_001(self): """ Test the energy of a simple sequence (1, 2, -1, -2). """ # input and expected results src_data = (1, 1, 1, 1) expected_result = 1 # blocks fft_size = len(src_data) mavg_size = 1 src = blocks.vector_source_c(data=src_data) dst = blocks.probe_signal_f() ed = EnergySSArch(fft_size, mavg_size, EnergyDecision(1)) #radio_device = RadioDevice(the_source = src, the_sink = dst) radio_device = RadioDevice() radio_device.add_arch(source=src, arch=ed, sink=dst, uhd_device=None, name='ed') ################ FIM NOVO RADIO DEVICE ## flowgraph ##self.tb.add_arch(ed, radio_device, 'ed') self.tb.add_radio(radio_device) self.tb.run() result_data = dst.level() self.assertEqual(expected_result, result_data) def test_002(self): """ Test a sequence with float number (0.1, 0.1, 0.1, 0.1). """ # input and expected results src_data = (0.1, 0.1, 0.1, 0.1) expected_result = 0 # blocks fft_size = len(src_data) mavg_size = 1 src = blocks.vector_source_c(data=src_data) ed = EnergyDetectorC(fft_size, mavg_size, EnergyDecision(1)) dst = blocks.probe_signal_f() # flowgraph self.tb.connect(src, ed, dst) self.tb.run() result_data = dst.level() self.assertEqual(expected_result, result_data) def test_003(self): """ Test EDTopBlock with the input (1, 1, 1, 1, 1, 1, 1, 1). """ arr = (1, 1, 1, 1, 1, 1, 1, 1) expected_out = 8 ed = EnergySSArch(fft_size=len(arr), mavg_size=8, algorithm=EnergyDecision(expected_out - 1) ) src = blocks.vector_source_c(data=arr, vlen=1) sink = blocks.probe_signal_f() device = RadioDevice() device.add_arch(source=src, arch=ed, sink=sink, uhd_device=None, name='ed') self.tb.add_radio(device, 'ed') self.tb.run() ##self.assertEqual(1 , device.sink.level()) # didn't work self.assertEqual(1, device.output()[0]) def test_004(self): """ Test EDTopBlock with a simple input (1, 2, 3, 4). """ arr = (1.0, 2.0, 3.0, 4.0) expected_result = 30 # before expected result was 2536 ed = EnergySSArch(fft_size=len(arr), mavg_size=1, algorithm=EnergyDecision(expected_result + 1) # (expected_out + 1) ) src = blocks.vector_source_c(data=arr, vlen=1) sink = blocks.probe_signal_f() device = RadioDevice() device.add_arch(source=src, arch=ed, sink=sink, uhd_device=None, name='ed') self.tb.add_radio(device, 'ed') self.tb.start() self.tb.wait() ###self.assertEqual(expected_result , device.sink.output()[1]) self.assertEqual(expected_result, device.ed.output()[1]) # uses 'name' parameter of the add_arch method