Package jmri.jmrix.lenz
Class LenzCommandStation
- java.lang.Object
-
- jmri.jmrix.lenz.LenzCommandStation
-
- All Implemented Interfaces:
CommandStation
- Direct Known Subclasses:
HornbyEliteCommandStation
,RocoCommandStation
public class LenzCommandStation extends java.lang.Object implements CommandStation
Defines the standard/common routines used in multiple classes related to the a Lenz Command Station, on an XpressNet network.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) XNetSystemConnectionMemo
adaptermemo
-
Constructor Summary
Constructors Constructor Description LenzCommandStation()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
calcLocoAddress(int AH, int AL)
We need to calculate the locomotive address when doing the translations back to text.float
getCommandStationSoftwareVersion()
Get the CS Software Version.float
getCommandStationSoftwareVersionBCD()
Get the CS Software Version in BCD (for use in comparisons).int
getCommandStationType()
Return the CS Type.static int
getDCCAddressHigh(int address)
Get the Upper byte of a locomotive address from the decimal locomotive address.static int
getDCCAddressLow(int address)
Get the Lower byte of a locomotive address from the decimal locomotive address.java.lang.String
getSystemPrefix()
java.lang.String
getUserName()
java.lang.String
getVersionString()
Provide the version string returned during the initial check.boolean
isOpsModePossible()
XpressNet command station does provide Ops Mode.boolean
sendPacket(byte[] packet, int repeats)
Send a specific packet to the rails.void
setCommandStationSoftwareVersion(float v)
Set the CS Software Version.void
setCommandStationSoftwareVersion(XNetReply l)
Set the CS Software Version based on an XpressNet Message.void
setCommandStationType(int t)
Set the CS Type.void
setCommandStationType(XNetReply l)
Set the CS Type based on an XpressNet Message.void
setSystemConnectionMemo(XNetSystemConnectionMemo memo)
void
setTrafficController(XNetTrafficController tc)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.CommandStation
sendAccSignalDecoderPkt, sendAltAccSignalDecoderPkt
-
-
-
-
Field Detail
-
adaptermemo
XNetSystemConnectionMemo adaptermemo
-
-
Constructor Detail
-
LenzCommandStation
public LenzCommandStation()
-
-
Method Detail
-
getCommandStationType
public int getCommandStationType()
Return the CS Type.- Returns:
- CS type.
-
setCommandStationType
public void setCommandStationType(int t)
Set the CS Type.- Parameters:
t
- CS type.
-
setCommandStationType
public void setCommandStationType(XNetReply l)
Set the CS Type based on an XpressNet Message.- Parameters:
l
- XNetReply containing the CS type.
-
getCommandStationSoftwareVersion
public float getCommandStationSoftwareVersion()
Get the CS Software Version.- Returns:
- software version.
-
getCommandStationSoftwareVersionBCD
public float getCommandStationSoftwareVersionBCD()
Get the CS Software Version in BCD (for use in comparisons).- Returns:
- software version.
-
setCommandStationSoftwareVersion
public void setCommandStationSoftwareVersion(float v)
Set the CS Software Version.- Parameters:
v
- software version.
-
setCommandStationSoftwareVersion
public void setCommandStationSoftwareVersion(XNetReply l)
Set the CS Software Version based on an XpressNet Message.- Parameters:
l
- reply containing CS version.
-
getVersionString
public java.lang.String getVersionString()
Provide the version string returned during the initial check.- Returns:
- human readable version string.
-
isOpsModePossible
public boolean isOpsModePossible()
XpressNet command station does provide Ops Mode.- Returns:
- true if CS type 1 or 2, else false.
-
getDCCAddressLow
public static int getDCCAddressLow(int address)
Get the Lower byte of a locomotive address from the decimal locomotive address.- Parameters:
address
- loco address.- Returns:
- low address byte including DCC offset.
-
getDCCAddressHigh
public static int getDCCAddressHigh(int address)
Get the Upper byte of a locomotive address from the decimal locomotive address.- Parameters:
address
- loco address.- Returns:
- upper byte after DCC offset.
-
calcLocoAddress
public static int calcLocoAddress(int AH, int AL)
We need to calculate the locomotive address when doing the translations back to text. XpressNet Messages will have these as two elements, which need to get translated back into a single address by reversing the formulas used to calculate them in the first place.- Parameters:
AH
- the high order byte of the addressAL
- the low order byte of the address- Returns:
- the address as an integer.
-
sendPacket
public boolean sendPacket(byte[] packet, int repeats)
Send a specific packet to the rails.- Specified by:
sendPacket
in interfaceCommandStation
- Parameters:
packet
- Byte array representing the packet, including the error-correction byte. Must not be null.repeats
- Number of times to repeat the transmission.- Returns:
true
if the operation succeeds,false
otherwise.
-
setTrafficController
public void setTrafficController(XNetTrafficController tc)
-
setSystemConnectionMemo
public void setSystemConnectionMemo(XNetSystemConnectionMemo memo)
-
getUserName
public java.lang.String getUserName()
- Specified by:
getUserName
in interfaceCommandStation
-
getSystemPrefix
public java.lang.String getSystemPrefix()
- Specified by:
getSystemPrefix
in interfaceCommandStation
-
-