diff --git a/Bedruckungstabelle Typ M.ods b/Bedruckungstabelle Typ M.ods new file mode 100644 index 0000000..c22cdec Binary files /dev/null and b/Bedruckungstabelle Typ M.ods differ diff --git a/TYPM.JSN b/TYPM.JSN new file mode 100644 index 0000000..f2be248 --- /dev/null +++ b/TYPM.JSN @@ -0,0 +1 @@ +{"units": [{"name": "destination", "flags": [], "type": "text", "addr": 8, "x": 0, "y": 6, "width": 2, "height": 2, "len": 16, "home": 127, "map": "map_destination"}, {"name": "destination_b", "flags": [], "type": "text", "addr": 30, "x": 0, "y": 16, "width": 2, "height": 2, "len": 16, "home": 127, "map": "map_destination"}, {"name": "hour", "flags": [], "type": "map", "addr": 1, "x": 0, "y": 0, "width": 12, "height": 2, "len": 1, "home": 127, "map": "map_hour"}, {"name": "hour_b", "flags": [], "type": "map", "addr": 24, "x": 0, "y": 10, "width": 12, "height": 2, "len": 1, "home": 127, "map": "map_hour"}, {"name": "info_1", "flags": [], "type": "map", "addr": 4, "x": 0, "y": 2, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_info_1"}, {"name": "info_1_b", "flags": [], "type": "map", "addr": 26, "x": 0, "y": 12, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_info_1"}, {"name": "info_2", "flags": [], "type": "map", "addr": 5, "x": 0, "y": 4, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_info_2"}, {"name": "info_2_b", "flags": [], "type": "map", "addr": 28, "x": 0, "y": 14, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_info_2"}, {"name": "minute", "flags": [], "type": "map", "addr": 2, "x": 12, "y": 0, "width": 4, "height": 2, "len": 1, "home": 127, "map": "map_minute"}, {"name": "minute_b", "flags": [], "type": "map", "addr": 25, "x": 12, "y": 10, "width": 4, "height": 2, "len": 1, "home": 127, "map": "map_minute"}, {"name": "via_1", "flags": [], "type": "map", "addr": 6, "x": 16, "y": 2, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_via_1"}, {"name": "via_1_b", "flags": [], "type": "map", "addr": 27, "x": 16, "y": 12, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_via_1"}, {"name": "via_2", "flags": [], "type": "map", "addr": 7, "x": 16, "y": 4, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_via_2"}, {"name": "via_2_b", "flags": [], "type": "map", "addr": 29, "x": 16, "y": 14, "width": 16, "height": 2, "len": 1, "home": 127, "map": "map_via_2"}], "maps": {"map_destination": {"0": "0", "1": "1", "2": "2", "3": "3", "4": "4", "5": "5", "6": "6", "7": "7", "8": "8", "9": "9", "10": "A", "11": "B", "12": "C", "13": "D", "14": "E", "15": "F", "16": "G", "17": "H", "18": "I", "19": "J", "20": "K", "21": "L", "22": "M", "23": "N", "24": "O", "25": "P", "26": "Q", "27": "R", "28": "S", "29": "T", "30": "U", "31": "V", "32": "W", "33": "X", "34": "Y", "35": "Z", "36": "\u00c4", "37": "\u00d6", "38": "\u00dc", "39": "-", "40": ".", "41": "'", "42": "(", "43": ")", "44": "?", "45": "!", "46": "*", "47": ":", "48": "/", "49": ";", "50": "\"", "51": "\u201c", "52": "\u201e", "53": ",", "127": " "}, "map_hour": {"0": "Abfahrt 0", "1": "Abfahrt 1", "2": "Abfahrt 2", "3": "Abfahrt 3", "4": "Abfahrt 4", "5": "Abfahrt 5", "6": "Abfahrt 6", "7": "Abfahrt 7", "8": "Abfahrt 8", "9": "Abfahrt 9", "10": "Abfahrt 10", "11": "Abfahrt 11", "12": "Abfahrt 12", "13": "Abfahrt 13", "14": "Abfahrt 14", "15": "Abfahrt 15", "16": "Abfahrt 16", "17": "Abfahrt 17", "18": "Abfahrt 18", "19": "Abfahrt 19", "20": "Abfahrt 20", "21": "Abfahrt 21", "22": "Abfahrt 22", "23": "Abfahrt 23", "30": "Ankunft 0", "31": "Ankunft 1", "32": "Ankunft 2", "33": "Ankunft 3", "34": "Ankunft 4", "35": "Ankunft 5", "36": "Ankunft 6", "37": "Ankunft 7", "38": "Ankunft 8", "39": "Ankunft 9", "40": "Ankunft 10", "41": "Ankunft 11", "42": "Ankunft 12", "43": "Ankunft 13", "44": "Ankunft 14", "45": "Ankunft 15", "46": "Ankunft 16", "47": "Ankunft 17", "48": "Ankunft 18", "49": "Ankunft 19", "50": "Ankunft 20", "51": "Ankunft 21", "52": "Ankunft 22", "53": "Ankunft 23"}, "map_info_1": {"0": "IC zuschlagfrei bis Frankfurt(M)Hbf", "1": "ICE InterCityExpress", "2": "IC InterCity", "3": "IC zus\u00e4tzlicher Zug", "4": "EuroNight", "5": "EN Zuschlag siehe Abfahrtplan", "6": "ICE zus\u00e4tzlicher Zug", "7": "D Schnellzug", "8": "D Schnellzug Zuschlag siehe Abfahrtplan", "9": "Zus\u00e4tzlicher Schnellzug", "10": "D Schnellzug f\u00e4hrt in zwei Teilen", "11": "Milit\u00e4rschnellzug", "12": "D Schnellzug Nur Schlaf- und Liegewagen", "13": "D Autoreisezug Nur Schlaf- und Liegewagen", "14": "D Schnellzug nicht \u00fcber M\u00fcnchen Hbf", "15": "M Messe-Schnellzug nur 1. Kl.", "16": "M Messe-Schnellzug", "17": "AZ DB AutoZug", "18": "EX ExpoZug", "19": "EXE ExpoExpress", "20": "NZ InterCityNight und DB NachZug", "21": "Milit\u00e4reilzug", "22": "Wagenstand (modern)", "23": "Wagenstand (alt)", "24": "N \u00fcber Tafel \u201eZugschlu\u00df\u201c beachten", "25": "N Tafel \u201eZugschlu\u00df\u201c beachten", "26": "Reiseb\u00fcro-Sonderzug", "27": "Sonderzug", "28": "EC EuroCity", "29": "EC zus\u00e4tzlicher Zug", "30": "EC EuroCity mit Zuschlag Kurswagen Graz, Ljubljana", "31": "D Kurswagen Selzthal", "32": "RSB", "33": "D Kurswagen Innsbruck", "34": "D Kurswagen 2.Kl. Bad W\u00f6rishofen, Lindau", "35": "D Kurswagen Graz", "36": "D Liegewagen Graz", "37": "D Kurswagen Bad W\u00f6rishofen", "38": "D Liegewagen Innsbruck", "39": "D Kurswagen Lindau", "40": "IC mit Zuschlag Kurswagen Wien, Pfarrkirchen", "41": "D Schnellzug H\u00e4lt nicht bis Rosenheim", "42": "D zus\u00e4tzlicher Schnellzug Zuschlag siehe Abfahrtplan", "43": "D Schnellzug H\u00e4lt nicht bis K\u00f6ln", "44": "D Autoreisezug", "45": "Gleis\u00e4nderung", "46": "Anzeiger au\u00dfer Betrieb", "47": "IC mit Zuschlag Kurswagen Pfarrkirchen, Zwiesel", "48": "RegionalBahn", "49": "RB H\u00e4lt nicht \u00fcberall", "50": "RegionalExpress", "51": "RE H\u00e4lt nicht \u00fcberall", "52": "InterRegioExpress", "53": "D Kurswagen Emmerich", "54": "D Liegewagen Innsbruck Selzthal", "55": "UEX UrlaubsExpress", "56": "InterRegio", "57": "IR Zuschlag siehe Abfahrtplan", "58": "M\u00c1V Magyar \u00c1llamvasutak", "59": "ECE EuroCityExpress", "60": "MVV M\u00fcnchner Verkehrs- und Tarifverbund", "61": "railjet", "62": "alex"}, "map_info_2": {"0": "Holland-Italien-Express", "1": "Italien-Holland-Express", "2": "Schweiz-Express", "3": "Istanbul-Express", "4": "Riviera-Express", "5": "Wagenstand 1.Kl. A & 1. Kl. E", "6": "Wagenstand 1. Kl. B", "7": "Wagenstand 1. Kl. A", "8": "TUI FerienExpress", "9": "Alpen-See-Express", "10": "Alpen-See-Express / TUI FerienExpress", "11": "Liegewagenzug", "12": "Schlaf- und Liegewagen", "13": "Airport-City", "14": "bis Hamburg=Altona", "15": "bis Greifswald", "16": "bis Hannover", "17": "bis Braunschweig", "18": "Wagenstand 1. Kl. A-B", "19": "Wagenstand 1. Kl. A-B", "20": "Wagenstand 1. Kl. A-B", "21": "Wagenstand 1. Kl. A-B", "22": "Wagenstand 1. Kl. A-B", "23": "Wagenstand 1. Kl. D", "24": "Wagenstand 1. Kl. A-B", "25": "Wagenstand 1. Kl. B-C", "26": "Kurswagen Amsterdam", "27": "H\u00e4lt \u00fcberall", "28": "H\u00e4lt bis Heidelberg \u00fcberall", "29": "H\u00e4lt bis Darmstadt \u00fcberall", "30": "H\u00e4lt nicht in Mainz-Laubheim", "31": "Wagenstand 1. Kl. D", "32": "Wagenstand 1. Kl. B-C", "33": "Aufpreis Sprinter", "34": "Wagenstand 1. Kl. A & C-D", "35": "BRB Bayerische Regiobahn", "36": "S-Bahn Langzug 1 Traktion hinten", "37": "S-Bahn Langzug 2 Traktionen hinten/mitte", "38": "S-Bahn Langzug 1 Traktion vorne", "39": "S-Bahn Langzug 2 Traktionen vorne/mitte", "40": "S-Bahn Langzug 1 Traktion hinten", "41": "S-Bahn Vollzug 1 Traktion hinten ", "42": "S-Bahn Vollzug 1 Traktion vorne", "43": "S-Bahn Langzug 3 Traktionen", "44": "S-Bahn Kurzzug vorne", "45": "S-Bahn Vollzug vorne/mitte", "46": "Kurswagen siehe Abfahrtsplan", "47": "heute aus Gleis 1", "48": "heute aus Gleis 2", "49": "heute aus Gleis 3", "50": "heute aus Gleis 4", "51": "heute aus Gleis 5", "52": "heute aus Gleis 7", "53": "Bitte Ansage beachten", "54": "Nicht einsteigen", "55": "H\u00e4lt nicht \u00fcberall", "56": "platzkartenprlichtig", "57": "nicht \u00fcber Frankfurt Hbf", "58": "nicht \u00fcber Heidelberg", "59": "H\u00e4lt nicht in LU=Mundenheim und LU=Rheing\u00f6nheim", "60": "H\u00e4lt bis Neckarsteinach \u00fcberall", "61": "H\u00e4lt nicht in Neckarhausen", "62": "H\u00e4lt bis Homburg(Saar) \u00fcberall", "63": "Zug h\u00e4lt hier nur zum Aussteigen", "64": "Zug verkehrt in zwei Teilen Ansage beachten", "65": "Urlaubs-Express", "66": "2 Z\u00fcge im Gleis Zugbeschriftung beachten", "67": "hintere Wagen bleiben stehen: Zugbeschriftung beachten", "68": "\u00dcber 60 Min. sp\u00e4ter", "69": "heute aus Gleis 8", "70": "heute aus Gleis 9", "71": "heute aus Gleis 10", "72": "Etwa 5 Min. sp\u00e4ter", "73": "Etwa 10 Min. sp\u00e4ter", "74": "Etwa 15 Min. sp\u00e4ter", "75": "Etwa 20 Min. sp\u00e4ter", "76": "Etwa 30 Min. sp\u00e4ter", "77": "Etwa 45 Min. sp\u00e4ter", "78": "\u00dcber 45 Min. sp\u00e4ter"}, "map_minute": {"0": "00", "1": "01", "2": "02", "3": "03", "4": "04", "5": "05", "6": "06", "7": "07", "8": "08", "9": "09", "10": "10", "11": "11", "12": "12", "13": "13", "14": "14", "15": "15", "16": "16", "17": "17", "18": "18", "19": "19", "20": "20", "21": "21", "22": "22", "23": "23", "24": "24", "25": "25", "26": "26", "27": "27", "28": "28", "29": "29", "30": "30", "31": "31", "32": "32", "33": "33", "34": "34", "35": "35", "36": "36", "37": "37", "38": "38", "39": "39", "40": "40", "41": "41", "42": "42", "43": "43", "44": "44", "45": "45", "46": "46", "47": "47", "48": "48", "49": "49", "50": "50", "51": "51", "52": "52", "53": "53", "54": "54", "55": "55", "56": "56", "57": "57", "58": "58", "59": "59"}, "map_via_1": {"0": "Ingolstadt - W\u00fcrzburg", "1": "M\u00fcnchen-Pasing - Buchloe", "2": "Freising - Landau", "3": "M\u00fcnchen-Pasing - Augsburg - Stuttgart - Mannheim", "4": "Petershausen - Rohrbach - Ingolstadt", "5": "M\u00fcnchen-Harras - Holzkirchen", "6": "M\u00fcnchen-Pasing - Starnberg - Tutzing - Weilheim", "7": "M\u00fcnchen-Pasing - Tutzing", "8": "M\u00fcnchen-Pasing - Weilheim", "9": "M\u00fcnchen-Pasing - Weilheim - Mittenwald", "10": "M\u00fcnchen-Pasing - Augsburg", "11": "Geltendorf", "12": "Freising - Landshut", "13": "M\u00fcnchen-Ost", "14": "Lindau-Reutin - Bregenz - St. Gallen - Winterthur", "15": "Mammendorf - Mering - Augsburg - Nordendorf", "16": "Ingolstadt", "17": "Petershausen - Rohrbach", "18": "M\u00fcnchen-Ost - Markt Schwaben - Ampfing", "19": "N\u00fcrnberg - W\u00fcrzburg - Kassel-Wilhelmsh\u00f6he - Hannover", "20": "M\u00fcnchen-Pasing - Geltendorf", "21": "Augsburg - Ulm - Stuttgart - Mannheim", "22": "N\u00fcrnberg - W\u00fcrzburg - Frankfurt/M Hbf - Frankfurt/M Flgfn.", "23": "M\u00fcnchen-Ost - Rosenheim - Salzburg - Bad Gastein", "24": "W\u00f6rgl - Innsbruck - Fortezza - Bolzano", "25": "Landshut - Regensburg", "26": "M\u00fcnchen-Ost - Rosenheim", "27": "M\u00fcnchen-Pasing - Geltendorf - Buchloe - Mammendorf", "28": "M\u00fcnchen-Pasing", "29": "Leuchtenbergring", "30": "Donnersbergerbr\u00fccke", "31": "Starnberg", "32": "Mammendorf", "33": "Feldmoching", "34": "Freising", "35": "Grafing=Bahnhof", "36": "Ebersberg", "37": "Holzkirchen", "38": "Solln", "39": "Mittersendling", "40": "M\u00fcnchen-Heimeranplatz", "41": "Frankfurt/M Hbf", "42": "Ingolstadt Hbf", "43": "N\u00fcrnberg", "44": "W\u00fcrzburg", "45": "Stuttgart", "46": "Berlin Hbf", "47": "Hamburg Hbf", "48": "Salzburg - Linz - St. P\u00f6lten - Wien Hbf - Hegyeshalom - Gy\u00f6r", "49": "Rosenheim", "50": "Buchloe - Mindelheim - Memmingen - Aichstetten - Ki\u00dflegg - Hergatz", "51": "Pasing - Augsburg - Stuttgart"}, "map_via_2": {"0": "Frankfurt(M) - K\u00f6ln", "1": "Mindelheim", "2": "Plattling - Vilshofen", "3": "Frankfurt(M) - Eisenach - Gotha", "4": "Erfurt", "5": "Ingolstadt Audi - Eichst\u00e4tt - Pappenheim", "6": "Bad T\u00f6lz - Obergrie\u00df", "7": "Moosrain - Gmund", "8": "Darching - Miesbach - Fischbachau - Geitau", "9": "Murnau - Garmisch P.K. - Reutte in Tirol", "10": "Seefeld in Tirol - Innsbruck-H\u00f6tting", "11": "Dinkelscherben - Leipheim", "12": "Kaufering", "13": "Domazlice - Plzen hl.h.", "14": "Regensburg", "15": "Stuttgart", "16": "Frankfurt(M)Hbf - Essen", "17": "Rosenheim - Freilassing", "18": "Seeshaupt - Penzberg", "19": "Hamburg Hbf", "20": "Kempten Hbf - Sonthofen", "21": "Kempten Hbf - Hergatz", "22": "Kaiserslautern - Homburg(Saar)", "23": "D\u00fcsseldorf - Duisburg - Essen - Bochum", "24": "Villach", "25": "Bremen", "26": "Verona Porta Nuova", "27": "Frankfurt(M)Hbf", "28": "Kassel-Wilhelmsh\u00f6he", "29": "Tutzing", "30": "Rosenheim", "31": "Geltendorf", "32": "Dachau", "33": "Moosach", "34": "Markt Schwaben", "35": "Grafing-Stadt", "36": "Kreuzstra\u00dfe", "37": "Deisenhofen", "38": "Siemenswerke", "39": "M\u00fcnchen-Harras", "40": "H\u00f6llriegelskreuth", "41": "Montabaur - Siegburg/Bonn", "42": "N\u00fcrnberg", "43": "W\u00fcrzburg", "44": "K\u00f6ln", "45": "Berlin-Gesundbrunnen", "46": "Hamburg-Altona", "47": "K\u00f6ln Messe/Deutz", "48": "D\u00fcsseldorf - Duisburg - Essen", "49": "Mannheim - Frankfurt(M)", "50": "Salzburg", "51": "Salzburg - Selzthal", "52": "Salzburg - Villach - Kranj - Ljubljana - Sevnica", "53": "Salzburg - Villach - Ljubljana - Pivka - Sapjane", "54": "Bologna - Firenze", "55": "Frankfurt/M - Erfurt - Leipzig - Lutherstadt Wittenberg"}}} \ No newline at end of file diff --git a/run.py b/run.py index 09dd1d1..aa017a4 100644 --- a/run.py +++ b/run.py @@ -1,6 +1,5 @@ from deutschebahn import DBInfoscreen -from pyfis.krone import Krone8200Display -from pyfis.krone.exceptions import CommunicationError +from pyfis.xatlabs import xatLabsCheetah from pyfis.utils import get_vias from util import timeout, TimeoutError @@ -169,69 +168,18 @@ def update_display(display, dbi): def main(): - ctrl = Krone8200Display(SERIAL_PORT, address=(0x41, 0x49), debug=True) - ctrl.port.timeout=5.0 + ctrl = xatLabsCheetah("http://typ-m-zza.local") + display = ctrl.get_splitflap_display() dbi = DBInfoscreen(DBI_HOST) - display = TypMZZA(ctrl) display.clear() - - last_update = 0 - last_heartbeat = 0 - while True: - now = time.time() - - if now - last_heartbeat >= 10: - print("\n" + "=" * 60 + "\n") - print("Sending heartbeat") - ctrl.send_end_comm() - last_heartbeat = now - continue - - if now - last_update < 60: - time.sleep(1) - continue - - print("\n" + "=" * 60 + "\n") - - try: - display_id = update_display(display, dbi) - try: - with open("/tmp/m-zza-status.json", 'r') as f: - status = json.load(f) - except (FileNotFoundError, ValueError): - status = {'displayHash': None} - - display_hash = hashlib.sha256(bytes(display_id, 'utf-8')).hexdigest() - - update = True - if status['displayHash'] == display_hash: - print("No need to update display.") - update = False - else: - status['displayHash'] = display_hash - - if update: - num_tries = 10 - for i in range(num_tries): - try: - display.update() - break - except CommunicationError: - print("Communication error! Retrying... {}/{}".format(i+1, num_tries)) - time.sleep(5) - - with open("/tmp/m-zza-status.json", 'w') as f: - json.dump(status, f) - except: - traceback.print_exc() - - last_update = now - - - display.update() + try: + display_id = update_display(display, dbi) + display.update() + except: + traceback.print_exc() if __name__ == "__main__": diff --git a/settings_phalos.py b/settings_phalos.py index 290c57f..64b64b9 100644 --- a/settings_phalos.py +++ b/settings_phalos.py @@ -2,23 +2,6 @@ from pyfis.splitflap_display import SplitFlapDisplay, TextField, CustomMapField, from pyfis.utils import vias_from_csv, map_from_csv -def _load_map(file): - _map = {} - with open(file, 'r') as f: - lines = f.readlines() - for line in lines: - line = line.strip() - if not line: - continue - parts = line.split(maxsplit=1) - pos = int(parts[0]) - if len(parts) > 1: - text = parts[1] - _map[pos] = text - return _map - - -SERIAL_PORT = "/dev/serial/by-path/platform-3f980000.usb-usb-0:1.5:1.0-port0" DBI_HOST = "trains.xatlabs.com" STATION_CODE = "MH" STATION_NAME = "München Hbf" @@ -176,14 +159,15 @@ VIA_WEIGHTS = { } +# Wird nur noch gebraucht, um neue JSON-Datei zu erstellen class TypMZZA(SplitFlapDisplay): - hour = CustomMapField(MAP_HOUR, start_address=1, x=0, y=0, module_width=12, module_height=2, home_pos=99) - minute = CustomMapField(MAP_MINUTE, start_address=2, x=12, y=0, module_width=4, module_height=2, home_pos=99) - info_1 = CustomMapField(MAP_INFO_1, start_address=4, x=0, y=2, module_width=16, module_height=2, home_pos=99) - info_2 = CustomMapField(MAP_INFO_2, start_address=5, x=0, y=4, module_width=16, module_height=2, home_pos=99) - via_1 = CustomMapField(MAP_VIA_1, start_address=6, x=16, y=2, module_width=16, module_height=2, home_pos=99) - via_2 = CustomMapField(MAP_VIA_2, start_address=7, x=16, y=4, module_width=16, module_height=2, home_pos=99) - destination = TextField(start_address=8, length=16, x=0, y=6, module_width=2, module_height=2, display_mapping=MAP_ALNUM, home_pos=99) + hour = CustomMapField(MAP_HOUR, start_address=1, x=0, y=0, module_width=12, module_height=2, home_pos=127) + minute = CustomMapField(MAP_MINUTE, start_address=2, x=12, y=0, module_width=4, module_height=2, home_pos=127) + info_1 = CustomMapField(MAP_INFO_1, start_address=4, x=0, y=2, module_width=16, module_height=2, home_pos=127) + info_2 = CustomMapField(MAP_INFO_2, start_address=5, x=0, y=4, module_width=16, module_height=2, home_pos=127) + via_1 = CustomMapField(MAP_VIA_1, start_address=6, x=16, y=2, module_width=16, module_height=2, home_pos=127) + via_2 = CustomMapField(MAP_VIA_2, start_address=7, x=16, y=4, module_width=16, module_height=2, home_pos=127) + destination = TextField(start_address=8, length=16, x=0, y=6, module_width=2, module_height=2, display_mapping=MAP_ALNUM, home_pos=127) hour_b = MirrorField(hour, start_address=24, x=0, y=10) minute_b = MirrorField(minute, start_address=25, x=12, y=10)