User Tools

Site Tools


Sidebar



Minetest Forum
Content Database
Git Repository
Bug Tracker
Website

dev:proposals:xatc

This is an old revision of the document!


Table of Contents

xATC

xATC is a proposed system to supersede conventional ATC, by incorporating and taking advantage of new features, like:

  • Approach callbacks
  • Train variables(line, routingcode, texts)
  • Timetables (planned) and Railway Time scheduling
  • programmatically splitting and joining trains

This is a roadmap. Suggestions, ideas and improvements are welcome

Constraints

  • MUST support everything conventional ATC can do
  • SHOULD support everything LuaATC can do
  • Should be easy to use for newcomers (not pure Lua)
  • Setups should be copyable, and there should be a way to modularize setups (“templates”/“functions”)

The following things should be doable through xATC:

  • Controlling current train target speed, open/close doors, reverse train
  • Using the LZB mechanism to brake a train in advance/make it stop
  • Schedule execution of further commands by both simple time delay (like “D”) and Railway Time
  • Setting train parameters (line, rc, inside/outside text, custom values)
  • Allow for splitting/joining trains and managing train sections (different parts of the train designated for different destinations, planned)
  • Control interlocking (set/cancel routes, enable/disable ARS on train)
  • Interface to external components (e.g. digilines)
  • Be extensible to new features introduced over time

Draft

xATC will use a subset of Lua to express actions. The following things are restricted:

  • “while” and “repeat/until” loops are not supported
  • “for” loops only allow using a counter variable, not an iterator function
  • The global environment is not writable. A number of standard variables and functions exists to be used.

xATC code is organized in so-called “events”. An event can be a builtin event or a user-defined event. The RWT scheduler, which has a builtin DOS protection, will serve as event queue.

An xATC code snippet would, for example, look like this:

On Approach:
train.text_outside = "E3 - Trisiston\nvia Tanh Cliffs"
train.text_inside = "Next Stop: Euler Street\nTerminus, please get off."
train.ars = false
train.stop()   -- makes train stop at the rail and emits "Stop" afterwards
rail.digiline_send("DFI-controller", "Arr:E3W")

On Stop:
train.reverse()
train.text_inside = "Euler Street"
train.doors("R")
schedule("+02;00", "Depart-Ready") -- Schedule departure in 2 minutes
rail.digiline_send("DFI-controller", "Stp:E3W")

On Depart-Ready:
signal.ars().wait("Depart") -- Tell the next signal to do ARS and emit "Depart" when route is set

On Depart:
train.doors("C").wait() -- Wait in-place (without another event) for doors to close
train.text_inside = "Welcome on board! Next stop: Mountain South"
train.ars = true
train.speed()
rail.digiline_send("DFI-controller", "Dep:E3W")

Notable things:

  • Events are denoted by “On Eventname:”. They are not lua-conformant and handled externally.
  • The pre-defined entities “train”, “signal” and “rail” refer to the current train, the next signal in direction of travel and the emitting xATC rail respectively
  • “schedule()” simply schedules an event based on railway time.
  • Actions (like doors(), speed(), ars()) are asynchronous in first term. You can make them explicitly synchronous by calling wait() without arguments on them. This only works on some actions (e.g. not on ars(), because that might never return)
  • Alternatively, calling wait(“Eventname”) emits the specified event when the action is complete.
dev/proposals/xatc.1572335363.txt.gz · Last modified: 2019-10-29 08:49 by 141.76.180.151