def _do_connect(self):
     ret = False
     if self.isConnected():
         self.disconnect()
     self.pyradio = None
     self.pyradio_cls = None
     if self.radio_type is None or self.radio_type == "":
         self.last_error = "No radio type defined"
     elif self.radio_type not in CyberRadioDriver.getSupportedRadios():
         self.last_error = "Unsupported radio type: %s" % str(self.radio_type)
     else:
         self.pyradio_cls = CyberRadioDriver.getRadioClass(self.radio_type)
         self.pyradio = CyberRadioDriver.getRadioObject(self.radio_type, \
                                                   verbose=self.verbose, \
                                                   logFile=self.log_file)
         if self.connect_mode == "":
             # No connection -- this mode supports class method queries
             # only.
             pass
         elif not self.isConnectionModeSupported(self.connect_mode):
             self.last_error = "Unsupported connection mode: %s" % \
                               self.connect_mode
         elif self.connect_mode == "tty":
             ret = self.connect(self.connect_mode, self.dev_name, \
                                self.baud_rate, False, False, False)
             if not ret:
                 self.last_error = "Could not connect to %s radio at %s" % \
                                   (self.getName(), self.dev_name)
         elif self.connect_mode in ["tcp", "udp"]:
             ret = self.connect(self.connect_mode, self.host_name, \
                                self.host_port, False, False, False)
             if not ret:
                 self.last_error = "Could not connect to %s radio at %s" % \
                                   (self.getName(), self.host_name)
     return ret
Example #2
0
 def update_radio(
     self,
     disable=False,
 ):
     print((" update_radio(disable=%s) " % (disable)).center(80, '~'))
     if not self.init:
         self.ten_gbe_radio = not any(i in self.radio_type
                                      for i in ("304", "470", "472"))
         self.radio = crd.getRadioObject(self.radio_type,
                                         verbose=self.verbose,
                                         logFile=self.fileLikeObjectSource)
         self.radio.connect(self.radio.getConnectionModeList()[0],
                            self.radio_hostname, self.radio_port)
         self._disable_all_ddcs()
Example #3
0
 def initRadioConnection(self,):
     self.log.debug("initRadioConnection")
     self.radioObj = self.radioParam.get("obj",None)
     if self.radioObj is None:
         self.log.debug("Creating radio object")
         self.radioObj = crd.getRadioObject(self.radioParam["type"])
     if not self.radioObj.isConnected():
         self.log.debug("Connecting to radio...")
         if all( self.radioParam.has_key(i) for i in ("host","port") ):
             self.radioObj.connect( "tcp", self.radioParam["host"], self.radioParam["port"] )
         elif all( self.radioParam.has_key(i) for i in ("device","baudrate") ):
             self.radioObj.connect( "tty", self.radioParam["device"], self.radioParam["baudrate"] )
         else:
             raise Exception("%s :: Can't connect to radio"%(self._name))
     if self.radioObj.isConnected():
         self.log.info("Connected to radio!")
