Exemplo n.º 1
0
 def testBasicBehavior(self):
     #######################################################################
     # Make sure start and stop can be called without throwing exceptions
     self.comp.start()
     alloc = frontend.createTunerAllocation(tuner_type='RX_DIGITIZER',allocation_id='master',center_frequency=100)
     listen_alloc = frontend.createTunerListenerAllocation('master','slave')
     another_listen_alloc = frontend.createTunerListenerAllocation('master','another_slave')
     self.comp.allocateCapacity(alloc)
     self.comp.allocateCapacity(listen_alloc)
     self.comp.allocateCapacity(another_listen_alloc)
     master=sb.DataSink()
     slave=sb.DataSink()
     another_slave=sb.DataSink()
     self.comp.connect(master,connectionId='master')
     self.comp.connect(slave,connectionId='slave')
     self.comp.connect(another_slave,connectionId='another_slave')
     time.sleep(3)
     self.assertEquals(master.eos(),False)
     self.assertEquals(slave.eos(),False)
     self.assertEquals(another_slave.eos(),False)
     self.comp.deallocateCapacity(listen_alloc)
     self.assertEquals(master.eos(),False)
     self.assertEquals(slave.eos(),True)
     self.assertEquals(another_slave.eos(),False)
     self.comp.deallocateCapacity(alloc)
     self.assertEquals(master.eos(),True)
     self.assertEquals(slave.eos(),True)
     self.assertEquals(another_slave.eos(),True)
     sb.release()
     self.fp.close()
     self.fp = open(self.filename,'r')
     stuff = self.fp.read()
     self.fp.close()
     self.assertEquals(stuff.find('the application attempted to invoke an operation on a nil reference'), -1)
 def testBasicBehavior(self):
     #######################################################################
     # Make sure start and stop can be called without throwing exceptions
     self.comp.start()
     alloc = frontend.createTunerAllocation(tuner_type='RX_DIGITIZER',allocation_id='master',center_frequency=100)
     listen_alloc = frontend.createTunerListenerAllocation('master','slave')
     another_listen_alloc = frontend.createTunerListenerAllocation('master','another_slave')
     self.comp.allocateCapacity(alloc)
     self.comp.allocateCapacity(listen_alloc)
     self.comp.allocateCapacity(another_listen_alloc)
     master=sb.DataSink()
     slave=sb.DataSink()
     another_slave=sb.DataSink()
     self.comp.connect(master,connectionId='master')
     self.comp.connect(slave,connectionId='slave')
     self.comp.connect(another_slave,connectionId='another_slave')
     time.sleep(3)
     self.assertEquals(master.eos(),False)
     self.assertEquals(slave.eos(),False)
     self.assertEquals(another_slave.eos(),False)
     self.comp.deallocateCapacity(listen_alloc)
     self.assertEquals(master.eos(),False)
     self.assertEquals(slave.eos(),True)
     self.assertEquals(another_slave.eos(),False)
     self.comp.deallocateCapacity(alloc)
     self.assertEquals(master.eos(),True)
     self.assertEquals(slave.eos(),True)
     self.assertEquals(another_slave.eos(),True)
Exemplo n.º 3
0
    def testBasicBehavior(self):
        #######################################################################
        # Make sure start and stop can be called without throwing exceptions
        sb.start()
        alloc = frontend.createTunerAllocation(tuner_type='RX_DIGITIZER',allocation_id='master',center_frequency=100)
        listen_alloc = frontend.createTunerListenerAllocation('master','slave')
        another_listen_alloc = frontend.createTunerListenerAllocation('master','another_slave')
        self.comp.allocateCapacity(alloc)
        self.comp.allocateCapacity(listen_alloc)
        self.comp.allocateCapacity(another_listen_alloc)

        master = sb.StreamSink()
        slave = sb.StreamSink()
        another_slave = sb.StreamSink()
        self.comp.connect(master,connectionId='master')
        self.comp.connect(slave,connectionId='slave')
        self.comp.connect(another_slave,connectionId='another_slave')

        def get_eos(streamSink, **kwargs):
            streamData = streamSink.read(**kwargs)
            if streamData:
                return streamData.eos
            return False

        time.sleep(1)
        self.assertEquals(get_eos(master), False)
        self.assertEquals(get_eos(slave), False)
        self.assertEquals(get_eos(another_slave), False)

        self.comp.deallocateCapacity(listen_alloc)
        self.assertEquals(get_eos(master), False)
        # Save result so we dont call read() twice after eos.
        eos_slave = get_eos(slave, timeout=1, eos=True)
        self.assertEquals(eos_slave, True)
        self.assertEquals(get_eos(another_slave), False)

        self.comp.deallocateCapacity(alloc)
        self.assertEquals(get_eos(master, timeout=1, eos=True), True)
        self.assertEquals(eos_slave, True)
        self.assertEquals(get_eos(another_slave, timeout=1, eos=True), True)

        sb.release()
        self.fp.close()
        self.fp = open(self.filename,'r')
        stuff = self.fp.read()
        self.fp.close()
        self.assertEquals(stuff.find('the application attempted to invoke an operation on a nil reference'), -1)
