Changeset 619:7763179ff6b0
- Timestamp:
- 03/29/15 12:10:53 (10 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r612 r619 1 1 2 2 import const 3 import gates 3 4 import checks 4 5 import fs … … 620 621 gateList = "" 621 622 occupiedGateNumbers = fleet.getOccupiedGateNumbers() 622 for gate Number in const.lhbpGateNumbers:623 if gate Number not in occupiedGateNumbers:623 for gate in gates.lhbpGates.gates: 624 if gate.isAvailable(gates.lhbpGates, occupiedGateNumbers): 624 625 if gateList: gateList += ", " 625 gateList += gate Number626 gateList += gate.number 626 627 fs.sendMessage(const.MESSAGETYPE_GATE_SYSTEM, 627 628 "Free gates: " + gateList, 20) -
src/mlx/const.py
r618 r619 471 471 #------------------------------------------------------------------------------- 472 472 473 ## The available gates at LHBP474 lhbpGateNumbers = []475 476 for i in range(1, 7):477 lhbpGateNumbers.append(str(i))478 479 for i in range(10, 19):480 lhbpGateNumbers.append(str(i))481 482 for i in range(24, 28):483 lhbpGateNumbers.append(str(i))484 485 for i in range(31, 39):486 lhbpGateNumbers.append(str(i))487 488 for i in range(42, 47):489 lhbpGateNumbers.append(str(i))490 491 for i in range(60, 84):492 if i!=70 and i!=80:493 lhbpGateNumbers.append(str(i))494 495 #-------------------------------------------------------------------------------496 497 473 languages = ["$system", "en_GB", "hu_HU"] 498 474 -
src/mlx/gates.py
r618 r619 1 #-------------------------------------------------------------------------------------- 2 3 ## @package mlx.gates 4 # 5 # The module to handle the LHBP gate information. 6 # 7 8 #-------------------------------------------------------------------------------------- 9 10 class Gate(object): 11 """Information about a gate.""" 12 def __init__(self, number, terminal, type, 13 availableFn = None): 14 """Construct the gate with the given information. 15 16 number is the gate's number as a string (as it can contain letters). 17 terminal is the terminal the gate belongs to (not used currently). 18 type is the gate's type: G for gate, S for stand. 19 availableFn is a function that can determine if the gate is available based on 20 the statuses of other gates. Its arguments are: 21 - a collection of the gates, and 22 - a set of occupied gate numbers.""" 23 self._number = number 24 self._terminal = terminal 25 self._type = type 26 self._availableFn = availableFn 27 28 @property 29 def number(self): 30 """Get the number of the gate.""" 31 return self._number 32 33 def isAvailable(self, gates, occupiedGateNumbers): 34 """Determine if this gate is available given the set of gates and 35 occupied gate numbers.""" 36 if self._number in occupiedGateNumbers: 37 return False 38 return True if self._availableFn is None else \ 39 self._availableFn(gates, occupiedGateNumbers) 40 41 #-------------------------------------------------------------------------------------- 42 43 class Gates(object): 44 """A collection of gates.""" 45 # Display info type: a gate (number) 46 DISPLAY_GATE=1 47 48 # Display info type: a space 49 DISPLAY_SPACE=2 50 51 # Display info type: a new column 52 DISPLAY_NEW_COLUMN=3 53 54 def __init__(self): 55 """Construct the gate collection.""" 56 self._gates = [] 57 self._displayInfos = [] 58 self._numColumns = 1 59 self._numRows = 0 60 self._numRowsInColumn = 0 61 62 @property 63 def gates(self): 64 """Get an iterator over the gates.""" 65 return iter(self._gates) 66 67 @property 68 def displayInfos(self): 69 """Get an iterator over the display info tuples. 70 71 Each tuple consists of 72 - a type (one of the DISPLAY_XXX constants), and 73 - an additional data (the gate for DISPLAY_GATE, None for others).""" 74 return iter(self._displayInfos) 75 76 @property 77 def numRows(self): 78 """Get the number of rows.""" 79 return self._numRows 80 81 @property 82 def numColumns(self): 83 """Get the number of columns.""" 84 return self._numColumns 85 86 def add(self, gate): 87 """Add a gate to the collection.""" 88 self._gates.append(gate) 89 self._displayInfos.append((Gates.DISPLAY_GATE, gate)) 90 self._addRow() 91 92 def addSpace(self): 93 """Add a space between subsequent gates.""" 94 self._displayInfos.append((Gates.DISPLAY_SPACE, None)) 95 self._addRow() 96 97 def addNewColumn(self): 98 """Start a new column of gates.""" 99 self._displayInfos.append((Gates.DISPLAY_NEW_COLUMN, None)) 100 self._numRowsInColumn = 0 101 self._numColumns += 1 102 103 def _addRow(self): 104 """Add a new row.""" 105 self._numRowsInColumn += 1 106 if self._numRowsInColumn > self._numRows: 107 self._numRows = self._numRowsInColumn 108 109 #-------------------------------------------------------------------------------------- 110 111 def availableIf(occupiedGateNumbers, othersAvailable = []): 112 """Determine if a gate is available. 113 114 othersAvailable is a list of numbers of gates, that must be available so 115 that the one we are considering is available.""" 116 for otherNumber in othersAvailable: 117 if otherNumber in occupiedGateNumbers: 118 return False 119 return True 120 121 #-------------------------------------------------------------------------------------- 122 123 def getAvilableIf(othersAvailable = []): 124 """Get a function that determines if a gate is available based on the 125 statuses of other gates.""" 126 return lambda gates, occupiedGateNumbers: availableIf(occupiedGateNumbers, 127 othersAvailable = 128 othersAvailable) 129 130 #-------------------------------------------------------------------------------------- 131 132 # The gates at LHBP 133 lhbpGates = Gates() 134 135 lhbpGates.add(Gate("1", "1", "S")) 136 lhbpGates.add(Gate("2", "1", "S")) 137 lhbpGates.add(Gate("3", "1", "S")) 138 lhbpGates.add(Gate("4", "1", "S")) 139 lhbpGates.add(Gate("5", "1", "S")) 140 lhbpGates.add(Gate("6", "1", "S")) 141 lhbpGates.add(Gate("25", "1", "S")) 142 lhbpGates.add(Gate("26", "1", "S")) 143 lhbpGates.add(Gate("27", "1", "S")) 144 lhbpGates.addSpace() 145 146 lhbpGates.add(Gate("31", "2B", "G")) 147 lhbpGates.add(Gate("32", "2B", "G")) 148 lhbpGates.add(Gate("33", "2B", "G")) 149 lhbpGates.addNewColumn() 150 151 lhbpGates.add(Gate("34", "2B", "G")) 152 lhbpGates.add(Gate("35", "2B", "G")) 153 lhbpGates.add(Gate("36", "2B", "G")) 154 lhbpGates.add(Gate("37", "2B", "G")) 155 lhbpGates.add(Gate("38", "2B", "G")) 156 lhbpGates.add(Gate("39", "2B", "G")) 157 lhbpGates.addSpace() 158 159 lhbpGates.add(Gate("42", "2A", "G")) 160 lhbpGates.add(Gate("43", "2A", "G")) 161 lhbpGates.add(Gate("44", "2A", "G")) 162 lhbpGates.add(Gate("45", "2A", "G")) 163 lhbpGates.addNewColumn() 164 165 lhbpGates.add(Gate("107", "1", "S")) 166 lhbpGates.add(Gate("108", "1", "S")) 167 lhbpGates.add(Gate("109", "1", "S")) 168 lhbpGates.add(Gate("R110", "1", "S", 169 availableFn = getAvilableIf(othersAvailable = ["R111"]))) 170 lhbpGates.add(Gate("R111", "1", "S", 171 availableFn = getAvilableIf(othersAvailable = ["R110", "R112"]))) 172 lhbpGates.add(Gate("R112", "1", "S", 173 availableFn = getAvilableIf(othersAvailable = ["R111"]))) 174 lhbpGates.add(Gate("R113", "1", "S", 175 availableFn = getAvilableIf(othersAvailable = ["R114"]))) 176 lhbpGates.add(Gate("R114", "1", "S", 177 availableFn = getAvilableIf(othersAvailable = ["R113"]))) 178 lhbpGates.add(Gate("R115", "1", "S")) 179 lhbpGates.add(Gate("R116", "1", "S")) 180 lhbpGates.add(Gate("R117", "1", "S")) 181 lhbpGates.addNewColumn() 182 183 lhbpGates.add(Gate("R210", "2A", "S", 184 availableFn = getAvilableIf(othersAvailable = ["R212A"]))) 185 lhbpGates.add(Gate("R211", "2A", "S", 186 availableFn = getAvilableIf(othersAvailable = ["R212A"]))) 187 lhbpGates.add(Gate("R212", "2A", "S", 188 availableFn = getAvilableIf(othersAvailable = ["R212A"]))) 189 lhbpGates.add(Gate("R212A", "2A", "S", 190 availableFn = getAvilableIf(othersAvailable = ["R210", "R211", "R212"]))) 191 lhbpGates.addSpace() 192 193 lhbpGates.add(Gate("R220", "2B", "S")) 194 lhbpGates.add(Gate("R221", "2B", "S")) 195 lhbpGates.add(Gate("R222", "2B", "S")) 196 lhbpGates.add(Gate("R223", "2B", "S")) 197 lhbpGates.addSpace() 198 199 lhbpGates.add(Gate("R224", "2A", "R")) 200 lhbpGates.add(Gate("R225", "2A", "S")) 201 lhbpGates.add(Gate("R226", "2A", "S")) 202 lhbpGates.add(Gate("R227", "2A", "S")) 203 lhbpGates.addNewColumn() 204 205 lhbpGates.add(Gate("R270", "2A", "S")) 206 lhbpGates.add(Gate("R271", "2A", "S")) 207 lhbpGates.add(Gate("R272", "2A", "S")) 208 lhbpGates.add(Gate("R274", "2A", "S")) 209 lhbpGates.add(Gate("R275", "2A", "S")) 210 lhbpGates.add(Gate("R276", "2A", "S")) 211 lhbpGates.add(Gate("R277", "2A", "S")) 212 lhbpGates.add(Gate("R278", "2A", "S", 213 availableFn = getAvilableIf(othersAvailable = ["R278A"]))) 214 lhbpGates.add(Gate("R278A", "2A", "S", 215 availableFn = getAvilableIf(othersAvailable = ["R278", "R279"]))) 216 lhbpGates.add(Gate("R279", "2A", "S", 217 availableFn = getAvilableIf(othersAvailable = ["R278A"]))) -
src/mlx/gui/flight.py
r607 r619 7 7 from mlx.flight import Flight 8 8 from mlx.checks import PayloadChecker 9 from mlx.gates import lhbpGates 9 10 import mlx.util as util 10 11 from mlx.pirep import PIREP … … 818 819 self._gateList.set_sensitive(True) 819 820 occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers() 820 for gate Number in const.lhbpGateNumbers:821 if gate Number not in occupiedGateNumbers:822 self._listStore.append([gate Number])821 for gate in lhbpGates: 822 if gate.isAvailable(lhbpGates, occupiedGateNumbers): 823 self._listStore.append([gate.number]) 823 824 824 825 def finalize(self): … … 3253 3254 self._wizard.bookedFlight.arrivalICAO=="LHBP" and \ 3254 3255 not self._wizard.entranceExam: 3255 occupiedGate s = self._wizard._fleet.getOccupiedGateNumbers()3256 for gate Number in const.lhbpGateNumbers:3257 if gate Number not in occupiedGates:3258 self._gatesModel.append([gate Number])3256 occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers() 3257 for gate in lhbpGates.gates: 3258 if gate.isAvailable(lhbpGates, occupiedGateNumbers): 3259 self._gatesModel.append([gate.number]) 3259 3260 self._gateLabel.set_sensitive(True) 3260 3261 self._gate.set_sensitive(True) -
src/mlx/gui/gates.py
r300 r619 4 4 from mlx.i18n import xstr 5 5 import mlx.const as const 6 from mlx.gates import Gates, lhbpGates 6 7 7 8 #------------------------------------------------------------------------------- … … 82 83 statusBox.pack_start(gatesFrame, True, True, 4) 83 84 84 self._gatesTable = table = gtk.Table(14, 4) 85 self._gatesTable = table = gtk.Table(lhbpGates.numRows, 86 lhbpGates.numColumns) 85 87 table.set_tooltip_markup(xstr("gates_gates_tooltip")) 86 88 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 94 96 column = 0 95 97 row = 0 96 for gateNumber in const.lhbpGateNumbers: 97 label = gtk.Label() 98 label.set_markup("<b>" + gateNumber + "</b>") 99 table.attach(label, column, column + 1, row, row + 1) 98 for (type, data) in lhbpGates.displayInfos: 99 if type==Gates.DISPLAY_GATE: 100 gate = data 100 101 101 self._gateLabels[gateNumber] = label 102 103 if column==1 and row==12: 104 column = 2 105 row = 1 106 elif row==13: 102 label = gtk.Label() 103 label.set_markup("<b>" + gate.number + "</b>") 104 table.attach(label, column, column + 1, row, row + 1) 105 106 self._gateLabels[gate.number] = label 107 row += 1 108 elif type==Gates.DISPLAY_SPACE: 109 row += 1 110 elif type==Gates.DISPLAY_NEW_COLUMN: 111 row = 0 107 112 column += 1 108 row = 0 109 else: 110 row += 1 111 113 112 114 button = gtk.Button(xstr("gates_refresh")) 113 115 button.set_use_underline(True) … … 168 170 169 171 occupiedGateNumbers = fleet.getOccupiedGateNumbers() 170 for gateNumber in const.lhbpGateNumbers: 172 for gate in lhbpGates.gates: 173 gateNumber = gate.number 171 174 markup = gateNumber 172 175 if gateNumber in occupiedGateNumbers:
Note:
See TracChangeset
for help on using the changeset viewer.