Exemplo n.º 1
0
    def load(self):
        servers = 0
        self.cfg = wx.Config('rtlsdr-scanner')
        self.saveWarn = self.cfg.ReadBool('saveWarn', self.saveWarn)
        self.fileHistory.Load(self.cfg)
        self.annotate = self.cfg.ReadBool('annotate', self.annotate)
        self.retainScans = self.cfg.ReadBool('retainScans', self.retainScans)
        self.fadeScans = self.cfg.ReadBool('fadeScans', self.fadeScans)
        self.maxScans = self.cfg.ReadInt('maxScans', self.maxScans)
        self.start = self.cfg.ReadInt('start', self.start)
        self.stop = self.cfg.ReadInt('stop', self.stop)
        self.mode = self.cfg.ReadInt('mode', self.mode)
        self.dwell = self.cfg.ReadFloat('dwell', self.dwell)
        self.nfft = self.cfg.ReadInt('nfft', self.nfft)
        self.liveUpdate = self.cfg.ReadBool('liveUpdate', self.liveUpdate)
        self.calFreq = self.cfg.ReadFloat('calFreq', self.calFreq)
        self.autoScale = self.cfg.ReadBool('autoScale', self.autoScale)
        self.yMax = self.cfg.ReadInt('yMax', self.yMax)
        self.yMin = self.cfg.ReadInt('yMin', self.yMin)
        self.index = self.cfg.ReadInt('index', self.index)
        self.cfg.SetPath("/Devices")
        group = self.cfg.GetFirstGroup()
        while group[0]:
            self.cfg.SetPath("/Devices/" + group[1])
            device = Device()
            device.name = group[1]
            device.serial = self.cfg.Read('serial', '')
            device.isDevice = self.cfg.ReadBool('isDevice', True)
            if not device.isDevice:
                servers += 1
            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)
            self.devices.append(device)
            self.cfg.SetPath("/Devices")
            group = self.cfg.GetNextGroup(group[2])

        if servers == 0:
            device = Device()
            device.name = 'Server'
            device.isDevice = False
            device.server = 'localhost'
            device.port = 1234
            self.devices.append(device)
Exemplo n.º 2
0
 def load(self):
     self.cfg = wx.Config('rtlsdr-scanner')
     self.display = self.cfg.ReadInt('display', self.display)
     self.saveWarn = self.cfg.ReadBool('saveWarn', self.saveWarn)
     self.fileHistory.Load(self.cfg)
     self.dirScans = self.cfg.Read('dirScans', self.dirScans)
     self.dirExport = self.cfg.Read('dirExport', self.dirExport)
     self.annotate = self.cfg.ReadBool('annotate', self.annotate)
     self.retainScans = self.cfg.ReadBool('retainScans', self.retainScans)
     self.fadeScans = self.cfg.ReadBool('fadeScans', self.fadeScans)
     self.lineWidth = self.cfg.ReadFloat('lineWidth', self.lineWidth)
     self.retainMax = self.cfg.ReadInt('retainMax', self.retainMax)
     self.colourMap = self.cfg.Read('colourMap', self.colourMap)
     self.background = self.cfg.Read('background', self.background)
     self.wireframe = self.cfg.ReadBool('wireframe', self.wireframe)
     self.average = self.cfg.ReadBool('average', self.average)
     self.pointsLimit = self.cfg.ReadBool('pointsLimit', self.pointsLimit)
     self.pointsMax = self.cfg.ReadInt('pointsMax', self.pointsMax)
     self.grid = self.cfg.ReadBool('grid', self.grid)
     self.start = self.cfg.ReadInt('start', self.start)
     self.stop = self.cfg.ReadInt('stop', self.stop)
     self.mode = self.cfg.ReadInt('mode', self.mode)
     self.dwell = self.cfg.ReadFloat('dwell', self.dwell)
     self.nfft = self.cfg.ReadInt('nfft', self.nfft)
     self.overlap = self.cfg.ReadFloat('overlap', self.overlap)
     self.winFunc = self.cfg.Read('winFunc', self.winFunc)
     self.liveUpdate = self.cfg.ReadBool('liveUpdate', self.liveUpdate)
     self.calFreq = self.cfg.ReadFloat('calFreq', self.calFreq)
     self.autoF = self.cfg.ReadBool('autoF', self.autoF)
     self.autoL = self.cfg.ReadBool('autoL', self.autoL)
     self.autoT = self.cfg.ReadBool('autoT', self.autoT)
     self.showMeasure = self.cfg.ReadBool('showMeasure', self.showMeasure)
     self.alert = self.cfg.ReadBool('alert', self.alert)
     self.alertLevel = self.cfg.ReadFloat('alertLevel', self.alertLevel)
     self.index = self.cfg.ReadInt('index', self.index)
     self.cfg.SetPath("/Devices")
     group = self.cfg.GetFirstGroup()
     while group[0]:
         self.cfg.SetPath("/Devices/" + group[1])
         device = Device()
         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.devices.append(device)
         self.cfg.SetPath("/Devices")
         group = self.cfg.GetNextGroup(group[2])
Exemplo n.º 3
0
    def __init__(self, pool, args):
        start = args.start
        end = args.end
        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_export_type(ext) == -1:
            error = "File extension should be .rfs, "
            error += File.get_export_pretty()
        else:
            device = Device()
            if remote is None:
                self.settings.devices = get_devices()
                count = len(self.settings.devices)
                if index > count - 1:
                    error = "Device not found ({0} devices in total):\n".format(count)
                    for device in self.settings.devices:
                        error += "\t{0}: {1}\n".format(device.index,
                                                       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.devices.append(device)
                index = len(self.settings.devices) - 1

        if error is not None:
            print "Error: {0}".format(error)
            exit(1)

        if end - 1 < start:
            end = start + 1
        if remote is None:
            gain = nearest(gain, self.settings.devices[index].gains)

        self.settings.start = start
        self.settings.stop = end
        self.settings.dwell = calc_real_dwell(dwell)
        self.settings.nfft = nfft
        self.settings.devices[index].gain = gain
        self.settings.devices[index].lo = lo

        print "{0} - {1}MHz".format(start, end)
        print "{0}dB Gain".format(gain)
        print "{0}s Dwell".format(self.settings.dwell)
        print "{0} FFT points".format(nfft)
        print "{0}MHz LO".format(lo)
        if remote is not None:
            print remote
        else:
            print self.settings.devices[index].name

        self.scan(self.settings, index, pool)

        if ext == ".rfs":
            scanInfo = ScanInfo()
            scanInfo.setFromSettings(self.settings)
            save_plot(directory, filename, scanInfo, self.spectrum)
        else:
            exportType = File.get_export_type(ext)
            export_plot(directory, filename, exportType, self.spectrum)

        print "Done"