def fe_setTunerCenterFrequency(self, alloc_id, freq): tuner_id = self.getTunerMapping(alloc_id) if tuner_id < 0: raise FRONTEND.FrontendException("ERROR: ID: %s IS NOT ASSOCIATED WITH ANY TUNER!"%(alloc_id)) if alloc_id != self.tunerChannels[tuner_id].control_allocation_id: raise FRONTEND.FrontendException("ERROR: ID: %s DOES NOT HAVE AUTHORIZATION TO MODIFY TUNER!"%(alloc_id)) try: # If the freq has changed (change in stream) or the tuner is disabled, then set it as disabled isTunerEnabled = self.tunerChannels[tuner_id].frontend_status.enabled if not isTunerEnabled or self.tunerChannels[tuner_id].frontend_status.center_frequency != freq: self.enableTuner(tuner_id, False) # TODO: is this a generic thing we can assume is desired when changing any tuner device? self.tunerChannels[tuner_id].lock.acquire() try: if not self._valid_center_frequency(freq,tuner_id): # TODO: add log message raise FRONTEND.BadParameterException("INVALID FREQUENCY") try: self._dev_set_center_frequency(freq,tuner_id) except: #TODO: add back log messages raise FRONTEND.FrontendException("WARNING: failed when configuring device hardware") try: self.tunerChannels[tuner_id].frontend_status.center_frequency = self._dev_get_center_frequency(tuner_id) except: #TODO: add back log messages raise FRONTEND.FrontendException("WARNING: failed when querying device hardware") finally: self.tunerChannels[tuner_id].lock.release() if isTunerEnabled: self.enableTuner(tuner_id, True) except Exception, e: raise FRONTEND.FrontendException("WARNING: %s"%(e))
def setTunerCenterFrequency(self, allocation_id, freq): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") if allocation_id != self.getControlAllocationId(idx): raise FRONTEND.FrontendException( ("ID " + str(allocation_id) + " does not have authorization to modify the tuner")) if freq < 0: raise FRONTEND.BadParameterException("Bad CF") # set hardware to new value. Raise an exception if it's not possible #Check Frequency again min/max Range #Convert CF based on RFInfo. tuneFreq = self.convert_rf_to_if(freq) # Check the CF if not (validateRequestSingle(self.MINFREQ, self.MAXFREQ, tuneFreq)): self._log.debug("Center Freq Does not fit %s, %s, %s" % (tuneFreq, self.MINFREQ, self.MAXFREQ)) raise FRONTEND.BadParameterException( "Radio Center Freq of %s Does not fit in %s, %s" % (tuneFreq, self.MINFREQ, self.MAXFREQ)) #set tuner new freq self.datagenerators[idx].cf = tuneFreq self.datagenerators[idx].keyword_dict['COL_RF'] = freq self.datagenerators[idx].keyword_dict['CHAN_RF'] = freq self.datagenerators[idx].updateandPushSRI() self.frontend_tuner_status[idx].center_frequency = freq
def fe_setTunerOutputSampleRate(self, alloc_id, sr): tuner_id = self.getTunerMapping(alloc_id) if tuner_id < 0: raise FRONTEND.FrontendException("ERROR: ID: %s IS NOT ASSOCIATED WITH ANY TUNER!"%(alloc_id)) if alloc_id != self.tunerChannels[tuner_id].control_allocation_id: raise FRONTEND.FrontendException("ERROR: ID: %s DOES NOT HAVE AUTHORIZATION TO MODIFY TUNER!"%(alloc_id)) try: self.tunerChannels[tuner_id].lock.acquire() try: if not self._valid_sample_rate(sr,tuner_id): # TODO: add log message raise FRONTEND.BadParameterException("INVALID SAMPLE RATE") try: self._dev_set_sample_rate(sr,tuner_id) except: #TODO: add back log messages raise FRONTEND.FrontendException("WARNING: failed when configuring device hardware") try: self.tunerChannels[tuner_id].frontend_status.sample_rate = self._dev_get_sample_rate(tuner_id) except: #TODO: add back log messages raise FRONTEND.FrontendException("WARNING: failed when querying device hardware") finally: self.tunerChannels[tuner_id].lock.release() except Exception, e: raise FRONTEND.FrontendException("WARNING: %s"%(e))
def setTunerEnable(self, allocation_id, enable): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") if allocation_id != self.getControlAllocationId(idx): raise FRONTEND.FrontendException( ("ID " + str(allocation_id) + " does not have authorization to modify the tuner")) # set hardware to new value. Raise an exception if it's not possible self.frontend_tuner_status[idx].enabled = enable
def fe_setTunerEnable(self, alloc_id, enable): tuner_id = self.getTunerMapping(alloc_id) if tuner_id < 0: raise FRONTEND.FrontendException("ERROR: ID: %s IS NOT ASSOCIATED WITH ANY TUNER!"%(alloc_id)) if alloc_id != self.tunerChannels[tuner_id].control_allocation_id: raise FRONTEND.FrontendException("ERROR: ID: %s DOES NOT HAVE AUTHORIZATION TO MODIFY TUNER!"%(alloc_id)) try: self.enableTuner(tuner_id, enable) except Exception, e: raise FRONTEND.FrontendException("WARNING: Exception Caught during enableTuner: %s"%(e))
def setTunerGain(self, allocation_id, gain): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") if allocation_id != self.getControlAllocationId(idx): raise FRONTEND.FrontendException( ("ID " + str(allocation_id) + " does not have authorization to modify the tuner")) if (gain < 0 or gain > 10): raise FRONTEND.BadParameterException("Invalid Gain") gain = round(gain, 1) # magnitude on data generators is 100+gain*10 self.datagenerators[idx].magnitude = 100 + gain * 10 self.frontend_tuner_status[idx].gain = gain
def fe_getTunerDeviceControl(self, alloc_id): tuner_id = self.getTunerMapping(alloc_id) if tuner_id < 0: raise FRONTEND.FrontendException("ERROR: ID: %s IS NOT ASSOCIATED WITH ANY TUNER!"%(alloc_id)) if alloc_id == self.tunerChannels[tuner_id].control_allocation_id: return True return False
def setTunerBandwidth(self, allocation_id, bw): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") if allocation_id != self.getControlAllocationId(idx): raise FRONTEND.FrontendException( ("ID " + str(allocation_id) + " does not have authorization to modify the tuner")) if bw < 0: raise FRONTEND.BadParameterException("Invalid BW") newbw, newsr, decimation = self.findBestBWSR(bw, 0) if not newbw: self._log.debug("Can't Satisfy BW and SR request") raise FRONTEND.BadParameterException( "Can't Satisfy BW and SR request") # set hardware to new value. Raise an exception if it's not possible self.datagenerators[idx].keyword_dict['FRONTEND::BANDWIDTH'] = newbw self.datagenerators[idx].updateandPushSRI() self.frontend_tuner_status[idx].bandwidth = newsr self.frontend_tuner_status[idx].bandwidth = newbw self.frontend_tuner_status[idx].decimation = decimation
def setTunerOutputSampleRate(self, allocation_id, sr): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") if allocation_id != self.getControlAllocationId(idx): raise FRONTEND.FrontendException( ("ID " + str(allocation_id) + " does not have authorization to modify the tuner")) if sr < 0: raise FRONTEND.BadParameterException("Invalid SR") newbw, newsr, decimation = self.findBestBWSR(0, sr) if not newbw: self._log.debug("Can't Satisfy BW and SR request") raise FRONTEND.BadParameterException( "Can't Satisfy BW and SR request") self._log.debug("Setting BW and Sample Rate %s, %s " % (newbw, newsr)) #set new SR self.datagenerators[idx].sr = sr self.datagenerators[idx].keyword_dict['FRONTEND::BANDWIDTH'] = newbw self.datagenerators[idx].updateandPushSRI() self.frontend_tuner_status[idx].sample_rate = newsr self.frontend_tuner_status[idx].bandwidth = newbw self.frontend_tuner_status[idx].decimation = decimation
def getTunerOutputSampleRate(self, allocation_id): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") return self.frontend_tuner_status[idx].sample_rate
def getTunerEnable(self, allocation_id): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") return self.frontend_tuner_status[idx].enabled
def getTunerCenterFrequency(self, allocation_id): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") return self.frontend_tuner_status[idx].center_frequency
def getTunerDeviceControl(self, allocation_id): idx = self.getTunerMapping(allocation_id) if idx < 0: raise FRONTEND.FrontendException("Invalid allocation id") if self.getControlAllocationId(idx) == allocation_id: return True return False
def fe_getTunerOutputSampleRate(self, alloc_id): tuner_id = self.getTunerMapping(alloc_id) if tuner_id < 0: raise FRONTEND.FrontendException("ERROR: ID: %s IS NOT ASSOCIATED WITH ANY TUNER!"%(alloc_id)) return self.tunerChannels[tuner_id].frontend_status.sample_rate
def fe_getTunerCenterFrequency(self, alloc_id): tuner_id = self.getTunerMapping(alloc_id) if tuner_id < 0: raise FRONTEND.FrontendException("ERROR: ID: %s IS NOT ASSOCIATED WITH ANY TUNER!"%(alloc_id)) return self.tunerChannels[tuner_id].frontend_status.center_frequency
def fe_getTunerStatus(self, alloc_id): tuner_id = self.getTunerMapping(alloc_id) if tuner_id < 0: raise FRONTEND.FrontendException("ERROR: ID: %s IS NOT ASSOCIATED WITH ANY TUNER!"%(alloc_id)) return struct_to_props(self.tunerChannels[tuner_id].frontend_status)