Changeset 1154:516ca7c94d1d
- Timestamp:
- 04/24/24 18:31:17 (8 months ago)
- Branch:
- python3
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r1137 r1154 673 673 if fleet is not None: 674 674 gateList = "" 675 occupiedGateNumbers = fleet.getOccupiedGateNumbers() 676 for gate in gates.lhbpGates.gates: 677 if gate.isAvailable(gates.lhbpGates, occupiedGateNumbers): 678 if gateList: gateList += ", " 679 gateList += gate.number 675 for gate in fleet.iterAvailableLHBPGates(self.flight.bookedFlight.tailNumber): 676 if gateList: gateList += ", " 677 gateList += gate.number 680 678 fs.sendMessage(const.MESSAGETYPE_GATE_SYSTEM, 681 679 "Free gates: " + gateList, 20) -
src/mlx/gates.py
r1151 r1154 11 11 """Information about a gate.""" 12 12 def __init__(self, number, terminal, type, 13 availableFn = None, taxiThrough = False): 13 availableFn = None, taxiThrough = False, 14 maxSpan = 0.0, maxLength = 0.0): 14 15 """Construct the gate with the given information. 15 16 … … 21 22 - a collection of the gates, and 22 23 - a set of occupied gate numbers.""" 23 self. _number = number24 self. _terminal = terminal25 self. _type = type24 self.number = number 25 self.terminal = terminal 26 self.type = type 26 27 self._availableFn = availableFn 27 self._taxiThrough = taxiThrough 28 29 @property 30 def number(self): 31 """Get the number of the gate.""" 32 return self._number 33 34 @property 35 def taxiThrough(self): 36 """Get if the gate is a taxi through one.""" 37 return self._taxiThrough 38 39 def isAvailable(self, gates, occupiedGateNumbers): 40 """Determine if this gate is available given the set of gates and 41 occupied gate numbers.""" 42 if self._number in occupiedGateNumbers: 28 self.taxiThrough = taxiThrough 29 self.maxSpan = maxSpan 30 self.maxLength = maxLength 31 32 def isAvailable(self, plane, gates, occupiedGateNumbers): 33 """Determine if this gate is available for the given plane and the 34 given the set of gates and occupied gate numbers.""" 35 if self.number in occupiedGateNumbers: 43 36 return False 44 return True if self._availableFn is None else \ 45 self._availableFn(gates, occupiedGateNumbers) 37 if self._availableFn is None or \ 38 self._availableFn(gates, occupiedGateNumbers): 39 return plane is None or \ 40 (plane.wingSpan <= self.maxSpan and \ 41 plane.fuselageLength <= self.maxLength) 42 else: 43 return False 46 44 47 45 #-------------------------------------------------------------------------------------- … … 112 110 self._numRowsInColumn = 0 113 111 self._numColumns += 1 112 113 def merge(self, otherGates): 114 """Merge the information from the given gate list (retrieved from the 115 MAVA server) into this gate list.""" 116 for otherGate in otherGates.gates: 117 gate = self.find(otherGate.number) 118 if gate is None: 119 print("Received data for gate %s, but it does not exist locally!" % 120 (otherGate.number,)) 121 else: 122 if gate.terminal != otherGate.terminal: 123 print("The terminal for gate %s is received as: %s" % 124 (gate.number, otherGate.terminal)) 125 gate.terminal = otherGate.terminal 126 if gate.type != otherGate.type: 127 print("The type for gate %s is received as: %s" % 128 (gate.number, otherGate.type)) 129 gate.type = otherGate.type 130 131 gate.maxSpan = otherGate.maxSpan 132 gate.maxLength = otherGate.maxLength 133 134 for gate in self.gates: 135 if gate.maxSpan==0.0 or gate.maxLength==0.0: 136 print("Gate %s has no maximal dimensions from the database" % 137 (gate.number,)) 114 138 115 139 def _addRow(self): -
src/mlx/gui/flight.py
r1152 r1154 1500 1500 self._listStore.clear() 1501 1501 self._gateList.set_sensitive(True) 1502 occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers() 1503 for gate in lhbpGates.gates: 1504 if gate.isAvailable(lhbpGates, occupiedGateNumbers): 1505 self._listStore.append([gate.number]) 1502 for gate in self._wizard.iterAvailableLHBPGates(): 1503 self._listStore.append([gate.number]) 1506 1504 1507 1505 def finalize(self): … … 6023 6021 self._wizard.bookedFlight.arrivalICAO=="LHBP" and \ 6024 6022 not self._wizard.entranceExam: 6025 occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers() 6026 for gate in lhbpGates.gates: 6027 if gate.isAvailable(lhbpGates, occupiedGateNumbers): 6028 self._gatesModel.append([gate.number]) 6023 for gate in self._wizard.iterAvailableLHBPGates(): 6024 self._gatesModel.append([gate.number]) 6029 6025 self._gateLabel.set_sensitive(True) 6030 6026 self._gate.set_sensitive(True) … … 6871 6867 if result.loggedIn: 6872 6868 self._loginResult = result 6869 self._mergeGates() 6873 6870 self.gui.loginSuccessful() 6874 6871 else: … … 6960 6957 self._simBriefingPage.finalizeCEF() 6961 6958 6959 def iterAvailableLHBPGates(self): 6960 """Iterate over the available gates at LHBP for the current flight's plane.""" 6961 for gate in self._fleet.iterAvailableLHBPGates(self._bookedFlight.tailNumber): 6962 yield gate 6963 6962 6964 def _connectSimulator(self, simulatorType): 6963 6965 """Connect to the simulator.""" … … 6986 6988 assert False 6987 6989 6990 def _mergeGates(self): 6991 """Merge the gate information retrieved during login into the 6992 existing gate information for LHBP.""" 6993 lhbpGates.merge(self._loginResult.gates) 6994 6988 6995 #----------------------------------------------------------------------------- -
src/mlx/rpc.py
r1153 r1154 1 1 from . import const 2 2 from . import rpccommon 3 from . import gates 3 4 4 5 from .common import MAVA_BASE_URL, fixUnpickled … … 630 631 #--------------------------------------------------------------------------------------- 631 632 633 class Gate(gates.Gate, RPCObject): 634 """A gate.""" 635 _instructions = { 636 "number": str, 637 "terminal": str, 638 "type": str, 639 "maxSpan": float, 640 "maxLength": float 641 } 642 643 def __init__(self, value): 644 """Construct the gate.""" 645 RPCObject.__init__(self, value, instructions = Gate._instructions) 646 647 #--------------------------------------------------------------------------------------- 648 649 class Gates(gates.Gates): 650 """The gates.""" 651 def __init__(self, value): 652 """Construct the gates.""" 653 super(Gates, self).__init__() 654 for gateValue in value: 655 self.add(Gate(gateValue)) 656 657 #--------------------------------------------------------------------------------------- 658 632 659 class Registration(object): 633 660 """Data for registration.""" … … 808 835 return Fleet(value) 809 836 837 def getGates(self): 838 """Query and return the gate information.""" 839 value = self._performCall(lambda sessionID: 840 self._server.getGates(sessionID)) 841 842 return Gates(value) 843 810 844 def updatePlane(self, tailNumber, status, gateNumber): 811 845 """Update the state and position of the plane with the given tail -
src/mlx/rpccommon.py
r919 r1154 4 4 5 5 from . import const 6 from .gates import lhbpGates 6 7 7 8 #------------------------------------------------------------------------------ … … 51 52 """Check if the gate of the given plane conflicts with another plane's 52 53 position.""" 54 gate = lhbpGates.find(plane.gateNumber) 53 55 for p in self._planes.values(): 54 56 if p.tailNumber!=plane.tailNumber and \ 55 p.status==const.PLANE_HOME and \ 56 p.gateNumber==plane.gateNumber: 57 return True 57 p.status==const.PLANE_HOME: 58 if p.gateNumber==plane.gateNumber: 59 return True 60 if gate is not None and not gate.isAvailable(plane, 61 lhbpGates, 62 [p.gateNumber]): 63 return True 58 64 59 65 return False … … 66 72 gateNumbers.add(p.gateNumber) 67 73 return gateNumbers 74 75 def iterAvailableLHBPGates(self, tailNumber): 76 """Iterate over the available gates at LHBP.""" 77 occupiedGateNumbers = self.getOccupiedGateNumbers() 78 plane = self.__getitem__(tailNumber) 79 for gate in lhbpGates.gates: 80 if gate.isAvailable(plane, lhbpGates, occupiedGateNumbers): 81 yield gate 68 82 69 83 def updatePlane(self, tailNumber, status, gateNumber = None): -
src/mlx/web.py
r1114 r1154 476 476 result.password = password 477 477 result.fleet = client.getFleet() 478 result.gates = client.getGates() 478 479 flights = client.getFlights() 479 480 result.flights = flights[0]
Note:
See TracChangeset
for help on using the changeset viewer.