Exemplo n.º 4
0
    def testBasicBehavior(self):
        #######################################################################
        # Make sure start and stop can be called without throwing exceptions
        sb.start()
        alloc = frontend.createTunerAllocation(tuner_type='RX_DIGITIZER',allocation_id='master',center_frequency=100)
        listen_alloc = frontend.createTunerListenerAllocation('master','slave')
        another_listen_alloc = frontend.createTunerListenerAllocation('master','another_slave')
        self.comp.allocateCapacity(alloc)
        self.comp.allocateCapacity(listen_alloc)
        self.comp.allocateCapacity(another_listen_alloc)

        master = sb.StreamSink()
        slave = sb.StreamSink()
        another_slave = sb.StreamSink()
        self.comp.connect(master,connectionId='master')
        self.comp.connect(slave,connectionId='slave')
        self.comp.connect(another_slave,connectionId='another_slave')

        time.sleep(1)
        fake_master_alloc = frontend.createTunerListenerAllocation('master','master')
        self.assertRaises(CF.Device.InvalidCapacity, self.comp.deallocateCapacity, fake_master_alloc)
        self.assertEquals(self.comp.frontend_tuner_status[0].allocation_id_csv[:6],'master')

        def get_eos(streamSink, **kwargs):
            streamData = streamSink.read(**kwargs)
            if streamData:
                return streamData.eos
            return False

        self.assertEquals(get_eos(master), False)
        self.assertEquals(get_eos(slave), False)
        self.assertEquals(get_eos(another_slave), False)

        self.comp.deallocateCapacity(listen_alloc)
        time.sleep(0.5)
        self.assertEquals(get_eos(master), False)
        # Save result so we dont call read() twice after eos.
        eos_slave = get_eos(slave, timeout=1, eos=True)
        self.assertEquals(eos_slave, True)
        self.assertEquals(get_eos(another_slave), False)

        self.comp.deallocateCapacity(alloc)
        self.assertEquals(get_eos(master, timeout=1, eos=True), True)
        self.assertEquals(eos_slave, True)
        self.assertEquals(get_eos(another_slave, timeout=1, eos=True), True)
 def testTypoErrorAllocation(self):
     center_frequency = 110e6
     sample_rate = 2.5e6
     bandwidth = 2e6
     alloc = self._generateAlloc(cf=center_frequency,sr=sample_rate,bw=bandwidth)
     retval = self.comp.allocateCapacity(alloc)
     self.assertEquals(retval, True)
     _type = properties.props_to_dict(alloc)['FRONTEND::tuner_allocation']['FRONTEND::tuner_allocation::tuner_type']
     _alloc_id = properties.props_to_dict(alloc)['FRONTEND::tuner_allocation']['FRONTEND::tuner_allocation::allocation_id']
     listen_alloc = [frontend.createTunerListenerAllocation(_alloc_id, listener_allocation_id='foo',returnDict=False)]
     retval = self.comp.allocateCapacity(listen_alloc)
     self.assertEquals(retval, True)
     self.assertRaises(CF.Device.InvalidCapacity, self.comp.allocateCapacity, listen_alloc)
     self.comp.deallocateCapacity(listen_alloc)
     self.comp.deallocateCapacity(alloc)
