Skip to content
Permalink
Browse files

MERG CBUS Throttle Speed Increment Fix

  • Loading branch information...
icklesteve committed Mar 20, 2019
1 parent 10a7054 commit 365d16750104fbd40135641039195880e11642a6
@@ -88,7 +88,7 @@ public CbusThrottle(CanSystemConnectionMemo memo, LocoAddress address, int handl
// case CbusConstants.DEC_MODE_14: this.speedIncrement = 8; break;
// }
// Only 128 speed step supported at the moment
this.speedIncrement = 1;
this.speedIncrement = SPEED_STEP_128_INCREMENT;

// start periodically sending keep alives, to keep this
// attached
@@ -410,7 +410,7 @@ protected void updateFunction(int fn, boolean state) {
*/
@Override
public void setSpeedSetting(float speed) {
// if (log.isDebugEnabled()) log.debug("setSpeedSetting({}) ", speed);
log.debug("setSpeedSetting({}) ", speed);
float oldSpeed = this.speedSetting;
this.speedSetting = speed;
if (speed < 0) {
@@ -421,7 +421,7 @@ public void setSpeedSetting(float speed) {
if (this.isForward) {
new_spd = new_spd | 0x80;
}
// if (log.isDebugEnabled()) log.debug("Sending speed/dir for speed: " + new_spd);
log.debug("Sending speed/dir for speed: {}",new_spd);
// reset timeout
mRefreshTimer.stop();
mRefreshTimer.setRepeats(true);
@@ -201,7 +201,7 @@ public void testIncomingSpeedDirection() {
JUnitUtil.waitFor(()->{ return(cbtmb.getThrottleInfo(addr,"F0")!=null); }, "reply didn't arrive");

Assert.assertEquals("speed setting",0.0f,cbtmb.getThrottleInfo(addr,"SpeedSetting"));
Assert.assertEquals("speed increment",1.0f,cbtmb.getThrottleInfo(addr,"SpeedIncrement"));
Assert.assertEquals("speed increment",(1.0f/126.0f),cbtmb.getThrottleInfo(addr,"SpeedIncrement"));
Assert.assertEquals("speed step mode",CbusConstants.CBUS_SS_128,cbtmb.getThrottleInfo(addr,"SpeedStepMode"));

CanReply r = new CanReply( new int[]{CbusConstants.CBUS_DSPD, 1, 0 },0x12 );
@@ -26,7 +26,7 @@ public void testCTor() {
@Override
@Test
public void testGetSpeedIncrement() {
float expResult = 1.0F;
float expResult = 1.0F/126.0F;
float result = instance.getSpeedIncrement();
Assert.assertEquals(expResult, result, 0.0);
}

0 comments on commit 365d167

Please sign in to comment.
You can’t perform that action at this time.