Welcome to the forum   
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post in this topic Go to first unread post in this topic
Offline fabstar68  
#1 Posted : 29 July 2024 16:41:44(UTC)
fabstar68

Italy   
Joined: 14/12/2023(UTC)
Posts: 60
Location: Milan
hi all,

i am progressing with my Rocrail setup, now i wanted to do something more advanced. I have a train that, when i start the locomotive in automatic mode, performs a certain loop. That works well without XML. But now I want to define 2 buttons (output) that do the following :

Button 1 (Terminate the service for the train)
- Terminate the automatic mode for that train
- send it to a specific block in my hidden yard (that are routes then can be used by this train from wherever it is in its normal loop, to the specific block i want it to rest. but i don't know which block the train is, of couse, when i hit this button)
- change logical direction, for the next start

Button 2 (start the service for the train)
- Send the train from the specific block in my hidden yard, to another specific block where there is a diesel pump facility (there are routes defined that allow this, there are several intermediate blocks to travel to, anche change direction and switches in the travel)
- activate some loco functions (i need to be able to specifity which functions activate, durations, delay, etc)
- Send the train to the block where the normal service begins
- activate the automatic mode for the train

i believe that everything i mentioned above is doable, but i cannot find many examples of XML scripts in the online documentation, this is why i am asking here, where i understand there are several people with yearly experience on rocrail, who i hope can help, thanks.

Fab





Offline JohnjeanB  
#2 Posted : 30 July 2024 00:13:17(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi Fab
Terminate the service for the train
You need, on a specific block to detect the loco and its cars
- stop the loco from its fish bowl operation
- add a small xml program to activate a decoupler
- must verify the cars have stayed just near the decoupler (otherwise, the loco must come back to the decoupler and try again,
- start a schedule (route) to extract the loco and send it to the depot

start the service for the train
You need to
- start a schedule (route) to extract a loco from its shed, send it to its cars
- verify the consist is coupled properly
- when the loco is presented in front of a main line, start the fishbowl (command "go"

Surprisingly you need very very little XML to do this but simple actions to:
- start or stop the fishbowl operation of the loco
- assemble the train or disassemble the train (tell Rocrail that consist abc is attached to a loco or removed from it.

In fact, in my case I use an output (a button) to start a tour that then cascades "Fahrpläne" (not sure about about the English Rocrail translation. This starts the service.
I use another button to autorise or lock the automatic triggering of the end of service operation

Here is an example of this operation Two buttons like you asked, two xml programs one to decouple the loco at end of service and another to start some decoupling tries whan the cars are iin the proper siding.
Here we start with start of service then fish bowl operation and then end of service. This is followed by another start of service


Here is the Rocrail synoptic with loads of buttons to start new services
Sans titre.png

Note: you may even start without any XML program but using the command recorder to create a chain of text, Rocral will interpret for you (less precise than XML because the time granularity is one second and not one millisecond)
Cheers
Jean
Offline fabstar68  
#3 Posted : 30 July 2024 11:20:06(UTC)
fabstar68

Italy   
Joined: 14/12/2023(UTC)
Posts: 60
Location: Milan
thanks, that is much appreciated. could you just send some examples of XML code, even if not 100% related to my needing, so that i can have a look at them ? also, the definition (actions) of your buttons, and so on. i understand that i am asking some effort from you, but that would save me a lot of trial and errors activity, as well as things that otherwise i could never knew i could do. thanks
Offline JohnjeanB  
#4 Posted : 31 July 2024 00:05:12(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi Fab
This forum does not allow me to include xml files
(you need to go on the Rocrail forum for this)

So here is one example of a decoupler periodic triggering to uncouple variable length consists
********************************************************************

<?xml version="1.0" encoding="UTF-8"?>
<xmlscript>

<!---Entkuppeln versuch #1 -->
<sw id="167EK" cmd="straight"/>
<sleep time="400"/>
<!---Entkuppeln versuch #2 -->
<sw id="167EK" cmd="straight"/>
<sleep time="400"/>
<!---Entkuppeln versuch #3 -->
<sw id="167EK" cmd="straight"/>
<sleep time="400"/>
<!---Entkuppeln versuch #4 -->
<sw id="167EK" cmd="straight"/>
<sleep time="400"/>
</xmlscript>

*******************************************************
Here is an example of an uncoupling using a loco with Telex coupling
*******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<xmlscript>
<!-- Kein Last -->
<fn id="T16_KPEV" fnchanged="8" f8="true"/>
<!-- Telex Aus -->
<fn id="T16_KPEV" fnchanged="4" f4="false"/>
<!-- Stop Lok -->
<lc id="T16_KPEV" V="0"/>
<sleep time="3000"/>
<!-- Telex Ein -->
<fn id="T16_KPEV" fnchanged="4" f4="true"/>
<!-- Startet Lok V=40 -->
<lc id="T16_KPEV" V="44" dir="false"/>
<sleep time="3000"/>
<!-- Stop Lok -->
<lc id="T16_KPEV" V="00"/>
<sleep time="1000"/>
<!-- Last Ein-->
<fn id="T16_KPEV" fnchanged="8" f8="false"/>
<sleep time="1000"/>
<!-- Telex Aus -->
<fn id="T16_KPEV" fnchanged="4" f4="false"/>


</xmlscript>

************************************************
Cheers
Jean
Offline fabstar68  
#5 Posted : 31 July 2024 10:53:11(UTC)
fabstar68

Italy   
Joined: 14/12/2023(UTC)
Posts: 60
Location: Milan
thx, that was very helpful. i tried giving a try to the rocrail german forum, but of course i cannot understand anything there.... and i only have my company pc, which is not enabled to use the automatic translator. so any more examples of scripts, like the ones that you previously posted, will be good. i am a software engineer so i just need few basic info to be able to stand up on my feet....
Offline jcrtrains  
#6 Posted : 31 July 2024 21:14:52(UTC)
jcrtrains

Canada   
Joined: 31/10/2009(UTC)
Posts: 609
Location: Toronto, Ontario
I continue to lack XML capabilities but I sincerely admire you guys and what you are doing.

Sincerely - a help desk nightmare

IMG_20200716_092527~small.jpg
Offline JohnjeanB  
#7 Posted : 01 August 2024 10:13:40(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi JCRTrains
I tried to send you an email through the forum so here is the text
but when trying to insert a file it did not work
So I include the text file at the bottom of this or you give an email address by PM where I can send the file and possibly others

Here is a more complicated example of XML program
What it does is to search for all locos listed in Rocrail by inspecting its tables.
Then it looks where these locos are located:
1- on the line
2- in a shed
3- not on the layout
Depending on the location, it will turn headlights on, sound on
It also processes the special cars with a fonction decoder

All activity and results are "traced" They leave a message in the bottom left quadrant

In your case, you have to list the names of shed blocks, for it to work
Cheers
Jean

<?xml version="1.0" encoding="UTF-8"?>
<xmlscript>
<!-- Programme recherche des locos -->
<!-- Allumage locos sur voie -->
<!-- Extinction locos remisées -->
<vr id="var15" value="0"/>
<vr id="var16" value="0"/>
<trace text="Démarrage début de journée" />
<foreach table="lclist" >
<query vr="vr_SBFLZtmp" table="lclist" id="%oid%" get="blockid"/>
<query vr="vr_engine" table="lclist" id="%oid%" get="engine"/>
<query vr="vr_id" table="lclist" id="%oid%" get="id"/>
<if condition="@vr_SBFLZtmp = (null)">
<then>
<if condition="@vr_engine = automobile">
<then>
<trace text="Décodeur de fonction %oid%"/>
<if condition="@vr_id = Speisewagen_DB">
<then>
<trace text="Programmation décodeur de fonction %oid%"/>
<fn id="Speisewagen_DB" fnchanged="4" f4="true"/>
<fn id=%oid% fnchanged="0" f0="true"/> <!-- Ecl restaurant -->
<fn id=%oid% fnchanged="1" f1="true"/> <!-- Ecl couloir -->
<fn id=%oid% fnchanged="2" f2="true"/> <!-- Lampes tables -->
<fn id=%oid% fnchanged="3" f3="true"/> <!-- Ecl rame -->
<fn id=%oid% fnchanged="4" f4="true"/> <!-- Ecl cuisine H -->
<fn id=%oid% fnchanged="5" f5="true"/> <!-- Ecl cuisine B -->
<fn id=%oid% fnchanged="13" f13="false"/> <!-- La graisse brûle -->
</then>
</if>
</then>
<else>
<trace text="La loco %oid% n'est pas sur le réseau" />
</else>
</if>
</then>
<else>
<if condition="@vr_SBFLZtmp = 200|@vr_SBFLZtmp = 201|@vr_SBFLZtmp = 202|@vr_SBFLZtmp = 203|@vr_SBFLZtmp = 204|@vr_SBFLZtmp = 205|@vr_SBFLZtmp = 206|@vr_SBFLZtmp = 207|@vr_SBFLZtmp = 208|@vr_SBFLZtmp = 211|@vr_SBFLZtmp = 213|@vr_SBFLZtmp = 215|@vr_SBFLZtmp = 216|@vr_SBFLZtmp = 217|@vr_SBFLZtmp = 163|@vr_SBFLZtmp = 164|@vr_SBFLZtmp = 165|@vr_SBFLZtmp = 174" alltrue="false">
<then>
<trace text="La loco %oid% est en remise = @vr_SBFLZtmp" />
<fn id=%oid% fnchanged="0" f0="false"/>
</then>
<else>

<trace text="Allumage loco %oid% en = @vr_SBFLZtmp" />
<fn id=%oid% fnchanged="0" f0="true"/>
<query vr="vr_engine" table="lclist" id="%oid%" get="engine"/>
<query vr="vr_id" table="lclist" id="%oid%" get="id"/>
<if condition="@vr_engine = steam">
<then>
<trace text="La loco vapeur %oid% est en = @vr_SBFLZtmp" />
<fn id=%oid% fnchanged="1" f1="false"/> <!-- Kein Rauchen -->
<!-- Son des vapeurs en pleine voie activé -->
<fn id=%oid% fnchanged="2" f2="true"/>
</then>
</if>
<!-- Conditions spéciales locos -->
<if condition="@vr_id = Micheline">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="0" f0="true"/>
<fn id=%oid% fnchanged="1" f1="true"/> <!-- Innenlicht -->
</then>
</if> <if condition="@vr_id = 241_A_002_EST">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="2" f2="true"/>
<fn id=%oid% fnchanged="6" f6="true"/> <!-- Innenlicht -->
</then>
</if>
<if condition="@vr_id = 241_A_65_SNCF">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="2" f2="true"/>
<fn id=%oid% fnchanged="5" f5="true"/> <!-- Innenlicht -->
<fn id=%oid% fnchanged="6" f8="true"/> <!-- Innenlicht -->
</then>
</if>
<if condition="@vr_id = BR_01_138">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="2" f2="true"/>
<fn id=%oid% fnchanged="8" f8="false"/> <!-- Kohle voll -->
</then>
</if>
<if condition="@vr_id = BR_01_147">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="2" f2="true"/> <!-- Sound -->
<fn id=%oid% fnchanged="6" f6="truse"/> <!-- Brandende Feuer -->
</then>
</if>
<if condition="@vr_id = BR_110_1287">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="1" f2="false"/> <!-- Panto AR -->
<fn id=%oid% fnchanged="2" f2="true"/> <!-- Sound -->
<fn id=%oid% fnchanged="4" f4="false"/> <!-- Sound -->
</then>
</if>
<if condition="@vr_id = BR_98_FestZug_MFX">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="2" f2="true"/> <!-- Sound -->
<fn id=%oid% fnchanged="8" f8="true"/> <!-- Fest licht -->

</then>
</if>
<!-- Ne fonctionne que si pas d'espace dans le nom de la loco -->
<if condition="@vr_id = SBB_RAM">
<then>
<trace text="fonctions speciales %oid%" />
<fn id=%oid% fnchanged="2" f2="true"/> <!-- Sound -->
<fn id=%oid% fnchanged="6" f6="true"/> <!-- Innenlicht -->
<fn id=%oid% fnchanged="8" f8="true"/> <!-- Getriebelicht -->
</then>
</if>
</else>
</if>

</else>
</if>
</foreach>
<trace text="Fin du programme début de journée" />
</xmlscript>
Offline fabstar68  
#8 Posted : 01 August 2024 17:03:36(UTC)
fabstar68

Italy   
Joined: 14/12/2023(UTC)
Posts: 60
Location: Milan
that was gold, J.
I got all of it. very clever. just confirm that VAR15 and VAR16 are unused variables so they can be removed. Feed me others !!!! I am like a sponge.

A couple of points :
1) i have a loco with separate lights control for front cab and rear cab, i need a xml example that lets me understand the direction the loco is going, so that i can turn on the appropriate cab lights in the departure event of the blocks
2) i need to test the condition if a certan output button is on, have you got an example ? if i had to guess, it would be : <query vr="vr_xxxxx_state" table="output" id="xxxxx" get="state"/>, where xxxxx is my output button name ?

thanks

Edited by user 01 August 2024 20:35:18(UTC)  | Reason: Not specified

Offline rbonet  
#9 Posted : 01 August 2024 22:15:00(UTC)
rbonet

Spain   
Joined: 01/02/2009(UTC)
Posts: 146
Location: Barcelona, Spain
I`m a happy user of a simplified version of the XML JohnJean posted above. Each time I start my trains I remember Johnjean and his advice on Rocrail.
Rafael
Collecting Era I, II & III, mainly German, French & Spanish RR, some USA
Offline JohnjeanB  
#10 Posted : 02 August 2024 00:08:47(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi Fab
You are correct, I checked and indeed Var15 and var16 are not used in this program so you may delete both lines including these variables
Cheers
Jean
Offline JohnjeanB  
#11 Posted : 02 August 2024 09:55:17(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi all
Here is another example of XML program

What is does
In a shadow station including one entry block, four parallel block and one exit block, one of the block being a long staging block (capable of holding up to 7 locos or trains behing each other, the program checks which trains are in the 3 normal parallel blocks to detect the shortest, see if there is enough space remaining in the staging block and send it into it by reversing the train back into the entry block

Here is are the blocks
Sans titre.png
Where block 150 is the entry block, 145, 146 and 147 are the 3 normal blocks in parallel, 148 is the staging block with 7 sections and 149 is the exit block.

Here is the XML program (there are surely better ways to do this but anyways..)
Cheers
Jean

<?xml version="1.0" encoding="UTF-8"?>
<xmlscript>
<!---Program um Aufstellblock 148 zu fühlen 30-01-2020 -->
<vr id="var15" value="0"/>
<vr id="ShortestTrainLocation" value="0"/>
<vr id="ShortestTrainLength" value="0"/>
<vr id="var145_loco" text="no loco"/>
<vr id="var146_loco" text="no loco"/>
<vr id="var147_loco" text="no loco"/>
<vr id="var145_length" value="2500"/>
<vr id="var146_length" value="2500"/>
<vr id="var147_length" value="2500"/>
<!-- Variabeln zu bearbeiten -->
<vr id="vr_frei_gleis_lange" value="0"/>
<!-- Variabeln zu entfernen
var15
numb_sections
numb_sections_libres
section_length
-->
<trace text="Aufstellblock fullen: start. V11 31-01-2024" />
<vr id="vr_SBFLZcount" text="" value="0" generated="true"/>
<tx id="tx_SBFLZcount" format="#vr_SBFLZcount"/>
<!---Program um Aufstellblock 148 zu fühlen -->
<if state="bk 150 = free|fb ABaf0 = off|fb ABaf1 = off" alltrue="true">
<then>
<trace text="Aufstellblock fuller: bk 150, ABaf0, ABaf1 sind alle frei" />
<foreach table="lclist" >
<query vr="vr_SBFLZtmp" table="lclist" id="%oid%" get="blockid"/>

<if condition="@vr_SBFLZtmp = 145">
<then>
<vr id="var145_loco" text="%oid%"/>
<trace text="lc in 145 = %oid%" />
<query vr="vr_SBFLZtmp" table="lclist" id="%oid%" get="trainlen"/>
<vr id="var145_length" value="#vr_SBFLZtmp"/>
<if condition="@var145_length = 0" >
<then>
<vr id="var145_length" value="2500"/>
</then>
</if>
<trace text="Train length in 145= #var145_length" />
</then>
</if>
<if condition="@vr_SBFLZtmp = 146">
<then>
<vr id="var146_loco" text="%oid%"/>
<trace text="lc in 146 = %oid%" />
<query vr="vr_SBFLZtmp" table="lclist" id="%oid%" get="trainlen"/>
<vr id="var146_length" value="#vr_SBFLZtmp"/>
<if condition="@var146_length = 0" >
<then>
<vr id="var146_length" value="2500"/>
</then>
</if>
<trace text="Train length in 146 = #var146_length" />
</then>
</if>
<if condition="@vr_SBFLZtmp = 147">
<then>
<vr id="var147_loco" text="%oid%"/>
<trace text="lc in 147 = %oid%" />
<query vr="vr_SBFLZtmp" table="lclist" id="%oid%" get="trainlen"/>
<vr id="var147_length" value="#vr_SBFLZtmp"/>
<if condition="@var147_length = 0" >
<then>
<vr id="var147_length" value="2500"/>
</then>
</if>
<trace text="Train length in 147= #var147_length" />
</then>
</if>
</foreach>
<!---Search for shortest train -->
<trace text="var145_loco = @var145_loco" />
<trace text="var145 length = #var145_length" />
<trace text="var146_loco = @var146_loco" />
<trace text="var146 length = #var146_length" />
<trace text="var147_loco = @var147_loco" />
<trace text="var147 length = #var147_length" />
<if condition="#var145_length < #var146_length">
<then>
<if condition="#var145_length < #var147_length">
<then>
<trace text="shortest train in 145"/>
<vr id="ShortestTrainLocation" value="145"/>
<vr id="ShortestTrainLength" value="#var145_length"/>
</then>
<else>
<trace text="shortest train in 147"/>
<vr id="ShortestTrainLocation" value="147"/>
<vr id="ShortestTrainLength" value="#var147_length"/>
</else>
</if>
</then>
<else>
<if condition="#var146_length < #var147_length">
<then>
<trace text="shortest train in 146"/>
<vr id="ShortestTrainLocation" value="146"/>
<vr id="ShortestTrainLength" value="#var146_length"/>
</then>
<else>
<trace text="shortest train in 147"/>
<vr id="ShortestTrainLocation" value="147"/>
<vr id="ShortestTrainLength" value="#var147_length"/>
</else>
</if>
</else>
</if>
<!------------------------------------>
<!---Jetzt messen freiblockstrecke -->
<!------------------------------------>
<!-- verify if shortest train can fit in bk 148--->
<trace text="shortest train (final) in #ShortestTrainLocation"/>
<trace text="shortest train length (final) : #ShortestTrainLength"/>
<!--&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&-->
<vr id="vr_ID" value="0"/>
<vr id="vr_section" value="0"
<vr id="vr_locid1" value="0"/>
<vr id="vr_frei_gleis_lange" value="0"/>
<vr id="vr_fini" value="false"/>
<trace text="Début analyse Block Transfert"/>
<vr id="vr_locid1" value="0"/>
<vr id="vr_locid2" value="0"/>
<vr id="vr_locid3" value="0"/>
<vr id="vr_locid4" value="0"/>
<vr id="vr_locid5" value="0"/>
<vr id="vr_locid6" value="0"/>
<vr id="vr_locid7" value="0"/>
<foreach table="sblist" >
<query vr="vr_ID" table="sblist" id="%oid%" get="id"/>
<if condition="@vr_ID = 148">
<then>
<!-- le bloc de transfert 148 est trouvé -->
<trace text="Bloc de transfert %oid%"/>
<query vr="vr_locid7" table="sblist" id="%oid%" sub="section" subidx="6" get="lcid"/>
<query vr="vr_locid6" table="sblist" id="%oid%" sub="section" subidx="5" get="lcid"/>
<query vr="vr_locid5" table="sblist" id="%oid%" sub="section" subidx="4" get="lcid"/>
<query vr="vr_locid4" table="sblist" id="%oid%" sub="section" subidx="3" get="lcid"/>
<query vr="vr_locid3" table="sblist" id="%oid%" sub="section" subidx="2" get="lcid"/>
<query vr="vr_locid2" table="sblist" id="%oid%" sub="section" subidx="1" get="lcid"/>
<query vr="vr_locid1" table="sblist" id="%oid%" sub="section" subidx="0" get="lcid"/>
<if condition="@vr_locid1 = (null)|#vr_fini = false" alltrue="true">
<then>
<trace text="section 1 vide"/>
<!-- le premier segment est raccourci de 80mm 320 devient 260 -->
<vr id="vr_frei_gleis_lange" value="#vr_frei_gleis_lange + 260"/>
</then>
<else>
<trace text="recherche finie Section 1"/>
<vr id="vr_fini" value="true"/>
</else>
</if>
<if condition="@vr_locid2 = (null)|#vr_fini = false" alltrue="true">
<then>
<trace text="section 2 vide"/>
<vr id="vr_frei_gleis_lange" value="#vr_frei_gleis_lange + 320"/>
</then>
<else>
<trace text="recherche finie Section 2"/>
<vr id="vr_fini" value="true"/>
</else>
</if>
<if condition="@vr_locid3 = (null)|#vr_fini = false" alltrue="true">
<then>
<trace text="section 3 vide"/>
<vr id="vr_frei_gleis_lange" value="#vr_frei_gleis_lange + 320"/>
</then>
<else>
<trace text="recherche finie Section 3"/>
<vr id="vr_fini" value="true"/>
</else>
</if>
<if condition="@vr_locid4 = (null)|#vr_fini = false" alltrue="true">
<then>
<trace text="section 4 vide"/>
<vr id="vr_frei_gleis_lange" value="#vr_frei_gleis_lange + 320"/>
</then>
<else>
<trace text="recherche finie Section 4"/>
<vr id="vr_fini" value="true"/>
</else>
</if>
<if condition="@vr_locid5 = (null)|#vr_fini = false" alltrue="true">
<then>
<trace text="section 5 vide"/>
<vr id="vr_frei_gleis_lange" value="#vr_frei_gleis_lange + 320"/>
</then>
<else>
<trace text="recherche finie Section 5"/>
<vr id="vr_fini" value="true"/>
</else>
</if>
<if condition="@vr_locid6 = (null)|#vr_fini = true" alltrue="true">
<then>
<trace text="section 6 vide"/>
<vr id="vr_frei_gleis_lange" value="#vr_frei_gleis_lange + 320"/>
</then>
<else>
<trace text="recherche finie Section 6"/>
<vr id="vr_fini" value="true"/>
</else>
</if>
<if condition="@vr_locid7 = (null)|#vr_fini = false" alltrue="true">
<then>
<trace text="section 7 vide"/>
<vr id="vr_frei_gleis_lange" value="#vr_frei_gleis_lange + 250"/>
</then>
<else>
<trace text="recherche finie Section 7"/>
<vr id="vr_fini" value="true"/>
</else>
</if>
<trace text="occupation segment 7 = @vr_locid7"/>
<trace text="occupation segment 6 = @vr_locid6"/>
<trace text="occupation segment 5 = @vr_locid5"/>
<trace text="occupation segment 4 = @vr_locid4"/>
<trace text="occupation segment 3 = @vr_locid3"/>
<trace text="occupation segment 2 = @vr_locid2"/>
<trace text="occupation segment 1 = @vr_locid1"/>
</then>
</if>
</foreach>
<trace text="total available length = #vr_frei_gleis_lange"/>
<!-- Muss Freiraum zwischenZüge Afddieren -->
<if condition="#ShortestTrainLength < #vr_frei_gleis_lange">
<then>
<trace text="OK to move"/>
<if condition="#ShortestTrainLocation = 145">
<then>
<trace text="OK to move from 145"/>
<co id="Rueckw.frei" cmd="off"/>
<co id="Reverse145" cmd="on"/>
</then>
</if>
<if condition="#ShortestTrainLocation = 146">
<then>
<trace text="OK to move from 146"/>
<co id="Rueckw.frei" cmd="off"/>
<co id="Reverse146" cmd="on"/>
</then>
</if>
<if condition="#ShortestTrainLocation = 147">
<then>
<trace text="OK to move from 147"/>
<co id="Rueckw.frei" cmd="off"/>
<co id="Reverse147" cmd="on"/>
</then>
</if>

</then>
<else>
<trace text="not enough space to move"/>
</else
</if>
<!-- end of program now sort all reject cases--->
</then>
<else>
<!---Program blocked because BK or ABaf0 or ABaf1 not free--->
<trace text="Aufstellblock fuller: bk 150, ABaf0, ABaf1 sind nicht alle frei" />
</else>
</if>
<trace text="Aufstellblock fuller: end" />
</xmlscript>
Offline fabstar68  
#12 Posted : 06 August 2024 19:20:38(UTC)
fabstar68

Italy   
Joined: 14/12/2023(UTC)
Posts: 60
Location: Milan
THANK YOU MAN, that was another piece of code that helps me understand things.

now, if you want, i need some advice on how to handle the hidden yard flow management. i have defined the blocks of the hidden yard, i alse created a location to group them, but now i don't know how to proceed... where do i use the location object ? also, i don't want to "normally" let my trains go in the hidden yard. i want to push a button, and this should allow trains to enter the hidden yard (instead of my shadow station, from which my trains can enter the hidden yard). i would need to dynamically set the route to the shadow station as "closed", and set the route to the HY as "free", and vice versa. i can see that you can define an action as "route", and apperently you could achieve what i want setting the route as "open" and "closes". something like that ? thanks.
Offline JohnjeanB  
#13 Posted : 07 August 2024 11:52:20(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi Fab
Shadow station are the easiest to create:
- simply create the blocks as any other regular block
- now train will use them in fishbowl operation (you simply press power ON, AUTO ON and right click on a loco and select start)
- in this case, the blocks (if multiple in parallel) will be used randomly.

Additional Tricks

Locations
- create a location (tab tables and then select locations, give it a name
- list the blocks belonging to this location (ParisBigGrin
- you may indicate the minimum number of trains you want to have in the location (your shadow station) so no train is leaving before that number is reached
- you may specify FIFO (first in first out) or Random.

Length management
- you specvify for each train, its total length or you manage car by car and edit the content of a train (see below)
- you specify the length of each block (I use mm but you may use any other unit)
- RR will only send a train to a block offering more space (length)
- RR offers you the option to use the shortest available block (leaving longer ones for longer trains
- RR offers you to use STAGING BLOCKS (A block, capable of containing more than one train). In this case RR will computer the occupancy of each section of the block.

train / consist edition
Sans titre.png

Routes and schedules
- routes are generated by the ROUTER (Tab Track plan / ROUTER).
- it generates all the routes between adjacent blocks
- you may add / edit / delete any route at your convenience

- schedules are used to create a circulation that makes sense (e.g.: in a depot) and specify either consecutive blocks to be used. Blocks may be replaced with locations.
- schedules must be created manually for turntables

Other possibilities
- you may assign a given block of your shadow station to a given train (in PERMISSIONS specify only this loco is allowed)
- you may lock / unlock the exit of a given block by creating an OUTPUT (a virtual relay with a name you give) and insert this output in the SENSOR field of the routes.
The output appear on your "PLAN" as a toggle and so, you may lock / unlock any train at any place
Outputs on my layout
(each of these red or green squares represent an output to start a tour, lock or unlock a fonction, etc
Sans titre1.png

Sorry there as so many more possibilities that you may get bored
Thats all for now
Cheers
Jean
Offline fabstar68  
#14 Posted : 08 August 2024 19:06:57(UTC)
fabstar68

Italy   
Joined: 14/12/2023(UTC)
Posts: 60
Location: Milan
thanks again for taking the time to write this long reply,

i had already managed to setup most of the things you wrote about, but a couple of things were news to me so that helped.
Offline JohnjeanB  
#15 Posted : 12 August 2024 23:56:03(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi Fab
The forum went garbled for one day or two and I received this truncated question by email
"can you call, from within an XML script, an Action ? i don't see any in the examples above... in particular, i would also need to be able to call some..."

Answer Yes, you can. Here is an example below (sorry text only)
Cheers
Jean

<actionctrl id="Start Lok swap 98 Ank.Phase 1" cmd="on"/>
<sleep time="200"/>
<actionctrl id="Start Lok swap 98 Ank.Phase 1" cmd="off"/>


Although it may look funny you have to turn off the action after having requested it (otherwise next time, it may not trigger the action



Offline fabstar68  
#16 Posted : 13 August 2024 09:37:19(UTC)
fabstar68

Italy   
Joined: 14/12/2023(UTC)
Posts: 60
Location: Milan
again thanks, that was useful. i am now playing with more advanced options. i am changing a block wait time according to some other conditions. funny thing is, after i modify a block waittime from within an xml script, if i go check that block waittime from its properties - details window, it reports the updated value. however, if i check the waittime value from a quey statement, it still reports the previous value. here is what i am doing :

<query vr="vr_bk_waittime" table="bklist" id="MS-4" get="waittime"/>
<trace text="MS-4 waittime is now @vr_bk_waittime" />

<if state="co Sound = on">
<then>
<trace text="Sound is now ON " />
<bk id="MS-4" waittime="60"/>
<bk id="MS-3" waittime="60"/>
<bk id="MS-2" waittime="60"/>
<bk id="MS-1" waittime="60"/>
</then>
<else>
<trace text="Sound is now OFF " />
<bk id="MS-4" waittime="5"/>
<bk id="MS-3" waittime="5"/>
<bk id="MS-2" waittime="5"/>
<bk id="MS-1" waittime="5"/>
</else>
</if>

<query vr="vr_bk_waittime" table="bklist" id="MS-4" get="waittime"/>
<trace text="MS-4 waittime is now @vr_bk_waittime" />

here is what i get in the trace panel :


09:34:36 9999 MS-4 waittime is now 5
09:34:36 9999 Sound is now ON
09:34:36 9999 MS-4 waittime is now 5

you can see that the XML code under "Sound is now ON" has been executed, so the waittime has been set to 60. If i go check the block properties, it reports 60. but the query performed at the end of the script still reports 5. and if i try to run a loco on that block, it waits 5 seconds, not 60. so it seems that the updated value of 60 shows up only in the block properties, but the previous value is the one that is effectivly used. i am clearly missing something. Only if i click "apply" in the block details window, then the updated value of 60 is taken into consideration. so i am clearly missing something, any hint ?
Offline JohnjeanB  
#17 Posted : 13 August 2024 10:11:23(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,555
Location: Paris, France
Hi Fab
Truth is I am discovering the Rocrail basics and am certainly not in a position to give lectures.

From all these operation years and seeking help from experienced users or from the designer (Rob Versluis), I think:
- same data is found in many places in multiple files (Plan.xml, Locomotive.xml, Occ.xml so changing in one place may be reverted by Rocrail itself
- unanimously, all say avoid making changes in these files directly. Why? It can create discrepancies (incoherencies) between the files
- they also recommend never, when using XML, try to replicate the RR operation or contradict it.
- never forget RR ends up being a multi tasking program (some may contradict others).
- beware of re-entrancy. Example: I wrote an XML program to drive the coal crane (3 motors and a solenoid). Nice and dandy but I discovered by accident that the same program could be executed multiple times in quasi-parallel when invoked multiple times by a stuttering sensor. So in some case I installed a re-entrancy lock to prevent a parallel start of the same program before the previous instance is finished.
- I rather make the changes from the outside of Rocrail files
- normally RR manages and correct discrepancies but not always. I had one instance where I had to delete some RR objects because I had erratic fonctioning (some routes were OK but never started the selected train)

Cheers
Jean
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

| Powered by YAF.NET | YAF.NET © 2003-2025, Yet Another Forum.NET
This page was generated in 0.843 seconds.