Esempio n. 1
0
 def data(self, index, role):
     row = index.row()
     col = index.column()
     if col == 0:  # RWY name
         if role == Qt.DisplayRole:
             return self.runways[row].name
     elif col == 1:  # DEP tick box
         if role == Qt.CheckStateRole:
             return Qt.Checked if self.deplst[row] else Qt.Unchecked
     elif col == 2:  # ARR tick box
         if role == Qt.CheckStateRole:
             return Qt.Checked if self.arrlst[row] else Qt.Unchecked
     elif col == 3:  # Wind stuff
         rwy = self.runways[row]
         wind_diff = env.RWD(rwy.orientation().opposite())
         if role == Qt.DisplayRole:
             return '' if wind_diff == None else '%+d°' % wind_diff
         elif role == Qt.DecorationRole:
             w = env.primaryWeather()
             if wind_diff == None and w != None and w.mainWind() != None:
                 wind_diff = 0  # allows a green icon for VRB wind
             if wind_diff != None:
                 k = 255 / 90 * abs(wind_diff)
                 red = min(221, k)
                 green = min(221, 510 - k)
                 return coloured_square_icon(QColor(red, green, 0),
                                             width=24)
Esempio n. 2
0
 def updateLocalAnalysis(self):
     qnh = env.QNH(noneSafe=False)
     if qnh == None:
         self.transitionLevel_info.setText('N/A')
         self.QFE_info.setText('N/A')
     else:
         self.transitionLevel_info.setText('FL%03d' % env.transitionLevel())
         if env.airport_data == None:
             self.QFE_info.setText('N/A')
         else:
             qfe = env.QFE(qnh)
             self.QFE_info.setText('%d hPa, %.2f inHg' %
                                   (qfe, hPa2inHg * qfe))
     w = env.primaryWeather()
     main_wind = None if w == None else w.mainWind()
     if env.airport_data == None or main_wind == None:  # no runways or wind info
         self.rwyPref_info.setText('N/A')
     elif main_wind[0] == None:  # no predominant heading
         self.rwyPref_info.setText('any')
     else:
         difflst = [(rwy.name, abs(env.RWD(rwy.orientation().opposite())))
                    for rwy in env.airport_data.allRunways()]
         preflst = sorted([pair for pair in difflst if pair[1] <= 90],
                          key=(lambda pair: pair[1]))
         self.rwyPref_info.setText(', '.join(pair[0] for pair in preflst))
Esempio n. 3
0
 def updateDisplays(self):
     self.selectedStationWeather_groupBox.setTitle(
         settings.primary_METAR_station)
     self.selectedStation_widget.updateDisp(env.primaryWeather())
     self.updateLocalAnalysis()
     for i, ams in enumerate(settings.additional_METAR_stations):
         self.additionalStations_tabs.widget(i).updateDisp(
             settings.session_manager.getWeather(ams))
Esempio n. 4
0
	def ensureClearWeather(self, toggle):
		settings.TWR_view_clear_weather_cheat = toggle
		if toggle:
			weather = mkWeather(settings.location_code) # clear weather with location code as station
			settings.controlled_tower_viewer.setWeather(weather)
		else:
			weather = env.primaryWeather()
			if weather != None:
				settings.controlled_tower_viewer.setWeather(weather)
def rnd_rwy(choose_from, condition):
    '''
	Picks a runway from the first arg list (or any by wind if empty), satisfying the given condition.
	'''
    if choose_from == []:  # Choose any from current wind
        w = env.primaryWeather()
        main_wind = w.mainWind() if w != None else None
        main_wind_hdg = main_wind[0] if main_wind != None else Heading(
            360, True)
        choose_from = [
            rwy for rwy in env.airport_data.allRunways()
            if abs(main_wind_hdg.diff(rwy.orientation())) <= 90
        ]
    choose_from = [rwy for rwy in choose_from if condition(rwy)]
    return None if choose_from == [] else choice(choose_from)
