Skip to content

Commit

Permalink
fix all issues in lock module
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor Baart committed Feb 29, 2024
1 parent 833b14c commit 5b9e574
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions opentnsim/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ def wait_for_next_lockage(vessel, direction, lock, door2, timeout_required=True,
lock.node_doors2,
waiting_required,
)
vessel.Location_end_of_lineup_area = vessel.env.vessel_traffic_service.provide_location_over_edges(
vessel.location_end_of_lineup_area = vessel.env.vessel_traffic_service.provide_location_over_edges(
vessel,
start_node,
lock.node_doors2,
Expand All @@ -1845,7 +1845,7 @@ def wait_for_next_lockage(vessel, direction, lock, door2, timeout_required=True,
lock.node_doors1,
waiting_required,
)
vessel.Location_end_of_lineup_area = vessel.env.vessel_traffic_service.provide_location_over_edges(
vessel.location_end_of_lineup_area = vessel.env.vessel_traffic_service.provide_location_over_edges(
vessel,
start_node,
lock.node_doors1,
Expand Down Expand Up @@ -1914,6 +1914,7 @@ def wait_for_next_lockage(vessel, direction, lock, door2, timeout_required=True,
- distance_to_end_lineup
)

@staticmethod
def leave_lock(vessel, node_doors1, node_doors2, direction):
"""Processes vessels which are waiting in the lock chamber to be levelled and after levelling:
checks if vessels which have entered the lock chamber have to wait for the other vessels to enter the lock chamber and
Expand Down Expand Up @@ -2027,7 +2028,7 @@ def leave_lock(vessel, node_doors1, node_doors2, direction):

# Formal request access to lock chamber and calculate position within the lock chamber
for user in lock.in_next_lockage[node_doors2].users:
if not user.obj.id == vessel.id:
if user.obj.id != vessel.id:
yield lock.length.put(lock.length.capacity - lock.length.level)
else:
break
Expand Down Expand Up @@ -2162,6 +2163,7 @@ def leave_lock(vessel, node_doors1, node_doors2, direction):
vessel, lock.node_doors2, lock.node_doors1, vessel.logbook[-1]["Geometry"]
)

@staticmethod
def leave_opposite_lineup_area(vessel, start_node, end_node, direction):
"""Processes vessels which have left the lock chamber after levelling and are now in the next line-up area in order to leave the lock complex through the next waiting area:
release of their requests for accessing their second encountered line-up area and lock chamber.
Expand All @@ -2180,7 +2182,8 @@ def leave_opposite_lineup_area(vessel, start_node, end_node, direction):
if lineup_area.name not in vessel.lock_information.keys():
continue

lock, direction = lineup_area.find_lock(vessel, start_node, end_node, direction=-1)
# TODO: check if direction=direction works
lock, direction = lineup_area.find_lock(vessel, start_node, end_node, direction=direction)

if direction:
distance_from_lock_doors = lock.distance_doors2_from_second_waiting_area
Expand Down

0 comments on commit 5b9e574

Please sign in to comment.