def __on_add(self, _event): device = DeviceRTL() device.isDevice = False self.devices.append(device) self.gridDev.AppendRows(1) self.__set_dev_grid() self.SetSizerAndFit(self.devbox) self.__set_button_state()
def __load_devices_rtl(self): self.cfg.SetPath("/DevicesRTL") group = self.cfg.GetFirstGroup() while group[0]: self.cfg.SetPath("/DevicesRTL/" + group[1]) device = DeviceRTL() device.name = group[1] device.serial = self.cfg.Read("serial", "") device.isDevice = self.cfg.ReadBool("isDevice", True) device.server = self.cfg.Read("server", "localhost") device.port = self.cfg.ReadInt("port", 1234) device.gain = self.cfg.ReadFloat("gain", 0) device.calibration = self.cfg.ReadFloat("calibration", 0) device.lo = self.cfg.ReadFloat("lo", 0) device.offset = self.cfg.ReadFloat("offset", 250e3) device.tuner = self.cfg.ReadInt("tuner", 0) self.devicesRtl.append(device) self.cfg.SetPath("/DevicesRTL") group = self.cfg.GetNextGroup(group[2])
def __init__(self, pool, args): start = args.start end = args.end sweeps = args.sweeps gain = args.gain dwell = args.dwell nfft = args.fft lo = args.lo index = args.index remote = args.remote directory, filename = os.path.split(args.file) _null, ext = os.path.splitext(args.file) self.lock = threading.Lock() self.stepsTotal = 0 self.steps = 0 self.spectrum = {} self.settings = Settings(load=False) self.queue = Queue.Queue() error = None if end <= start: error = "Start should be lower than end" elif dwell <= 0: error = "Dwell should be positive" elif nfft <= 0: error = "FFT bins should be positive" elif ext != ".rfs" and File.get_type_index(ext) == -1: error = "File extension should be " error += File.get_type_pretty(File.Types.SAVE) error += File.get_type_pretty(File.Types.PLOT) else: device = DeviceRTL() if remote is None: self.settings.devicesRtl = get_devices_rtl() count = len(self.settings.devicesRtl) if index > count - 1: error = "Device not found ({} devices in total):\n".format(count) for device in self.settings.devicesRtl: error += "\t{}: {}\n".format(device.indexRtl, device.name) else: device.isDevice = False url = urlparse('//' + remote) if url.hostname is not None: device.server = url.hostname else: error = "Invalid hostname" if url.port is not None: device.port = url.port else: device.port = 1234 self.settings.devicesRtl.append(device) index = len(self.settings.devicesRtl) - 1 if error is not None: print "Error: {}".format(error) exit(1) if end - 1 < start: end = start + 1 if remote is None: gain = nearest(gain, self.settings.devicesRtl[index].gains) self.settings.start = start self.settings.stop = end self.settings.dwell = calc_real_dwell(dwell) self.settings.nfft = nfft self.settings.devicesRtl[index].gain = gain self.settings.devicesRtl[index].lo = lo print "{} - {}MHz".format(start, end) print "{} Sweeps".format(sweeps) print "{}dB Gain".format(gain) print "{}s Dwell".format(self.settings.dwell) print "{} FFT points".format(nfft) print "{}MHz LO".format(lo) if remote is not None: print remote else: print self.settings.devicesRtl[index].name self.__scan(sweeps, self.settings, index, pool) fullName = os.path.join(directory, filename) if ext == ".rfs": scanInfo = ScanInfo() scanInfo.set_from_settings(self.settings) save_plot(fullName, scanInfo, self.spectrum, {}) else: exportType = File.get_type_index(ext) export_plot(fullName, exportType, self.spectrum) print "Done"
def __init__(self, pool, args): start = args.start end = args.end sweeps = args.sweeps gain = args.gain dwell = args.dwell nfft = args.fft lo = args.lo index = args.index remote = args.remote directory, filename = os.path.split(args.file) _null, ext = os.path.splitext(args.file) self.lock = threading.Lock() self.stepsTotal = 0 self.steps = 0 self.spectrum = OrderedDict() self.locations = OrderedDict() self.settings = Settings(load=False) self.queueNotify = Queue.Queue() self.queueScan = Queue.Queue() self.queueLocation = Queue.Queue() self.threadLocation = None error = None if end <= start: error = "Start should be lower than end" elif dwell <= 0: error = "Dwell should be positive" elif nfft <= 0: error = "FFT bins should be positive" elif ext != ".rfs" and File.get_type_index(ext) == -1: error = "File extension should be " error += File.get_type_pretty(File.Types.SAVE) error += File.get_type_pretty(File.Types.PLOT) else: device = DeviceRTL() if remote is None: self.settings.devicesRtl = get_devices_rtl() count = len(self.settings.devicesRtl) if index > count - 1: error = "Device not found ({} devices in total):\n".format( count) for device in self.settings.devicesRtl: error += "\t{}: {}\n".format(device.indexRtl, device.name) else: device.isDevice = False url = urlparse('//' + remote) if url.hostname is not None: device.server = url.hostname else: error = "Invalid hostname" if url.port is not None: device.port = url.port else: device.port = 1234 self.settings.devicesRtl.append(device) index = len(self.settings.devicesRtl) - 1 if args.conf is not None: if os.path.exists(args.conf): error = self.settings.load_conf(args.conf) else: error = 'Cannot find {}'.format(args.conf) if end - 1 < start: end = start + 1 if remote is None: if len(self.settings.devicesRtl): gain = nearest(gain, self.settings.devicesRtl[index].gains) else: error = 'No devices found' if error is not None: print "Error: {}".format(error) exit(1) self.settings.start = start self.settings.stop = end self.settings.dwell = calc_real_dwell(dwell) self.settings.scanDelay = args.delay self.settings.nfft = nfft self.settings.devicesRtl[index].gain = gain self.settings.devicesRtl[index].lo = lo print "{} - {}MHz".format(start, end) print "{} Sweeps".format(sweeps) print "{}dB Gain".format(gain) print "{}s Dwell".format(self.settings.dwell) print "{} FFT points".format(nfft) print "{}MHz LO".format(lo) if remote is not None: print remote else: print self.settings.devicesRtl[index].name if len(self.settings.devicesGps): self.threadLocation = ThreadLocation(self.queueLocation, self.settings.devicesGps[0]) if not self.__gps_wait(): self.__gps_stop() exit(1) self.__scan(sweeps, self.settings, index, pool) fullName = os.path.join(directory, filename) if ext == ".rfs": scanInfo = ScanInfo() scanInfo.set_from_settings(self.settings) save_plot(fullName, scanInfo, self.spectrum, self.locations) else: exportType = File.get_type_index(ext) export_plot(fullName, exportType, self.spectrum) self.__gps_stop() print "Done"
def __load_devices_rtl(self): self.cfg.SetPath("/DevicesRTL") group = self.cfg.GetFirstGroup() while group[0]: self.cfg.SetPath("/DevicesRTL/" + group[1]) device = DeviceRTL() device.name = group[1] device.serial = self.cfg.Read('serial', '') device.isDevice = self.cfg.ReadBool('isDevice', True) device.server = self.cfg.Read('server', 'localhost') device.port = self.cfg.ReadInt('port', 1234) device.gain = self.cfg.ReadFloat('gain', 0) device.calibration = self.cfg.ReadFloat('calibration', 0) device.lo = self.cfg.ReadFloat('lo', 0) device.offset = self.cfg.ReadFloat('offset', 250e3) device.tuner = self.cfg.ReadInt('tuner', 0) self.devicesRtl.append(device) self.cfg.SetPath("/DevicesRTL") group = self.cfg.GetNextGroup(group[2])