def refreshSettings(self):
        self.settingValues = settings.Settings()

        self.showoutput = int(self.settingValues.getDebugSettingValue('showoutput'))
        
        self.timeinmins = int(self.settingValues.getAppSettingValue('autotimeperiod'))
        self.autoatstart = int(self.settingValues.getAppSettingValue('autoonatstart'))
        self.autooption = int(self.settingValues.getAppSettingValue('autoselectedoption'))

        self.autocombo.current(self.autooption) #set the selected item
        
        self.MAX_TIMER=self.timeinmins*60    
    
        self.serverPortVar = StringVar()
        self.serverVar = IntVar()
        
        self.serverPortVar.set(int(self.settingValues.getNetworkSettingValue('serverport')))
        self.serverVar.set(self.settingValues.getNetworkSettingValue('serverip'))
        
        self.gpsOption = self.settingValues.getGPSHardwareSettingValue('option')
    
        self.gpsComPortVar = StringVar()
        self.gpsComPortSpeedVar = StringVar()
        
        self.gpsComPortVar.set(self.settingValues.getGPSHardwareSettingValue('gpscomport'))
        self.gpsComPortSpeedVar.set(self.settingValues.getGPSHardwareSettingValue('gpsportspeed'))
        self.maidPreceision.set(self.settingValues.getAppSettingValue('precision'))
        self.autoTimeVar.set(self.settingValues.getAppSettingValue('autotimeperiod'))
        self.autoGridToJS8Call.set(self.settingValues.getAppSettingValue('autoonatstart'))
        
        self.autoGridCheck.configure(text="Enable Auto update every "+str(self.timeinmins)+" mins.")
        
        if self.gpsOption=='None':
            self.autoGridCheck.configure(state='disabled')
            self.autoGridToJS8Call.set(0)
        else:
            self.autoGridCheck.configure(state='normal')
            
            
        if self.gpsl!=None:
            self.gpsl.setPrecision(int(self.settingValues.getAppSettingValue('precision')))
            self.gpsl.setShowDebug(self.showoutput)
            
        if self.gpsOptionBeforeRefresh!=self.gpsOption:
            if self.gpsl!=None:
                print('Shutting down GPS Listener')
                #self.gpsl.destroy()
                self.gpsl.setReadGPS(False)
                self.gpsl.join()
                self.gpsl=None
            if self.gpsOption!='None':
                print('Starting GPS Listener')
                if self.gpsOption=='GPSD':
                    self.gpsl = gpsdGPSListener.GpsListener( self.settingValues.getAppSettingValue('precision'),
                                                            self.showoutput
                                                            )
                else:
                    print('Running serial gps again')
                    self.gpsl = serialGPSlistener.GPSListener(self.settingValues.getGPSHardwareSettingValue('gpscomport'),
                                                            self.settingValues.getGPSHardwareSettingValue('gpsportspeed'),
                                                            self.settingValues.getAppSettingValue('precision'),
                                                            self.showoutput
                                                            )
                self.gpsl.start()
            else:
                print('Setting thread to None')
                self.gpsl=None    
        self.gpsOptionBeforeRefresh=self.gpsOption
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        
        self.seq=1
        
        self.settingValues = settings.Settings()
        
        self.showoutput = int(self.settingValues.getDebugSettingValue('showoutput'))
        
        self.timeinmins = int(self.settingValues.getAppSettingValue('autotimeperiod'))
        self.autoatstart = int(self.settingValues.getAppSettingValue('autoonatstart'))
        self.autooption = int(self.settingValues.getAppSettingValue('autoselectedoption'))

        #self.autocombo.set(self.autooption)
        
        self.MAX_TIMER=self.timeinmins*60    
    
        self.serverPortVar = StringVar()
        self.serverVar = IntVar()
        
        self.serverPortVar.set(int(self.settingValues.getNetworkSettingValue('serverport')))
        self.serverVar.set(self.settingValues.getNetworkSettingValue('serverip'))
        
        self.api = js8callAPIsupport.js8CallUDPAPICalls(self.settingValues.getNetworkSettingValue('serverip'),
                                                        int(self.settingValues.getNetworkSettingValue('serverport')))
        
        self.gpsOption = self.settingValues.getGPSHardwareSettingValue('option')
    
        self.gpsComPortVar = StringVar()
        self.gpsComPortSpeedVar = StringVar()
        
        self.gpsComPortSpeedVar = self.settingValues.getGPSHardwareSettingValue('gpsportspeed')
        self.gpsComPortVar = self.settingValues.getGPSHardwareSettingValue('gpscomport') 
        
        self.gpsOptionBeforeRefresh = self.gpsOption
        
        self.gpsl=None
        
        if self.gpsOption!="None":
            if self.gpsOption=='GPSD':
                self.gpsl = gpsdGPSListener.GpsListener( self.settingValues.getAppSettingValue('precision'),
                                                        self.showoutput
                                                        )
            else:
                self.gpsl = serialGPSlistener.GPSListener(self.settingValues.getGPSHardwareSettingValue('gpscomport'),
                                                        self.settingValues.getGPSHardwareSettingValue('gpsportspeed'),
                                                        self.settingValues.getAppSettingValue('precision'),
                                                        self.showoutput
                                                        )
        
            self.gpsl.start()

        self.geometry(str(WIDTH)+"x"+str(HEIGHT))
        self.title("JS8Call Utilities by M0IAX")
        
        self.gpsComPortVar = StringVar()
        self.gpsComPortSpeedVar = StringVar()
        self.maidPreceision = StringVar()
        self.autoTimeVar = StringVar()
        self.autoGridToJS8Call = IntVar()
        
        self.var1 = StringVar()
        self.var2 = StringVar()
        self.latlonvar = StringVar()
        
        #set default values
        self.gpsComPortVar.set(self.settingValues.getGPSHardwareSettingValue('gpscomport'))
        self.gpsComPortSpeedVar.set(self.settingValues.getGPSHardwareSettingValue('gpsportspeed'))
        self.maidPreceision.set(self.settingValues.getAppSettingValue('precision'))
        self.autoTimeVar.set(self.settingValues.getAppSettingValue('autotimeperiod'))
        self.autoGridToJS8Call.set(self.settingValues.getAppSettingValue('autoonatstart'))
        
        #Main window frame
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        
        self.frames = {}

        for F in (GPSPage, MessagePage, SettingsPage):
            frame = F(container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky='nsew')
            
        self.show_frame(GPSPage)

        bottomFrame=Frame(self)
        bottomFrame.pack()
                
        self.autocombo = Combobox(bottomFrame, state='readonly',width=45)
        self.autocombo.state='disabled'
        self.autocombo.bind('<<ComboboxSelected>>', self.autocomboChange)    
        self.autocombo['values']= ("Auto update JS8Call Grid", "Auto TX Grid to APRSIS", "Auto TX Grid to APRSIS and Update JS8Call Grid")
 
        self.autocombo.current(self.autooption) #set the selected item
        #self.autocombo.place(relx=0.05,rely=0.63, relwidth=0.9,relheight=0.1)
        self.autocombo.grid(row=0, column=0,sticky=W+E+N+S)
    
        self.autoGridToJS8Call = IntVar(value=self.autoatstart)
        self.autoGridCheck = Checkbutton(bottomFrame, text="Enable Auto update every "+str(self.timeinmins)+" mins.", variable=self.autoGridToJS8Call, command=self.cb)
        #self.autoGridCheck.place(relx=0.05,rely=0.71, relwidth=0.9,relheight=0.1)
        self.autoGridCheck.grid(row=1, column=0, sticky=W+E+N+S, padx=5, pady=5)

        if self.gpsOption=='None':
            self.autoGridCheck.configure(state='disabled')
            self.autoGridToJS8Call.set(0)
        else:
            self.autoGridCheck.configure(state='normal')
        
        self.timer=60 #Set timer to 60 for the first tx GPS should have a lock in that time
        self.timerStr = StringVar()
        
        self.timerStr.set("Timer Not Active")
        self.timerlabel = Label(bottomFrame, textvariable=self.timerStr )
        #self.timerlabel.place(relx=0.05,rely=0.81, relwidth=0.9,relheight=0.1)
        self.timerlabel.grid(row=2, column=0,sticky=W+E+N+S)
    
        buttonFrame=Frame(self)
        buttonFrame.pack()
        
        self.nav_buttons(buttonFrame, self)
        
        self.update_timer()
Exemplo n.º 3
0
            self.sendJS8CallALLCALLButton.configure(state='normal')
            self.ngrStr.set(ngr)
        else:
            self.setJS8CallGridButton.configure(state='disabled')
            self.sendJS8CallALLCALLButton.configure(state='disabled')
            self.ngrStr.set('No Fix')
            self.var1.set('No Fix')
        
        if gpsText=='JJ00aa00':
            self.ngrStr.set('No Fix')
    
        return gpsText
        
        

try:

    gpsl = gpsdGPSListener.GpsListener()
    gpsl.start()

    ui = UserInterface()
    
    gpsl.setReadGPS(False)
    
finally:
    gpsl.setReadGPS(False)
    gpsl.join()