Ignore:
Timestamp:
04/24/24 18:31:17 (4 weeks ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Gate dimensions are retrieved from the server and are used to restrict the set of gates available for a plane (re #386).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gates.py

    r1151 r1154  
    1111    """Information about a gate."""
    1212    def __init__(self, number, terminal, type,
    13                  availableFn = None, taxiThrough = False):
     13                 availableFn = None, taxiThrough = False,
     14                 maxSpan = 0.0, maxLength = 0.0):
    1415        """Construct the gate with the given information.
    1516
     
    2122        - a collection of the gates, and
    2223        - a set of occupied gate numbers."""
    23         self._number = number
    24         self._terminal = terminal
    25         self._type = type
     24        self.number = number
     25        self.terminal = terminal
     26        self.type = type
    2627        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:
    4336            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
    4644
    4745#--------------------------------------------------------------------------------------
     
    112110        self._numRowsInColumn = 0
    113111        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,))
    114138
    115139    def _addRow(self):
Note: See TracChangeset for help on using the changeset viewer.