Example #4
0
    def __init__(self, dataPort=1, ducIndex=1, ducRateIndex=1, hostname='ndr651', localInterface="eth6", txChannel=1):
        gr.top_block.__init__(self, "NDR651 Single Tx/Rx Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NDR651 Single Tx/Rx Example")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "ndr651_single_trx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.dataPort = dataPort
        self.ducIndex = ducIndex
        self.ducRateIndex = ducRateIndex
        self.hostname = hostname
        self.localInterface = localInterface
        self.txChannel = txChannel

        ##################################################
        # Variables
        ##################################################
        self.confPath = confPath = os.path.expanduser("~/.ndr651_single_trx.cfg")
        self._txFreqCfg_config = ConfigParser.ConfigParser()
        self._txFreqCfg_config.read(confPath)
        try: txFreqCfg = self._txFreqCfg_config.getfloat('tx', 'freq')
        except: txFreqCfg = 1000
        self.txFreqCfg = txFreqCfg
        self._txAttenCfg_config = ConfigParser.ConfigParser()
        self._txAttenCfg_config.read(confPath)
        try: txAttenCfg = self._txAttenCfg_config.getint('tx', 'atten')
        except: txAttenCfg = 0
        self.txAttenCfg = txAttenCfg
        self.radioObj = radioObj = crd.getRadioObject("ndr651", verbose=False)
        self._ducFreqCfg_config = ConfigParser.ConfigParser()
        self._ducFreqCfg_config.read(confPath)
        try: ducFreqCfg = self._ducFreqCfg_config.getfloat('duc', 'fre')
        except: ducFreqCfg = 0
        self.ducFreqCfg = ducFreqCfg
        self._ducAttenCfg_config = ConfigParser.ConfigParser()
        self._ducAttenCfg_config.read(confPath)
        try: ducAttenCfg = self._ducAttenCfg_config.getfloat('duc', 'atten')
        except: ducAttenCfg = 0
        self.ducAttenCfg = ducAttenCfg
        self._cwFreqCfg_config = ConfigParser.ConfigParser()
        self._cwFreqCfg_config.read(confPath)
        try: cwFreqCfg = self._cwFreqCfg_config.getfloat('cw', 'freq')
        except: cwFreqCfg = 1.25
        self.cwFreqCfg = cwFreqCfg
        self._cwAmpCfg_config = ConfigParser.ConfigParser()
        self._cwAmpCfg_config.read(confPath)
        try: cwAmpCfg = self._cwAmpCfg_config.getfloat('cw', 'amp1')
        except: cwAmpCfg = -1.0
        self.cwAmpCfg = cwAmpCfg
        self.txFreq = txFreq = txFreqCfg
        self.txAtten = txAtten = txAttenCfg
        self.radioParam = radioParam = {"type":"ndr651", "host":hostname, "port":8617, "obj":radioObj}
        self.ducRateSet = ducRateSet = radioObj.getWbducRateSet()
        self.ducFreq = ducFreq = ducFreqCfg
        self.ducAtten = ducAtten = ducAttenCfg
        self.cwFreq = cwFreq = cwFreqCfg
        self.cwAmp = cwAmp = cwAmpCfg

        ##################################################
        # Blocks
        ##################################################
        self._txFreq_range = Range(2, 6000, 40, txFreqCfg, 200)
        self._txFreq_win = RangeWidget(self._txFreq_range, self.set_txFreq, 'TX Freq (MHz)', "counter_slider", float)
        self.top_layout.addWidget(self._txFreq_win)
        self._txAtten_range = Range(0, 15, 1, txAttenCfg, 16)
        self._txAtten_win = RangeWidget(self._txAtten_range, self.set_txAtten, 'TX Atten', "counter_slider", int)
        self.top_layout.addWidget(self._txAtten_win)
        self._ducFreq_range = Range(-25.5, +25.5, 0.5, ducFreqCfg, 4001)
        self._ducFreq_win = RangeWidget(self._ducFreq_range, self.set_ducFreq, 'DUC Freq (MHz)', "counter_slider", float)
        self.top_layout.addWidget(self._ducFreq_win)
        self._ducAtten_range = Range(-20, 60, 1.0, ducAttenCfg, int(60/0.25)+1)
        self._ducAtten_win = RangeWidget(self._ducAtten_range, self.set_ducAtten, 'DUC Attenuation', "counter_slider", float)
        self.top_layout.addWidget(self._ducAtten_win)
        self._cwFreq_range = Range(-40.0, +40.0, 1.25, cwFreqCfg, int((80.0/2.5)+1))
        self._cwFreq_win = RangeWidget(self._cwFreq_range, self.set_cwFreq, 'GR CW Freq (% BW)', "counter_slider", float)
        self.top_layout.addWidget(self._cwFreq_win)
        self._cwAmp_range = Range(-90, +10, 1, cwAmpCfg, 101)
        self._cwAmp_win = RangeWidget(self._cwAmp_range, self.set_cwAmp, 'GR CW Amp (dB)', "counter_slider", float)
        self.top_layout.addWidget(self._cwAmp_win)
        self.new_651_sink = CyberRadio.ndr651_sink(hostname, 1024, True)
        self.new_651_sink.setDUCParameters(ducIndex, ducRateIndex, txChannel)
        self.new_651_sink.setDUCFreq(ducFreq*1e6)
        self.new_651_sink.setDUCAtten(ducAtten)
        self.new_651_sink.setEthernetInterface(dataPort, localInterface, ducIndex+65000)
        self.new_651_sink.setTxFreq(txFreq)
        self.new_651_sink.setTxAtten(txAtten)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(float(cwFreq)*numpy.pi/50)
        self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 10.0**(float(cwAmp)/20))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.new_651_sink, 0))
