94 lines
2.9 KiB
Python
94 lines
2.9 KiB
Python
import argparse
|
|
import json
|
|
|
|
from pprint import pprint
|
|
|
|
from vag_api import VagApi
|
|
from vag_zza import VagZza
|
|
|
|
from station_map import *
|
|
|
|
import sys, os
|
|
if sys.executable.endswith("pythonw.exe"):
|
|
sys.stdout = open(os.devnull, "w");
|
|
sys.stderr = open(os.path.join(os.getenv("TEMP"), "stderr-"+os.path.basename(sys.argv[0])), "w")
|
|
|
|
|
|
def display_train(zza, train):
|
|
line = train['Linienname']
|
|
via = ""
|
|
if train['Richtungstext'] == "Flughafen":
|
|
dest = "Bitte achten Sie auf die Zugbeschilderung"
|
|
else:
|
|
dest = zza.get_closest_destination(train['Richtungstext'])
|
|
|
|
if line == "U1":
|
|
# Standort Maximilianstraße
|
|
if dest not in ("Langwasser-Süd", "Fürth Hardhöhe"):
|
|
line = "U11"
|
|
|
|
if dest in ("Fürth Hardhöhe", "Fürth Klinikum", "Fürth / Stadthalle"):
|
|
via = "Stadtgrenze - Fürth / Hauptbahnhof"
|
|
elif dest in ("Fürth / Hauptbahnhof", "Jakobinenstraße"):
|
|
via = "Stadtgrenze"
|
|
elif dest in ("Weißer Turm", "Hauptbahnhof"):
|
|
via = "Plärrer"
|
|
elif dest in ("Aufseßplatz", "Maffeiplatz", "Frankenstraße", "Hasenbuck", "Bauernfeindstraße", "Messe"):
|
|
via = "Plärrer - Hauptbahnhof"
|
|
elif dest in ("Scharfreiterring", "Langwasser-Süd"):
|
|
via = "Plärrer - Hauptbahnhof - Messe"
|
|
|
|
if line == "U2":
|
|
# Standort Rennweg
|
|
if dest not in ("Bitte achten Sie auf die Zugbeschilderung", "Röthenbach"):
|
|
line = "U21"
|
|
|
|
if dest in ("Hauptbahnhof", "Plärrer"):
|
|
via = "Rathenauplatz"
|
|
elif dest in ("St. Leonhard", "Schweinau"):
|
|
via = "Rathenauplatz - Hauptbahnhof - Plärrer"
|
|
elif dest in ("Hohe Marter", "Röthenbach"):
|
|
via = "Rothenburgerstraße - Schweinau"
|
|
|
|
if dest == "":
|
|
line = "Sonderzug"
|
|
dest = "Bitte achten Sie auf die Zugbeschilderung"
|
|
|
|
zza.set_line(line)
|
|
zza.set_via(via)
|
|
zza.set_destination(dest)
|
|
zza.update()
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-p", "--port", type=str, required=True, help="Serial port for display")
|
|
parser.add_argument("-s", "--station", type=str, required=True, help="Station name to display departures of")
|
|
parser.add_argument("-pl", "--platform", type=int, required=True, help="Which platform the display is on")
|
|
args = parser.parse_args()
|
|
|
|
api = VagApi()
|
|
api.load_station_data("stations.json")
|
|
|
|
try:
|
|
station_id = int(args.station)
|
|
except ValueError:
|
|
station_id = api.get_station_info(args.station)[0]['VGNKennung']
|
|
|
|
departures = api.get_departures(station_id, products=["Ubahn"])
|
|
if len(departures) == 0:
|
|
train = {
|
|
"Linienname": "",
|
|
"Richtungstext": f"Betriebsschluß Gleis {args.platform}"
|
|
}
|
|
else:
|
|
train = departures[0]
|
|
|
|
zza = VagZza(args.port)
|
|
pprint(train)
|
|
display_train(zza, train)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|