Automation with JMRI
JMRI provides powerful tools for automating your layout, from simple signal logic to complex operational sequences.
Logix: The Logic Engine
Logix evaluates conditions and triggers actions - like IF/THEN statements for your layout.
Creating a Logix
- Go to Tools → Tables → Logix
- Click "Add"
- Create Conditionals (the IF part)
- Add Actions (the THEN part)
Example: Automatic Crossing Gates
Conditional: IF Block 5 is OCCUPIED
Actions:
- Set Signal "CrossingLights" to FLASHING RED
- Throw Turnout "CrossingGate" to CLOSED
Signal Mast Logic
For prototype signaling, use Signal Mast Logic instead of simple signal logic.
Setup Steps
- Define Signal Masts (the physical signals)
- Create Signal Mast Logic entries
- Specify the mast being controlled
- Set watched blocks and turnouts
- JMRI calculates correct aspects automatically
Aspect Calculation
Signal Mast Logic considers:
- Block occupancy ahead
- Turnout positions
- Next signal's aspect
- Speed limits
Automatic Train Running
Use Dispatcher for automatic train operation:
- Define Sections (track segments)
- Create Transit (path through sections)
- Allocate sections to a train
- Set auto-run parameters
The train will follow signals, stop at red, and proceed automatically.
Python Scripting
For ultimate flexibility, write Jython scripts:
import jmri
Get a turnout
turnout = turnouts.getTurnout("LT1")
Throw it
turnout.setState(THROWN)
Scripts can respond to events, create sequences, and integrate external systems.