Example #5
0
    def constructor(self):
        """
        This is called by the framework immediately after your device registers with the system.
        
        In general, you should add customization here and not in the __init__ constructor.  If you have 
        a custom port implementation you can override the specific implementation here with a statement
        similar to the following:
          self.some_port = MyPortImplementation()

        For a tuner device, the structure frontend_tuner_status needs to match the number
        of tuners that this device controls and what kind of device it is.
        The options for devices are: TX, RX, RX_DIGITIZER, CHANNELIZER, DDC, RC_DIGITIZER_CHANNELIZER
     
        For example, if this device has 5 physical
        tuners, each an RX_DIGITIZER, then the code in the construct function should look like this:

        self.setNumChannels(5, "RX_DIGITIZER");
     
        The incoming request for tuning contains a string describing the requested tuner
        type. The string for the request must match the string in the tuner status.
        """
        # TODO add customization here.
        # Redefine the control port
        self.port_DigitalTuner_in = frontend.InDigitalTunerPort("DigitalTuner_in",self)
        
        # get the model number for this device and make sure CRD supports it
        radioClass = crd.getRadioClass(self.model)
        if radioClass is None: 
            raise Exception("Unknown radio model %t. Available radio types: %s"%(self.model,crd.getSupportedRadios()))
        
        # connect to the radio
        self.radio = crd.getRadioObject(self.model)
        self.radio.connect("tcp", self.host_or_dev, self.port_or_baud)
        
        if self.radio.isConnected():
            print self.radio.getVersionInfo()
        else:
            raise Exception("Unable to connect to host : %s:%s"%(self.host_or_dev, self.port_or_baud))
            
        # query the number of DDC, DUC, RX, and TX, along with rates and bandwidths
        self.numRx = self.radio.getNumTuner()
        self.numWbddc = self.radio.getNumWbddc()
        self.ratesWbddc = self.radio.getWbddcRateList()
        self.numNbddc = self.radio.getNumNbddc()
        self.ratesNbddc = self.radio.getNbddcRateList()
        
        self.numTx = self.radio.getNumTransmitters()
        self.numDuc = self.radio.getNumWbduc()    
        self.ratesDuc = self.radio.getWbducRateList()
        
        self.numDdc = self.numWbddc + self.numNbddc
        self.numChannels = self.numWbddc + self.numNbddc + self.numDuc
        
        self.bwfactor = 0.8
        
        # get the frequency range and step
        self.freqRange = self.radio.getTunerFrequencyRange()
        self.freqRes = self.radio.getTunerFrequencyRes()

        self.txfreqRange = self.radio.getTransmitterFrequencyRange()
        self.txfreqRes = self.radio.getTransmitterFrequencyRes()
        
        # set the number of channels         
        self.setNumChannels(self.numChannels,"RX_DIGITIZER")
                
        # set the TX channels
        for i in range(self.numChannels-self.numDuc, self.numChannels):
            self.frontend_tuner_status[i].tuner_type="TX"
        
        # init the frequency
        for i in range(0, self.numChannels):
            self.frontend_tuner_status[i].center_frequency=1000e6        
        
        # set the reference mode
        self.radio.setReferenceMode(self.reference)
        
        # set the cal signal
        self.addPropertyChangeListener('calf', self.setCALF)
        self.radio.setCalibrationFrequency(self.calf)
        
        # command handler
        self.addPropertyChangeListener('cmd', self.setCMD)
        
        # attenuation
        ## TODO: add attenuation control      
        
        # create lists to hold the vita49 objects
        self.SV49=[]
        self.Tx_SV49=[]
        self.Tx_SV49_ports=[]
        self.sris=[]
        
        # get a copy of the full unit configuration
        self.confdict=self.radio.getConfiguration()
        
        # set tuner allocation
        print self.frontend_tuner_allocation
        self.frontend_tuner_allocation.center_frequency=1000e6
        
        # set of SIP/DIP tables
        self.num10gbe = self.radio.getNumGigE()
        self.numDIPEntries = self.radio.getNumGigEDipEntries()
        
        for i in range(0,self.num10gbe):
            # set the source IP as .1 address corresponding to eth address
            if i == 0:                
                ethconf=crd.getInterfaceAddresses(self.tenGbe1)
            else:
                ethconf=crd.getInterfaceAddresses(self.tenGbe2)
            
            # set source IP address to x.x.x.1
            ipparts = ethconf[1].split('.')
            self.confdict[cfgKeys.CONFIG_IP][i+1][cfgKeys.IP_SOURCE]=ipparts[0]+'.'+ipparts[1]+'.'+ipparts[2]+'.1'
            
            # set the destination IP table
            for j in range(0,self.numDIPEntries):
                # set the destinations in sequence
                self.confdict[cfgKeys.CONFIG_IP][i+1][cfgKeys.IP_DEST][j][cfgKeys.GIGE_DEST_PORT]=41000+i*500+j
                self.confdict[cfgKeys.CONFIG_IP][i+1][cfgKeys.IP_DEST][j][cfgKeys.GIGE_SOURCE_PORT]=31000+i*500+j
                self.confdict[cfgKeys.CONFIG_IP][i+1][cfgKeys.IP_DEST][j][cfgKeys.GIGE_MAC_ADDR]=ethconf[0]
                self.confdict[cfgKeys.CONFIG_IP][i+1][cfgKeys.IP_DEST][j][cfgKeys.GIGE_IP_ADDR]=ethconf[1]
        
        # write back the ip configuration
        self.radio.setConfiguration(self.confdict)
