Class SpeedStepScaleSpeedMatcher
- java.lang.Object
-
- jmri.jmrix.bachrus.speedmatcher.SpeedMatcher
-
- jmri.jmrix.bachrus.speedmatcher.speedStepScale.SpeedStepScaleSpeedMatcher
-
- All Implemented Interfaces:
java.util.EventListener
,ProgListener
,ThrottleListener
- Direct Known Subclasses:
SpeedStepScaleESUTableSpeedMatcher
,SpeedStepScaleSpeedTableSpeedMatcher
public abstract class SpeedStepScaleSpeedMatcher extends SpeedMatcher
Abstract class defining the basic operations of a Speed Step Scale speed matcher (sets up the complex speed table such that the speed step equals the locomotive speed when using "128" speed step mode). All speed step scale speed matcher implementations must extend this class.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.bachrus.speedmatcher.SpeedMatcher
SpeedMatcher.ProgrammerState, SpeedMatcher.SpeedMatcherCV, SpeedMatcher.SpeedTableStep
-
Nested classes/interfaces inherited from interface jmri.ThrottleListener
ThrottleListener.DecisionType
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.JLabel
actualMaxSpeedField
protected float
measuredMaxSpeedKPH
protected float
speedMatchMaxSpeedKPH
protected Speed.Unit
speedUnit
protected float
targetMaxSpeedKPH
protected SpeedTableStepSpeed
targetMaxSpeedStep
-
Fields inherited from class jmri.jmrix.bachrus.speedmatcher.SpeedMatcher
ALLOWED_SPEED_MATCH_ERROR, attempt, currentSpeedKPH, dccLocoAddress, INITIAL_MOMENTUM, opsModeProgrammer, powerManager, programmerState, REVERSE_TRIM_MAX, REVERSE_TRIM_MIN, speedMatchError, speedMatcherValueDelta, startStopButton, statusLabel, stepDuration, trimReverseSpeed, warmUpForwardSeconds, warmUpReverseSeconds
-
Fields inherited from interface jmri.ProgListener
CommError, ConfirmFailed, FailedTimeout, NoAck, NoLocoDetected, NotImplemented, OK, ProgrammerBusy, ProgrammingShort, SequenceError, UnknownError, UserAborted
-
-
Constructor Summary
Constructors Constructor Description SpeedStepScaleSpeedMatcher(SpeedStepScaleSpeedMatcherConfig config)
Constructs the abstract SpeedStepScaleSpeedMatcher at the core of any Speed Step Scale Speed Matcher
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
getNextLowestSpeedTableStepForSpeed(float speed)
Gets the next lowest speed table step for the given speedstatic float
getSpeedForSpeedTableStep(int speedStep)
Gets the 128 speed step mode speed for a speed table stepprotected int
getSpeedStepLinearValue(int speedStep)
Gets the speed step value for a linear speed tableprotected float
getSpeedStepScaleSpeedInKPH(int speedStep)
Gets the speed in KPH for a given speed step for a speed step scale speed matcherprotected boolean
validate()
Validates the speed matcher's configuration-
Methods inherited from class jmri.jmrix.bachrus.speedmatcher.SpeedMatcher
cleanUpSpeedMatcher, getNextSpeedMatchValue, initializeAndStartSpeedMatcher, isSpeedMatcherIdle, notifyDecisionRequired, notifyFailedThrottleRequest, notifyThrottleFound, programmingOpReply, resetSpeedMatcher, setSpeedMatchError, setSpeedMatchStateTimerDuration, setThrottle, startSpeedMatcher, startSpeedMatchStateTimer, stopSpeedMatcher, stopSpeedMatchStateTimer, updateCurrentSpeed, writeForwardTrim, writeMomentumAccel, writeMomentumDecel, writeReverseTrim, writeSpeedTableStep, writeVHigh, writeVMid, writeVStart
-
-
-
-
Field Detail
-
targetMaxSpeedStep
protected final SpeedTableStepSpeed targetMaxSpeedStep
-
targetMaxSpeedKPH
protected final float targetMaxSpeedKPH
-
speedUnit
protected final Speed.Unit speedUnit
-
actualMaxSpeedField
protected final javax.swing.JLabel actualMaxSpeedField
-
measuredMaxSpeedKPH
protected float measuredMaxSpeedKPH
-
speedMatchMaxSpeedKPH
protected float speedMatchMaxSpeedKPH
-
-
Constructor Detail
-
SpeedStepScaleSpeedMatcher
public SpeedStepScaleSpeedMatcher(SpeedStepScaleSpeedMatcherConfig config)
Constructs the abstract SpeedStepScaleSpeedMatcher at the core of any Speed Step Scale Speed Matcher- Parameters:
config
- SpeedStepScaleSpeedMatcherConfig
-
-
Method Detail
-
validate
protected boolean validate()
Validates the speed matcher's configuration- Specified by:
validate
in classSpeedMatcher
- Returns:
- true if the configuration is valid, false otherwise
-
getSpeedStepScaleSpeedInKPH
protected float getSpeedStepScaleSpeedInKPH(int speedStep)
Gets the speed in KPH for a given speed step for a speed step scale speed matcher- Parameters:
speedStep
- the int speed step to get the speed for- Returns:
- speed for the given speedStep in KPH
-
getSpeedStepLinearValue
protected int getSpeedStepLinearValue(int speedStep)
Gets the speed step value for a linear speed table- Parameters:
speedStep
- the inst speed step to get the value for- Returns:
- value for the speed step
-
getSpeedForSpeedTableStep
public static float getSpeedForSpeedTableStep(int speedStep)
Gets the 128 speed step mode speed for a speed table step- Parameters:
speedStep
- the int speed table step to get the 128 speed step mode speed for- Returns:
- the 128 speed step mode speed for the given speedStep
-
getNextLowestSpeedTableStepForSpeed
public static int getNextLowestSpeedTableStepForSpeed(float speed)
Gets the next lowest speed table step for the given speed- Parameters:
speed
- float speed in the user facing unit- Returns:
- the next lowest int speed table step for the given speed
-
-