The place where random ideas get written down and lost in time.
2020-04-11 - Cab Engineer “scripting”
Category DEVOne feature I miss with trains is scripting. Back in 2014 or 2015, I wrote a very simple cab command interpreter in python for JMRI, “cab3.py”.
I should add something like in Cab Engineer:
- Tie it with an existing throttle (e.g. for a specific DCC address)
- Or let the script change/mix engines.
- Be able to save / recall scripts.
- Also control turnouts.
- Introduce a mini-editor with a less cryptic language, and buttons to quickly insert language keywords.
- Make it line-agnostic so that the script can be one line or multi lines.
Random examples:
Label start
Throttle 537 speed +12 for 5s until B370 then speed 0
Reverse T330
F2 press
F5 on
Throttle 113 speed +12 for 2s
Speed 0
Speed -12 for 2s
Normal T330
F5 off
Throttle 537 speed -12 for 5s until B310 then speed 0
Loop start
Here each command is one keyword + one value, and the “then” keyword is a no-op.
A command like “for” or “until” would simply introduce a pause.
A “function press” would toggle it for a fixed time, e.g. 300-500 ms.
A logical extension is a “record macro” mode, that records the actions, generates the script, which can then be edited, saved, recalled.
Recalling a script would open a card on the recycle view with a status/run/stop. Running would “inject” commands in controllers, but not block the user. E.g. one could try to “beat” the system, or start/stop an engine during a macro run. Useful for things like horn/bell, or prevent a collision.