Esempio n. 6
0
def text_alias_replacement(text_alias, current_selection):
    alias = text_alias.lower()
    weather = env.primaryWeather()
    ## Check for general alias
    if alias == 'ad':
        noNone(env.airport_data)
        return env.locationName()
    elif alias == 'atis':
        return noNone(settings.last_ATIS_recorded)
    elif alias == 'decl':
        return noNone(env.readDeclination())
    elif alias == 'elev':
        return '%d ft' % noNone(env.airport_data).field_elevation
    elif alias == 'frq':
        return str(noNone(settings.publicised_frequency))
    elif alias == 'icao':
        return settings.location_code
    elif alias == 'me':
        return settings.session_manager.myCallsign()
    elif alias == 'metar':
        return noNone(weather).METAR()
    elif alias == 'qfe':
        noNone(env.airport_data)
        return '%d' % env.QFE(noNone(env.QNH(noneSafe=False)))
    elif alias == 'qnh':
        return '%d' % noNone(env.QNH(noneSafe=False))
    elif alias == 'qnhg':
        return '%.2f' % (hPa2inHg * noNone(env.QNH(noneSafe=False)))
    elif alias == 'runways':
        noNone(env.airport_data)
        return env.readRunwaysInUse()
    elif alias == 'rwyarr':
        rwys = [
            rwy.name for rwy in noNone(env.airport_data).allRunways()
            if rwy.use_for_arrivals
        ]
        if rwys == []:
            raise ValueError('No RWY marked for arrival')
        return ', '.join(rwys)
    elif alias == 'rwydep':
        rwys = [
            rwy.name for rwy in noNone(env.airport_data).allRunways()
            if rwy.use_for_departures
        ]
        if rwys == []:
            raise ValueError('No RWY marked for departure')
        return ', '.join(rwys)
    elif alias == 'ta':
        return '%d ft' % env.transitionAltitude()
    elif alias == 'tl':
        noNone(env.QNH(noneSafe=False))
        return 'FL%03d' % env.transitionLevel()
    elif alias == 'utc':
        return timestr()
    elif alias == 'vis':
        return noNone(weather).readVisibility()
    elif alias == 'wind':
        return noNone(weather).readWind()
    else:  # Check for selection-dependant alias
        strip = current_selection.strip
        acft = current_selection.acft
        if alias == 'cralt':
            return noNone(noNone(strip).lookup(FPL.CRUISE_ALT, fpl=True))
        elif alias == 'dest':
            return noNone(noNone(strip).lookup(FPL.ICAO_ARR, fpl=True))
        elif alias == 'dist':
            coords = noNone(acft).coords()
            return dist_str(
                noNone(
                    env.airport_data).navpoint.coordinates.distanceTo(coords))
        elif alias == 'nseq':
            return str(env.strips.stripSequenceNumber(noNone(
                strip)))  # rightly fails with ValueError if strip is loose
        elif alias == 'qdm':
            coords = noNone(acft).coords()
            return coords.headingTo(
                noNone(env.airport_data).navpoint.coordinates).read()
        elif alias == 'rack':
            return noNone(noNone(strip).lookup(rack_detail))
        elif alias == 'route':
            return noNone(noNone(strip).lookup(FPL.ROUTE, fpl=True))
        elif alias == 'rwy':
            box = noNone(noNone(strip).lookup(runway_box_detail))
            return env.airport_data.physicalRunwayNameFromUse(
                box)  # code unreachable if env.airport_data == None
        elif alias == 'sq':
            sq = noNone(strip).lookup(assigned_SQ_detail)
            return '%04o' % noNone(sq)
        elif alias == 'valt':
            valt = noNone(strip).lookup(assigned_altitude_detail)
            return noNone(valt)  # valt is a "reading"
        elif alias == 'vhdg':
            vhdg = noNone(strip).lookup(assigned_heading_detail)
            return noNone(vhdg).read()
        elif alias == 'vspd':
            vspd = noNone(strip).lookup(assigned_speed_detail)
            return str(noNone(vspd))
        elif alias == 'wpnext':
            coords = noNone(acft).coords()
            route = noNone(strip).lookup(parsed_route_detail)
            return str(noNone(route).currentWaypoint(coords))
        elif alias == 'wpsid':
            route = noNone(strip).lookup(parsed_route_detail)
            return noNone(noNone(route).SID())
        elif alias == 'wpstar':
            route = noNone(strip).lookup(parsed_route_detail)
            return noNone(noNone(route).STAR())
        else:
            ## Check for custom alias, in order: general notes, location-specific notes, selected strip comments
            try:
                return custom_alias_search(alias, settings.general_notes)
            except ValueError:
                try:
                    return custom_alias_search(alias, settings.local_notes)
                except ValueError:
                    comments = noNone(noNone(strip).lookup(FPL.COMMENTS))
                    return custom_alias_search(alias, comments)