Lua Automatic Train Control version 2.0

Achte bitte darauf, dass Du mit deinem Thema bzw. mit deiner Frage im richtigen Bereich bist.
Die Bereiche sind: Einstellungen im Forum, EEP aktuell ab EEP7 , Splines, Rollmaterialien, Immobilien, Landschaftselemente, Signale und Schaltung, Anlagenvorstellungen, Schnappschüsse Konstrukteure, EEP Treffen , Laberecke, Online - Handbuch EEP Vielen Dank für die Unterstützung das Forum übersichtlich zu halten.
Bilder/Fotos aus dem Internet sind nur als Link gestattet. Eigene Fotos, also Fotos aus dem realen Leben, sind erstens mit Eigenes Bild als Quellenangabe zu kennzeichnen und zweitens nur als Dateianhang im Beitrag zulässig. Bilder ohne Quellenangaben und Bilder dessen Quelle das Internet wie z. B. Google ist, werden gelöscht.
  • In a continuous exchange of ideas with Frank Buchholz and thanks to Frank’s programming skills we’re happy to present version 2 of the EEP Lua Automatic Train Control. The previous version was posted earlier on this forum: link to version 1 thread.

    The original idea is still the same: trains run fully automatically from block to block, whereby the user can define which trains are allowed in which blocks and if there are scheduled stopping times per train and block.

    What's new is that it’s easier than ever to prepare your EEP layout for automatic train traffic. All that is needed is a stop signal at the end of each block and an entry sensor at the beginning. The "memory signals" that were required in version 1 have been eliminated. Tool tips are available that can help identify turnouts and signals.

    Another improvement is that the somewhat tedious way of placing trains is replaced by fully automatic train detection. A new train can simply be placed in front of the pre-signal of any block, be given a name and a speed, and as it approaches the signal the Lua code automatically detects it.

    A new feature is that "allowed blocks" can be configured as groups. If multiple trains are allowed in the same blocks, it can be beneficial to name a group, such as “intercity” or “cargo shuttle”, and define the allowed blocks for that group. This way the same allowed blocks don’t have to be kept repeated in the trains table, which also becomes much better readable this way.

    The new version 2 also includes a provision to avoid “deadlocks”. With some layouts it could happen that opposing trains can not find a free block in front of them anymore. This is avoided by defining "anti-deadlock" paths. An example of such a path: {{3,4,5}, 6, {7,8}}, where 3,4,5,7,8 are dead ends and 6 is a "via" block. This definition means that a train in block 3,4 or 5 will only depart via block 6 if at least one of the blocks 7 or 8 is free. Without this provision a train could enter block 6, which would lead to a deadlock if there already are trains in both block 7 and 8.

    And then perhaps the greatest new feature is a tool that can automatically generate the Lua tables to define the layout. Simply enter your .anl3 file in the tool and it will create the tables that can then be copy & pasted into your Lua code, saving quite some work. Please have a look at the user manual, chapter “Tools for Generating Lua Configuration Tables”, to see how to do this.

    A ZIP file can be downloaded here: EEP Lua Automatic Train Control v2. It contains:

    • the Lua control file, which must be placed in the EEP installation folder \LUA.
    • several demo layouts explaining how to configure Lua tables to enable automatic train traffic
    • a user manual in English and in German

    If you’d like to have a look at the user manual beforehand, the pdf can be downloaded here:

    Have fun, Frank Buchholz & Rudy Boer.


  • EEP Lua Automatic Train Control v2 Example 1

    With the aid of Lua code automatic train traffic can be generated for any EEP layout, without doing any coding yourself. All that is needed is to define a couple of Lua tables, on trains, on which turnouts to switch per route, and on allowed blocks and scheduled stop times. Lua will then generate the train traffic whereby trains drive automatically from block to block.

    Link to the video.

    Link to download the complete package as a ZIP file: see the first post of this thread.

  • RudyB:

    How do I handle a 2-way track section that has a signal at one end (wait on signal to turn green) but none at the other end (select direction of a turnout).

    All I can possibly think of is to add a signal at the none signal end, but I’d rather not do that since it increases the complexity.

  • chucksim2 Demo 3 shows how to define two way tracks.

    For the Lua code to work without collisions a two way track requires a signal at both ends. Lua treats this as two blocks, one in each direction, with the extra that if a train reserves one of the blocks, Lua will also reserve the twin block.

    So, you will have to place a signal at the other end. You probably had your reasons not to have that signal ... if you don't want the signal to show you can use the invisible signal type.

  • EEP Lua Automatic Train Control v2 Example 2

    In demo 2 we add a second train. They drive around, controlled by Lua, without ever colliding. Lua only allows a train to start driving if the destination block and all the required turnouts on the way are free. If a train is allowed to start, Lua reserves the turnouts and the destination block; these are now unavailable to other trains until they are released again when the train arrives at its destination block, which is detected via the block entry sensor.

    Link to the video.

    To download the ZIP with demo layouts and user manual: see the first post in this thread.

  • EEP 17 – Lua Ver 2 - Questions

    1. It appears to me that you have code for turnouts that you can drive thru, is that code required, or just for appearance?

    2. Regarding Tip Text on your signals and turnouts. To set the record straight, I have not tried Lua Rev 2 code yet, I’m working on utilizing Tip Texts on my layout.

    2a. When I enter several lines into the Tip (such as block number, signal position, train name), they are all on one line when I edit the tip again (not 3 lines).

    2b. What does “<bgrgb=0,220,0>free” mean, particularly “<bgrgb=0,220,0>”. Are there any tutorials on using Tips.

    3. What purpose does the “Signal-Counter” do? No familiar with that type of signal.

    4. As to installation – see below.

    Regarding “Gleisplan program”. Install in the Program directory or the EEP17 directory.

    blockControl Program. Install in the Program directory or the EEP17 directory.

    Inventar Program. Install in the Program directory or the EEP17 directory.

    BetterContacts. Install in the EEP 17 directory.

    5. RudyB, do I first have to install all the above before using Rev 2 or can I just modify your layout 5 Lua file with my info.

  • chucksim2

    Why do you always have to use a bold font, do we really want to shout at each other, isn't the normal font size enough?

    Even if you just want to support, help... do you have to use bold font, is the normal font size not enough?

    We think it is. Normal font size is enough. This request is not only addressed to you, it is addressed to all members. :ae_1:

    Gruß icke

  • Zitat

    2b. What does “<bgrgb=0,220,0>free” mean, particularly “<bgrgb=0,220,0>”. Are there any tutorials on using Tips.

    We create the tipp texts in Lua.

    The format codes are described here:

    7.6.3 Tipp-Texte für Objekte und Kontaktpunkte

    <j> left-aligned

    <c> centered

    <r> right-aligned

    <br> line break (*)

    <b>Bold</b>

    <i>Italic</i>

    <fgrgb=0,0,0> font color with rgb colors

    <bgrgb=0,0,0> background color with rgb colors

    (*) via Lua we use "\n" instead, which might result in the effect which you describe, that the text converts to a single line as soon as you touch it in EEP. (I'll test it, and maybe change it in a future version.)

    Examples for color codes in our Lua module:

    local tippTextRED = "<bgrgb=240,0,0>"

    local tippTextGREEN = "<bgrgb=0,220,0>"

    local tippTextYELLOW = "<bgrgb=220,220,0>"

    Zitat

    4. As to installation

    The “Gleisplan program” https://frankbuchholz.github.io/EEP_convert_an…_Gleisplan.html

    the "Inventar program" https://frankbuchholz.github.io/EEP_convert_an…P_Inventar.html

    and the "EEP_blockControl program" https://frankbuchholz.github.io/EEP_convert_an…ockControl.html

    are online tools which could help you to see and verify the EEP track layout respective generate the data desctibing the blocks of the layout.

    These tools are useful but not technically required.

    The module BetterContacts.lua from https://emaps-eep.de/lua/bettercontacts is optional as well, depending on how you want to define the Lua function in the contacts defining the entry point of blocks. See the documentation about if and how to use it.

    The only mandatoty piece is the module blockControl.lua which you have to place into the /LUA folder of your EEP installation.

    You find the documentation of our package blockControl v2 here:

    https://github.com/FrankBuchholz/…_Control_v2.pdf

    Online EEP-Tools: Gleisplan-Programm / Inventar-Programm

    EEP 15 ab Mai 2019 und EEP 17 ab Nov. 2021
    EEP 6 in 2011 und EEP 13 ab Januar 2019 sind eingemottet
    XMP Core 17 Laptop mit Intel Core i7-10870H 8-Core-CPU, 16 GB Arbeitsspeicher, NVIDIA GeForce RTX 3060 Laptop GPU mit DirectX 12

    2 Mal editiert, zuletzt von frank.buchholz (30. April 2022 um 14:30)

  • icke I’m sorry about using bold fonts, but I’m 85 years old and they make it easy for me. I will make sure I don’t use it in the future.

    RudyB; 1. It appears to me that you have code for turnouts that you can drive thru, is that code required, or just for appearance?

    2. When I enter several lines into the Tip (such as block number, signal position, train name), they are all on one line when I edit the tip again (not 3 lines).

    3. What purpose does the “Signal-Counter” do? No familiar with that type of signal.

    Thanks to all of you for your help and patience.

  • Q1: The blockControl.lua software switches the turnouts that you specify in your routes table. If you don't want drive thru switches to switch, then simply don't mention them in your routes table.

    Q2: See the reply Frank gave.

    Q3: It is used to show less or more information in the Lua messages window. 0 = no messages, 1 = normal, 2 = more, 3 = excessive. 2 and 3 are mainly used for debugging purposes, to monitor what is going when things don't go as expected.

  • EEP Lua Automatic Train Control v2 Example 3

    Let's have a two way traffic track in the layout and see how this can be configured.

    A two way track is treated as two separate one way blocks on the same track. Both blocks have their own block signal and entry sensor. When Lua reserves one of the two blocks for a train, the other block has to be reserved too. Likewise, when released, the twin block also has to be released. We'll have to tell Lua which blocks are 'two way twin' blocks, such that this extra reservation and release can take place.

    Link to the video.

    To download the ZIP with demo layouts and User Manual: see the first post in this thread.


  • A question from chucksim2 in another thread:

    Zitat

    I have one question for RudyB regarding Lua Rev 2 code. Can DST switches be used and if so, what entries do I enter?

    I‘ve to confess that I never have used Double Slip Turnouts together with Lua. I know that there exist different types of DST which might require different treatment.


    Who could explain how to deal with DST using Lua?

    Online EEP-Tools: Gleisplan-Programm / Inventar-Programm

    EEP 15 ab Mai 2019 und EEP 17 ab Nov. 2021
    EEP 6 in 2011 und EEP 13 ab Januar 2019 sind eingemottet
    XMP Core 17 Laptop mit Intel Core i7-10870H 8-Core-CPU, 16 GB Arbeitsspeicher, NVIDIA GeForce RTX 3060 Laptop GPU mit DirectX 12

  • Let's give it a try: Here is a small test layout containing both types of DST: A 4-turnout-DST on the top (created using the built in track templates of EEP) and a track object DST at the bottom.

    Here is the corresponding picture from the Gleisplan program:

    Here is the corresponding code which was derived from the generated template of the BlockControl program :

    Observations and adjustments:

    • I use the optional module BetterContacts to ease the creation of the Lua contacts.
    • The track object DST has only one turnout id having 4 positions.
    • The generated code does not know about this track object DST. (That's another item for the wish list for a future version.)
    • Therefore, it was neccessary to create the corresponding routes manually. I activated the checkbox about turnout events in the Lua skript editor to view the position numbers of this turnout depending on the positions. This way it way quite easy to define the routes via this DST.
    • Finally I extended the generated routes via the 4-turnout DST to secure the crossing by adding a turnout from the other part of the crossing.

    Success!

    Online EEP-Tools: Gleisplan-Programm / Inventar-Programm

    EEP 15 ab Mai 2019 und EEP 17 ab Nov. 2021
    EEP 6 in 2011 und EEP 13 ab Januar 2019 sind eingemottet
    XMP Core 17 Laptop mit Intel Core i7-10870H 8-Core-CPU, 16 GB Arbeitsspeicher, NVIDIA GeForce RTX 3060 Laptop GPU mit DirectX 12

    Einmal editiert, zuletzt von frank.buchholz (5. Mai 2022 um 14:58)

  • Hi Frank,

    Is it possible to publish this layout with this track object DST on your GitHub channel or make it available in some other way?

    As a practice exercise, I have been rebuilding this layout, but can't get it to work. There is a bug but can't figure out where yet. The Lua script is operational, but not all switches respond correctly and all signals are set to drive-though simultaneously.

    In comparison with your layout, I hope to find out.

    So that will be some more puzzling.

    Thanks in advance for the effort.

    Für nicht-HolländischeTexte verwende ich ein Online-Übersetzungstool. Entschuldigung, wenn die Sätze grammatikalisch falsch sind. For the non-Dutch Text I use an online translation tool (DeepL) Sorry for some grammer errors.

    Grüße aus Holland.

    Warner


    Laptop: Dell G15 - AMD Ryzen 7 5800H - RTX 3060 6GB - 64Gb - Windows 11 / EEP 15.1 Patch 2 - Plugin 1 / EEP 17.2 Expert [X64] Plugins: 1,2