Beispiel #1
0
def arrow(a_row, inp, length, begining=2):
    if inp == curses.KEY_DOWN:
        a_row += 1
    elif inp == curses.KEY_UP:
        a_row -= 1
    a_row = limit(a_row, length + begining, begining)
    return a_row
Beispiel #2
0
    def __create_lookat(self):
        if not len(self.server.locations):
            return ''

        begin = format_iso_time(min(self.server.locations))
        end = format_iso_time(max(self.server.locations))

        lat = [y for y, _x, _z in self.server.locations.itervalues()]
        lon = [x for _y, x, _z in self.server.locations.itervalues()]
        latMin = min(lat)
        latMax = max(lat)
        lonMin = min(lon)
        lonMax = max(lon)
        latCen = (latMax + latMin) / 2
        lonCen = (lonMax + lonMin) / 2
        dist = haversine(latMin, latMax, lonMin, lonMax)
        dist = limit(dist, 100, 50000)

        lookAt = ('\t\t<LookAt>\n'
                  '\t\t\t<latitude>{}</latitude>\n'
                  '\t\t\t<longitude>{}</longitude>\n'
                  '\t\t\t<altitudeMode>clampToGround</altitudeMode>\n'
                  '\t\t\t<range>{}</range>\n'
                  '\t\t\t<gx:TimeSpan>\n'
                  '\t\t\t\t<begin>{}</begin>\n'
                  '\t\t\t\t<end>{}</end>\n'
                  '\t\t\t</gx:TimeSpan>\n'
                  '\t\t</LookAt>\n').\
            format(latCen, lonCen, dist * 2, begin, end)

        return lookAt
 def __refresh_devices(self):
     self.settings.devicesRtl = get_devices_rtl(self.devicesRtl,
                                                self.status)
     self.settings.indexRtl = limit(self.settings.indexRtl, 0,
                                    len(self.devicesRtl) - 1)
     self.settings.save()
     return self.settings.devicesRtl
    def __set_dev_grid(self):
        self.gridDev.Unbind(grid.EVT_GRID_EDITOR_CREATED)
        self.Unbind(grid.EVT_GRID_CELL_LEFT_CLICK)
        self.Unbind(grid.EVT_GRID_CELL_CHANGE)
        self.gridDev.ClearGrid()

        i = 0
        for device in self.devices:
            self.gridDev.SetReadOnly(i, self.COL_SEL, True)
            self.gridDev.SetCellRenderer(i, self.COL_SEL, TickCellRenderer())
            self.gridDev.SetCellValue(i, self.COL_NAME, device.name)
            cell = grid.GridCellChoiceEditor(sorted(DeviceGPS.TYPE), allowOthers=False)
            self.gridDev.SetCellValue(i, self.COL_TYPE, DeviceGPS.TYPE[device.type])
            self.gridDev.SetCellEditor(i, self.COL_TYPE, cell)

            if device.type == DeviceGPS.NMEA_SERIAL:
                self.gridDev.SetCellValue(i, self.COL_HOST, device.get_serial_desc())
                self.gridDev.SetReadOnly(i, self.COL_HOST, True)
            else:
                self.gridDev.SetCellValue(i, self.COL_HOST, device.resource)
                self.gridDev.SetReadOnly(i, self.COL_HOST, False)

            self.gridDev.SetCellValue(i, self.COL_TEST, "...")
            self.gridDev.SetCellAlignment(i, self.COL_SEL, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
            i += 1

        self.index = limit(self.index, 0, len(self.devices) - 1)
        self.__select_row(self.index)
        self.index = self.index

        self.gridDev.AutoSize()

        self.gridDev.Bind(grid.EVT_GRID_EDITOR_CREATED, self.__on_create)
        self.Bind(grid.EVT_GRID_CELL_LEFT_CLICK, self.__on_click)
        self.Bind(grid.EVT_GRID_CELL_CHANGE, self.__on_change)
Beispiel #5
0
    def __create_lookat(self):
        if not len(self.server.locations):
            return ''

        begin = format_iso_time(min(self.server.locations))
        end = format_iso_time(max(self.server.locations))

        lat = [y for y, _x, _z in self.server.locations.itervalues()]
        lon = [x for _y, x, _z in self.server.locations.itervalues()]
        latMin = min(lat)
        latMax = max(lat)
        lonMin = min(lon)
        lonMax = max(lon)
        latCen = (latMax + latMin) / 2
        lonCen = (lonMax + lonMin) / 2
        dist = haversine(latMin, latMax, lonMin, lonMax)
        dist = limit(dist, 100, 50000)

        lookAt = ('\t\t<LookAt>\n'
                  '\t\t\t<latitude>{}</latitude>\n'
                  '\t\t\t<longitude>{}</longitude>\n'
                  '\t\t\t<altitudeMode>clampToGround</altitudeMode>\n'
                  '\t\t\t<range>{}</range>\n'
                  '\t\t\t<gx:TimeSpan>\n'
                  '\t\t\t\t<begin>{}</begin>\n'
                  '\t\t\t\t<end>{}</end>\n'
                  '\t\t\t</gx:TimeSpan>\n'
                  '\t\t</LookAt>\n').\
            format(latCen, lonCen, dist * 2, begin, end)

        return lookAt
    def __set_dev_grid(self):
        self.gridDev.Unbind(grid.EVT_GRID_EDITOR_CREATED)
        self.Unbind(grid.EVT_GRID_CELL_LEFT_CLICK)
        self.Unbind(grid.EVT_GRID_CELL_CHANGE)
        self.gridDev.ClearGrid()

        i = 0
        for device in self.devices:
            self.gridDev.SetReadOnly(i, self.COL_SEL, True)
            self.gridDev.SetCellRenderer(i, self.COL_SEL,
                                         TickCellRenderer())
            self.gridDev.SetCellValue(i, self.COL_NAME, device.name)
            cell = grid.GridCellChoiceEditor(sorted(DeviceGPS.TYPE),
                                             allowOthers=False)
            self.gridDev.SetCellValue(i, self.COL_TYPE,
                                      DeviceGPS.TYPE[device.type])
            self.gridDev.SetCellEditor(i, self.COL_TYPE, cell)

            if device.type == DeviceGPS.NMEA_SERIAL:
                self.gridDev.SetCellValue(i, self.COL_HOST,
                                          device.get_serial_desc())
                self.gridDev.SetReadOnly(i, self.COL_HOST, True)
            else:
                self.gridDev.SetCellValue(i, self.COL_HOST, device.resource)
                self.gridDev.SetReadOnly(i, self.COL_HOST, False)

            self.gridDev.SetCellValue(i, self.COL_TEST, '...')
            self.gridDev.SetCellAlignment(i, self.COL_SEL,
                                          wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
            i += 1

        self.index = limit(self.index, 0, len(self.devices) - 1)
        self.__select_row(self.index)
        self.index = self.index

        self.gridDev.AutoSize()
        font = self.gridDev.GetFont()
        dc = wx.WindowDC(self.gridDev)
        dc.SetFont(font)
        width, _height = dc.GetTextExtent(max(DeviceGPS.TYPE, key=len))
        self.gridDev.SetColSize(self.COL_TYPE, width * 1.5)

        self.gridDev.Bind(grid.EVT_GRID_EDITOR_CREATED, self.__on_create)
        self.Bind(grid.EVT_GRID_CELL_LEFT_CLICK, self.__on_click)
        self.Bind(grid.EVT_GRID_CELL_CHANGE, self.__on_change)
Beispiel #7
0
 def __refresh_devices(self):
     self.settings.devicesRtl = get_devices_rtl(self.devicesRtl, self.status)
     self.settings.indexRtl = limit(self.settings.indexRtl, 0, len(self.devicesRtl) - 1)
     self.settings.save()
     return self.settings.devicesRtl
Beispiel #8
0
    def __init__(self, title, pool):

        self.pool = pool
        self.lock = threading.Lock()

        self.sdr = None
        self.threadScan = None
        self.threadUpdate = None
        self.threadLocation = None

        self.serverKml = None

        self.isNewScan = True
        self.isScanning = False

        self.stopAtEnd = False
        self.stopScan = False

        self.dlgCal = None
        self.dlgSats = None
        self.dlgLog = None

        self.menuMain = None
        self.menuPopup = None

        self.graph = None
        self.toolbar = None
        self.canvas = None

        self.buttonStart = None
        self.buttonStop = None
        self.controlGain = None
        self.choiceMode = None
        self.choiceDwell = None
        self.choiceNfft = None
        self.spinCtrlStart = None
        self.spinCtrlStop = None
        self.choiceDisplay = None

        self.spectrum = OrderedDict()
        self.scanInfo = ScanInfo()
        self.locations = OrderedDict()
        self.lastLocation = [None] * 4

        self.isSaved = True

        self.settings = Settings()
        self.devicesRtl = get_devices_rtl(self.settings.devicesRtl)
        self.settings.indexRtl = limit(self.settings.indexRtl, 0, len(self.devicesRtl) - 1)
        self.filename = ""
        self.oldCal = 0

        self.remoteControl = None

        self.log = Log()

        self.pageConfig = wx.PageSetupDialogData()
        self.pageConfig.GetPrintData().SetOrientation(wx.LANDSCAPE)
        self.pageConfig.SetMarginTopLeft((20, 20))
        self.pageConfig.SetMarginBottomRight((20, 20))
        self.printConfig = wx.PrintDialogData(self.pageConfig.GetPrintData())
        self.printConfig.EnableSelection(False)
        self.printConfig.EnablePageNumbers(False)

        wx.Frame.__init__(self, None, title=title)

        self.timerGpsRetry = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.__on_gps_retry, self.timerGpsRetry)

        self.Bind(wx.EVT_CLOSE, self.__on_exit)

        self.status = Statusbar(self, self.log)
        self.status.set_info(title)
        self.SetStatusBar(self.status)

        add_colours()
        self.__create_widgets()
        self.__create_menu()
        self.__create_popup_menu()
        self.__set_control_state(True)
        self.Show()

        displaySize = wx.DisplaySize()
        toolbarSize = self.toolbar.GetBestSize()
        self.SetClientSize((toolbarSize[0] + 10, displaySize[1] / 2))
        self.SetMinSize((displaySize[0] / 4, displaySize[1] / 4))

        self.Connect(-1, -1, EVENT_THREAD, self.__on_event)

        self.SetDropTarget(DropTarget(self))

        self.SetIcon(load_icon("rtlsdr_scan"))

        self.steps = 0
        self.stepsTotal = 0

        self.__start_gps()
        self.__start_kml()
    def __init__(self, title, pool):

        self.pool = pool
        self.lock = threading.Lock()

        self.sdr = None
        self.threadScan = None
        self.threadUpdate = None
        self.threadLocation = None

        self.serverLocation = None

        self.isNewScan = True
        self.isScanning = False

        self.stopAtEnd = False
        self.stopScan = False

        self.dlgCal = None
        self.dlgSats = None
        self.dlgLog = None

        self.menuMain = None
        self.menuPopup = None

        self.graph = None
        self.toolbar = None
        self.canvas = None

        self.buttonStart = None
        self.buttonStop = None
        self.controlGain = None
        self.choiceMode = None
        self.choiceDwell = None
        self.choiceNfft = None
        self.spinCtrlStart = None
        self.spinCtrlStop = None
        self.choiceDisplay = None

        self.spectrum = OrderedDict()
        self.scanInfo = ScanInfo()
        self.locations = OrderedDict()
        self.lastLocation = [None] * 4

        self.isSaved = True

        self.settings = Settings()
        self.devicesRtl = get_devices_rtl(self.settings.devicesRtl)
        self.settings.indexRtl = limit(self.settings.indexRtl, 0,
                                       len(self.devicesRtl) - 1)
        self.filename = ""
        self.oldCal = 0

        self.remoteControl = None

        self.log = Log()

        self.pageConfig = wx.PageSetupDialogData()
        self.pageConfig.GetPrintData().SetOrientation(wx.LANDSCAPE)
        self.pageConfig.SetMarginTopLeft((20, 20))
        self.pageConfig.SetMarginBottomRight((20, 20))
        self.printConfig = wx.PrintDialogData(self.pageConfig.GetPrintData())
        self.printConfig.EnableSelection(False)
        self.printConfig.EnablePageNumbers(False)

        wx.Frame.__init__(self, None, title=title)

        self.timerGpsRetry = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.__on_gps_retry, self.timerGpsRetry)

        self.Bind(wx.EVT_CLOSE, self.__on_exit)

        self.status = Statusbar(self, self.log)
        self.status.set_info(title)
        self.SetStatusBar(self.status)

        add_colours()
        self.__create_widgets()
        self.__create_menu()
        self.__create_popup_menu()
        self.__set_control_state(True)
        self.Show()

        displaySize = wx.DisplaySize()
        toolbarSize = self.toolbar.GetBestSize()
        self.SetClientSize((toolbarSize[0] + 10, displaySize[1] / 2))
        self.SetMinSize((displaySize[0] / 4, displaySize[1] / 4))

        self.Connect(-1, -1, EVENT_THREAD, self.__on_event)

        self.SetDropTarget(DropTarget(self))

        self.SetIcon(load_icon('rtlsdr_scan'))

        self.steps = 0
        self.stepsTotal = 0

        self.__start_gps()
        self.__start_location_server()