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 JMRI Jython programming question
Is there a straightforward way to send a specific speed step (i.e. 0-28 or 0-126) instead of a throttle value 0.0 to 1.0 to a throttle? I can't seem to find a place in the code where it will let me do that... My apology in advance if this is a stupid question.
I'm using?jmri.jmrit.automat.AbstractAutomaton ... self.throttle.setSpeedSetting(1.0) Thanks, -Erich |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Erich,
toggle quoted message
Show quoted text
I once tried this approach: /g/jmriusers/topic/19531335#131532 And this worked for me. Klaus Am 20.07.2018 um 23:43 schrieb Erich Whitney: Is there a straightforward way to send a specific speed step (i.e. 0-28 or 0-126) instead of a throttle value 0.0 to 1.0 to a throttle? I can't seem to find a place in the code where it will let me do that... My apology in advance if this is a stupid question. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Thanks Klaus!
I was thinking along these lines as my workaround. I'm messing about with speed tables and I want to make sure I can select each of the 28 entries in that table. I will try the scaling approach, but I need a way to verify the actual value being sent to the decoder. There's also the issue of how the decoder does the mapping but that will have to be an experiment... -Erich |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Here's an illustration of what I'm trying to do...
Below is a table I made of JMRI Throttle Speed settings that are mapped to the 126 speed steps. What I want to know is what JMRI Throttle speed value do I pick so that I'm exactly selecting one of the 28 speed table entries in the decoder and not one of the ones that the decoder is interpolating? You can see from the example, there's four choices of the 128 step table that maps to '1' of the 28 speed steps. Which one does the decoder use?
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hi Erich,
I'm not a JMRI designer and I haven't picked through the Java code to see how it translates the floating value 0 to 1 into DCC speed steps. Could you not just pick a floating value in the centre of the 28 speed step mapping in your example?. Would that not give a good chance of always mapping to the same 28 speed step?. You don't say what DCC system you have but if JMRI supports monitoring of the DCC commands for your command station you can see how the floating point values translate into speed steps. Or have you already done this in order to produce your example?. If you have a compact roundy test track with an optical position sensor and fast feedback bus maybe you could write a script to accurately time a reliable loco to check how the JMRI speed value maps to loco speeds. However I've found track cleanliness/loco mechanism variations can be quite pronounced. Regards Nick |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dear Klaus,
Many thanks. I've already had a quick look through the code but I will have a deeper look. Thanks to you I've now can set the speed step type of the DCC to 28 while using AbstractAutomation. Snippet from Jython code (the Class init part): # get loco address. For long address change "False" to "True" ??self.throttle = self.getThrottle(5001, True)? #? LONG address 5001 # set speed mode to 28 steps ? ??self.throttle.setSpeedStepMode(28) Many thanks Nick |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Klaus, thank you! This helps a lot!!!
This is the nugget that was eluding me: int value = (int) Math.ceil((steps - 1) * speed); I think for the purpose I'm trying to achieve, I can set the throttle to 28 steps, use this to get the speed values that map to those and then when I'm done playing with the speed table, resume 128 speed step mode for smoother operation. -Erich |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Erich, Nick,
toggle quoted message
Show quoted text
Thank you both for your replies. I am glad that I could help. Klaus Am 22.07.2018 um 14:41 schrieb Erich Whitney: Klaus, thank you! This helps a lot!!! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I have finally confirmed the JMRI throttle behavior by using a Digital Logic Analyzer and DCC parser (Saleae Logic Pro 8 running a custom DCC Low Lever Analyzer with a python High Level Analyzer used to decode the packets). Here's the data I found:
NOTE that for 28 speed step mode, there's an offset of 3 between the speed step and the value in the packet. And for 128 speed step mode, there's an offset of 1. On a related note, I also found and fixed the problem with using throttle.setSpeedStepMode() The argument to this has change. Instead of using 28, you need to use jmri.SpeedStepMode.NMRA_DCC_28 Instead of using 128, you need to use jmri.SpeedStepMode.NMRA_DCC_128 I hope this saves someone else a bunch of time trying to figure out... -- Erich Whitney Black Cat Model Railroad Derry, NH |
to navigate to use esc to dismiss