Skip to content

Commit 49e73f6

Browse files
Merge pull request #55 from simulate-digital-rail/planning-state
Planning state
2 parents d7960fa + 16cf0df commit 49e73f6

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

yaramo/geo_node.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ def __init__(self, x, y, **kwargs):
1919

2020
@abstractmethod
2121
def get_distance_to_other_geo_node(self, geo_node_b: "GeoNode"):
22+
"""Returns to distance to the given other GeoNode."""
2223
pass
2324

24-
def to_serializable(self):
25-
return self.__dict__, {}
26-
2725
@abstractmethod
28-
def to_wgs84(self):
26+
def to_wgs84(self) -> "Wgs84GeoNode":
2927
pass
3028

3129
@abstractmethod
32-
def to_dbref(self):
30+
def to_dbref(self) -> "DbrefGeoNode":
3331
pass
3432

33+
def to_serializable(self):
34+
return self.__dict__, {}
35+
3536

3637
class Wgs84GeoNode(GeoNode):
3738
def get_distance_to_other_geo_node(self, geo_node_b: "Wgs84GeoNode"):

yaramo/topology.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
from collections import defaultdict
12
from datetime import datetime
3+
from enum import Enum
24

35
import simplejson as json
46

@@ -11,10 +13,28 @@
1113
from 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+
1431
class 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

Comments
 (0)