def add_gateway(self, gateway, gateway_name=None): """创建接口""" if gateway_name not in self.gateways: self.gateways[gateway_name] = gateway(self, gateway_name)
def __init__(self): self.CurrentWindow = None self.CurrentParent = None self.LatestLoRaSentence = None self.LatestLoRaPacketHeader = None self.LatestLoRaValues = None self.LatestRTTYSentence = None self.LatestRTTYValues = None self.LatestHABValues = None self.SelectedSSDVIndex = 0 self.LoRaFrequencyError = 0 self.CurrentGPSPosition = None self.SettingsEditBox = None #self.GladeFile = resource_filename('habgui', # 'habgui.glade') self.GladeFile = '/home/pi/habgui/habgui.glade' self.builder = Gtk.Builder() self.builder.add_from_file(self.GladeFile) self.builder.connect_signals(self) self.windowMain = self.builder.get_object("windowMain") self.frameMain = self.builder.get_object("frameMain") self.frameDefault = self.builder.get_object("frameDefault") ## Screens self.HABScreen = HABScreen(self.builder) self.LoRaScreen = LoRaScreen(self.builder) self.RTTYScreen = RTTYScreen(self.builder) self.GPSScreen = GPSScreen(self.builder) self.SSDVScreen = SSDVScreen(self.builder) self.frameSettings = self.builder.get_object("frameSettings") ## Default window self.SetNewWindow(self.frameDefault) ## Set windowsize to match display ScreenInfo = Gdk.Screen.get_default() ScreenWidth = ScreenInfo.get_width() ScreenHeight = ScreenInfo.get_height() self.windowMain.resize(min(ScreenWidth, 800), min(ScreenHeight, 414)) # If this is the official touchscreen or smaller, position at top-left if (ScreenWidth <= 800) or (ScreenHeight <= 480): self.windowMain.move(0, 0) else: self.windowMain.move(100, 100) self.windowMain.show_all() self.PositionDlFldigi() # Read config file self.ConfigFileName = os.path.join(os.environ['HOME'], '.config/habgui.ini') self.LoadSettingsFromFile(self.ConfigFileName) # Show current settings self.LoRaScreen.ShowLoRaFrequencyAndMode(self.LoRaFrequency, self.LoRaMode) self.RTTYScreen.ShowRTTYFrequency(self.RTTYFrequency) # Timer for updating UI GObject.timeout_add_seconds(1, self.ssdv_update_timer) # Gateway self.gateway = gateway(CarID=self.ChaseCarID, CarPeriod=30, CarEnabled=self.ChaseCarEnabled, RadioCallsign=self.ReceiverCallsign, LoRaChannel=1, LoRaFrequency=self.LoRaFrequency, LoRaMode=self.LoRaMode, EnableLoRaUpload=self.EnableLoRaUpload, RTTYFrequency=self.RTTYFrequency, OnNewGPSPosition=self._NewGPSPosition, OnNewRTTYData=self._NewRTTYData, OnNewRTTYSentence=self._NewRTTYSentence, OnNewLoRaSentence=self._NewLoRaSentence, OnNewLoRaSSDV=self._NewLoRaSSDV, OnLoRaFrequencyError=self._LoRaFrequencyError, GPSDevice=self.GPSDevice) if self.gateway.gps.IsOpen: self.GPSScreen.ShowPortStatus("OK") else: self.GPSScreen.ShowPortStatus("Failed to open GPS device " + self.GPSDevice) self.gateway.run()