TrainRBCSim
ADR-029 Train (EVC) simulator — dual-homed TCP client speaking the RBC wire protocol
Loading...
Searching...
No Matches
train.site_data Namespace Reference

Functions

 balise_names (railml_path=None)

Variables

str _RAILML_NS = "https://www.railml.org/schemas/3.3"
str _SAPI_NS = "https://safeapirbc2oo2.example/schemas/sapi-ext/1"
dict _NS = {"r": _RAILML_NS, "sapi": _SAPI_NS}
 _WORKSPACE_ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", ".."))
 DEFAULT_RAILML_PATH = os.path.join(_WORKSPACE_ROOT, "safeAPIRBC2oo2SA", "etc", "site", "ab_site.railml.xml")
dict _FALLBACK_BALISE_NAMES

Detailed Description

site_data.py - Train sim's own tiny RailML reader.

Independently re-parses safeAPIRBC2oo2SA/etc/site/ab_site.railml.xml -
the same single source of truth safeAPIRBC2oo2GP/etc/scripts/
generate_ab_site_gp.py and safeAPIRBC2oo2GA/etc/scripts/generate_ab_site_ga.py
already generate GP's/GA's own C site-data tables from, and
safeAPIRBC2oo2TestEnv/src/web_runner/site_data.py already reads for the
live schematic - deliberately a FOURTH independent reader, not a call
into any of those three, matching the "each generator re-parses the file
itself, no pipeline coupling" convention those two C-side generators'
own header comments already establish (see either one's own doc for the
full rationale: no build-order coupling, and a real cross-check
opportunity instead of one silently trusting another's derived output).

Train only ever needs ONE thing from the file: the `nid_lrbg -> name`
mapping this sim uses purely for its own log-line decoration (see
train_sim.py's own get_balise_name()) - replaces what used to be a
hardcoded BALISE_NAMES dict that was, by actual comparison, a byte-for-
byte duplicate of this file's own <baliseGroup> data.

Function Documentation

◆ balise_names()

balise_names ( railml_path = None)
@return {nid_lrbg: name} parsed fresh from the RailML file (no
caching - this sim's own catalog/config loading is likewise done
once at import/startup time, matching that same "read once, live
for the process's lifetime" posture). Falls back to a hardcoded copy
of today's known-good data (see _FALLBACK_BALISE_NAMES's own doc) and
logs a warning if the file can't be found/parsed, rather than raising
- a missing balise-name mapping is a log-decoration cosmetic, never
worth failing sim startup over.

Definition at line 52 of file site_data.py.

Variable Documentation

◆ _FALLBACK_BALISE_NAMES

dict train.site_data._FALLBACK_BALISE_NAMES
protected
Initial value:
= {
1001: "BG_W_TRK1", 1002: "BG_W_TRK2", 1003: "BG_W_TRK3", 1004: "BG_W_TRK4",
1005: "BG_UP_1", 1006: "BG_UP_2", 1007: "BG_DOWN_1", 1008: "BG_DOWN_2",
1009: "BG_E_TRK1", 1010: "BG_E_TRK2", 1011: "BG_E_TRK3", 1012: "BG_E_TRK4",
}

Definition at line 45 of file site_data.py.

◆ _NS

dict train.site_data._NS = {"r": _RAILML_NS, "sapi": _SAPI_NS}
protected

Definition at line 28 of file site_data.py.

◆ _RAILML_NS

str train.site_data._RAILML_NS = "https://www.railml.org/schemas/3.3"
protected

Definition at line 26 of file site_data.py.

◆ _SAPI_NS

str train.site_data._SAPI_NS = "https://safeapirbc2oo2.example/schemas/sapi-ext/1"
protected

Definition at line 27 of file site_data.py.

◆ _WORKSPACE_ROOT

train.site_data._WORKSPACE_ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", ".."))
protected

Definition at line 34 of file site_data.py.

◆ DEFAULT_RAILML_PATH

train.site_data.DEFAULT_RAILML_PATH = os.path.join(_WORKSPACE_ROOT, "safeAPIRBC2oo2SA", "etc", "site", "ab_site.railml.xml")

Definition at line 35 of file site_data.py.