Package jmri.jmrit.roster
Class RosterSpeedProfile
java.lang.Object
jmri.jmrit.roster.RosterSpeedProfile
A class to store a speed profile for a given loco.
The speed steps against the profile are on a scale of 0 to 1000,
this equates to the float speed x 1000.
This allows a single profile to cover different throttle speed step settings.
A profile generated for a loco using 28 steps can be used for a throttle with 126 steps.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatSpeed conversion Millimetres per second to Kilometres per hour.static final floatSpeed conversion Millimetres per second to Miles per hour. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) floatcalculateInitialOverRun(float distance) (package private) voidcalculateStepDetails(float speedStep, float distance, boolean andStop) voidThis method is called to cancel the existing change in speed.voidchangeLocoSpeed(DccThrottle t, float distance, float requestedSpeed) Set speed of a throttle.voidchangeLocoSpeed(DccThrottle t, Block blk, float speed) Set speed of a throttle.voidchangeLocoSpeed(DccThrottle t, Block blk, float speed, float usePercentage) Set speed of a throttle.voidchangeLocoSpeed(DccThrottle t, Section sec, float speed) Set speed of a throttle to a speeed set by a float, using the section for the length details Set speed of a throttle.voidchangeLocoSpeed(DccThrottle t, Section sec, float speed, float usePercentage) Set speed of a throttle.voidstatic StringconvertMMSToScaleSpeedWithUnits(float mms) Returns the scale speed format as I18N string with the units added given MilliMetres per Second.floatconvertScaleSpeedToMMS(float scaleSpeed) MilliMetres per Second given scale speed.convertThrottleSettingToScaleSpeedWithUnits(float throttleSetting, boolean isForward) Returns the scale speed format as a string with the units added given a throttle setting. and direction.voiddeleteStep(Integer step) (package private) voidreset everything back to default once the change has finished.floatgetDistanceTravelled(boolean isForward, float speedStep, float duration) Get the approximate distance a loco may travel a given duration at a given speed step.floatgetDurationOfTravelInSeconds(boolean isForward, float speedStep, int distance) Get the approximate time a loco may travel a given distance at a given speed step.floatgetForwardSpeed(float speedStep) return the forward speed in milli-meters per second for a given percentage throttlefloatfloatintGet the number of SpeedSteps.floatgetReverseSpeed(float speedStep) return the reverse speed in millimetres per second for a given percentage throttleGet the RosterEntry associated with the profile.floatgetSpeed(float speedStep, boolean isForward) Get track speed in millimeters per second from throttle settinggetSpeedStep(float speed) Gets the speed step trace array.floatgetThrottleSetting(float speed, boolean isForward) Get the throttle setting to achieve a track speedfloatgetThrottleSettingFromSignalMapSpeed(float signalMapSpeed, boolean isForward) Converts from signal map speed to a throttle setting.booleanCheck if the Speed Profile contains Forward Speeds.booleanCheck if the Speed Profile contains Reverse Speeds.voidload(org.jdom2.Element e) floatmmsToScaleSpeed(float mms) Returns the scale speed as a numeric.floatmmsToScaleSpeed(float mms, boolean factorFastClock) Returns the scale speed.floatMMSToScaleSpeed(float mms) Deprecated, for removal: This API element is subject to removal in a future version.voidsetExtraInitialDelay(float eDelay) voidsetForwardSpeed(float speedStep, float forward) voidsetForwardSpeed(float throttleSetting, float speed, float speedIncrement) Merge raw throttleSetting value with an existing profile SpeedStep if key for the throttleSetting is within the speedIncrement of the SpeedStep.voidsetMinMaxLimits(float minReliableOperatingSpeed, float maxOperatingSpeed) (package private) voidvoidsetOverRunTimeForward(float dt) voidsetOverRunTimeReverse(float dt) voidsetReverseSpeed(float speedStep, float reverse) voidsetReverseSpeed(float throttleSetting, float speed, float speedIncrement) Merge raw throttleSetting value with an existing profile SpeedStep if key for the throttleSetting is within the speedIncrement of the SpeedStep.voidsetSpeed(int speedStep, float forward, float reverse) Set the speed for the given speed step.voidsetTestMode(boolean value) place / remove SpeedProfile from test mode.voidstore(org.jdom2.Element e)
-
Field Details
-
MMS_TO_MPH
Speed conversion Millimetres per second to Miles per hour.- See Also:
-
MMS_TO_KPH
Speed conversion Millimetres per second to Kilometres per hour.- See Also:
-
-
Constructor Details
-
RosterSpeedProfile
Create a new RosterSpeedProfile.- Parameters:
re- the Roster Entry associated with the profile.
-
-
Method Details
-
getRosterEntry
Get the RosterEntry associated with the profile.- Returns:
- the RosterEntry.
-
getOverRunTimeForward
-
setOverRunTimeForward
-
getOverRunTimeReverse
-
setOverRunTimeReverse
-
clearCurrentProfile
-
deleteStep
-
hasForwardSpeeds
Check if the Speed Profile contains Forward Speeds.- Returns:
- true if forward speeds are present, else false.
-
hasReverseSpeeds
Check if the Speed Profile contains Reverse Speeds.- Returns:
- true if reverse speeds are present, else false.
-
setTestMode
place / remove SpeedProfile from test mode. reinitializes speedstep trace array- Parameters:
value- true/false
-
getSpeedStepTrace
Gets the speed step trace array.- Returns:
- speedstep trace array
-
mmsToScaleSpeed
Returns the scale speed. If Warrant preferences are not a speed, value returns unchanged.- Parameters:
mms- MilliMetres per second.factorFastClock- true to factor in the Fast Clock ratio, else false.- Returns:
- scale speed in units specified by Warrant Preferences, unchanged if Warrant preferences are not a speed.
-
MMSToScaleSpeed
Deprecated, for removal: This API element is subject to removal in a future version.Returns the scale speed as a numeric. If Warrant preferences are not a speed, value returns unchanged.- Parameters:
mms- MilliMetres per second- Returns:
- scale speed in units specified by Warrant Preferences, unchanged if Warrant preferences are not a speed.
-
mmsToScaleSpeed
Returns the scale speed as a numeric. If Warrant preferences are not a speed, value returns unchanged. Does not factor Fast Clock ratio.- Parameters:
mms- MilliMetres per second- Returns:
- scale speed in units specified by Warrant Preferences, unchanged if Warrant preferences are not a speed.
-
convertMMSToScaleSpeedWithUnits
Returns the scale speed format as I18N string with the units added given MilliMetres per Second. If the warrant preference is a percentage of normal or throttle will use metres per second. The Fast Clock Ratio is not used in the calculation.- Parameters:
mms- MilliMetres per second- Returns:
- a string with scale speed and units
-
convertThrottleSettingToScaleSpeedWithUnits
Returns the scale speed format as a string with the units added given a throttle setting. and direction. The Fast Clock Ratio is not used in the calculation.- Parameters:
throttleSetting- as percentage of 1.0isForward- true or false- Returns:
- a string with scale speed and units
-
convertScaleSpeedToMMS
MilliMetres per Second given scale speed. The Fast Clock Ratio is not used in the calculation.- Parameters:
scaleSpeed- in MPH or KPH- Returns:
- MilliMetres per second
-
getThrottleSettingFromSignalMapSpeed
Converts from signal map speed to a throttle setting. The Fast Clock Ratio is not used in the calculation.- Parameters:
signalMapSpeed- value from warrants preferencesisForward- direction of travel- Returns:
- throttle setting
-
setSpeed
Set the speed for the given speed step.- Parameters:
speedStep- the speed step to setforward- speed in meters per second for running forward at speedStepreverse- speed in meters per second for running in reverse at speedStep
-
getSpeedStep
-
setForwardSpeed
-
setForwardSpeed
Merge raw throttleSetting value with an existing profile SpeedStep if key for the throttleSetting is within the speedIncrement of the SpeedStep.- Parameters:
throttleSetting- raw throttle setting valuespeed- track speedspeedIncrement- throttle's speed step increment.
-
setReverseSpeed
Merge raw throttleSetting value with an existing profile SpeedStep if key for the throttleSetting is within the speedIncrement of the SpeedStep.- Parameters:
throttleSetting- raw throttle setting valuespeed- track speedspeedIncrement- throttle's speed step increment.
-
setReverseSpeed
-
getForwardSpeed
return the forward speed in milli-meters per second for a given percentage throttle- Parameters:
speedStep- which is actual percentage throttle- Returns:
- MilliMetres per second using straight line interpolation for missing points
-
getReverseSpeed
return the reverse speed in millimetres per second for a given percentage throttle- Parameters:
speedStep- percentage of throttle 0.nnn- Returns:
- millimetres per second
-
getDurationOfTravelInSeconds
Get the approximate time a loco may travel a given distance at a given speed step.- Parameters:
isForward- true if loco is running forward; false otherwisespeedStep- the desired speed stepdistance- the desired distance in millimeters- Returns:
- the approximate time in seconds
-
getDistanceTravelled
Get the approximate distance a loco may travel a given duration at a given speed step.- Parameters:
isForward- true if loco is running forward; false otherwisespeedStep- the desired speed stepduration- the desired time in seconds- Returns:
- the approximate distance in millimeters
-
finishChange
void finishChange()reset everything back to default once the change has finished. -
setExtraInitialDelay
-
setMinMaxLimits
-
changeLocoSpeed
Set speed of a throttle.- Parameters:
t- the throttle to setblk- the block used for length detailsspeed- the speed to set
-
changeLocoSpeed
Set speed of a throttle.- Parameters:
t- the throttle to setsec- the section used for length detailsspeed- the speed to setusePercentage- the percentage of the block to be used for stopping
-
changeLocoSpeed
Set speed of a throttle.- Parameters:
t- the throttle to setblk- the block used for length detailsspeed- the speed to setusePercentage- the percentage of the block to be used for stopping
-
changeLocoSpeed
Set speed of a throttle to a speeed set by a float, using the section for the length details Set speed of a throttle.- Parameters:
t- the throttle to setsec- the section used for length detailsspeed- the speed to set
-
changeLocoSpeed
Set speed of a throttle.- Parameters:
t- the throttle to setdistance- the distance in metersrequestedSpeed- the speed to set
-
calculateStepDetails
-
calculateInitialOverRun
-
cancelSpeedChange
This method is called to cancel the existing change in speed. -
setNextStep
void setNextStep() -
store
-
load
-
getProfileSize
Get the number of SpeedSteps. If there are too few SpeedSteps, it may be difficult to get reasonable distances and speeds over a large range of throttle settings.- Returns:
- the number of Speed Steps in the profile.
-
getProfileSpeeds
-
getThrottleSetting
Get the throttle setting to achieve a track speed- Parameters:
speed- desired track speed in mm/secisForward- direction- Returns:
- throttle setting
-
getSpeed
Get track speed in millimeters per second from throttle setting- Parameters:
speedStep- throttle settingisForward- direction- Returns:
- track speed
-
mmsToScaleSpeed(float mms)