Keyboard Shortcuts
Likes
Search
Locked How to run multiple locomotives with one script?
I started with the back and forth timed script and have been able to get it running just once. I¡¯ve added turnout control and run function keys for light, horn, bell. All under timer control. It works great.
But I¡¯ve not been able to run two locomotives in same script by switching the throttle to different number and sending new commands. I get inconsistency. I tried creating a second def and starting both but not consistently working. Anyone have simple example of how to do this? I don¡¯t have any sensors or complex stuff. Thanks Fred |
Fred,
toggle quoted message
Show quoted text
I have two separate scripts running to control two locos on the same single track mainline with a passing siding for them to meet. An internal sensor set by Logix when they meet permits each script to contineu. Bob Bucklew ----- Original Message -----
From: "i50fwe via Groups.Io" <i50fwe@...> To: "jmriusers" <[email protected]> Sent: Saturday, December 28, 2019 10:30:03 PM Subject: [jmriusers] How to run multiple locomotives with one script? I started with the back and forth timed script and have been able to get it running just once. I¡¯ve added turnout control and run function keys for light, horn, bell. All under timer control. It works great. But I¡¯ve not been able to run two locomotives in same script by switching the throttle to different number and sending new commands. I get inconsistency. I tried creating a second def and starting both but not consistently working. Anyone have simple example of how to do this? I don¡¯t have any sensors or complex stuff. Thanks Fred |
Fred, The keyword in your request is the word "simple" and how that fits in your context.
If you attempt to run two copies of "BackAndForthTimed.py" and only edit the loco number within each, the most recently loaded copy will overwrite any previously loaded versions of the script. That is, unless you rename the classes defined. For example, you could edit your copies so that the classes have different names, perhaps BackAndForthTimed1 and BackAndForthTimed2 or append your loco numbers. But even if that works for you, there are several more complicated issues to deal with, and many of them have been discussed in this group. For an in-your-face introduction, while logged on to this group's website use the search function at the top of the page with the text BackAndForth to find at least forty previous postings. Your numbers may vary, since each response to this thread will increment the search count, but not necessarily help. Also, look in the files/Script Examples for several subfolders of examples to pick apart and choose from. Without any idea of your scripting experience, there is not much more specific help that can be offered. If you wish to examine a heavily documented and lengthy working example that our club uses, respond to me off-list, that is, use the "Private" button just below and to the right of the "Reply" text frame. Again, that is if responding while logged on to the webpage. Cliff in Baja SoCal |