def set_mass_of_payload(value=0.0):
    data = database.read_structures_specifications()
    try:
        data[mass_of_payload] = value
        database.write_structures_specification(data)
    except Exception as e:
        logging.error(e)
        data.update({mass_of_payload: value})
        database.write_structures_specification(data)
def set_maximum_takeoff_weight(value=0.0):
    data = database.read_structures_specifications()
    try:
        data[maximum_takeoff_weight] = value
        database.write_aircraft_specification(data)
    except Exception as e:
        logging.error(e)
        data.update({maximum_takeoff_weight: value})
        database.write_structures_specification(data)
def set_mass_of_fuselage(value=0.0):
    data = database.read_structures_specifications()
    try:
        data[mass_of_fuselage] = value
        database.write_aircraft_specification(data)
    except Exception as e:
        logging.error(e)
        data.update({mass_of_fuselage: value})
        database.write_structures_specification(data)
def get_moments_of_inertia():
    try:
        value = database.read_structures_specifications()[moments_of_inertia]
        return value
    except Exception as e:
        dialog = QMessageBox()
        dialog.setIcon(QMessageBox.Warning)
        dialog.setText(f"{e.__str__()}")
        dialog.addButton(QMessageBox.Ok)
        dialog.exec()
def get_center_of_mass():

    try:
        value = database.read_structures_specifications()[center_of_gravity]
        return value
    except:
        dialog = QMessageBox()
        dialog.setIcon(QMessageBox.Warning)
        dialog.setText(f"{e.__str__()}")
        dialog.addButton(QMessageBox.Ok)
        dialog.exec()
def set_moments_of_inertia(value=None):
    if value is None:
        value = {}
    data = database.read_structures_specifications()
    try:
        data[moments_of_inertia].update(value)
        database.write_structures_specification(data)
    except Exception as e:
        logging.error(e)
        data.update({moments_of_inertia: value})
        database.write_structures_specification(data)
def set_center_of_mass(value=None):
    if value is None:
        value = {}
    data = database.read_structures_specifications()
    try:
        data[center_of_gravity].update(value)
        database.write_structures_specification(data)
    except Exception as e:
        logging.error(e)
        data.update({center_of_gravity: value})
        database.write_structures_specification(data)
def set_mass_of_engine_or_motor(value=None):
    if value is None:
        value = {}
    data = database.read_structures_specifications()
    try:
        data[mass_of_engine_or_motor].update(value)
        database.write_structures_specification(data)
    except Exception as e:
        logging.error(e)
        data.update({mass_of_battery_or_fuel: value})
        database.write_structures_specification(
            {mass_of_engine_or_motor: value})
def get_structures_specifications():
    value = database.read_structures_specifications()

    mass_of_battery_or_fuel_ = value[mass_of_battery_or_fuel]

    maximum_takeoff_weight_ = value[maximum_takeoff_weight]

    mass_of_payload_ = value[mass_of_payload]

    mass_of_engine_or_motor_ = value[mass_of_engine_or_motor]
    return mass_of_battery_or_fuel_,\
           mass_of_engine_or_motor_,\
           maximum_takeoff_weight_, \
           mass_of_payload_, \
def exportValues():
    output = ""
    for major_key in database.read_datcom_stability_specifications().keys():
        for key in database.read_datcom_stability_specifications(
        )[major_key].keys():
            alpha_, velocity_, y = read_datcom_table_data(type_=datcom_data,
                                                          major_key=major_key,
                                                          key=key)
            try:
                value = y[alpha_.index(0)]
            except:
                value = 0
            output = output + f"{key}:{value},"
    for key, value in database.read_propulsion_specifications(
    )["propulsion_dialogs"].items():
        output = output + f"{key}:{value},"
    for key, value in database.read_structures_specifications().items():
        try:
            for k, v in value.items():
                output = output + f"{k}:{v},"
        except:
            output = output + f"{key}:{value},"
    writeTxt(sim_export_txt_dir, output)
def get_mass_of_engine_or_motor():
    return database.read_structures_specifications()[mass_of_engine_or_motor]
def get_mass_of_battery_or_fuel():
    return database.read_structures_specifications()[mass_of_battery_or_fuel]
def get_maximum_takeoff_weight():
    return database.read_structures_specifications()[maximum_takeoff_weight]
def get_mass_of_fuselage():
    return database.read_structures_specifications()[mass_of_fuselage]
def get_mass_of_wing():
    return database.read_structures_specifications()[mass_of_wing]
def get_mass_of_payload():
    return database.read_structures_specifications()[mass_of_payload]