Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Locked
Script to set "Default Maximum Speed" in a Dispatcher Train Info file
#dispatcher
#jython
#loconet
#scripting
I currently have an automation for my fiddle yard, where the Dispatcher takes over the train and parks it. This is working fine except for one thing.
If the current speed of the train is less than the Default Maximum Speed in the Train Info file, then the train speeds up to this maximum upon take over, which is not really wanted. I tried setting the "Maximum Speed" as a transit action but this appears to be ignored. ?
So I set about trying to write a script which would read the current speed of the locomotive from the LocoNet slot?
? ?LocoNetSlot.speed() and write this information temporarily to the TrainInfo file before loading it into the Dispatcher
? ?TrainInfo.setMaxSpeed() ?
I am able to identify which locomotive is triggering the Dispatcher Autotrain by means of block values (headcode), and a lookup of headcode and corresponding DCC address in the Roster.
With this DCC adress I need to identify in which Loconet slot the locomotive is running and hence what speed it is currently travelling. ?
Studying the API I came across the method
? ?SlotManager.slotFromLocoAddress ?
which appears to be just what I need but I don't understand how to setup the required listener
? ?SlotManager.addSlotListener ?
"The slot listener will be invoked every time a slot changes state". The method slotFromLocoAddress "sends an info request. When the echo of this is returned from the LocoNet, the next slot-read is recognized as the response.
The object that's looking for this information must provide a SlotListener to notify when the slot ID becomes available". ?
Can anyone show me an example of the script coding using the above method (slotFromLocoAddress) with its initialisation?
?
JMRI version 5.6 +R89a87446cb
Java version 11.0.21 (en)
?
|
All of my block speeds are still set to the default "Global", which has the value "Normal". I am using SML and the signal at the first transition block is showing the aspect "Proceed"
Is one of these conditions maybe causing the increase of speed when entering the transition? ?
I ran a series of tests running a train at 35% (LocoNet Speed 45) and changing the value of the Default Max Speed in the Train Info file each time before the Dispatcher picked up the train
?
Max Speed ????? Change ? ? ?Range
0.3 (30%) ???????? Decrease ? ?45-39 (35% -> 30%) 0.4 (40%) ???????? Increase ? ? 45-51 (35% -> 40%) 0.5 (50%) ???????? Increase ? ? 45-64 (35% -> 50%) 0.6 (60%) ???????? Increase ? ? 45-64 (35% -> 50%) 0.7 (70%) ???????? Increase ? ? 45-64 (35% -> 50%) ?
The results showed that if the Default Max Speed is higher than the current speed, it will cause an unwanted acceleration up to a maximum of 50%.?
If it is lower than the current speed then there will be a deceleration, which is acceptable as it is the "maximum" speed. ?
Even if this is the cause of the problem, I would still be interested in learning how to correctly use the API methods slotFromLocoAddress and addSlotListener if anyone can help here
?
Pete
|
Pete
First. Are you using "Signal Masts", "Signal Heads" or "No signals"?
Speed settings differ between them.
Are you using speed profiled locos or not?
?
If you are not using speed profiled locomotives then "speed" is relative to the maximum line speed, else speed is scale mph/kph". I strongly recommend speed profiling your locos, you dont have to do every step, start with step 42 and increment 42) 0,42,84,126.
?
If not using scale mph/kph? the maximum line speed is the maximum speed existing on the layout, and speeds are a percentage of that.?
?
see more here /g/jmriusers/message/152623
?
If using SSL the basic speeds are red,yellow,green, lunar -> stop (0) ,slow (30%), normal (60%) ,restricted (20%).
If using SSL with a speed profile it uses the displayed aspect.?
If using SSL the max of block speed? and aspect speed is used.
If using SSL the speed is set according to the signal infront / block infront.
If using SML the speeds is the minimum of aspect and path speed.
If using "No Signals" it uses Stop, Medium, Normal. or the block speed if lower.
?
The speed is then adjusted by max speed and speed adjustment.
?
Steve G.
?
?
?
?
?
?
?
?
?
? |
@Steve,
Thanks for your suggestions, especially the very informative link /g/jmriusers/message/152623 "Dispatcher, Signal Mast definitions (BR-2003) and speeds". I think that this has probably solved or will solve the problem. Initial Tests showed a change to the positive (i.e. no speeding up). Clearly I need to read up, understand and then trial the various settings.
?
To answer your questions:
?
Dispatcher Options were still set to "No Signals" although I have a working Signal Mast Logic which was entered manually. After changing this to "Signal Masts/SML" the speed no longer increased upon entering the transit as before.
Not all of my locos are yet speed profiled, but the one that was being tested is speed profiled.
?
@Ken,
Thanks for your suggestion. I will bear this in mind when I have fully understood what is going on
?
@All
Nevertheless, I would still be interested if anyone could show me an example of initialising and using the API methods slotFromLocoAddress and addSlotListener
?
Pete |
to navigate to use esc to dismiss