Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor refactoring and code cleanup in XPressNet throttles.
- Loading branch information
Showing
12 changed files
with
441 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,98 @@ | |||
package jmri.jmrix.roco; | |||
|
|||
import jmri.LocoAddress; | |||
import jmri.jmrix.lenz.XNetMessage; | |||
import jmri.jmrix.lenz.XNetReply; | |||
import jmri.jmrix.lenz.XNetSystemConnectionMemo; | |||
import jmri.jmrix.lenz.XNetTrafficController; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
|
|||
/** | |||
* An implementation of DccThrottle with code specific to a Roco XpressNet | |||
* connection. | |||
* | |||
* @author Paul Bender (C) 2015 | |||
* @author Giorgio Terdina (C) 2007 | |||
*/ | |||
public class RocoXNetThrottle extends jmri.jmrix.lenz.XNetThrottle { | |||
|
|||
/** | |||
* Constructor | |||
*/ | |||
public RocoXNetThrottle(XNetSystemConnectionMemo memo, XNetTrafficController controller) { | |||
super(memo,controller); | |||
} | |||
|
|||
/** | |||
* Constructor | |||
*/ | |||
public RocoXNetThrottle(XNetSystemConnectionMemo memo, LocoAddress address, XNetTrafficController controller) { | |||
super(memo,address,controller); | |||
} | |||
|
|||
// The Roco doesn't support setting the momentary/continuous status of | |||
// functions, so override the sending of all momentary/continuous | |||
// from the parent class. | |||
@Override | |||
protected void sendMomentaryFunctionGroup1() { | |||
log.debug("Command station does not support Momentary functions"); | |||
} | |||
|
|||
@Override | |||
protected void sendMomentaryFunctionGroup2() { | |||
log.debug("Command station does not support Momentary functions"); | |||
} | |||
|
|||
@Override | |||
protected void sendMomentaryFunctionGroup3() { | |||
log.debug("Command station does not support Momentary functions"); | |||
} | |||
|
|||
@Override | |||
protected void sendMomentaryFunctionGroup4() { | |||
log.debug("Command station does not support Momentary functions"); | |||
} | |||
|
|||
@Override | |||
protected void sendMomentaryFunctionGroup5() { | |||
log.debug("Command station does not support Momentary functions"); | |||
} | |||
|
|||
// also prevent requesting the momentary status information | |||
@Override | |||
synchronized protected void sendFunctionStatusInformationRequest() { | |||
log.debug("Command station does not support Momentary functions"); | |||
} | |||
|
|||
@Override | |||
synchronized protected void sendFunctionHighMomentaryStatusRequest() { | |||
log.debug("Command station does not support Momentary functions"); | |||
} | |||
|
|||
// The Roco Doesn't support the XpressNet directed emergency stop | |||
// instruction, so override sendEmergencyStop in the parent, and | |||
// just send speed step 0. | |||
@Override | |||
protected void sendEmergencyStop(){ | |||
setSpeedSetting(0); | |||
} | |||
|
|||
/** | |||
* Dispose when finished with this object. After this, further usage of this | |||
* Throttle object will result in a JmriException. | |||
* <p> | |||
* This is quite problematic, because a using object doesn't know when it's | |||
* the last user. | |||
*/ | |||
@Override | |||
protected void throttleDispose() { | |||
active = false; | |||
stopStatusTimer(); | |||
finishRecord(); | |||
} | |||
|
|||
// register for notification | |||
private final static Logger log = LoggerFactory.getLogger(RocoXNetThrottle.class); | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,44 @@ | |||
package jmri.jmrix.roco; | |||
|
|||
import jmri.LocoAddress; | |||
import jmri.jmrix.lenz.XNetSystemConnectionMemo; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
|
|||
/** | |||
* Roco XNet implementation of a ThrottleManager based on the | |||
* AbstractThrottleManager. | |||
* | |||
* @author Paul Bender Copyright (C) 2002-2004 | |||
*/ | |||
public class RocoXNetThrottleManager extends jmri.jmrix.lenz.XNetThrottleManager { | |||
|
|||
/** | |||
* Constructor. | |||
*/ | |||
public RocoXNetThrottleManager(XNetSystemConnectionMemo memo) { | |||
super(memo); | |||
} | |||
|
|||
/** | |||
* Request a new throttle object be created for the address, and let the | |||
* throttle listeners know about it. | |||
*/ | |||
@Override | |||
public void requestThrottleSetup(LocoAddress address, boolean control) { | |||
RocoXNetThrottle throttle; | |||
if (log.isDebugEnabled()) { | |||
log.debug("Requesting Throttle: " + address); | |||
} | |||
if (throttles.containsKey(address)) { | |||
notifyThrottleKnown(throttles.get(address), address); | |||
} else { | |||
throttle = new RocoXNetThrottle((XNetSystemConnectionMemo) adapterMemo, address, tc); | |||
throttles.put(address, throttle); | |||
notifyThrottleKnown(throttle, address); | |||
} | |||
} | |||
|
|||
private final static Logger log = LoggerFactory.getLogger(RocoXNetThrottleManager.class); | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
java/test/jmri/jmrix/roco/RocoXNetThrottleManagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
package jmri.jmrix.roco; | |||
|
|||
import jmri.jmrix.lenz.XNetInterfaceScaffold; | |||
import jmri.jmrix.lenz.XNetSystemConnectionMemo; | |||
import jmri.jmrix.lenz.XNetThrottleManagerTest; | |||
import jmri.util.JUnitUtil; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
|
|||
|
|||
/** | |||
* Tests for the jmri.jmrix.roco.RocoXNetThrottleManager class | |||
* | |||
* @author Paul Bender Copyright (C) 2015,2016 | |||
*/ | |||
public class RocoXNetThrottleManagerTest extends XNetThrottleManagerTest { | |||
|
|||
// The minimal setup for log4J | |||
@Override | |||
@Before | |||
public void setUp() { | |||
JUnitUtil.setUp(); | |||
XNetInterfaceScaffold tc = new XNetInterfaceScaffold(new RocoCommandStation()); | |||
tm = new RocoXNetThrottleManager(new XNetSystemConnectionMemo(tc)); | |||
} | |||
|
|||
@After | |||
@Override | |||
public void tearDown() { | |||
tm = null; | |||
JUnitUtil.tearDown(); | |||
} | |||
|
|||
} |
Oops, something went wrong.