Example #6
0
    def __init__(
        self,
        radioType="ndr804",
        hostname="ndr308",
        verbose=True,
        interface="eth6",
        dataPort=1,
        tunerFreq=1000,
        tunerAtten=0,
        tunerFilter=1,
        tunerIndex=1,
        calFrequency=0,
        wbddcEnable=True,
        wbddcVitaLevel=3,
        wbddcRate=0,
        wbddcFormat=1,
        wbddcFreq=0.0,
        wbddcPort=10100,
        wbddcIndex=1,
        specRate=1,
        nbddcEnable=True,
        nbddcVitaLevel=3,
        nbddcRate=0.0,
        #~ nbddcFormat=0,
        nbddcDemodType=0,
        nbddcDemodBfo=0,
        nbddcDemodDcBlock=0,
        nbddcDemodAlcType=0,
        nbddcDemodAlcLevel=0,
        nbddcDemodSquelchLevel=0,
        nbddcDagcType=0,
        nbddcDagcLevel=0,
        nbddcFreq=0.0,
        nbddcPort=10101,
        nbddcIndex=46,
        otherNbddcEnable=False,
        otherNbddcPort=10102,
    ):
        gr.hier_block2.__init__(
            self,
            "CyberRadio/NDR_demo_control",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_char * 1),
        )
        self.fileLikeObjectSource = CyberRadio.file_like_object_source()
        self.connect((self.fileLikeObjectSource, 0), (self, 0))

        print("radioType = %r (%s)" % (radioType, type(radioType)))
        print("hostname = %r (%s)" % (hostname, type(hostname)))
        print("verbose = %r (%s)" % (verbose, type(verbose)))
        print("interface = %r (%s)" % (interface, type(interface)))
        print("dataPort = %r (%s)" % (dataPort, type(dataPort)))
        print("tunerFreq = %r (%s)" % (tunerFreq, type(tunerFreq)))
        print("tunerAtten = %r (%s)" % (tunerAtten, type(tunerAtten)))
        print("tunerIndex = %r (%s)" % (tunerIndex, type(tunerIndex)))
        print("calFrequency = %r (%s)" % (calFrequency, type(calFrequency)))
        print("wbddcEnable = %r (%s)" % (wbddcEnable, type(wbddcEnable)))
        print("wbddcVitaLevel = %r (%s)" %
              (wbddcVitaLevel, type(wbddcVitaLevel)))
        print("wbddcRate = %r (%s)" % (wbddcRate, type(wbddcRate)))
        print("wbddcFormat = %r (%s)" % (wbddcFormat, type(wbddcFormat)))
        print("wbddcFreq = %r (%s)" % (wbddcFreq, type(wbddcFreq)))
        print("wbddcPort = %r (%s)" % (wbddcPort, type(wbddcPort)))
        print("wbddcIndex = %r (%s)" % (wbddcIndex, type(wbddcIndex)))
        print("specRate = %r (%s)" % (specRate, type(specRate)))
        print("nbddcEnable = %r (%s)" % (nbddcEnable, type(nbddcEnable)))
        print("nbddcVitaLevel = %r (%s)" %
              (nbddcVitaLevel, type(nbddcVitaLevel)))
        print("nbddcRate = %r (%s)" % (nbddcRate, type(nbddcRate)))
        print("nbddcFreq = %r (%s)" % (nbddcFreq, type(nbddcFreq)))
        print("nbddcPort = %r (%s)" % (nbddcPort, type(nbddcPort)))
        print("nbddcIndex = %r (%s)" % (nbddcIndex, type(nbddcIndex)))
        print("otherNbddcEnable = %r (%s)" %
              (otherNbddcEnable, type(otherNbddcEnable)))
        print("otherNbddcPort = %r (%s)" %
              (otherNbddcPort, type(otherNbddcPort)))

        self.init = True
        self.set_radioType(radioType)
        self.set_hostname(hostname)
        self.set_verbose(verbose)
        #~ self.set_interface( interface )
        #~ self.set_dataPort( dataPort )
        self.set_tunerFreq(tunerFreq)
        self.set_tunerAtten(tunerAtten)
        self.set_tunerFilter(tunerFilter)
        self.set_tunerIndex(tunerIndex)
        self.set_calFrequency(calFrequency)
        self.set_wbddcEnable(wbddcEnable)
        self.set_wbddcVitaLevel(wbddcVitaLevel)
        self.set_wbddcRate(wbddcRate)
        self.set_wbddcFormat(wbddcFormat)
        self.set_wbddcFreq(wbddcFreq)
        self.set_wbddcPort(wbddcPort)
        self.set_wbddcIndex(wbddcIndex)
        self.set_specRate(specRate)
        self.set_nbddcEnable(nbddcEnable)
        self.set_nbddcVitaLevel(nbddcVitaLevel)
        self.set_nbddcRate(nbddcRate)
        #~ self.set_nbddcFormat( nbddcFormat )
        self.set_nbddcDemodType(nbddcDemodType)
        self.set_nbddcDemodBfo(nbddcDemodBfo)
        self.set_nbddcDemodDcBlock(nbddcDemodDcBlock)
        self.set_nbddcDemodAlcType(nbddcDemodAlcType)
        self.set_nbddcDemodAlcLevel(nbddcDemodAlcLevel)
        self.set_nbddcDemodSquelchLevel(nbddcDemodSquelchLevel)
        self.set_nbddcDagcType(nbddcDagcType)
        self.set_nbddcDagcLevel(nbddcDagcLevel)
        self.set_nbddcFreq(nbddcFreq)
        self.set_nbddcPort(nbddcPort)
        self.set_nbddcIndex(nbddcIndex)
        self.set_otherNbddcEnable(otherNbddcEnable)
        self.set_otherNbddcPort(otherNbddcPort)

        self.init = False
        self.radio = crd.getRadioObject(
            self.radioType,
            verbose=self.verbose,
            logFile=self.fileLikeObjectSource,
        )
        self.radio.connect("tcp", self.hostname, 8617)
        self.set_dataPort(interface, dataPort)
        for dipIndex, udpPort in (
            (self.wbddcDipIndex, self.wbddcPort),
            (self.nbddcDipIndex, self.nbddcPort),
            (self.otherNbddcDipIndex, self.otherNbddcPort),
            (self.spectralDipIndex, self.wbddcPort + 4),
            (self.demodDipIndex, self.wbddcPort + 5),
        ):
            self.setDipEntry(dipIndex, udpPort)
        self.disableWbddc(True)
        self.disableNbddc(True)
        self.updateWbddc()
        self.updateNbddc()
        self.updateTuner()
        self.updateCal()
