Move blocks around to set priorities, add multi train hint
This commit is contained in:
parent
70319e511e
commit
3fe4733e30
38
run.py
38
run.py
|
@ -75,6 +75,10 @@ def update_display(display, dbi):
|
|||
|
||||
is_arrival = any(filter(lambda arrival_station_name: filter_route(train['route'])[-1]['name'].startswith(arrival_station_name), ARRIVAL_STATIONS))
|
||||
|
||||
# Check for multiple trains coupled together with different destinations
|
||||
multi_trains = [t for t in trains[1:] if t.get('scheduledDeparture') == train.get('scheduledDeparture') and t.get('platform') == train.get('platform') and filter_route(t['route'])[-1]['name'] != filter_route(train['route'])[-1]['name']]
|
||||
is_multi_train = len(multi_trains) > 0
|
||||
|
||||
#if train['platform'] != PLATFORM:
|
||||
# platform = int("".join(c for c in train['platform'] if c.isdigit()))
|
||||
# display.info_2.set(PLATFORM_CHANGE_FORMAT.format(platform))
|
||||
|
@ -95,6 +99,21 @@ def update_display(display, dbi):
|
|||
if is_arrival:
|
||||
display.info_2.set(DO_NOT_BOARD_TEXT)
|
||||
|
||||
if train_type == "BRB":
|
||||
# Special case for BRB because it's on info_2
|
||||
display.info_2.set("BRB Bayerische Regiobahn")
|
||||
else:
|
||||
train_type_text = TRAIN_TYPE_MAP.get(train_type, "")
|
||||
display.info_1.set(train_type_text)
|
||||
|
||||
if train_type == "RE" and any([stop.get('isCancelled') for stop in train['route']]):
|
||||
# If we have an RE train and any stop on the way is cancelled
|
||||
display.info_1.set("RE hält nicht überall")
|
||||
|
||||
if train_type in ("BRB", "RB", "ALX", "WB") and any([stop.get('isCancelled') for stop in train['route']]):
|
||||
# If we have an RB train and any stop on the way is cancelled
|
||||
display.info_1.set("RB hält nicht überall")
|
||||
|
||||
if train['isCancelled']:
|
||||
display.info_2.set(CANCELLED_TEXT)
|
||||
elif delay >= 5:
|
||||
|
@ -112,25 +131,12 @@ def update_display(display, dbi):
|
|||
delay_text = UNSPECIFIC_DELAY_TEXT
|
||||
display.info_2.set(delay_text)
|
||||
elif train_type == "S":
|
||||
# Random train length indicator for S-Bahn
|
||||
# If no delay: random train length indicator for S-Bahn
|
||||
random.seed(train['trainNumber'])
|
||||
train_length_pos = random.randint(36, 45)
|
||||
display.info_2.set(MAP_INFO_2[train_length_pos])
|
||||
|
||||
if train_type == "BRB":
|
||||
# Special case for BRB because it's on info_2
|
||||
display.info_2.set("BRB Bayerische Regiobahn")
|
||||
else:
|
||||
train_type_text = TRAIN_TYPE_MAP.get(train_type, "")
|
||||
display.info_1.set(train_type_text)
|
||||
|
||||
if train_type == "RE" and any([stop.get('isCancelled') for stop in train['route']]):
|
||||
# If we have an RE train and any stop on the way is cancelled
|
||||
display.info_1.set("RE hält nicht überall")
|
||||
|
||||
if train_type in ("BRB", "RB", "ALX", "WB") and any([stop.get('isCancelled') for stop in train['route']]):
|
||||
# If we have an RB train and any stop on the way is cancelled
|
||||
display.info_1.set("RB hält nicht überall")
|
||||
elif is_multi_train:
|
||||
display.info_2.set("2 Züge im Gleis Zugbeschriftung beachten")
|
||||
|
||||
route = route_from([VIA_MAP.get(stop['name'], stop['name']) for stop in [s for s in train['route'] if not s.get('isCancelled')]], STATION_NAME)[:-1]
|
||||
via_combination = get_vias(route, VIA_WEIGHTS, VIA_1, VIA_2, check_dashes=False, debug=True)
|
||||
|
|
Loading…
Reference in New Issue