Text this: A mathematical model for railway control systems