Skip to content

Conversation

@kallelix
Copy link

@kallelix kallelix commented Oct 8, 2025

I like the ideas in #465. I need SAVESPEED/RESTORESPEED, so I’ve implemented a simple version for now, until a more advanced solution can be developed.

@Asbelos
Copy link
Contributor

Asbelos commented Oct 9, 2025

Should we save the speed against the exrail task (as you have done) or save it against the loco id...
Your solution, on the task, works well I think but will not survive a construct like
ONBLOCKENTER save speed and slow down
ONBLOCKEXIT restore speed... Cant because it was not saved for this task.

(I appreciate this is looking a little further ahead to having Railcom implemented)

@kallelix
Copy link
Author

I think storing the speed on the locomotive is absolutely logical and correct. In my case, the use case is very simple. I used SAVESPEED and RESTORESPEED for the reservation case, since RESERVE always forces the loco to slow down:

SAVESPEED
RESERVE(B_3)
RESTORESPEED

So I only need the reference to the task. That’s why I kept the task reference simple. The LocoSlot class would be the right place for this, wouldn’t it?

@Asbelos
Copy link
Contributor

Asbelos commented Oct 13, 2025

Yes locoslot would be the place where we keep loco specific variables. This should be saved as a copy of the targetSpeed byte which is the most recent speed set by a throttle or exrail.

…orks. I would prefer a method at locoslot, but there are any calls to DCC until now. Maybe by reason.
@Asbelos
Copy link
Contributor

Asbelos commented Oct 14, 2025

Generally speaking, throttle commands call the DCC layer. The DCC layer creates packets etc but is also responsible for maintaining the reminders table, which is where the the original locoslots came from.

Sometimes, as in the case of a non-zero momentum, the DCC packet is not created/sent immediately but the target speed is updated and the reminder loop will pick up the calculation of the real packets as it goes around the active loco reminder loop.

This it make sense that the current throttle setting (target speed) is saved and on restore the DCC throttle is called so it can make the usual decision based on the optional momentum.

@kallelix
Copy link
Author

Tested at my setup. Restore is working as expected.

@kallelix kallelix marked this pull request as draft October 14, 2025 22:55
@kallelix
Copy link
Author

Converted to draft. Usage of setThrottle is currently wrong because LocoSlot::savedspeed is a speedcode, not a exrail user speed. Maybe introduce a DCC::restoreThrottle(loco), because we don't want to know the internal speedcode in exrail.

@kallelix kallelix marked this pull request as ready for review October 21, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants