Package jmri.jmrix.dccpp
Class DCCppCommandStation
- java.lang.Object
-
- jmri.jmrix.dccpp.DCCppCommandStation
-
- All Implemented Interfaces:
CommandStation
public class DCCppCommandStation extends java.lang.Object implements CommandStation
Defines the standard/common routines used in multiple classes related to the DCC++ Command Station, on a DCC++ network.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
mInServiceMode
Remember whether or not in service mode.
-
Constructor Summary
Constructors Constructor Description DCCppCommandStation()
DCCppCommandStation(DCCppSystemConnectionMemo memo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getBuild()
Get the Build of the connected Command Station it is populated by response from the CS, initially "Unknown"protected int
getCommandStationMaxNumSlots()
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.int
getRegisterAddress(int num)
int
getRegisterNum(int addr)
java.lang.String
getStationType()
Get the Station Type of the connected Command Station it is populated by response from the CS, initially "Unknown"DCCppSystemConnectionMemo
getSystemConnectionMemo()
java.lang.String
getSystemPrefix()
java.lang.String
getUserName()
java.lang.String
getVersion()
Get the canonical version of the connected Command Station it is populated by response from the CS, so initially '0.0.0'java.lang.String
getVersionString()
Provide the version string returned during the initial check.boolean
isFunctionRefreshRequired()
Does this command station require JMRI to send periodic function refresh packets?boolean
isFunctionV4Supported()
Can this command station handle the newer (V4) function message format?boolean
isOpsModePossible()
DCC++ command station does provide Ops Mode.boolean
isProgramV4Supported()
Can this command station handle the newer (V4) program message formats?boolean
isReadStartValSupported()
Can this command station handle the Read with a starting value ('V'erify)boolean
isServoTurnoutCreationSupported()
Can this command station handle the Servo and Vpin Turnout creation message formats?boolean
isThrottleRegisterRequired()
Does this command station need the throttle register to be sent?boolean
isTurnoutIDsMessageRequired()
Does this command station require the new "J" commands for turnout definitions?void
releaseRegister(int addr)
int
requestNewRegister(int addr)
boolean
sendPacket(byte[] packet, int repeats)
Send a specific packet to the rails.void
setBuild(java.lang.String s)
protected void
setCommandStationInfo(DCCppReply l)
Parse the DCC++ CS status response to pull out the base station version and software version.protected void
setCommandStationMaxNumSlots(int newNumSlots)
protected void
setCommandStationMaxNumSlots(DCCppReply l)
void
setStationType(java.lang.String s)
void
setSystemConnectionMemo(DCCppSystemConnectionMemo memo)
void
setTrafficController(DCCppTrafficController tc)
void
setVersion(java.lang.String s)
-
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
-
mInServiceMode
boolean mInServiceMode
Remember whether or not in service mode.
-
-
Constructor Detail
-
DCCppCommandStation
public DCCppCommandStation()
-
DCCppCommandStation
public DCCppCommandStation(DCCppSystemConnectionMemo memo)
-
-
Method Detail
-
setStationType
public void setStationType(java.lang.String s)
-
getStationType
@Nonnull public java.lang.String getStationType()
Get the Station Type of the connected Command Station it is populated by response from the CS, initially "Unknown"- Returns:
- StationType
-
setBuild
public void setBuild(java.lang.String s)
-
getBuild
@Nonnull public java.lang.String getBuild()
Get the Build of the connected Command Station it is populated by response from the CS, initially "Unknown"- Returns:
- Build
-
setVersion
public void setVersion(java.lang.String s)
-
getVersion
@Nonnull public java.lang.String getVersion()
Get the canonical version of the connected Command Station it is populated by response from the CS, so initially '0.0.0'- Returns:
- Version
-
setCommandStationInfo
protected void setCommandStationInfo(DCCppReply l)
Parse the DCC++ CS status response to pull out the base station version and software version.- Parameters:
l
- status response to query.
-
setCommandStationMaxNumSlots
protected void setCommandStationMaxNumSlots(DCCppReply l)
-
setCommandStationMaxNumSlots
protected void setCommandStationMaxNumSlots(int newNumSlots)
-
getCommandStationMaxNumSlots
protected int getCommandStationMaxNumSlots()
-
getVersionString
public java.lang.String getVersionString()
Provide the version string returned during the initial check.- Returns:
- version string.
-
isOpsModePossible
public boolean isOpsModePossible()
DCC++ command station does provide Ops Mode.- Returns:
- always true.
-
isFunctionRefreshRequired
public boolean isFunctionRefreshRequired()
Does this command station require JMRI to send periodic function refresh packets?- Returns:
- true if required, false if not
-
isReadStartValSupported
public boolean isReadStartValSupported()
Can this command station handle the Read with a starting value ('V'erify)- Returns:
- true if yes or false if no
-
isServoTurnoutCreationSupported
public boolean isServoTurnoutCreationSupported()
Can this command station handle the Servo and Vpin Turnout creation message formats?- Returns:
- true if yes or false if no
-
isTurnoutIDsMessageRequired
public boolean isTurnoutIDsMessageRequired()
Does this command station require the new "J" commands for turnout definitions?- Returns:
- true if yes or false if no
-
isThrottleRegisterRequired
public boolean isThrottleRegisterRequired()
Does this command station need the throttle register to be sent?- Returns:
- true if yes or false if no
-
isFunctionV4Supported
public boolean isFunctionV4Supported()
Can this command station handle the newer (V4) function message format?- Returns:
- true if yes or false if no
-
isProgramV4Supported
public boolean isProgramV4Supported()
Can this command station handle the newer (V4) program message formats?- Returns:
- true if yes or false if no
-
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:
- loco address byte lo.
-
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:
- high byte of address.
-
sendPacket
public boolean sendPacket(@Nonnull 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(DCCppTrafficController tc)
-
setSystemConnectionMemo
public void setSystemConnectionMemo(DCCppSystemConnectionMemo memo)
-
getSystemConnectionMemo
public DCCppSystemConnectionMemo getSystemConnectionMemo()
-
getUserName
public java.lang.String getUserName()
- Specified by:
getUserName
in interfaceCommandStation
-
getSystemPrefix
@Nonnull public java.lang.String getSystemPrefix()
- Specified by:
getSystemPrefix
in interfaceCommandStation
-
requestNewRegister
public int requestNewRegister(int addr)
-
releaseRegister
public void releaseRegister(int addr)
-
getRegisterNum
public int getRegisterNum(int addr)
-
getRegisterAddress
public int getRegisterAddress(int num)
-
-