Skip to content
Permalink
Browse files

Id did not work having several locomotives controlled by an ECOS.

Since they all got DCC address 0, selecting one of them in a JMRI throttle just took the oldest registrered MFX locomotive.
  • Loading branch information...
kjlisby committed Sep 8, 2018
1 parent 4d42d0d commit bb1d7c9b7ca9c3b10937acde491a2dd0e2322e06
@@ -85,8 +85,15 @@ public EcosDccThrottle(DccLocoAddress address, EcosSystemConnectionMemo memo, bo

ecosretry = 0;

log.debug("EcosDccThrottle constructor " + address);

//We go on a hunt to find an object with the dccaddress sent by our controller.
objEcosLoco = objEcosLocoManager.provideByDccAddress(address.getNumber());
if (address.getNumber() < EcosLocoAddress.MFX_DCCAddressOffset) {
objEcosLoco = objEcosLocoManager.provideByDccAddress(address.getNumber());
} else {
int ecosID = address.getNumber()-EcosLocoAddress.MFX_DCCAddressOffset;
objEcosLoco = objEcosLocoManager.provideByEcosObject(String.valueOf(ecosID));
}

this.objectNumber = objEcosLoco.getEcosObject();
if (this.objectNumber == null) {
@@ -86,6 +86,7 @@ public boolean addressTypeUnique() {
public String[] getAddressTypes() {
return new String[]{
LocoAddress.Protocol.DCC.getPeopleName(),
LocoAddress.Protocol.MFX.getPeopleName(),
LocoAddress.Protocol.MOTOROLA.getPeopleName(),
LocoAddress.Protocol.SELECTRIX.getPeopleName(),
LocoAddress.Protocol.LGB.getPeopleName()};
@@ -94,6 +95,7 @@ public boolean addressTypeUnique() {
@Override
public LocoAddress.Protocol[] getAddressProtocolTypes() {
return new LocoAddress.Protocol[]{LocoAddress.Protocol.DCC,
LocoAddress.Protocol.MFX,
LocoAddress.Protocol.MOTOROLA,
LocoAddress.Protocol.SELECTRIX,
LocoAddress.Protocol.LGB};
@@ -104,7 +106,7 @@ public boolean addressTypeUnique() {
* Decide whether given a long address or not.
*/
static boolean isLongAddress(int num) {
return (num >= 100);
return (num >= 127);
}

@Override
@@ -24,6 +24,7 @@
boolean direction;
int currentSpeed;
private boolean doNotAddToRoster = false;
public static int MFX_DCCAddressOffset = 20000;

public EcosLocoAddress(int dCCAddress) {
_dccAddress = dCCAddress;
@@ -542,7 +542,11 @@ private void selectedDecoder(DecoderFile pDecoderFile) {
re.setDecoderModel(pDecoderFile.getModel());
re.setDecoderFamily(pDecoderFile.getFamily());

re.setDccAddress(Integer.toString(ecosLoco.getNumber()));
if (ecosLoco.getNumber() == 0) {
re.setDccAddress(Integer.toString(ecosLoco.MFX_DCCAddressOffset+ecosLoco.getEcosObjectAsInt()));
} else {
re.setDccAddress(Integer.toString(ecosLoco.getNumber()));
}
//re.setLongAddress(true);

re.setRoadName("");

0 comments on commit bb1d7c9

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