Exemplo n.º 6
0
    def testBasicBehavior(self):
        #######################################################################
        # Make sure start and stop can be called without throwing exceptions
        self.comp.start()
        self.comp.stop()
        
        for _port in self.comp.ports:
            if _port.name == 'DigitalTuner_in':
                port = _port
                break
        
        print self.comp.frontend_tuner_status
        self.assertEquals(len(self.comp.frontend_tuner_status),2)
        alloc = frontend.createTunerAllocation(tuner_type='RX_DIGITIZER',allocation_id='hello',center_frequency=100)
        self.assertRaises(redhawk.frontendInterfaces.FRONTEND.FrontendException, port.ref.getTunerEnable, 'hello')
        
        listen_alloc = frontend.createTunerListenerAllocation('hello','hello_listen')
        listen_2_alloc = frontend.createTunerListenerAllocation('hello','hello_2_listen')
        
        retval = self.comp.allocateCapacity(listen_alloc)
        self.assertEquals(retval, False)
        
        retval = self.comp.allocateCapacity(alloc)
        self.assertEquals(retval, True)
        
        retval = self.comp.allocateCapacity(listen_alloc)
        self.assertEquals(retval, True)
        retval = self.comp.allocateCapacity(listen_2_alloc)
        self.assertEquals(retval, True)

        retval = port.ref.getTunerEnable('hello')
        self.assertEquals(retval, True)
        sample_rate = port.ref.getTunerOutputSampleRate('hello')
        self.assertEquals(sample_rate, 1)
        port.ref.setTunerOutputSampleRate('hello',5)
        sample_rate = port.ref.getTunerOutputSampleRate('hello')
        self.assertEquals(sample_rate, 5)
        port.ref.setTunerEnable('hello',False)
        retval = port.ref.getTunerEnable('hello')
        self.assertEquals(retval, False)
        port.ref.setTunerEnable('hello',True)
        retval = port.ref.getTunerEnable('hello')
        self.assertEquals(retval, True)
        _id = port.ref.getTunerRfFlowId('hello')
        self.assertEquals(_id, 'foo')
        
        self.assertEquals(self.comp.frontend_tuner_status[0].enabled, True)
        self.assertEquals(self.comp.frontend_tuner_status[0].center_frequency, 100)
        
        self.assertEquals(len(self.comp.connectionTable), 3)
        
        allocation_id_csv = self.comp.frontend_tuner_status[0].allocation_id_csv
        allocations = allocation_id_csv.split(',')
        self.assertEquals(len(allocations), 3)
        self.assertEquals('hello' in allocations, True)
        self.assertEquals('hello_2_listen' in allocations, True)
        self.assertEquals('hello_listen' in allocations, True)
        
        listen_alloc['FRONTEND::listener_allocation'].pop('FRONTEND::listener_allocation::existing_allocation_id')
        _old_id = [CF.DataType(id='FRONTEND::listener_allocation::listener_allocation_id',value=_any.to_any(listen_alloc['FRONTEND::listener_allocation']['FRONTEND::listener_allocation::listener_allocation_id']))]
        _listen_alloc = [CF.DataType(id='FRONTEND::listener_allocation',value=_any.to_any(_old_id))]
        self.comp.ref.deallocateCapacity(_listen_alloc)
        
        self.assertEquals(self.comp.frontend_tuner_status[0].enabled, True)
        self.assertEquals(self.comp.frontend_tuner_status[0].center_frequency, 100)
        
        allocation_id_csv = self.comp.frontend_tuner_status[0].allocation_id_csv
        allocations = allocation_id_csv.split(',')
        self.assertEquals(len(allocations), 2)
        self.assertEquals('hello' in allocations, True)
        self.assertEquals('hello_2_listen' in allocations, True)
        self.assertEquals('hello_listen' in allocations, False)
        
        self.comp.deallocateCapacity(alloc)
        self.assertEquals(self.comp.frontend_tuner_status[0].enabled, False)
        self.assertEquals(self.comp.frontend_tuner_status[0].center_frequency, 0)

        self.assertEquals(self.comp.frontend_tuner_status[0].enabled, False)
        self.assertEquals(self.comp.frontend_tuner_status[0].center_frequency, 0)
        
        allocation_id_csv = self.comp.frontend_tuner_status[0].allocation_id_csv
        allocations = allocation_id_csv.split(',')
        self.assertEquals(len(allocations), 1)
        self.assertEquals(allocations[0], '')
        self.assertEquals(len(self.comp.connectionTable), 0)

        self.assertRaises(redhawk.frontendInterfaces.FRONTEND.FrontendException, port.ref.getTunerEnable, 'hello')