Ejemplo n.º 1
0
    def load_performance(self):
        """
        Gets a filename for a JSON file specifying aircraft performance and initializes an SimpleAircraft model.
        """
        filename = get_open_filename(self,
                                     "Open Aircraft Performance JSON File",
                                     constants.MSS_CONFIG_PATH,
                                     "Performance File (*.json)",
                                     pickertag="filepicker_default")
        if filename is not None:
            try:
                performance = config_loader(config_file=filename)
                self.aircraft = aircrafts.SimpleAircraft(performance)
                self.lbAircraftName.setText(self.aircraft.name)
                self.dsbTakeoffWeight.setValue(self.aircraft.takeoff_weight)
                self.dsbFuel.setValue(self.aircraft.fuel)

            except KeyError as ex:
                QtWidgets.QMessageBox.critical(
                    self, self.tr("Performance JSON Load"),
                    self.tr("JSON File missing '{}' entry".format(ex)))
            except (FatalUserError, ValueError) as ex:
                QtWidgets.QMessageBox.critical(
                    self, self.tr("Performance JSON Load"),
                    self.tr("JSON File has Syntax Problems:\n{}".format(ex)))
Ejemplo n.º 2
0
    def load_performance(self):
        """
        Gets a filename for a JSON file specifying aircraft performance and initializes an SimpleAircraft model.
        """
        filename = get_open_filename(self,
                                     "Open Aircraft Performance JSON File",
                                     constants.MSS_CONFIG_PATH,
                                     "Performance File (*.json)",
                                     pickertag="filepicker_default")
        if filename is not None:
            try:
                performance = config_loader(config_file=filename)
                self.aircraft = aircrafts.SimpleAircraft(performance)
                self.lbAircraftName.setText(self.aircraft.name)
                self.dsbTakeoffWeight.setValue(self.aircraft.takeoff_weight)
                if not any(
                        hasattr(self.aircraft, _x)
                        for _x in ("fuel", "empty_weight")):
                    raise KeyError("empty_weight")
                if hasattr(self.aircraft, "empty_weight"):
                    self.dsbEmptyWeight.setValue(self.aircraft.empty_weight)
                else:
                    self.dsbEmptyWeight.setValue(self.aircraft.takeoff_weight -
                                                 self.aircraft.fuel)

                self.update_parent_performance()

            except KeyError as ex:
                QtWidgets.QMessageBox.critical(
                    self, self.tr("Performance JSON Load"),
                    self.tr(f"JSON File missing '{ex}' entry"))
            except (FatalUserError, ValueError) as ex:
                QtWidgets.QMessageBox.critical(
                    self, self.tr("Performance JSON Load"),
                    self.tr(f"JSON File has Syntax Problems:\n{ex}"))
Ejemplo n.º 3
0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""

from mslib.msui.mss_qt import get_open_filename
from PyQt5 import QtCore, QtWidgets
from mslib.utils import config_loader, FatalUserError
from mslib.msui import aircrafts
from mslib.msui import constants
from mslib.msui.mss_qt import ui_performance_settings as ui_ps

DEFAULT_PERFORMANCE = {
    "aircraft": aircrafts.SimpleAircraft(aircrafts.AIRCRAFT_DUMMY),
    "visible": False,
    "takeoff_weight": 0,
    "takeoff_time": QtCore.QDateTime.currentDateTimeUtc(),
    "fuel": 0,
    "ceiling_alt": [410],
}


class MSS_PerformanceSettingsDialog(QtWidgets.QDialog,
                                    ui_ps.Ui_PerformanceSettingsDialog):
    """Dialog to set map appearance parameters. User interface is
       defined in "ui_topview_mapappearance.py".
    """
    def __init__(self, parent=None, settings_dict=None):
        """