[117] | 1 |
|
---|
| 2 | from mlx.gui.common import *
|
---|
| 3 |
|
---|
| 4 | from mlx.i18n import xstr
|
---|
| 5 | from mlx.checks import PayloadChecker
|
---|
| 6 |
|
---|
| 7 | #-------------------------------------------------------------------------------
|
---|
| 8 |
|
---|
[300] | 9 | ## @package mlx.gui.weighthelp
|
---|
| 10 | #
|
---|
| 11 | # The weight calculation help tab.
|
---|
| 12 | #
|
---|
| 13 | # This module implements the tab containing the weight calculation help.
|
---|
| 14 |
|
---|
| 15 | #-------------------------------------------------------------------------------
|
---|
| 16 |
|
---|
[117] | 17 | class WeightHelp(gtk.VBox):
|
---|
| 18 | """The weight calculation help tab."""
|
---|
| 19 | @staticmethod
|
---|
| 20 | def _getMarkup(value, expectedValue = None, tolerance = None):
|
---|
| 21 | """Get the markup for the given value.
|
---|
| 22 |
|
---|
| 23 | If it is too much different from the expected value, it will be
|
---|
| 24 | colored yellow (if within the tolerance), or red (if out of the tolerance)."""
|
---|
| 25 | markup = "%.0f" % (value,)
|
---|
| 26 | if expectedValue is not None and tolerance is not None:
|
---|
| 27 | colour = None
|
---|
| 28 | diff = abs(value - expectedValue)
|
---|
| 29 | if diff>tolerance: colour = "red"
|
---|
| 30 | elif (diff*10)>=tolerance: colour = "orange"
|
---|
| 31 | else: colour = "darkgreen"
|
---|
| 32 | if colour is not None:
|
---|
| 33 | markup = '<span foreground="' + colour + '">' + markup + '</span>'
|
---|
| 34 | return markup
|
---|
| 35 |
|
---|
| 36 | def __init__(self, gui):
|
---|
| 37 | """Construct the tab."""
|
---|
| 38 | super(WeightHelp, self).__init__()
|
---|
| 39 |
|
---|
| 40 | self._gui = gui
|
---|
| 41 |
|
---|
| 42 | mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 43 | xscale = 1.0, yscale = 1.0)
|
---|
| 44 | mainAlignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 45 | padding_left = 12, padding_right = 12)
|
---|
| 46 | self.add(mainAlignment)
|
---|
| 47 |
|
---|
| 48 | self._mainBox = mainBox = gtk.VBox()
|
---|
| 49 | mainAlignment.add(mainBox)
|
---|
| 50 |
|
---|
| 51 | self._usingHelp = gtk.CheckButton(xstr("weighthelp_usinghelp"))
|
---|
| 52 | self._usingHelp.set_use_underline(True)
|
---|
| 53 | self._usingHelp.set_tooltip_text(xstr("weighthelp_usinghelp_tooltip"))
|
---|
| 54 | self._usingHelp.connect("toggled", self._usingHelpToggled)
|
---|
| 55 | mainBox.pack_start(self._usingHelp, False, False, 4)
|
---|
| 56 |
|
---|
| 57 |
|
---|
[899] | 58 | self._weightsTable = table = gtk.Table(17, 5)
|
---|
[117] | 59 | table.set_homogeneous(False)
|
---|
| 60 | table.set_row_spacings(4)
|
---|
| 61 | table.set_col_spacings(16)
|
---|
| 62 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 63 | xscale = 0.0, yscale = 0.0)
|
---|
| 64 | alignment.add(table)
|
---|
| 65 | mainBox.pack_start(alignment, True, True, 4)
|
---|
| 66 |
|
---|
| 67 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.0,
|
---|
| 68 | xscale = 0.0, yscale = 0.0)
|
---|
| 69 | alignment.set_padding(padding_bottom = 16, padding_top = 0,
|
---|
| 70 | padding_left = 0, padding_right = 0)
|
---|
| 71 | label = gtk.Label(xstr("weighthelp_header_calculated"))
|
---|
| 72 | label.set_use_markup(True)
|
---|
| 73 | # FIXME: should be a constant in common
|
---|
| 74 | label.set_justify(gtk.Justification.CENTER if pygobject
|
---|
| 75 | else gtk.JUSTIFY_CENTER)
|
---|
| 76 | alignment.add(label)
|
---|
| 77 | table.attach(alignment, 1, 2, 0, 1)
|
---|
| 78 |
|
---|
| 79 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.0,
|
---|
| 80 | xscale = 0.0, yscale = 0.0)
|
---|
| 81 | alignment.set_padding(padding_bottom = 16, padding_top = 0,
|
---|
| 82 | padding_left = 0, padding_right = 0)
|
---|
| 83 | button = gtk.Button(xstr("weighthelp_header_simulator"))
|
---|
| 84 | button.set_tooltip_markup(xstr("weighthelp_header_simulator_tooltip"))
|
---|
| 85 | button.connect("clicked", self._fsButtonClicked)
|
---|
| 86 | label = button.get_child()
|
---|
| 87 | label.set_justify(gtk.Justification.CENTER if pygobject
|
---|
| 88 | else gtk.JUSTIFY_CENTER)
|
---|
| 89 | alignment.add(button)
|
---|
| 90 | table.attach(alignment, 3, 4, 0, 1)
|
---|
| 91 |
|
---|
| 92 |
|
---|
[899] | 93 | self._cockpitCrewLabel = \
|
---|
| 94 | gtk.Label(xstr("weighthelp_cockpit_crew") % ("99",))
|
---|
[117] | 95 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 96 | xscale = 0.0, yscale = 0.0)
|
---|
[899] | 97 | alignment.add(self._cockpitCrewLabel)
|
---|
[117] | 98 | table.attach(alignment, 0, 1, 1, 2)
|
---|
| 99 |
|
---|
[899] | 100 | self._cockpitCrewWeight = gtk.Label("0")
|
---|
[117] | 101 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 102 | xscale = 0.0, yscale = 0.0)
|
---|
[899] | 103 | alignment.add(self._cockpitCrewWeight)
|
---|
[117] | 104 | table.attach(alignment, 1, 2, 1, 2)
|
---|
| 105 |
|
---|
| 106 | table.attach(gtk.Label("kg"), 2, 3, 1, 2)
|
---|
| 107 |
|
---|
[899] | 108 | self._cabinCrewLabel = \
|
---|
| 109 | gtk.Label(xstr("weighthelp_cabin_crew") % ("99",))
|
---|
| 110 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 111 | xscale = 0.0, yscale = 0.0)
|
---|
| 112 | alignment.add(self._cabinCrewLabel)
|
---|
| 113 | table.attach(alignment, 0, 1, 2, 3)
|
---|
| 114 |
|
---|
| 115 | self._cabinCrewWeight = gtk.Label("0")
|
---|
| 116 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 117 | xscale = 0.0, yscale = 0.0)
|
---|
| 118 | alignment.add(self._cabinCrewWeight)
|
---|
| 119 | table.attach(alignment, 1, 2, 2, 3)
|
---|
| 120 |
|
---|
| 121 | table.attach(gtk.Label("kg"), 2, 3, 2, 3)
|
---|
| 122 |
|
---|
[117] | 123 | text = xstr("weighthelp_pax") % ("999",)
|
---|
| 124 | self._paxLabel = gtk.Label(text)
|
---|
| 125 | self._paxLabel.set_width_chars(len(text))
|
---|
| 126 | self._paxLabel.set_alignment(0.0, 0.5)
|
---|
| 127 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 128 | xscale = 0.0, yscale = 0.0)
|
---|
| 129 | alignment.add(self._paxLabel)
|
---|
[899] | 130 | table.attach(alignment, 0, 1, 3, 4)
|
---|
[117] | 131 |
|
---|
| 132 | self._paxWeight = gtk.Label("20000")
|
---|
| 133 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 134 | xscale = 0.0, yscale = 0.0)
|
---|
| 135 | alignment.add(self._paxWeight)
|
---|
[899] | 136 | table.attach(alignment, 1, 2, 3, 4)
|
---|
[117] | 137 |
|
---|
[899] | 138 | table.attach(gtk.Label("kg"), 2, 3, 3, 4)
|
---|
[117] | 139 |
|
---|
| 140 | label = gtk.Label(xstr("weighthelp_baggage"))
|
---|
| 141 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 142 | xscale = 0.0, yscale = 0.0)
|
---|
| 143 | alignment.add(label)
|
---|
[899] | 144 | table.attach(alignment, 0, 1, 4, 5)
|
---|
[117] | 145 |
|
---|
| 146 | self._bagWeight = gtk.Label("2000")
|
---|
| 147 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 148 | xscale = 0.0, yscale = 0.0)
|
---|
| 149 | alignment.add(self._bagWeight)
|
---|
[899] | 150 | table.attach(alignment, 1, 2, 4, 5)
|
---|
[117] | 151 |
|
---|
[899] | 152 | table.attach(gtk.Label("kg"), 2, 3, 4, 5)
|
---|
[117] | 153 |
|
---|
| 154 | label = gtk.Label(xstr("weighthelp_cargo"))
|
---|
| 155 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 156 | xscale = 0.0, yscale = 0.0)
|
---|
| 157 | alignment.add(label)
|
---|
[899] | 158 | table.attach(alignment, 0, 1, 5, 6)
|
---|
[117] | 159 |
|
---|
| 160 | self._cargoWeight = gtk.Label("2000")
|
---|
| 161 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 162 | xscale = 0.0, yscale = 0.0)
|
---|
| 163 | alignment.add(self._cargoWeight)
|
---|
[899] | 164 | table.attach(alignment, 1, 2, 5, 6)
|
---|
[117] | 165 |
|
---|
[899] | 166 | table.attach(gtk.Label("kg"), 2, 3, 5, 6)
|
---|
[117] | 167 |
|
---|
| 168 | label = gtk.Label(xstr("weighthelp_mail"))
|
---|
| 169 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 170 | xscale = 0.0, yscale = 0.0)
|
---|
| 171 | alignment.add(label)
|
---|
[899] | 172 | table.attach(alignment, 0, 1, 6, 7)
|
---|
[117] | 173 |
|
---|
| 174 | self._mailWeight = gtk.Label("2000")
|
---|
| 175 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 176 | xscale = 0.0, yscale = 0.0)
|
---|
| 177 | alignment.add(self._mailWeight)
|
---|
[899] | 178 | table.attach(alignment, 1, 2, 6, 7)
|
---|
[117] | 179 |
|
---|
[899] | 180 | table.attach(gtk.Label("kg"), 2, 3, 6, 7)
|
---|
[117] | 181 |
|
---|
[899] | 182 | table.attach(gtk.HSeparator(), 1, 2, 7, 8)
|
---|
[117] | 183 |
|
---|
| 184 | label = gtk.Label("<b>" + xstr("weighthelp_payload") + "</b>")
|
---|
| 185 | label.set_use_markup(True)
|
---|
| 186 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 187 | xscale = 0.0, yscale = 0.0)
|
---|
| 188 | alignment.add(label)
|
---|
| 189 | table.attach(alignment, 0, 1, 8, 9)
|
---|
| 190 |
|
---|
[899] | 191 | self._payload = gtk.Label("<b>32000</b>")
|
---|
| 192 | self._payload.set_use_markup(True)
|
---|
| 193 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 194 | xscale = 0.0, yscale = 0.0)
|
---|
| 195 | alignment.add(self._payload)
|
---|
| 196 | table.attach(alignment, 1, 2, 8, 9)
|
---|
| 197 |
|
---|
| 198 | table.attach(gtk.Label("kg"), 2, 3, 8, 9)
|
---|
| 199 |
|
---|
| 200 | self._fsPayload = gtk.Label("<b>32001</b>")
|
---|
| 201 | self._fsPayload.set_use_markup(True)
|
---|
| 202 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 203 | xscale = 0.0, yscale = 0.0)
|
---|
| 204 | alignment.add(self._fsPayload)
|
---|
| 205 | table.attach(alignment, 3, 4, 8, 9)
|
---|
| 206 |
|
---|
| 207 | table.attach(gtk.Label("kg"), 4, 5, 8, 9)
|
---|
| 208 |
|
---|
| 209 | label = gtk.Label(xstr("weighthelp_dow"))
|
---|
| 210 | label.set_use_markup(True)
|
---|
| 211 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 212 | xscale = 0.0, yscale = 0.0)
|
---|
| 213 | alignment.add(label)
|
---|
| 214 | table.attach(alignment, 0, 1, 9, 10)
|
---|
| 215 |
|
---|
[117] | 216 | self._dow = gtk.Label("35000")
|
---|
| 217 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 218 | xscale = 0.0, yscale = 0.0)
|
---|
| 219 | alignment.add(self._dow)
|
---|
[899] | 220 | table.attach(alignment, 1, 2, 9, 10)
|
---|
[117] | 221 |
|
---|
[899] | 222 | table.attach(gtk.Label("kg"), 2, 3, 9, 10)
|
---|
[117] | 223 |
|
---|
| 224 | self._fsDOW = gtk.Label("33012")
|
---|
| 225 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 226 | xscale = 0.0, yscale = 0.0)
|
---|
| 227 | alignment.add(self._fsDOW)
|
---|
[899] | 228 | table.attach(alignment, 3, 4, 9, 10)
|
---|
[117] | 229 |
|
---|
[899] | 230 | table.attach(gtk.Label("kg"), 4, 5, 9, 10)
|
---|
[117] | 231 |
|
---|
[899] | 232 | table.attach(gtk.HSeparator(), 1, 2, 10, 11)
|
---|
[117] | 233 |
|
---|
[899] | 234 | table.attach(gtk.HSeparator(), 3, 4, 10, 11)
|
---|
[117] | 235 |
|
---|
| 236 | label = gtk.Label("<b>" + xstr("weighthelp_zfw") + "</b>")
|
---|
| 237 | label.set_use_markup(True)
|
---|
| 238 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 239 | xscale = 0.0, yscale = 0.0)
|
---|
| 240 | alignment.add(label)
|
---|
[899] | 241 | table.attach(alignment, 0, 1, 11, 12)
|
---|
[117] | 242 |
|
---|
| 243 | self._zfw = gtk.Label("<b>122000</b>")
|
---|
| 244 | self._zfw.set_use_markup(True)
|
---|
| 245 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 246 | xscale = 0.0, yscale = 0.0)
|
---|
| 247 | alignment.add(self._zfw)
|
---|
[899] | 248 | table.attach(alignment, 1, 2, 11, 12)
|
---|
[117] | 249 |
|
---|
[899] | 250 | table.attach(gtk.Label("kg"), 2, 3, 11, 12)
|
---|
[117] | 251 |
|
---|
| 252 | self._fsZFW = gtk.Label("<b>124000</b>")
|
---|
| 253 | self._fsZFW.set_use_markup(True)
|
---|
| 254 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 255 | xscale = 0.0, yscale = 0.0)
|
---|
| 256 | alignment.add(self._fsZFW)
|
---|
[899] | 257 | table.attach(alignment, 3, 4, 11, 12)
|
---|
[117] | 258 |
|
---|
[899] | 259 | table.attach(gtk.Label("kg"), 4, 5, 11, 12)
|
---|
[117] | 260 |
|
---|
[899] | 261 | table.attach(gtk.HSeparator(), 0, 5, 12, 13)
|
---|
[117] | 262 |
|
---|
| 263 | label = gtk.Label(xstr("weighthelp_gross"))
|
---|
| 264 | label.set_use_markup(True)
|
---|
| 265 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 266 | xscale = 0.0, yscale = 0.0)
|
---|
| 267 | alignment.add(label)
|
---|
[899] | 268 | table.attach(alignment, 0, 1, 13, 14)
|
---|
[117] | 269 |
|
---|
| 270 | self._fsGross = gtk.Label("124000")
|
---|
| 271 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 272 | xscale = 0.0, yscale = 0.0)
|
---|
| 273 | alignment.add(self._fsGross)
|
---|
[899] | 274 | table.attach(alignment, 3, 4, 13, 14)
|
---|
[117] | 275 |
|
---|
[899] | 276 | table.attach(gtk.Label("kg"), 4, 5, 13, 14)
|
---|
[117] | 277 |
|
---|
| 278 | label = gtk.Label(xstr("weighthelp_mzfw"))
|
---|
| 279 | label.set_use_markup(True)
|
---|
| 280 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 281 | xscale = 0.0, yscale = 0.0)
|
---|
| 282 | alignment.add(label)
|
---|
[899] | 283 | table.attach(alignment, 0, 1, 14, 15)
|
---|
[117] | 284 |
|
---|
| 285 | self._mzfw = gtk.Label("35000")
|
---|
| 286 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 287 | xscale = 0.0, yscale = 0.0)
|
---|
| 288 | alignment.add(self._mzfw)
|
---|
[899] | 289 | table.attach(alignment, 1, 2, 14, 15)
|
---|
[117] | 290 |
|
---|
[899] | 291 | table.attach(gtk.Label("kg"), 2, 3, 14, 15)
|
---|
[117] | 292 |
|
---|
| 293 | label = gtk.Label(xstr("weighthelp_mtow"))
|
---|
| 294 | label.set_use_markup(True)
|
---|
| 295 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 296 | xscale = 0.0, yscale = 0.0)
|
---|
| 297 | alignment.add(label)
|
---|
[899] | 298 | table.attach(alignment, 0, 1, 15, 16)
|
---|
[117] | 299 |
|
---|
| 300 | self._mtow = gtk.Label("35000")
|
---|
| 301 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 302 | xscale = 0.0, yscale = 0.0)
|
---|
| 303 | alignment.add(self._mtow)
|
---|
[899] | 304 | table.attach(alignment, 1, 2, 15, 16)
|
---|
[117] | 305 |
|
---|
[899] | 306 | table.attach(gtk.Label("kg"), 2, 3, 15, 16)
|
---|
[117] | 307 |
|
---|
| 308 | label = gtk.Label(xstr("weighthelp_mlw"))
|
---|
| 309 | label.set_use_markup(True)
|
---|
| 310 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 311 | xscale = 0.0, yscale = 0.0)
|
---|
| 312 | alignment.add(label)
|
---|
[899] | 313 | table.attach(alignment, 0, 1, 16, 17)
|
---|
[117] | 314 |
|
---|
| 315 | self._mlw = gtk.Label("35000")
|
---|
| 316 | alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 317 | xscale = 0.0, yscale = 0.0)
|
---|
| 318 | alignment.add(self._mlw)
|
---|
[899] | 319 | table.attach(alignment, 1, 2, 16, 17)
|
---|
[117] | 320 |
|
---|
[899] | 321 | table.attach(gtk.Label("kg"), 2, 3, 16, 17)
|
---|
[117] | 322 |
|
---|
| 323 | self.show_all()
|
---|
| 324 |
|
---|
| 325 | def disable(self):
|
---|
| 326 | """Disable the widget."""
|
---|
| 327 | self._mainBox.set_sensitive(False)
|
---|
| 328 |
|
---|
| 329 | def enable(self):
|
---|
| 330 | """Enable the widget."""
|
---|
| 331 | self._mainBox.set_sensitive(True)
|
---|
| 332 |
|
---|
| 333 | def reset(self):
|
---|
| 334 | """Reset all calculated and FS data."""
|
---|
| 335 |
|
---|
| 336 | self._usingHelp.set_active(False)
|
---|
| 337 | self._usingHelp.set_sensitive(True)
|
---|
| 338 | self._weightsTable.set_sensitive(False)
|
---|
| 339 |
|
---|
[899] | 340 | self._cockpitCrew = -1
|
---|
| 341 | self._cabinCrew = -1
|
---|
[117] | 342 | self._pax = -1
|
---|
[899] | 343 | self._dowCockpit = 2
|
---|
| 344 | self._cockpitCrewMemberWeight = 85.0
|
---|
| 345 | self._dowCabin = 2
|
---|
| 346 | self._cabinCrewMemberWeight = 75.0
|
---|
| 347 | self._humanWeight = 84.0
|
---|
[117] | 348 | self._bag = -1
|
---|
| 349 | self._cargo = -1
|
---|
| 350 | self._mail = -1
|
---|
| 351 | self._dowValue = -1
|
---|
| 352 | self._mzfwValue = -1
|
---|
| 353 | self._mtowValue = -1
|
---|
| 354 | self._mlwValue = -1
|
---|
| 355 |
|
---|
| 356 | self._fsPayloadValue = -1
|
---|
| 357 | self._fsDOWValue = -1
|
---|
| 358 | self._fsZFWValue = -1
|
---|
| 359 | self._fsGrossValue = -1
|
---|
| 360 |
|
---|
| 361 | self._setupCalculated()
|
---|
| 362 | self._setupFS()
|
---|
| 363 |
|
---|
| 364 | def _setupCalculated(self):
|
---|
| 365 | """Setup the labels for the calculated values."""
|
---|
[899] | 366 | if self._cockpitCrew<0:
|
---|
| 367 | self._cockpitCrewLabel.set_text(xstr("weighthelp_cockpit_crew") % ("-",))
|
---|
| 368 | self._cockpitCrewWeight.set_text("-")
|
---|
[117] | 369 | else:
|
---|
[899] | 370 | self._cockpitCrewLabel.set_text(xstr("weighthelp_cockpit_crew") %
|
---|
| 371 | (str(self._cockpitCrew),))
|
---|
| 372 | crewWeight = (self._cockpitCrew - self._dowCockpit) * self._cockpitCrewMemberWeight
|
---|
| 373 | self._cockpitCrewWeight.set_text("%.0f" % (crewWeight,))
|
---|
| 374 |
|
---|
| 375 | if self._cabinCrew<0:
|
---|
| 376 | self._cabinCrewLabel.set_text(xstr("weighthelp_cabin_crew") % ("-",))
|
---|
| 377 | self._cabinCrewWeight.set_text("-")
|
---|
| 378 | else:
|
---|
| 379 | self._cabinCrewLabel.set_text(xstr("weighthelp_cabin_crew") %
|
---|
| 380 | (str(self._cabinCrew),))
|
---|
| 381 | crewWeight = (self._cabinCrew - self._dowCabin) * self._cabinCrewMemberWeight
|
---|
| 382 | self._cabinCrewWeight.set_text("%.0f" % (crewWeight,))
|
---|
[117] | 383 |
|
---|
| 384 | if self._pax<0:
|
---|
| 385 | self._paxLabel.set_text(xstr("weighthelp_pax") % ("-",))
|
---|
| 386 | self._paxWeight.set_text("-")
|
---|
| 387 | else:
|
---|
| 388 | self._paxLabel.set_text(xstr("weighthelp_pax") % (str(self._pax),))
|
---|
| 389 | paxWeight = self._pax * self._humanWeight
|
---|
| 390 | self._paxWeight.set_text("%.0f" % (paxWeight,))
|
---|
| 391 |
|
---|
| 392 | self._setWeightLabel(self._bagWeight, self._bag)
|
---|
| 393 |
|
---|
| 394 | self._setWeightLabel(self._cargoWeight, self._cargo)
|
---|
| 395 |
|
---|
| 396 | self._setWeightLabel(self._mailWeight, self._mail)
|
---|
| 397 |
|
---|
| 398 | (payload, zfw) = self._calculateWeights()
|
---|
| 399 |
|
---|
| 400 | self._setWeightLabel(self._payload, payload, bold = True)
|
---|
| 401 |
|
---|
| 402 | self._setWeightLabel(self._dow, self._dowValue)
|
---|
| 403 |
|
---|
| 404 | if zfw<0:
|
---|
| 405 | self._zfw.set_text("-")
|
---|
| 406 | else:
|
---|
| 407 | markup = "%.0f" % (zfw,)
|
---|
| 408 | if self._mzfwValue>0 and zfw>self._mzfwValue:
|
---|
| 409 | markup = '<span foreground="red">' + markup + '</span>'
|
---|
| 410 | markup = '<b>' + markup + '</b>'
|
---|
| 411 | self._zfw.set_markup(markup)
|
---|
| 412 |
|
---|
| 413 | self._setWeightLabel(self._mzfw, self._mzfwValue)
|
---|
| 414 |
|
---|
| 415 | self._setWeightLabel(self._mtow, self._mtowValue)
|
---|
| 416 |
|
---|
| 417 | self._setWeightLabel(self._mlw, self._mlwValue)
|
---|
| 418 |
|
---|
| 419 | def _setupFS(self):
|
---|
| 420 | if self._dowValue<0:
|
---|
| 421 | self._dow.set_text("-")
|
---|
| 422 | else:
|
---|
| 423 | self._dow.set_text("%.0f" % (self._dowValue,))
|
---|
| 424 |
|
---|
| 425 | """Setup the labels for the FS values."""
|
---|
| 426 | (payload, zfw) = self._calculateWeights()
|
---|
| 427 |
|
---|
| 428 | if self._fsPayloadValue<0:
|
---|
| 429 | self._fsPayload.set_text("-")
|
---|
| 430 | else:
|
---|
| 431 | markup = WeightHelp._getMarkup(self._fsPayloadValue, payload,
|
---|
| 432 | PayloadChecker.TOLERANCE)
|
---|
| 433 | self._fsPayload.set_markup("<b>" + markup + "</b>")
|
---|
| 434 |
|
---|
| 435 | if self._fsDOWValue<0:
|
---|
| 436 | self._fsDOW.set_text("-")
|
---|
| 437 | else:
|
---|
| 438 | markup = WeightHelp._getMarkup(self._fsDOWValue, self._dowValue,
|
---|
| 439 | PayloadChecker.TOLERANCE)
|
---|
| 440 | self._fsDOW.set_markup(markup)
|
---|
| 441 |
|
---|
| 442 | if self._fsZFWValue<0:
|
---|
| 443 | self._fsZFW.set_text("-")
|
---|
| 444 | else:
|
---|
| 445 | markup = WeightHelp._getMarkup(self._fsZFWValue, zfw,
|
---|
| 446 | PayloadChecker.TOLERANCE)
|
---|
| 447 | self._fsZFW.set_markup("<b>" + markup + "</b>")
|
---|
| 448 |
|
---|
| 449 | self._setWeightLabel(self._fsGross, self._fsGrossValue)
|
---|
| 450 |
|
---|
| 451 | def _calculateWeights(self):
|
---|
| 452 | """Calculate the payload and the zero-fuel weight.
|
---|
| 453 |
|
---|
| 454 | It returns a tuple with these two items. If any of the items cannot be
|
---|
| 455 | calculated, that is -1."""
|
---|
[899] | 456 | if self._cockpitCrew<0 or self._cabinCrew<0 or self._pax<0 or \
|
---|
[117] | 457 | self._bag<0 or self._cargo<0 or self._mail<0:
|
---|
| 458 | payload = -1
|
---|
| 459 | else:
|
---|
[899] | 460 | payload = \
|
---|
| 461 | (self._cockpitCrew - self._dowCockpit) * \
|
---|
| 462 | self._cockpitCrewMemberWeight + \
|
---|
| 463 | (self._cabinCrew - self._dowCabin) * \
|
---|
| 464 | self._cabinCrewMemberWeight + \
|
---|
| 465 | self._pax * self._humanWeight + \
|
---|
| 466 | self._bag + self._cargo + self._mail
|
---|
[117] | 467 |
|
---|
| 468 | if payload<0 or self._dowValue<0:
|
---|
| 469 | zfw = -1
|
---|
| 470 | else:
|
---|
| 471 | zfw = payload + self._dowValue
|
---|
| 472 |
|
---|
| 473 | return (payload, zfw)
|
---|
| 474 |
|
---|
| 475 | def _usingHelpToggled(self, button):
|
---|
| 476 | """Called when the Using help button is toggled."""
|
---|
| 477 | assert self._usingHelp.get_active()
|
---|
| 478 | self._usingHelp.set_sensitive(False)
|
---|
| 479 |
|
---|
| 480 | self._gui.logger.untimedMessage("The weight calculation help function was used by the pilot")
|
---|
| 481 |
|
---|
[899] | 482 | self._cockpitCrew = self._gui.numCockpitCrew
|
---|
| 483 | self._cabinCrew = self._gui.numCabinCrew
|
---|
[303] | 484 | self._pax = self._gui.numPassengers
|
---|
| 485 | self._bag = self._gui.bagWeight
|
---|
[117] | 486 | self._cargo = self._gui.cargoWeight
|
---|
[303] | 487 | self._mail = self._gui.mailWeight
|
---|
[117] | 488 |
|
---|
| 489 | aircraft = self._gui.flight.aircraft
|
---|
[899] | 490 | self._dowCockpit = aircraft.dowCockpit
|
---|
| 491 | self._cockpitCrewMemberWeight = aircraft.cockpitCrewWeight
|
---|
| 492 | self._dowCabin = aircraft.dowCabin
|
---|
| 493 | self._cabinCrewMemberWeight = aircraft.cabinCrewWeight
|
---|
[117] | 494 | self._humanWeight = aircraft.humanWeight
|
---|
| 495 | self._dowValue = aircraft.dow
|
---|
| 496 | self._mzfwValue = aircraft.mzfw
|
---|
| 497 | self._mtowValue = aircraft.mtow
|
---|
| 498 | self._mlwValue = aircraft.mlw
|
---|
| 499 |
|
---|
| 500 | self._setupCalculated()
|
---|
| 501 | self._weightsTable.set_sensitive(True)
|
---|
| 502 |
|
---|
| 503 | def _fsButtonClicked(self, button):
|
---|
| 504 | """Callback for the FS button being clicked."""
|
---|
| 505 | gui = self._gui
|
---|
| 506 | gui.beginBusy(xstr("weighthelp_busy"))
|
---|
| 507 | gui.simulator.requestWeights(self._handleWeights)
|
---|
| 508 |
|
---|
| 509 | def _handleWeights(self, dow, payload, zfw, grossWeight):
|
---|
| 510 | """Handle the given weights."""
|
---|
| 511 | gobject.idle_add(self._processWeights, dow, payload, zfw, grossWeight)
|
---|
| 512 |
|
---|
| 513 | def _processWeights(self, dow, payload, zfw, grossWeight):
|
---|
| 514 | """Process the given weights."""
|
---|
| 515 | self._gui.endBusy()
|
---|
| 516 | if self._usingHelp.get_active():
|
---|
| 517 | self._fsPayloadValue = payload
|
---|
| 518 | self._fsDOWValue = dow
|
---|
| 519 | self._fsZFWValue = zfw
|
---|
| 520 | self._fsGrossValue = grossWeight
|
---|
| 521 | self._setupFS()
|
---|
| 522 |
|
---|
| 523 | def _setWeightLabel(self, label, weight, bold = False):
|
---|
| 524 | """Set the given weight label to the given weight."""
|
---|
| 525 | if weight<0:
|
---|
| 526 | label.set_text("-")
|
---|
| 527 | else:
|
---|
| 528 | markup = "%.0f" % (weight,)
|
---|
| 529 | if bold: markup = "<b>" + markup + "</b>"
|
---|
| 530 | label.set_markup(markup)
|
---|
| 531 |
|
---|
| 532 |
|
---|