TRO-JSON v4: Slots je TRO und Staubereiche (jamAreas)
- model: Slot (separator/switch/scanner/drive + Rollen), JamArea (J<Separator>, Eingang eines TRO mit allen Vorgaengern), derive_slots, derive_jam_areas; Schema sps_skel-tro-v4, v3-Dateien werden weiter gelesen - scl_context: ein JamEntr je eigenem Staubereich statt je Vorgaenger (wie UH01-UH05), Ausgaenge nennen den Staubereich des Nachfolgers - Golden Files neu erzeugt, Tests fuer Slots/Staubereiche, Doku nachgezogen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dd2d98f2ee
commit
0115ef68b7
@@ -136,3 +136,65 @@ def test_scl_skeleton_renders_from_document(document):
|
||||
# Systemgrenzen sind keine Instanzen
|
||||
assert "SYS1 :" not in scl
|
||||
assert "Anfang bei TRO01" in scl
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Schema v4: Slots und Staubereiche
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_slots_aus_katalog_und_layout(document):
|
||||
weiche = document.by_id("TRO01")
|
||||
assert [(s.slot, s.layout_id) for s in weiche.slots] == [
|
||||
("separator1", "0040"), ("switch1", "")]
|
||||
assert weiche.slots[0].roles == ["sensor", "stopper", "jamSensor?", "partSensor?"]
|
||||
vario = document.by_id("TRO03")
|
||||
assert [s.slot for s in vario.slots] == ["separator1", "drive"]
|
||||
assert vario.slots[1].layout_id == "0001" # Host = angetriebene Strecke
|
||||
# Systemgrenzen haben keine Slots
|
||||
assert document.by_id("SYS1").slots == []
|
||||
|
||||
|
||||
def test_ein_staubereich_je_tro_eingang_nach_separator(document):
|
||||
areas = {a.jam_id: a for a in document.jam_areas}
|
||||
assert sorted(areas) == ["J0040", "J0041", "J0042"]
|
||||
assert areas["J0040"].tro == "TRO01"
|
||||
assert areas["J0040"].predecessors == ["SYS1"]
|
||||
assert areas["J0040"].position == (1030.0, 4700.0, 1500.0)
|
||||
assert areas["J0041"].predecessors == ["TRO01"]
|
||||
|
||||
|
||||
def test_zusammenfuehrung_ein_staubereich_mehrere_vorgaenger():
|
||||
analysis = Analysis(tros=[
|
||||
_tro("TRO01", "1Sep", separators=["0001"], successors=["TRO03"]),
|
||||
_tro("TRO02", "1Sep", separators=["0002"], successors=["TRO03"]),
|
||||
_tro("TRO03", "1Sep", separators=["0003"], predecessors=["TRO01", "TRO02"]),
|
||||
])
|
||||
doc = TroDocument.from_analysis(analysis, source="t")
|
||||
eingang = [a for a in doc.jam_areas if a.tro == "TRO03"]
|
||||
assert [(a.jam_id, a.predecessors) for a in eingang] == [("J0003", ["TRO01", "TRO02"])]
|
||||
|
||||
|
||||
def test_zwei_separatoren_zwei_eingaenge_aufteilung_offen():
|
||||
analysis = Analysis(tros=[
|
||||
_tro("TRO01", "2Sep2Swi", separators=["0005", "0036"], predecessors=["TRO09"]),
|
||||
])
|
||||
areas = TroDocument.from_analysis(analysis, source="t").jam_areas
|
||||
assert [(a.jam_id, a.entry, a.predecessors) for a in areas] == [
|
||||
("J0005", 1, ["TRO09"]), ("J0036", 2, [])]
|
||||
assert all("offen" in a.note for a in areas)
|
||||
|
||||
|
||||
def test_v4_round_trip_und_v3_ohne_jam_areas(document):
|
||||
data = json.loads(document.to_json())
|
||||
assert data["schema"] == "sps_skel-tro-v4"
|
||||
assert data["jamAreas"][0]["id"] == "J0040"
|
||||
assert data["tros"][0]["slots"][0]["layoutId"] == "0040"
|
||||
assert TroDocument.from_json(document.to_json()) == document
|
||||
# v3-Datei: keine jamAreas/slots -> beim Rendern abgeleitet
|
||||
del data["jamAreas"]
|
||||
for tro in data["tros"]:
|
||||
del tro["slots"]
|
||||
data["schema"] = "sps_skel-tro-v3"
|
||||
alt = TroDocument.from_json(json.dumps(data))
|
||||
assert alt.jam_areas == []
|
||||
assert [a.jam_id for a in alt.jam_areas_or_derived()] == ["J0040", "J0041", "J0042"]
|
||||
|
||||
Reference in New Issue
Block a user