1+ from collections import defaultdict
12from datetime import datetime
3+ from enum import Enum
24
35import simplejson as json
46
1113from yaramo .vacancy_section import VacancySection
1214
1315
16+ class PlanningState (Enum ):
17+ erstellt = 1
18+ qualitaetsgeprueft = 2
19+ plangeprueft = 3
20+ freigegeben = 4
21+ genehmigt = 5
22+ abgenommen = 6
23+ uebernommen = 7
24+ gleichgestellt = 8
25+ sonstige = 9
26+
27+ def __str__ (self ):
28+ return self .name
29+
30+
1431class Topology (BaseElement ):
1532 """The Topology is a collection of all track elements comprising that topology.
1633
1734 Elements like Signals, Nodes, Edges, Routes and Vacancy Sections can be accessed by their uuid in their respective dictionary.
35+
36+ The status_information provides additional information for each PlanningState, with the keys of the inner dict
37+ being based on the PlanPro Akteur_Zuordnung class.
1838 """
1939
2040 def __init__ (self , ** kwargs ):
@@ -24,6 +44,8 @@ def __init__(self, **kwargs):
2444 self .signals : dict [str , Signal ] = {}
2545 self .routes : dict [str , Route ] = {}
2646 self .vacancy_sections : dict [str , VacancySection ] = {}
47+ self .current_status : PlanningState = PlanningState .erstellt
48+ self .status_information : dict [PlanningState , dict [str , str ]] = defaultdict (dict )
2749
2850 self .created_at : datetime = datetime .now ()
2951 self .created_with : str = "unknown"
@@ -83,12 +105,16 @@ def to_serializable(self):
83105 "routes" : routes ,
84106 "objects" : objects ,
85107 "vacany_sections" : vacancy_sections ,
108+ "current_status" : self .current_status .value ,
109+ "status_information" : self .status_information ,
86110 }, {}
87111
88112 @classmethod
89113 def from_json (cls , json_str : str ):
90114 obj = json .loads (json_str )
91115 topology = cls ()
116+ topology .current_status = PlanningState (obj .get ("current_status" , PlanningState .erstellt ))
117+ topology .status_information = obj .get ("status_information" , defaultdict (dict ))
92118 for node in obj ["nodes" ]:
93119 node_obj = Node (** node )
94120 topology .add_node (node_obj )
0 commit comments