Example #7
0
    def __init__(self, radioHostname='192.168.0.20', radioType='ndr364'):
        gr.top_block.__init__(self, "Freq Msg Strobe Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Freq Msg Strobe Test")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "frq_strobe_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.radioHostname = radioHostname
        self.radioType = radioType

        ##################################################
        # Variables
        ##################################################
        self.radioObj = radioObj = crd.getRadioObject(radioType, verbose=bool(False), host=radioHostname)
        self.wbddcRateSet = wbddcRateSet = dict( [(k,v) for k,v in radioObj.getWbddcRateSet().iteritems() if radioObj.getDdcDataFormat(True).get(k,"iq")!="real"] )
        self.configFilePath = configFilePath = os.path.expanduser( os.path.join("~",".%s_demo.cfg"%(radioObj.name.lower(),)) )
        self._cfg_wbddcRateIndex_config = ConfigParser.ConfigParser()
        self._cfg_wbddcRateIndex_config.read(configFilePath)
        try: cfg_wbddcRateIndex = self._cfg_wbddcRateIndex_config.getint('wbddc', 'rate_index')
        except: cfg_wbddcRateIndex = sorted(wbddcRateSet.keys())[0]
        self.cfg_wbddcRateIndex = cfg_wbddcRateIndex
        self._cfg_iirAvgExp_config = ConfigParser.ConfigParser()
        self._cfg_iirAvgExp_config.read(configFilePath)
        try: cfg_iirAvgExp = self._cfg_iirAvgExp_config.getint('gui', 'iirAvgExp')
        except: cfg_iirAvgExp = int(3)
        self.cfg_iirAvgExp = cfg_iirAvgExp
        self.wbddcRateIndex = wbddcRateIndex = cfg_wbddcRateIndex
        self.wbddcBwSet = wbddcBwSet = dict( [(k,v) for k,v in radioObj.getWbddcBwSet().iteritems() if radioObj.getDdcDataFormat(True).get(k,"iq")!="real"] )
        self.iirAvgExp = iirAvgExp = cfg_iirAvgExp
        self._cfg_tunerIndex_config = ConfigParser.ConfigParser()
        self._cfg_tunerIndex_config.read(configFilePath)
        try: cfg_tunerIndex = self._cfg_tunerIndex_config.getint('tuner', 'index')
        except: cfg_tunerIndex = radioObj.getTunerIndexRange()[0]
        self.cfg_tunerIndex = cfg_tunerIndex
        self._cfg_tunerAtten_config = ConfigParser.ConfigParser()
        self._cfg_tunerAtten_config.read(configFilePath)
        try: cfg_tunerAtten = self._cfg_tunerAtten_config.getint('tuner', 'atten')
        except: cfg_tunerAtten = int(radioObj.getTunerAttenuationRange()[0])
        self.cfg_tunerAtten = cfg_tunerAtten
        self._cfg_rfFreqMhz_config = ConfigParser.ConfigParser()
        self._cfg_rfFreqMhz_config.read(configFilePath)
        try: cfg_rfFreqMhz = self._cfg_rfFreqMhz_config.getint('tuner', 'freq')
        except: cfg_rfFreqMhz = int(radioObj.getTunerFrequencyRange()[0]/1e6)
        self.cfg_rfFreqMhz = cfg_rfFreqMhz
        self._cfg_refLevel_config = ConfigParser.ConfigParser()
        self._cfg_refLevel_config.read(configFilePath)
        try: cfg_refLevel = self._cfg_refLevel_config.getint('display', 'ref_level')
        except: cfg_refLevel = 0
        self.cfg_refLevel = cfg_refLevel
        self._cfg_dynRange_config = ConfigParser.ConfigParser()
        self._cfg_dynRange_config.read(configFilePath)
        try: cfg_dynRange = self._cfg_dynRange_config.getint('display', 'dyn_range')
        except: cfg_dynRange = 120
        self.cfg_dynRange = cfg_dynRange
        self.wbSampleRate = wbSampleRate = wbddcRateSet[wbddcRateIndex]
        self.wbBw = wbBw = wbddcBwSet[wbddcRateIndex]
        self.udpBasePort = udpBasePort = 0xcafe
        self.tunerIndex = tunerIndex = cfg_tunerIndex
        self.tunerAtten = tunerAtten = cfg_tunerAtten
        self.samp_rate = samp_rate = 10e6
        self.rfFreqMhz = rfFreqMhz = cfg_rfFreqMhz
        self.refLevel = refLevel = cfg_refLevel
        self.pauseScan = pauseScan = False
        self.iirAlpha = iirAlpha = 2.0**(float(-iirAvgExp))
        self.fStep = fStep = 100
        self.f2 = f2 = int(radioObj.getTunerFrequencyRange()[1]/1e6)
        self.f1 = f1 = 100
        self.dynRange = dynRange = cfg_dynRange
        self.dwell = dwell = 0.5

        ##################################################
        # Blocks
        ##################################################
        self.wbTabs = Qt.QTabWidget()
        self.wbTabs_widget_0 = Qt.QWidget()
        self.wbTabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.wbTabs_widget_0)
        self.wbTabs_grid_layout_0 = Qt.QGridLayout()
        self.wbTabs_layout_0.addLayout(self.wbTabs_grid_layout_0)
        self.wbTabs.addTab(self.wbTabs_widget_0, 'Spectrum')
        self.top_grid_layout.addWidget(self.wbTabs, 1,0,1,3)
        self.controlTabs = Qt.QTabWidget()
        self.controlTabs_widget_0 = Qt.QWidget()
        self.controlTabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.controlTabs_widget_0)
        self.controlTabs_grid_layout_0 = Qt.QGridLayout()
        self.controlTabs_layout_0.addLayout(self.controlTabs_grid_layout_0)
        self.controlTabs.addTab(self.controlTabs_widget_0, 'control')
        self.top_grid_layout.addWidget(self.controlTabs, 0,0,1,1)
        self._wbddcRateIndex_options = sorted(wbddcRateSet.keys())
        self._wbddcRateIndex_labels = ["%d: %ssps"%(k,num_to_str(wbddcRateSet[k])) for k in sorted(wbddcRateSet.keys())]
        self._wbddcRateIndex_tool_bar = Qt.QToolBar(self)
        self._wbddcRateIndex_tool_bar.addWidget(Qt.QLabel('WBDDC Sample Rate'+": "))
        self._wbddcRateIndex_combo_box = Qt.QComboBox()
        self._wbddcRateIndex_tool_bar.addWidget(self._wbddcRateIndex_combo_box)
        for label in self._wbddcRateIndex_labels: self._wbddcRateIndex_combo_box.addItem(label)
        self._wbddcRateIndex_callback = lambda i: Qt.QMetaObject.invokeMethod(self._wbddcRateIndex_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._wbddcRateIndex_options.index(i)))
        self._wbddcRateIndex_callback(self.wbddcRateIndex)
        self._wbddcRateIndex_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_wbddcRateIndex(self._wbddcRateIndex_options[i]))
        self.controlTabs_grid_layout_0.addWidget(self._wbddcRateIndex_tool_bar, 0,1,1,1)
        self._tunerIndex_options = radioObj.getTunerIndexRange()
        self._tunerIndex_labels = map(str, self._tunerIndex_options)
        self._tunerIndex_tool_bar = Qt.QToolBar(self)
        self._tunerIndex_tool_bar.addWidget(Qt.QLabel('Tuner Index'+": "))
        self._tunerIndex_combo_box = Qt.QComboBox()
        self._tunerIndex_tool_bar.addWidget(self._tunerIndex_combo_box)
        for label in self._tunerIndex_labels: self._tunerIndex_combo_box.addItem(label)
        self._tunerIndex_callback = lambda i: Qt.QMetaObject.invokeMethod(self._tunerIndex_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._tunerIndex_options.index(i)))
        self._tunerIndex_callback(self.tunerIndex)
        self._tunerIndex_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_tunerIndex(self._tunerIndex_options[i]))
        self.controlTabs_grid_layout_0.addWidget(self._tunerIndex_tool_bar, 0,0,1,1)
        self._tunerAtten_range = Range(int(radioObj.getTunerAttenuationRange()[0]), int(radioObj.getTunerAttenuationRange()[1]), int(radioObj.getTunerAttenuationRes()), cfg_tunerAtten, 200)
        self._tunerAtten_win = RangeWidget(self._tunerAtten_range, self.set_tunerAtten, 'Tuner Atten (dB)', "counter", int)
        self.controlTabs_grid_layout_0.addWidget(self._tunerAtten_win, 0,2,1,1)
        self._rfFreqMhz_range = Range(int(radioObj.getTunerFrequencyRange()[0]/1e6), int(radioObj.getTunerFrequencyRange()[1]/1e6), 10, cfg_rfFreqMhz, 200)
        self._rfFreqMhz_win = RangeWidget(self._rfFreqMhz_range, self.set_rfFreqMhz, 'Tuner Freq (MHz)', "counter_slider", int)
        self.controlTabs_grid_layout_0.addWidget(self._rfFreqMhz_win, 0,3,1,2)
        self._refLevel_range = Range(-120, +10, 5, cfg_refLevel, (130/5)+1)
        self._refLevel_win = RangeWidget(self._refLevel_range, self.set_refLevel, "Ref.\nLevel\n(dB)", "dial", int)
        self.wbTabs_grid_layout_0.addWidget(self._refLevel_win, 0,1,1,1)
        self._pauseScan_options = (False, True, )
        self._pauseScan_labels = ('Run', 'Pause', )
        self._pauseScan_group_box = Qt.QGroupBox('Scan')
        self._pauseScan_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._pauseScan_button_group = variable_chooser_button_group()
        self._pauseScan_group_box.setLayout(self._pauseScan_box)
        for i, label in enumerate(self._pauseScan_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._pauseScan_box.addWidget(radio_button)
        	self._pauseScan_button_group.addButton(radio_button, i)
        self._pauseScan_callback = lambda i: Qt.QMetaObject.invokeMethod(self._pauseScan_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._pauseScan_options.index(i)))
        self._pauseScan_callback(self.pauseScan)
        self._pauseScan_button_group.buttonClicked[int].connect(
        	lambda i: self.set_pauseScan(self._pauseScan_options[i]))
        self.controlTabs_grid_layout_0.addWidget(self._pauseScan_group_box, 1,0,1,1)
        self._fStep_range = Range(1, 1000, 10, 100, 200)
        self._fStep_win = RangeWidget(self._fStep_range, self.set_fStep, 'Step (MHz)', "counter", float)
        self.controlTabs_grid_layout_0.addWidget(self._fStep_win, 1,3,1,1)
        self._f2_range = Range(int(radioObj.getTunerFrequencyRange()[0]/1e6), int(radioObj.getTunerFrequencyRange()[1]/1e6), 10, int(radioObj.getTunerFrequencyRange()[1]/1e6), 200)
        self._f2_win = RangeWidget(self._f2_range, self.set_f2, 'f2 (MHz)', "counter", float)
        self.controlTabs_grid_layout_0.addWidget(self._f2_win, 1,2,1,1)
        self._f1_range = Range(int(radioObj.getTunerFrequencyRange()[0]/1e6), int(radioObj.getTunerFrequencyRange()[1]/1e6), 10, 100, 200)
        self._f1_win = RangeWidget(self._f1_range, self.set_f1, 'f1 (MHz)', "counter", float)
        self.controlTabs_grid_layout_0.addWidget(self._f1_win, 1,1,1,1)
        self._dynRange_range = Range(5, 200, 5, cfg_dynRange, (195/5)+1)
        self._dynRange_win = RangeWidget(self._dynRange_range, self.set_dynRange, "Dyn.\nRange\n(dB)", "dial", int)
        self.wbTabs_grid_layout_0.addWidget(self._dynRange_win, 1,1,1,1)
        self._dwell_range = Range(0.001, 10.0, 0.1, 0.5, 200)
        self._dwell_win = RangeWidget(self._dwell_range, self.set_dwell, 'dwell', "counter", float)
        self.controlTabs_grid_layout_0.addWidget(self._dwell_win, 1,4,1,1)
        self.z_tunerControl = CyberRadio.generic_tuner_control_block(
                    radioObj,
                    tunerIndex,
                    True,
                    1000,
                    tunerAtten,
                    1,
                    None,
                    {},
                    False
                     )
        self.y_ddcControl = CyberRadio.generic_ddc_control_block(
                    radioObj,
                    tunerIndex,
                    True,
                    True,
                    wbddcRateIndex,
                    0,
                    0,
                    tunerIndex,
                    0,
                    -1,
                    -1,
                    '',
                    udpBasePort,
                    {},
                    True
                     )
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		otw_format='sc8',
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_1.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_1.set_center_freq(uhd.tune_request_t((rfFreqMhz+1)*1e6, 2*samp_rate), 0)
        self.uhd_usrp_sink_1.set_gain(20, 0)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	4096, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	wbSampleRate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(1.0/32)
        self.qtgui_freq_sink_x_0.set_y_axis(refLevel-dynRange, refLevel)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.wbTabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,3,1)
        self._iirAvgExp_range = Range(0, 8, 1, cfg_iirAvgExp, 200)
        self._iirAvgExp_win = RangeWidget(self._iirAvgExp_range, self.set_iirAvgExp, 'Avg.', "dial", int)
        self.wbTabs_grid_layout_0.addWidget(self._iirAvgExp_win, 2,1,1,1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, radioObj.getVitaPayloadSize()/4)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_message_debug_1 = blocks.message_debug()
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 0.1, 1, 0)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(1)
        self.CyberRadio_zero_copy_source_0 = CyberRadio.zero_copy_source(
              '255.255.255.255', udpBasePort,
              1, radioObj.getVitaHeaderSize(), radioObj.getVitaPayloadSize()/4,
              radioObj.isByteswapped(), radioObj.isIqSwapped(),
              "ip proto 17 and ip dst 255.255.255.255 and udp dst port %d"%(udpBasePort,), True,
               )
        self.CyberRadio_generic_group_control_block_0 = CyberRadio.generic_group_control_block(
                  radioObj,
                  0,
                  False,
                  True,
                  ([0,1,2,3,]),
                  {},
                  False,
                   )
        self.CyberRadio_freq_msg_strobe_0 = CyberRadio.freq_msg_strobe(
              pause = bool(pauseScan),
              f1 = f1,
              f2 = f2,
              step = fStep,
              dwell = dwell,
              wrap = True,
              fManual = rfFreqMhz,
              msgUnits = 1.0,
              msgRes = 1.0e6,
              debug = False,
               )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.CyberRadio_freq_msg_strobe_0, 'freq'), (self.uhd_usrp_sink_1, 'command'))
        self.msg_connect((self.CyberRadio_freq_msg_strobe_0, 'freq'), (self.z_tunerControl, 'freq'))
        self.msg_connect((self.y_ddcControl, 'status'), (self.blocks_message_debug_1, 'print'))
        self.msg_connect((self.z_tunerControl, 'freq'), (self.qtgui_freq_sink_x_0, 'freq'))
        self.connect((self.CyberRadio_zero_copy_source_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_1, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_freq_sink_x_0, 0))