jmri_core.state
Shared state enums matching JMRI's Java values.
Each enum mirrors the integer constants used in JMRI's wire formats and XML files. Do not renumber these — the values are part of the persisted contract that golden XML files in stage-0/contracts/xml/golden/ depend on.
Per-bean state enums also live in this module so persistence code can import
a single namespace without circular imports through beans.
1"""Shared state enums matching JMRI's Java values. 2 3Each enum mirrors the integer constants used in JMRI's wire formats and XML 4files. **Do not renumber these** — the values are part of the persisted 5contract that golden XML files in stage-0/contracts/xml/golden/ depend on. 6 7Per-bean state enums also live in this module so persistence code can import 8a single namespace without circular imports through ``beans``. 9""" 10from __future__ import annotations 11 12from enum import IntEnum, IntFlag 13 14 15class TurnoutState(IntEnum): 16 """Matches ``jmri.Turnout.UNKNOWN/CLOSED/THROWN/INCONSISTENT`` Java constants.""" 17 18 UNKNOWN = 1 19 CLOSED = 2 20 THROWN = 4 21 INCONSISTENT = 8 22 23 24class TurnoutFeedback(IntFlag): 25 """Matches ``jmri.Turnout`` feedback-mode flags.""" 26 27 DIRECT = 1 28 ONESENSOR = 2 29 TWOSENSOR = 4 30 EXACT = 8 31 SIGNAL = 16 32 MONITORING = 32 33 DELAYED = 64 34 LN_ALM = 128 35 PUSHBUTTON = 256 36 37 38class SensorState(IntEnum): 39 """Matches ``jmri.Sensor.UNKNOWN/ACTIVE/INACTIVE/INCONSISTENT``.""" 40 41 UNKNOWN = 1 42 ACTIVE = 2 43 INACTIVE = 4 44 INCONSISTENT = 8 45 46 47class SignalAppearance(IntEnum): 48 """Matches ``jmri.SignalHead`` appearance constants — the 9 standard aspects. 49 50 Custom signals may add manufacturer-specific appearances via the 51 SignalMast layer; SignalHead is restricted to this set. 52 """ 53 54 DARK = 0 55 RED = 1 56 YELLOW = 2 57 GREEN = 4 58 LUNAR = 8 59 FLASHRED = 16 60 FLASHYELLOW = 32 61 FLASHGREEN = 64 62 FLASHLUNAR = 128 63 64 65class BlockState(IntEnum): 66 """Matches ``jmri.Block.UNDETECTED/UNOCCUPIED/OCCUPIED/UNKNOWN``.""" 67 68 UNKNOWN = 1 69 OCCUPIED = 2 70 UNOCCUPIED = 4 71 UNDETECTED = 256 72 73 74class LightState(IntEnum): 75 """Matches ``jmri.Light.OFF/ON/INTERMEDIATE``.""" 76 77 UNKNOWN = 1 78 OFF = 2 79 ON = 4 80 INTERMEDIATE = 8 81 82 83class PowerState(IntEnum): 84 """Matches ``jmri.PowerManager.UNKNOWN/ON/OFF/IDLE``.""" 85 86 UNKNOWN = 0 87 ON = 2 88 OFF = 4 89 IDLE = 8 90 91 92class RouteState(IntEnum): 93 """Internal route state — JMRI has no equivalent integer enum, this maps 94 to behavior of ``jmri.Route`` (set / unlocked / locked).""" 95 96 UNLOCKED = 0 97 LOCKED = 1 98 UNKNOWN = 2 99 100 101class ThrottleDirection(IntEnum): 102 """Locomotive direction. Matches NMRA convention.""" 103 104 REVERSE = 0 105 FORWARD = 1
16class TurnoutState(IntEnum): 17 """Matches ``jmri.Turnout.UNKNOWN/CLOSED/THROWN/INCONSISTENT`` Java constants.""" 18 19 UNKNOWN = 1 20 CLOSED = 2 21 THROWN = 4 22 INCONSISTENT = 8
Matches jmri.Turnout.UNKNOWN/CLOSED/THROWN/INCONSISTENT Java constants.
25class TurnoutFeedback(IntFlag): 26 """Matches ``jmri.Turnout`` feedback-mode flags.""" 27 28 DIRECT = 1 29 ONESENSOR = 2 30 TWOSENSOR = 4 31 EXACT = 8 32 SIGNAL = 16 33 MONITORING = 32 34 DELAYED = 64 35 LN_ALM = 128 36 PUSHBUTTON = 256
Matches jmri.Turnout feedback-mode flags.
39class SensorState(IntEnum): 40 """Matches ``jmri.Sensor.UNKNOWN/ACTIVE/INACTIVE/INCONSISTENT``.""" 41 42 UNKNOWN = 1 43 ACTIVE = 2 44 INACTIVE = 4 45 INCONSISTENT = 8
Matches jmri.Sensor.UNKNOWN/ACTIVE/INACTIVE/INCONSISTENT.
48class SignalAppearance(IntEnum): 49 """Matches ``jmri.SignalHead`` appearance constants — the 9 standard aspects. 50 51 Custom signals may add manufacturer-specific appearances via the 52 SignalMast layer; SignalHead is restricted to this set. 53 """ 54 55 DARK = 0 56 RED = 1 57 YELLOW = 2 58 GREEN = 4 59 LUNAR = 8 60 FLASHRED = 16 61 FLASHYELLOW = 32 62 FLASHGREEN = 64 63 FLASHLUNAR = 128
Matches jmri.SignalHead appearance constants — the 9 standard aspects.
Custom signals may add manufacturer-specific appearances via the SignalMast layer; SignalHead is restricted to this set.
66class BlockState(IntEnum): 67 """Matches ``jmri.Block.UNDETECTED/UNOCCUPIED/OCCUPIED/UNKNOWN``.""" 68 69 UNKNOWN = 1 70 OCCUPIED = 2 71 UNOCCUPIED = 4 72 UNDETECTED = 256
Matches jmri.Block.UNDETECTED/UNOCCUPIED/OCCUPIED/UNKNOWN.
75class LightState(IntEnum): 76 """Matches ``jmri.Light.OFF/ON/INTERMEDIATE``.""" 77 78 UNKNOWN = 1 79 OFF = 2 80 ON = 4 81 INTERMEDIATE = 8
Matches jmri.Light.OFF/ON/INTERMEDIATE.
84class PowerState(IntEnum): 85 """Matches ``jmri.PowerManager.UNKNOWN/ON/OFF/IDLE``.""" 86 87 UNKNOWN = 0 88 ON = 2 89 OFF = 4 90 IDLE = 8
Matches jmri.PowerManager.UNKNOWN/ON/OFF/IDLE.
93class RouteState(IntEnum): 94 """Internal route state — JMRI has no equivalent integer enum, this maps 95 to behavior of ``jmri.Route`` (set / unlocked / locked).""" 96 97 UNLOCKED = 0 98 LOCKED = 1 99 UNKNOWN = 2
Internal route state — JMRI has no equivalent integer enum, this maps
to behavior of jmri.Route (set / unlocked / locked).
102class ThrottleDirection(IntEnum): 103 """Locomotive direction. Matches NMRA convention.""" 104 105 REVERSE = 0 106 FORWARD = 1
Locomotive direction. Matches NMRA convention.