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
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)