Finally I have had some time to implement the functionality I was requesting. I am attaching an explanation on what the motivation was, and how it can be used.
Since I am not at all an expert on C, neither on the rocrail code, it has taken me longer than expected.Moreover, there is still a problem with the code – a memory leak – I have not been able to solve. I think it is in the way I am attaching the speedcurve parameters to the loc command (loc.c file)… but I am not sure – any help, correction and suggestion for improvement is very welcome.
Basically I have modified the wrapper description file to include a new property to the loc (speedcurve). Then I have modified the loc.c file to explore if a locomotive has this property and include them in the commands sent to the stations. Finally, in DDX, this parameter is treated in MM locomotives.
The reason to address only MM is basically because DCC decoders use to have an actual speedcurve functionality. In any case, since the information is transmitted to any station, anyone could make use of it to implement the speedcurve as I have made for DDX MM.
Hope this new feature to be of interest.It needs still some refinement for the memory leak.. but hopefully someone could give me a hint on how to solve it, so it can be included in a stable release – if it is of interest of course.
I am attaching the three source code files modified, a plan example and the explanation of the functionality.
Description and motivation
ACCELERATION CURVE 1
|
DECELERATION CURVE 1
|
- Märklin DIGITAL 146871 PIC-Decoder 1. This low-cost decoder needs some pause after any speed change request to actually reach the new speed. This is important when two consecutive commands are sent, and especially critical if a change of direction is requested. In those cases, the decoder needs to stop before implementing the change of direction. Without the mandatory pause, the engine does not «accept» the request, and the change of direction is never achieved.
- TAMS LD_W_3. This decoder needs an update on the speed after a change of direction request. Otherwise, the delay in accepting the order depends on the loco stack of commands and active protocols in DDX – worst scenario up to 18 seconds of delay with MM, MMLP and DCC active.
- Motorola format I. This protocol forces a stop whenever a change of direction is requested. The behavior can be improved by implementing speed profiles, which may help considering the speed when
the change of direction is requested as a persistent variable. In this way, after the change of direction is implemented, the speed is recovered and the loco does not stop.
How it works
Step
|
Delay to next step (ms)
|
Next step
|
0
|
1500
|
1
|
1
|
1000
|
2
|
2
|
900
|
3
|
3
|
800
|
4
|
4
|
700
|
5
|
5
|
600
|
6
|
6
|
500
|
7
|
7
|
400
|
8
|
8
|
300
|
9
|
9
|
200
|
10
|
10
|
200
|
11
|
11
|
175
|
12
|
12
|
150
|
13
|
13
|
125
|
14
|
14
|
100
|
NA
|
Step
|
Delay to previous step (ms)
|
Next step
|
14
|
2000
|
13
|
13
|
1800
|
12
|
12
|
1200
|
11
|
11
|
1000
|
10
|
10
|
600
|
9
|
9
|
600
|
8
|
8
|
500
|
7
|
7
|
400
|
6
|
6
|
300
|
5
|
5
|
200
|
4
|
4
|
175
|
3
|
3
|
150
|
2
|
2
|
125
|
1
|
1
|
100
|
0
|
0
|
200
|
*Pause before sending a refresh in a
change direction request |
Configuration
<lc id=»130TB SNCF» mtime=»0″ prev_id=»130TB SNCF» shortid=»130TB» roadname=»former Royal Prussian State Railways (K.P.E.V.) class T 12.» number=»130TB» desc=»» docu=»» image=»tb130.png» imagenr=»0″ remark=»» len=»12″ nrcars=»0″ catnr=»36742″ purchased=»2010″ identifier=»0″ show=»true» useshortid=»false» mint=»40″ bus=»0″ addr=»78″ iid=»» prot=»M» protver=»2″ spcnt=»14″ fncnt=»2″ V_min=»10″ V_mid=»50″ V_max=»100″ V_Rmin=»0″ V_Rmid=»0″ V_Rmax=»0″ V_step=»0″ mass=»0″ V_mode=»percent» placing=»true» regulated=»true» restorefx=»true» dirpause=»0″ blockwaittime=»10″ evttimer=»0″ ent2incorr=»100″ priority=»10″ usescheduletime=»false» commuter=»false» trysamedir=»false» tryoppositedir=»false» forcesamedir=»false» shortin=»false» inatpre2in=»false» usemanualroutes=»false» engine=»steam» cargo=»mixed» secondnextblock=»false» consist_lightsoff=»false» consist=»» V=»0″ throttleid=»» fn=»true» fx=»0″ runtime=»33775″ dir=»true» mode=»» resumeauto=»false» active=»true» scidx=»-1″ server=»infw01EFE784″ dectype=»» blockenterside=»true» throttlenr=»0″ manual=»false» swaptimer=»0″ useownwaittime=»false» startupscid=»»>
<fundef fn=»4″ text=»» timer=»0″/>
<fundef fn=»0″ text=»Luces» timer=»0″/>
<speedcurvestep step=»0″ nsleep=»3000″ psleep=»0″/>
<speedcurvestep step=»1″ nsleep=»0″ psleep=»1500″/>
<speedcurvestep step=»2″ nsleep=»0″ psleep=»1000″/>
<speedcurvestep step=»3″ nsleep=»0″ psleep=»2000″/>
<speedcurvestep step=»4″ nsleep=»0″ psleep=»100″/>
<speedcurvestep step=»5″ nsleep=»0″ psleep=»100″/>
<speedcurvestep step=»6″ nsleep=»0″ psleep=»500″/>
<speedcurvestep step=»7″ nsleep=»0″ psleep=»100″/>
<speedcurvestep step=»8″ nsleep=»0″ psleep=»500″/>
<speedcurvestep step=»9″ nsleep=»0″ psleep=»300″/>
<speedcurvestep step=»10″ nsleep=»0″ psleep=»500″/>
<speedcurvestep step=»11″ nsleep=»0″ psleep=»300″/>
<speedcurvestep step=»12″ nsleep=»0″ psleep=»200″/>
<speedcurvestep step=»13″ nsleep=»0″ psleep=»200″/>
<speedcurvestep step=»14″ nsleep=»0″ psleep=»100″/>
</lc>
ACCELERATION CURVE 2 (wait in v=0 3000 ms)
|
DECELERATION CURVE 2
|
Examples
ACCELERATION CURVE 3(no delay)
|
DECELERATION CURVE 3
|
ACCELERATION CURVE 4 (no delay)
|
DECELERATION CURVE 4 (repeat chdir)
|