Class DCCppMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.dccpp.DCCppMessage
-
- All Implemented Interfaces:
java.lang.Comparable<java.util.concurrent.Delayed>
,java.util.concurrent.Delayed
,Message
public class DCCppMessage extends AbstractMRMessage implements java.util.concurrent.Delayed
Represents a single command or response on the DCC++.Content is represented with ints to avoid the problems with sign-extension that bytes have, and because a Java char is actually a variable number of bytes in Unicode.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DCCppProgrammingTimeout
-
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DCCppMessage(char c)
protected
DCCppMessage(char c, java.lang.String regex)
DCCppMessage(int len)
Create a new object, representing a specific-length message.DCCppMessage(java.lang.String s)
Create a DCCppMessage from a String containing bytes.DCCppMessage(DCCppMessage message)
Create a new object, that is a copy of an existing message.DCCppMessage(DCCppReply message)
Create an DCCppMessage from an DCCppReply.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(java.util.concurrent.Delayed o)
Comparing two queued message for refreshing the function calls, based on their expected execution time.void
delayFor(long millis)
Before adding the message to the delay queue call this method to set when the message should be repeated.boolean
equals(java.lang.Object obj)
This implementation of equals is targeted to the background function refreshing in SerialDCCppPacketizer.int
getAccessoryAddrInt()
java.lang.String
getAccessoryAddrString()
int
getAccessoryStateInt()
java.lang.String
getAccessoryStateString()
int
getAccessorySubInt()
java.lang.String
getAccessorySubString()
int
getAddressInt()
java.lang.String
getAddressString()
int
getBitInt()
java.lang.String
getBitString()
int
getCallbackNumInt()
java.lang.String
getCallbackNumString()
int
getCallbackSubInt()
java.lang.String
getCallbackSubString()
int
getClockMinutesInt()
java.lang.String
getClockMinutesString()
int
getClockRateInt()
java.lang.String
getClockRateString()
int
getCVInt()
java.lang.String
getCVString()
long
getDelay(java.util.concurrent.TimeUnit unit)
From theDelayed
interface, how long this message still has until it should be executed.int
getDirectionInt()
java.lang.String
getDirectionString()
int
getElement(int n)
Get a particular element in a Message.java.lang.String
getForgetCabString()
int
getFuncAddressInt()
java.lang.String
getFuncAddressString()
int
getFuncByte1Int()
java.lang.String
getFuncByte1String()
int
getFuncByte2Int()
java.lang.String
getFuncByte2String()
java.lang.String
getFuncV4CabString()
java.lang.String
getFuncV4FuncString()
java.lang.String
getFuncV4StateString()
int
getNumDataElements()
Get the number of data elements in a Message.int
getOpCode()
char
getOpCodeChar()
int
getOpsWriteAddrInt()
java.lang.String
getOpsWriteAddrString()
int
getOpsWriteBitInt()
java.lang.String
getOpsWriteBitString()
int
getOpsWriteCVInt()
java.lang.String
getOpsWriteCVString()
int
getOpsWriteValueInt()
java.lang.String
getOpsWriteValueString()
int
getOutputIDInt()
java.lang.String
getOutputIDString()
int
getOutputIFlagInt()
java.lang.String
getOutputIFlagString()
int
getOutputPinInt()
java.lang.String
getOutputPinString()
boolean
getOutputStateBool()
int
getOutputStateInt()
java.lang.String
getOutputStateString()
java.lang.String
getPacketString()
int
getProgValueInt()
java.lang.String
getProgValueString()
int
getRegisterInt()
java.lang.String
getRegisterString()
int
getSensorIDInt()
java.lang.String
getSensorIDString()
int
getSensorPinInt()
java.lang.String
getSensorPinString()
boolean
getSensorPullupBool()
int
getSensorPullupInt()
java.lang.String
getSensorPullupString()
int
getSpeedInt()
java.lang.String
getSpeedString()
int
getTOAddressInt()
java.lang.String
getTOAddressString()
int
getTOClosedPositionInt()
int
getTOIDInt()
java.lang.String
getTOIDString()
int
getTOPinInt()
int
getTOProfileInt()
int
getTOStateInt()
java.lang.String
getTOStateString()
int
getTOSubAddressInt()
java.lang.String
getTOSubAddressString()
int
getTOThrownPositionInt()
boolean
getValueBool(int idx)
int
getValueInt(int idx)
java.lang.String
getValueString(int idx)
int
hashCode()
Hash code from base data.boolean
isAccessoryMessage()
boolean
isClockRequestTimeMessage()
boolean
isClockSetTimeMessage()
boolean
isEEPROMClearMessage()
boolean
isEEPROMWriteMessage()
boolean
isForgetCabMessage()
boolean
isFunctionMessage()
boolean
isFunctionV4Message()
boolean
isListOutputsMessage()
boolean
isListSensorsMessage()
boolean
isListTurnoutsMessage()
boolean
isOpsWriteBitMessage()
boolean
isOpsWriteByteMessage()
boolean
isOutputAddMessage()
boolean
isOutputCmdMessage()
boolean
isOutputDeleteMessage()
boolean
isProgReadCVMessage()
boolean
isProgReadCVMessageV4()
boolean
isProgReadLocoIdMessage()
boolean
isProgVerifyMessage()
boolean
isProgWriteBitMessage()
boolean
isProgWriteBitMessageV4()
boolean
isProgWriteByteMessage()
boolean
isProgWriteByteMessageV4()
boolean
isQuerySensorStatesMessage()
boolean
isSensorAddMessage()
boolean
isSensorDeleteMessage()
boolean
isSensorMessage()
boolean
isThrottleMessage()
boolean
isThrottleV3Message()
boolean
isTrackManagerRequestMessage()
boolean
isTurnoutAddDCCMessage()
boolean
isTurnoutAddMessage()
boolean
isTurnoutAddServoMessage()
boolean
isTurnoutAddVpinMessage()
boolean
isTurnoutCmdMessage()
boolean
isTurnoutDeleteMessage()
boolean
isTurnoutIDMessage()
boolean
isTurnoutIDsMessage()
boolean
isTurnoutImplementationMessage()
boolean
isTurnoutMessage()
boolean
isValidMessageFormat()
Returns true if this DCCppMessage is properly formatted (or will generate a properly formatted command when converted to String).boolean
isWriteDccPacketMessage()
int
length()
static DCCppMessage
makeAccessoryDecoderMsg(int address, boolean activate)
static DCCppMessage
makeAccessoryDecoderMsg(int address, int subaddress, boolean activate)
Stationary Decoder Message.static DCCppMessage
makeAddressedEmergencyStop(int address)
Generate an emergency stop for the specified address.static DCCppMessage
makeAddressedEmergencyStop(int register, int address)
Generate an emergency stop for the specified address.static DCCppMessage
makeBitWriteDirectCVMsg(int cv, int bit, int val)
Write Direct CV Bit to Programming Track.static DCCppMessage
makeBitWriteDirectCVMsg(int cv, int bit, int val, int callbacknum, int callbacksub)
static DCCppMessage
makeBitWriteDirectCVMsgV4(int cv, int bit, int val)
static DCCppMessage
makeBitWriteOpsModeCVMsg(int address, int cv, int bit, int val)
Write Direct CV Bit to Main Track.static DCCppMessage
makeClockRequestTimeMsg()
static DCCppMessage
makeClockSetMsg(int minutes)
static DCCppMessage
makeClockSetMsg(int minutes, int rate)
static DCCppMessage
makeCSMaxNumSlotsMsg()
Get number of supported slots for this DCC++ Base Station Statusstatic DCCppMessage
makeCSStatusMsg()
Read DCC++ Base Station Statusstatic DCCppMessage
makeEmergencyStopAllMsg()
Generate an emergency stop for all locos in reminder table.static DCCppMessage
makeForgetCabMessage(int cab)
Generate a "Forget Cab" message '-'static DCCppMessage
makeFunctionGroup1OpsMsg(int address, boolean f0, boolean f1, boolean f2, boolean f3, boolean f4)
Generate a Function Group One Operation Request message.static DCCppMessage
makeFunctionGroup1SetMomMsg(int address, boolean f0, boolean f1, boolean f2, boolean f3, boolean f4)
Generate a Function Group One Set Momentary Functions message.static DCCppMessage
makeFunctionGroup2OpsMsg(int address, boolean f5, boolean f6, boolean f7, boolean f8)
Generate a Function Group Two Operation Request message.static DCCppMessage
makeFunctionGroup2SetMomMsg(int address, boolean f5, boolean f6, boolean f7, boolean f8)
Generate a Function Group Two Set Momentary Functions message.static DCCppMessage
makeFunctionGroup3OpsMsg(int address, boolean f9, boolean f10, boolean f11, boolean f12)
Generate a Function Group Three Operation Request message.static DCCppMessage
makeFunctionGroup3SetMomMsg(int address, boolean f9, boolean f10, boolean f11, boolean f12)
Generate a Function Group Three Set Momentary Functions message.static DCCppMessage
makeFunctionGroup4OpsMsg(int address, boolean f13, boolean f14, boolean f15, boolean f16, boolean f17, boolean f18, boolean f19, boolean f20)
Generate a Function Group Four Operation Request message.static DCCppMessage
makeFunctionGroup4SetMomMsg(int address, boolean f13, boolean f14, boolean f15, boolean f16, boolean f17, boolean f18, boolean f19, boolean f20)
Generate a Function Group Four Set Momentary Function message.static DCCppMessage
makeFunctionGroup5OpsMsg(int address, boolean f21, boolean f22, boolean f23, boolean f24, boolean f25, boolean f26, boolean f27, boolean f28)
Generate a Function Group Five Operation Request message.static DCCppMessage
makeFunctionGroup5SetMomMsg(int address, boolean f21, boolean f22, boolean f23, boolean f24, boolean f25, boolean f26, boolean f27, boolean f28)
Generate a Function Group Five Set Momentary Function message.static DCCppMessage
makeFunctionV4Message(int cab, int func, boolean state)
Generate a function message using the V4 'F' syntax supported by DCC-EXstatic DCCppMessage
makeLCDRequestMsg()
Request LCD Messages used for Virtual LCD Displaystatic DCCppMessage
makeListRegisterContentsMsg()
static DCCppMessage
makeMessage(java.lang.String msg)
static DCCppMessage
makeOutputAddMsg(int id, int pin, int iflag)
static DCCppMessage
makeOutputCmdMsg(int id, boolean state)
static DCCppMessage
makeOutputDeleteMsg(int id)
static DCCppMessage
makeOutputListMsg()
static DCCppMessage
makeQuerySensorStatesMsg()
Query All Sensors States.static DCCppMessage
makeReadDirectCVMsg(int cv)
Read Direct CV Byte from Programming Track.static DCCppMessage
makeReadDirectCVMsg(int cv, int callbacknum, int callbacksub)
static DCCppMessage
makeReadTrackCurrentMsg()
Read main operations track currentstatic DCCppMessage
makeSensorAddMsg(int id, int pin, int pullup)
Create/Delete/Query Sensor.static DCCppMessage
makeSensorDeleteMsg(int id)
static DCCppMessage
makeSensorListMsg()
static DCCppMessage
makeSetTrackPowerMsg(boolean on)
Set Track Power ON or OFF.static DCCppMessage
makeSpeedAndDirectionMsg(int address, float speed, boolean isForward)
Generate a Speed and Direction Request messagestatic DCCppMessage
makeSpeedAndDirectionMsg(int register, int address, float speed, boolean isForward)
Generate a Speed and Direction Request messagestatic DCCppMessage
makeTrackManagerRequestMsg()
static DCCppMessage
makeTrackPowerOffMsg()
static DCCppMessage
makeTrackPowerOnMsg()
static DCCppMessage
makeTurnoutAddMsg(int id, int addr, int subaddr)
static DCCppMessage
makeTurnoutCommandMsg(int id, boolean thrown)
Predefined Turnout Control Message.static DCCppMessage
makeTurnoutDeleteMsg(int id)
static DCCppMessage
makeTurnoutIDMsg(int id)
static DCCppMessage
makeTurnoutIDsMsg()
static DCCppMessage
makeTurnoutImplMsg(int id)
static DCCppMessage
makeTurnoutListMsg()
static DCCppMessage
makeVerifyCVMsg(int cv, int startVal)
Verify Direct CV Byte from Programming Track.static DCCppMessage
makeWriteDCCPacketMainMsg(int register, int numBytes, byte[] bytes)
Write DCC Packet to a specified Register on the Main.static DCCppMessage
makeWriteDCCPacketProgMsg(int register, int numBytes, byte[] bytes)
Write DCC Packet to a specified Register on the Programming Track.static DCCppMessage
makeWriteDirectCVMsg(int cv, int val)
Write Direct CV Byte to Programming Trackstatic DCCppMessage
makeWriteDirectCVMsg(int cv, int val, int callbacknum, int callbacksub)
static DCCppMessage
makeWriteDirectCVMsgV4(int cv, int val)
static DCCppMessage
makeWriteOpsModeCVMsg(int address, int cv, int val)
Write Direct CV Byte to Main Trackboolean
replyExpected()
Is a reply expected to this message?static void
setDCCppMessageRetries(int t)
Change the default number of retries for an DCC++ message.static void
setDCCppMessageTimeout(int t)
Change the default timeout for a DCC++ message.void
setElement(int n, int v)
Set a single Data Element at a particular index.void
setOpCode(int i)
java.lang.String
toMonitorString()
Generate text translations of messages for use in the DCCpp monitor.java.lang.String
toString()
Converts DCCppMessage to String format (without the<>
brackets)-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCodeHex, getRetries, getTimeout, isBinary, setBinary, setNeededMode, setRetries, setTimeout
-
-
-
-
Field Detail
-
DCCppProgrammingTimeout
protected static final int DCCppProgrammingTimeout
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DCCppMessage
public DCCppMessage(int len)
Create a new object, representing a specific-length message.- Parameters:
len
- Total bytes in message, including opcode and error-detection byte.
-
DCCppMessage
public DCCppMessage(DCCppMessage message)
Create a new object, that is a copy of an existing message.- Parameters:
message
- existing message.
-
DCCppMessage
public DCCppMessage(DCCppReply message)
Create an DCCppMessage from an DCCppReply. Not used. Really, not even possible. Consider removing.- Parameters:
message
- existing reply to replicate.
-
DCCppMessage
public DCCppMessage(java.lang.String s)
Create a DCCppMessage from a String containing bytes.Since DCCppMessages are text, there is no Hex-to-byte conversion.
NOTE 15-Feb-17: un-Deprecating this function so that it can be used in the DCCppOverTCP server/client interface. Messages shouldn't be parsed, they are already in DCC++ format, so we need the string constructor to generate a DCCppMessage from the incoming byte stream.
- Parameters:
s
- message in string form.
-
DCCppMessage
protected DCCppMessage(char c)
-
DCCppMessage
protected DCCppMessage(char c, java.lang.String regex)
-
-
Method Detail
-
toString
public java.lang.String toString()
Converts DCCppMessage to String format (without the<>
brackets)- Specified by:
toString
in interfaceMessage
- Overrides:
toString
in classAbstractMRMessage
- Returns:
- String form of message.
-
toMonitorString
public java.lang.String toMonitorString()
Generate text translations of messages for use in the DCCpp monitor.- Specified by:
toMonitorString
in interfaceMessage
- Returns:
- representation of the DCCpp as a string.
-
getNumDataElements
public int getNumDataElements()
Description copied from class:AbstractMessage
Get the number of data elements in a Message.- Specified by:
getNumDataElements
in interfaceMessage
- Overrides:
getNumDataElements
in classAbstractMessage
- Returns:
- number elements.
-
getElement
public int getElement(int n)
Description copied from class:AbstractMessage
Get a particular element in a Message.- Specified by:
getElement
in interfaceMessage
- Overrides:
getElement
in classAbstractMessage
- Parameters:
n
- Element Index.- Returns:
- single element of message.
-
setElement
public void setElement(int n, int v)
Description copied from class:AbstractMessage
Set a single Data Element at a particular index.- Specified by:
setElement
in interfaceMessage
- Overrides:
setElement
in classAbstractMessage
- Parameters:
n
- index of element.v
- value of element.
-
setOpCode
public void setOpCode(int i)
- Overrides:
setOpCode
in classAbstractMRMessage
-
getOpCode
public int getOpCode()
- Overrides:
getOpCode
in classAbstractMRMessage
-
getOpCodeChar
public char getOpCodeChar()
-
getValueString
public java.lang.String getValueString(int idx)
-
getValueInt
public int getValueInt(int idx)
-
getValueBool
public boolean getValueBool(int idx)
-
length
public int length()
- Returns:
- the message length
-
setDCCppMessageRetries
public static void setDCCppMessageRetries(int t)
Change the default number of retries for an DCC++ message.- Parameters:
t
- number of retries to attempt
-
setDCCppMessageTimeout
public static void setDCCppMessageTimeout(int t)
Change the default timeout for a DCC++ message.- Parameters:
t
- Timeout in milliseconds
-
isValidMessageFormat
public boolean isValidMessageFormat()
Returns true if this DCCppMessage is properly formatted (or will generate a properly formatted command when converted to String).- Returns:
- boolean true/false
-
isThrottleMessage
public boolean isThrottleMessage()
-
isThrottleV3Message
public boolean isThrottleV3Message()
-
isAccessoryMessage
public boolean isAccessoryMessage()
-
isFunctionMessage
public boolean isFunctionMessage()
-
isFunctionV4Message
public boolean isFunctionV4Message()
-
isForgetCabMessage
public boolean isForgetCabMessage()
-
isTurnoutMessage
public boolean isTurnoutMessage()
-
isSensorMessage
public boolean isSensorMessage()
-
isEEPROMWriteMessage
public boolean isEEPROMWriteMessage()
-
isEEPROMClearMessage
public boolean isEEPROMClearMessage()
-
isOpsWriteByteMessage
public boolean isOpsWriteByteMessage()
-
isOpsWriteBitMessage
public boolean isOpsWriteBitMessage()
-
isProgWriteByteMessage
public boolean isProgWriteByteMessage()
-
isProgWriteByteMessageV4
public boolean isProgWriteByteMessageV4()
-
isProgWriteBitMessage
public boolean isProgWriteBitMessage()
-
isProgWriteBitMessageV4
public boolean isProgWriteBitMessageV4()
-
isProgReadCVMessage
public boolean isProgReadCVMessage()
-
isProgReadCVMessageV4
public boolean isProgReadCVMessageV4()
-
isProgReadLocoIdMessage
public boolean isProgReadLocoIdMessage()
-
isProgVerifyMessage
public boolean isProgVerifyMessage()
-
isTurnoutCmdMessage
public boolean isTurnoutCmdMessage()
-
isTurnoutAddMessage
public boolean isTurnoutAddMessage()
-
isTurnoutAddDCCMessage
public boolean isTurnoutAddDCCMessage()
-
isTurnoutAddServoMessage
public boolean isTurnoutAddServoMessage()
-
isTurnoutAddVpinMessage
public boolean isTurnoutAddVpinMessage()
-
isTurnoutDeleteMessage
public boolean isTurnoutDeleteMessage()
-
isListTurnoutsMessage
public boolean isListTurnoutsMessage()
-
isSensorAddMessage
public boolean isSensorAddMessage()
-
isSensorDeleteMessage
public boolean isSensorDeleteMessage()
-
isListSensorsMessage
public boolean isListSensorsMessage()
-
isOutputCmdMessage
public boolean isOutputCmdMessage()
-
isOutputAddMessage
public boolean isOutputAddMessage()
-
isOutputDeleteMessage
public boolean isOutputDeleteMessage()
-
isListOutputsMessage
public boolean isListOutputsMessage()
-
isQuerySensorStatesMessage
public boolean isQuerySensorStatesMessage()
-
isWriteDccPacketMessage
public boolean isWriteDccPacketMessage()
-
isTurnoutIDsMessage
public boolean isTurnoutIDsMessage()
-
isTurnoutIDMessage
public boolean isTurnoutIDMessage()
-
isClockRequestTimeMessage
public boolean isClockRequestTimeMessage()
-
isClockSetTimeMessage
public boolean isClockSetTimeMessage()
-
isTrackManagerRequestMessage
public boolean isTrackManagerRequestMessage()
-
isTurnoutImplementationMessage
public boolean isTurnoutImplementationMessage()
-
getOutputIDString
public java.lang.String getOutputIDString()
-
getOutputIDInt
public int getOutputIDInt()
-
getOutputPinString
public java.lang.String getOutputPinString()
-
getOutputPinInt
public int getOutputPinInt()
-
getOutputIFlagString
public java.lang.String getOutputIFlagString()
-
getOutputIFlagInt
public int getOutputIFlagInt()
-
getOutputStateString
public java.lang.String getOutputStateString()
-
getOutputStateInt
public int getOutputStateInt()
-
getOutputStateBool
public boolean getOutputStateBool()
-
getSensorIDString
public java.lang.String getSensorIDString()
-
getSensorIDInt
public int getSensorIDInt()
-
getSensorPinString
public java.lang.String getSensorPinString()
-
getSensorPinInt
public int getSensorPinInt()
-
getSensorPullupString
public java.lang.String getSensorPullupString()
-
getSensorPullupInt
public int getSensorPullupInt()
-
getSensorPullupBool
public boolean getSensorPullupBool()
-
getAccessoryAddrString
public java.lang.String getAccessoryAddrString()
-
getAccessoryAddrInt
public int getAccessoryAddrInt()
-
getAccessorySubString
public java.lang.String getAccessorySubString()
-
getAccessorySubInt
public int getAccessorySubInt()
-
getAccessoryStateString
public java.lang.String getAccessoryStateString()
-
getAccessoryStateInt
public int getAccessoryStateInt()
-
getRegisterString
public java.lang.String getRegisterString()
-
getRegisterInt
public int getRegisterInt()
-
getAddressString
public java.lang.String getAddressString()
-
getAddressInt
public int getAddressInt()
-
getSpeedString
public java.lang.String getSpeedString()
-
getSpeedInt
public int getSpeedInt()
-
getDirectionString
public java.lang.String getDirectionString()
-
getDirectionInt
public int getDirectionInt()
-
getFuncAddressString
public java.lang.String getFuncAddressString()
-
getFuncAddressInt
public int getFuncAddressInt()
-
getFuncByte1String
public java.lang.String getFuncByte1String()
-
getFuncByte1Int
public int getFuncByte1Int()
-
getFuncByte2String
public java.lang.String getFuncByte2String()
-
getFuncByte2Int
public int getFuncByte2Int()
-
getFuncV4CabString
public java.lang.String getFuncV4CabString()
-
getFuncV4FuncString
public java.lang.String getFuncV4FuncString()
-
getFuncV4StateString
public java.lang.String getFuncV4StateString()
-
getForgetCabString
public java.lang.String getForgetCabString()
-
getTOIDString
public java.lang.String getTOIDString()
-
getTOIDInt
public int getTOIDInt()
-
getTOStateString
public java.lang.String getTOStateString()
-
getTOStateInt
public int getTOStateInt()
-
getTOAddressString
public java.lang.String getTOAddressString()
-
getTOAddressInt
public int getTOAddressInt()
-
getTOSubAddressString
public java.lang.String getTOSubAddressString()
-
getTOSubAddressInt
public int getTOSubAddressInt()
-
getTOThrownPositionInt
public int getTOThrownPositionInt()
-
getTOClosedPositionInt
public int getTOClosedPositionInt()
-
getTOProfileInt
public int getTOProfileInt()
-
getTOPinInt
public int getTOPinInt()
-
getClockMinutesString
public java.lang.String getClockMinutesString()
-
getClockMinutesInt
public int getClockMinutesInt()
-
getClockRateString
public java.lang.String getClockRateString()
-
getClockRateInt
public int getClockRateInt()
-
getOpsWriteAddrString
public java.lang.String getOpsWriteAddrString()
-
getOpsWriteAddrInt
public int getOpsWriteAddrInt()
-
getOpsWriteCVString
public java.lang.String getOpsWriteCVString()
-
getOpsWriteCVInt
public int getOpsWriteCVInt()
-
getOpsWriteBitString
public java.lang.String getOpsWriteBitString()
-
getOpsWriteBitInt
public int getOpsWriteBitInt()
-
getOpsWriteValueString
public java.lang.String getOpsWriteValueString()
-
getOpsWriteValueInt
public int getOpsWriteValueInt()
-
getCVString
public java.lang.String getCVString()
-
getCVInt
public int getCVInt()
-
getCallbackNumString
public java.lang.String getCallbackNumString()
-
getCallbackNumInt
public int getCallbackNumInt()
-
getCallbackSubString
public java.lang.String getCallbackSubString()
-
getCallbackSubInt
public int getCallbackSubInt()
-
getProgValueString
public java.lang.String getProgValueString()
-
getProgValueInt
public int getProgValueInt()
-
getBitString
public java.lang.String getBitString()
-
getBitInt
public int getBitInt()
-
getPacketString
public java.lang.String getPacketString()
-
replyExpected
public boolean replyExpected()
Description copied from class:AbstractMRMessage
Is a reply expected to this message?By default, a reply is expected to every message; either a reply or a timeout is needed before the next message can be sent.
If this returns false, the transmit queue will immediately go on to transmit the next message (if any).
- Overrides:
replyExpected
in classAbstractMRMessage
- Returns:
- true by default in Abstract MR message.
-
makeAccessoryDecoderMsg
public static DCCppMessage makeAccessoryDecoderMsg(int address, int subaddress, boolean activate)
Stationary Decoder Message.Note that many decoders and controllers combine the ADDRESS and SUBADDRESS into a single number, N, from 1 through a max of 2044, where
N = (ADDRESS - 1) * 4 + SUBADDRESS + 1, for all ADDRESS>0
OR
ADDRESS = INT((N - 1) / 4) + 1
SUBADDRESS = (N - 1) % 4
- Parameters:
address
- the primary address of the decoder (0-511).subaddress
- the subaddress of the decoder (0-3).activate
- true on, false off.- Returns:
- accessory decoder message.
-
makeAccessoryDecoderMsg
public static DCCppMessage makeAccessoryDecoderMsg(int address, boolean activate)
-
makeTurnoutCommandMsg
public static DCCppMessage makeTurnoutCommandMsg(int id, boolean thrown)
Predefined Turnout Control Message.- Parameters:
id
- the numeric ID (0-32767) of the turnout to control.thrown
- true thrown, false closed.- Returns:
- message to set turnout.
-
makeOutputCmdMsg
public static DCCppMessage makeOutputCmdMsg(int id, boolean state)
-
makeOutputAddMsg
public static DCCppMessage makeOutputAddMsg(int id, int pin, int iflag)
-
makeOutputDeleteMsg
public static DCCppMessage makeOutputDeleteMsg(int id)
-
makeOutputListMsg
public static DCCppMessage makeOutputListMsg()
-
makeTurnoutAddMsg
public static DCCppMessage makeTurnoutAddMsg(int id, int addr, int subaddr)
-
makeTurnoutDeleteMsg
public static DCCppMessage makeTurnoutDeleteMsg(int id)
-
makeTurnoutListMsg
public static DCCppMessage makeTurnoutListMsg()
-
makeTurnoutIDsMsg
public static DCCppMessage makeTurnoutIDsMsg()
-
makeTurnoutIDMsg
public static DCCppMessage makeTurnoutIDMsg(int id)
-
makeTurnoutImplMsg
public static DCCppMessage makeTurnoutImplMsg(int id)
-
makeClockRequestTimeMsg
public static DCCppMessage makeClockRequestTimeMsg()
-
makeClockSetMsg
public static DCCppMessage makeClockSetMsg(int minutes, int rate)
-
makeClockSetMsg
public static DCCppMessage makeClockSetMsg(int minutes)
-
makeTrackManagerRequestMsg
public static DCCppMessage makeTrackManagerRequestMsg()
-
makeMessage
public static DCCppMessage makeMessage(java.lang.String msg)
-
makeSensorAddMsg
public static DCCppMessage makeSensorAddMsg(int id, int pin, int pullup)
Create/Delete/Query Sensor.sensor, or
<X>
if no sensors defined.- Parameters:
id
- pin pullup (0-32767).pin
- Arduino pin index of sensor.pullup
- true if use internal pullup for PIN, false if not.- Returns:
- message to create the sensor.
-
makeSensorDeleteMsg
public static DCCppMessage makeSensorDeleteMsg(int id)
-
makeSensorListMsg
public static DCCppMessage makeSensorListMsg()
-
makeQuerySensorStatesMsg
public static DCCppMessage makeQuerySensorStatesMsg()
Query All Sensors States.- Returns:
- message to query all sensor states.
-
makeWriteDirectCVMsg
public static DCCppMessage makeWriteDirectCVMsg(int cv, int val)
Write Direct CV Byte to Programming TrackFormat:
<W CV VALUE CALLBACKNUM CALLBACKSUB>
CV: the number of the Configuration Variable memory location in the decoder to write to (1-1024) VALUE: the value to be written to the Configuration Variable memory location (0-255) CALLBACKNUM: an arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs that call this function CALLBACKSUB: a second arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs (e.g. DCC++ Interface) that call this function
Note: The two-argument form embeds the opcode in CALLBACKSUB to aid in decoding the responses.
returns:
<r CALLBACKNUM|CALLBACKSUB|CV Value)
where VALUE is a number from 0-255 as read from the requested CV, or -1 if verification read fails- Parameters:
cv
- CV index, 1-1024.val
- new CV value, 0-255.- Returns:
- message to write Direct CV.
-
makeWriteDirectCVMsg
public static DCCppMessage makeWriteDirectCVMsg(int cv, int val, int callbacknum, int callbacksub)
-
makeWriteDirectCVMsgV4
public static DCCppMessage makeWriteDirectCVMsgV4(int cv, int val)
-
makeBitWriteDirectCVMsg
public static DCCppMessage makeBitWriteDirectCVMsg(int cv, int bit, int val)
Write Direct CV Bit to Programming Track.Format:
<B CV BIT VALUE CALLBACKNUM CALLBACKSUB>
writes, and then verifies, a single bit within a Configuration Variable to the decoder of an engine on the programming track
CV: the number of the Configuration Variable memory location in the decoder to write to (1-1024) BIT: the bit number of the Configurarion Variable memory location to write (0-7) VALUE: the value of the bit to be written (0-1) CALLBACKNUM: an arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs that call this function CALLBACKSUB: a second arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs (e.g. DCC++ Interface) that call this function
Note: The two-argument form embeds the opcode in CALLBACKSUB to aid in decoding the responses.
returns:
<r CALLBACKNUM|CALLBACKSUB|CV BIT VALUE)
where VALUE is a number from 0-1 as read from the requested CV bit, or -1 if verification read fails- Parameters:
cv
- CV index, 1-1024.bit
- bit index, 0-7val
- bit value, 0-1.- Returns:
- message to write direct CV bit.
-
makeBitWriteDirectCVMsg
public static DCCppMessage makeBitWriteDirectCVMsg(int cv, int bit, int val, int callbacknum, int callbacksub)
-
makeBitWriteDirectCVMsgV4
public static DCCppMessage makeBitWriteDirectCVMsgV4(int cv, int bit, int val)
-
makeReadDirectCVMsg
public static DCCppMessage makeReadDirectCVMsg(int cv)
Read Direct CV Byte from Programming Track.Format:
<R CV CALLBACKNUM CALLBACKSUB>
reads a Configuration Variable from the decoder of an engine on the programming track
CV: the number of the Configuration Variable memory location in the decoder to read from (1-1024) CALLBACKNUM: an arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs that call this function CALLBACKSUB: a second arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs (e.g. DCC++ Interface) that call this function
Note: The two-argument form embeds the opcode in CALLBACKSUB to aid in decoding the responses.
returns:
<r CALLBACKNUM|CALLBACKSUB|CV VALUE>
where VALUE is a number from 0-255 as read from the requested CV, or -1 if read could not be verified- Parameters:
cv
- CV index.- Returns:
- message to send read direct CV.
-
makeReadDirectCVMsg
public static DCCppMessage makeReadDirectCVMsg(int cv, int callbacknum, int callbacksub)
-
makeVerifyCVMsg
public static DCCppMessage makeVerifyCVMsg(int cv, int startVal)
Verify Direct CV Byte from Programming Track.Format:
<V CV STARTVAL>
Verifies a Configuration Variable from the decoder of an engine on the programming track. Returns the current value of that CV. Used as faster replacement for 'R'eadCV command
CV: the number of the Configuration Variable memory location in the decoder to read from (1-1024) STARTVAL: a "guess" as to the current value of the CV. DCC-EX will try this value first, then read and return the current value if different
returns:
<v CV VALUE>
where VALUE is a number from 0-255 as read from the requested CV, -1 if read could not be performed- Parameters:
cv
- CV index.startVal
- "guess" as to current value- Returns:
- message to send verify direct CV.
-
makeWriteOpsModeCVMsg
@CheckForNull public static DCCppMessage makeWriteOpsModeCVMsg(int address, int cv, int val)
Write Direct CV Byte to Main TrackFormat:
<w CAB CV VALUE>
Writes, without any verification, a Configuration Variable to the decoder of an engine on the main operations track.
- Parameters:
address
- the short (1-127) or long (128-10293) address of the engine decoder.cv
- the number of the Configuration Variable memory location in the decoder to write to (1-1024).val
- the value to be written to the Configuration Variable memory location (0-255).- Returns:
- message to Write CV in Ops Mode.
-
makeBitWriteOpsModeCVMsg
public static DCCppMessage makeBitWriteOpsModeCVMsg(int address, int cv, int bit, int val)
Write Direct CV Bit to Main Track.Format:
<b CAB CV BIT VALUE>
writes, without any verification, a single bit within a Configuration Variable to the decoder of an engine on the main operations track
CAB: the short (1-127) or long (128-10293) address of the engine decoder CV: the number of the Configuration Variable memory location in the decoder to write to (1-1024) BIT: the bit number of the Configuration Variable register to write (0-7) VALUE: the value of the bit to be written (0-1)
returns: NONE
- Parameters:
address
- loco cab address.cv
- CV index, 1-1024.bit
- bit index, 0-7.val
- bit value, 0 or 1.- Returns:
- message to write direct CV bit to main track.
-
makeSetTrackPowerMsg
public static DCCppMessage makeSetTrackPowerMsg(boolean on)
Set Track Power ON or OFF.Format:
<1> (ON) or <0> (OFF)
- Parameters:
on
- true on, false off.- Returns:
- message to send track power on or off.
-
makeTrackPowerOnMsg
public static DCCppMessage makeTrackPowerOnMsg()
-
makeTrackPowerOffMsg
public static DCCppMessage makeTrackPowerOffMsg()
-
makeReadTrackCurrentMsg
public static DCCppMessage makeReadTrackCurrentMsg()
Read main operations track currentFormat:
<c>
reads current being drawn on main operations track- Returns:
- (for DCC-EX), 1 or more of
<c MeterName value C/V unit min max res warn>
where name and settings are used to define arbitrary meters on the DCC-EX side AND<a CURRENT>
where CURRENT = 0-1024, based on exponentially-smoothed weighting scheme
-
makeCSStatusMsg
public static DCCppMessage makeCSStatusMsg()
Read DCC++ Base Station StatusFormat:
<s>
returns status messages containing track power status, throttle status, turn-out status, and a version number NOTE: this is very useful as a first command for an interface to send to this sketch in order to verify connectivity and update any GUI to reflect actual throttle and turn-out settings
- Returns:
- series of status messages that can be read by an interface to determine status of DCC++ Base Station and important settings
-
makeCSMaxNumSlotsMsg
public static DCCppMessage makeCSMaxNumSlotsMsg()
Get number of supported slots for this DCC++ Base Station StatusFormat:
<N>
returns number of slots NOTE: this is not implemented in older versions which then do not return anything at all
- Returns:
- status message with to get number of slots.
-
makeFunctionV4Message
public static DCCppMessage makeFunctionV4Message(int cab, int func, boolean state)
Generate a function message using the V4 'F' syntax supported by DCC-EX- Parameters:
cab
- cab address to send function tofunc
- function number to setstate
- new state of function 0/1- Returns:
- function functionV4message
-
makeForgetCabMessage
public static DCCppMessage makeForgetCabMessage(int cab)
Generate a "Forget Cab" message '-'- Parameters:
cab
- cab address to send function to (or 0 for all)- Returns:
- forget message to be sent
-
makeAddressedEmergencyStop
public static DCCppMessage makeAddressedEmergencyStop(int register, int address)
Generate an emergency stop for the specified address.Note: This just sends a THROTTLE command with speed = -1
- Parameters:
register
- Register Number for the loco assigned address.address
- is the locomotive address.- Returns:
- message to send e stop to the specified address.
-
makeAddressedEmergencyStop
public static DCCppMessage makeAddressedEmergencyStop(int address)
Generate an emergency stop for the specified address.Note: This just sends a THROTTLE command with speed = -1
- Parameters:
address
- is the locomotive address.- Returns:
- message to send e stop to the specified address.
-
makeEmergencyStopAllMsg
public static DCCppMessage makeEmergencyStopAllMsg()
Generate an emergency stop for all locos in reminder table.- Returns:
- message to send e stop for all locos
-
makeSpeedAndDirectionMsg
public static DCCppMessage makeSpeedAndDirectionMsg(int register, int address, float speed, boolean isForward)
Generate a Speed and Direction Request message- Parameters:
register
- is the DCC++ base station register assigned.address
- is the locomotive addressspeed
- a normalized speed value (a floating point number between 0 and 1). A negative value indicates emergency stop.isForward
- true for forward, false for reverse. Format:<t REGISTER CAB SPEED DIRECTION>
sets the throttle for a given register/cab combination REGISTER: an internal register number, from 1 through MAX_MAIN_REGISTERS (inclusive), to store the DCC packet used to control this throttle setting CAB: the short (1-127) or long (128-10293) address of the engine decoder SPEED: throttle speed from 0-126, or -1 for emergency stop (resets SPEED to 0) DIRECTION: 1=forward, 0=reverse. Setting direction when speed=0 or speed=-1 only effects directionality of cab lighting for a stopped train- Returns:
<T REGISTER CAB SPEED DIRECTION>
-
makeSpeedAndDirectionMsg
public static DCCppMessage makeSpeedAndDirectionMsg(int address, float speed, boolean isForward)
Generate a Speed and Direction Request message- Parameters:
address
- is the locomotive addressspeed
- a normalized speed value (a floating point number between 0 and 1). A negative value indicates emergency stop.isForward
- true for forward, false for reverse. Format:<t CAB SPEED DIRECTION>
sets the throttle for a given register/cab combination CAB: the short (1-127) or long (128-10293) address of the engine decoder SPEED: throttle speed from 0-126, or -1 for emergency stop (resets SPEED to 0) DIRECTION: 1=forward, 0=reverse. Setting direction when speed=0 or speed=-1 only effects directionality of cab lighting for a stopped train- Returns:
<T CAB SPEED DIRECTION>
-
makeFunctionGroup1OpsMsg
public static DCCppMessage makeFunctionGroup1OpsMsg(int address, boolean f0, boolean f1, boolean f2, boolean f3, boolean f4)
Generate a Function Group One Operation Request message.- Parameters:
address
- is the locomotive addressf0
- is true if f0 is on, false if f0 is offf1
- is true if f1 is on, false if f1 is offf2
- is true if f2 is on, false if f2 is offf3
- is true if f3 is on, false if f3 is offf4
- is true if f4 is on, false if f4 is off- Returns:
- message to set function group 1.
-
makeFunctionGroup1SetMomMsg
public static DCCppMessage makeFunctionGroup1SetMomMsg(int address, boolean f0, boolean f1, boolean f2, boolean f3, boolean f4)
Generate a Function Group One Set Momentary Functions message.- Parameters:
address
- is the locomotive addressf0
- is true if f0 is momentaryf1
- is true if f1 is momentaryf2
- is true if f2 is momentaryf3
- is true if f3 is momentaryf4
- is true if f4 is momentary- Returns:
- message to set momentary function group 1.
-
makeFunctionGroup2OpsMsg
public static DCCppMessage makeFunctionGroup2OpsMsg(int address, boolean f5, boolean f6, boolean f7, boolean f8)
Generate a Function Group Two Operation Request message.- Parameters:
address
- is the locomotive addressf5
- is true if f5 is on, false if f5 is offf6
- is true if f6 is on, false if f6 is offf7
- is true if f7 is on, false if f7 is offf8
- is true if f8 is on, false if f8 is off- Returns:
- message to set function group 2.
-
makeFunctionGroup2SetMomMsg
public static DCCppMessage makeFunctionGroup2SetMomMsg(int address, boolean f5, boolean f6, boolean f7, boolean f8)
Generate a Function Group Two Set Momentary Functions message.- Parameters:
address
- is the locomotive addressf5
- is true if f5 is momentaryf6
- is true if f6 is momentaryf7
- is true if f7 is momentaryf8
- is true if f8 is momentary- Returns:
- message to set momentary function group 2.
-
makeFunctionGroup3OpsMsg
public static DCCppMessage makeFunctionGroup3OpsMsg(int address, boolean f9, boolean f10, boolean f11, boolean f12)
Generate a Function Group Three Operation Request message.- Parameters:
address
- is the locomotive addressf9
- is true if f9 is on, false if f9 is offf10
- is true if f10 is on, false if f10 is offf11
- is true if f11 is on, false if f11 is offf12
- is true if f12 is on, false if f12 is off- Returns:
- message to set function group 3.
-
makeFunctionGroup3SetMomMsg
public static DCCppMessage makeFunctionGroup3SetMomMsg(int address, boolean f9, boolean f10, boolean f11, boolean f12)
Generate a Function Group Three Set Momentary Functions message.- Parameters:
address
- is the locomotive addressf9
- is true if f9 is momentaryf10
- is true if f10 is momentaryf11
- is true if f11 is momentaryf12
- is true if f12 is momentary- Returns:
- message to set momentary function group 3.
-
makeFunctionGroup4OpsMsg
public static DCCppMessage makeFunctionGroup4OpsMsg(int address, boolean f13, boolean f14, boolean f15, boolean f16, boolean f17, boolean f18, boolean f19, boolean f20)
Generate a Function Group Four Operation Request message.- Parameters:
address
- is the locomotive addressf13
- is true if f13 is on, false if f13 is offf14
- is true if f14 is on, false if f14 is offf15
- is true if f15 is on, false if f15 is offf16
- is true if f18 is on, false if f16 is offf17
- is true if f17 is on, false if f17 is offf18
- is true if f18 is on, false if f18 is offf19
- is true if f19 is on, false if f19 is offf20
- is true if f20 is on, false if f20 is off- Returns:
- message to set function group 4.
-
makeFunctionGroup4SetMomMsg
public static DCCppMessage makeFunctionGroup4SetMomMsg(int address, boolean f13, boolean f14, boolean f15, boolean f16, boolean f17, boolean f18, boolean f19, boolean f20)
Generate a Function Group Four Set Momentary Function message.- Parameters:
address
- is the locomotive addressf13
- is true if f13 is Momentaryf14
- is true if f14 is Momentaryf15
- is true if f15 is Momentaryf16
- is true if f18 is Momentaryf17
- is true if f17 is Momentaryf18
- is true if f18 is Momentaryf19
- is true if f19 is Momentaryf20
- is true if f20 is Momentary- Returns:
- message to set momentary function group 4.
-
makeFunctionGroup5OpsMsg
public static DCCppMessage makeFunctionGroup5OpsMsg(int address, boolean f21, boolean f22, boolean f23, boolean f24, boolean f25, boolean f26, boolean f27, boolean f28)
Generate a Function Group Five Operation Request message.- Parameters:
address
- is the locomotive addressf21
- is true if f21 is on, false if f21 is offf22
- is true if f22 is on, false if f22 is offf23
- is true if f23 is on, false if f23 is offf24
- is true if f24 is on, false if f24 is offf25
- is true if f25 is on, false if f25 is offf26
- is true if f26 is on, false if f26 is offf27
- is true if f27 is on, false if f27 is offf28
- is true if f28 is on, false if f28 is off- Returns:
- message to set function group 5.
-
makeFunctionGroup5SetMomMsg
public static DCCppMessage makeFunctionGroup5SetMomMsg(int address, boolean f21, boolean f22, boolean f23, boolean f24, boolean f25, boolean f26, boolean f27, boolean f28)
Generate a Function Group Five Set Momentary Function message.- Parameters:
address
- is the locomotive addressf21
- is true if f21 is momentaryf22
- is true if f22 is momentaryf23
- is true if f23 is momentaryf24
- is true if f24 is momentaryf25
- is true if f25 is momentaryf26
- is true if f26 is momentaryf27
- is true if f27 is momentaryf28
- is true if f28 is momentary- Returns:
- message to set momentary function group 5.
-
makeWriteDCCPacketMainMsg
public static DCCppMessage makeWriteDCCPacketMainMsg(int register, int numBytes, byte[] bytes)
Write DCC Packet to a specified Register on the Main.
DCC++ BaseStation code appends its own error-correction byte so we must not provide one.- Parameters:
register
- the DCC++ BaseStation main register number to usenumBytes
- the number of bytes in the packetbytes
- byte array representing the packet. The firstnum_bytes
are used.- Returns:
- the formatted message to send
-
makeWriteDCCPacketProgMsg
public static DCCppMessage makeWriteDCCPacketProgMsg(int register, int numBytes, byte[] bytes)
Write DCC Packet to a specified Register on the Programming Track.
DCC++ BaseStation code appends its own error-correction byte so we must not provide one.- Parameters:
register
- the DCC++ BaseStation main register number to usenumBytes
- the number of bytes in the packetbytes
- byte array representing the packet. The firstnum_bytes
are used.- Returns:
- the formatted message to send
-
makeListRegisterContentsMsg
public static DCCppMessage makeListRegisterContentsMsg()
-
makeLCDRequestMsg
public static DCCppMessage makeLCDRequestMsg()
Request LCD Messages used for Virtual LCD DisplayFormat:
<@>
tells EX_CommandStation to send any LCD message updates to this instance of JMRI
- Returns:
- the formatted message to send
-
equals
public boolean equals(java.lang.Object obj)
This implementation of equals is targeted to the background function refreshing in SerialDCCppPacketizer. To keep only one function group in the refresh queue the logic is as follows. Two messages are equal if they are:- actually identical, or
- a function call to the same address and same function group
- Overrides:
equals
in classAbstractMessage
-
hashCode
public int hashCode()
Description copied from class:AbstractMessage
Hash code from base data.- Overrides:
hashCode
in classAbstractMessage
- Returns:
- hashcode from sum of elements.
-
delayFor
public void delayFor(long millis)
Before adding the message to the delay queue call this method to set when the message should be repeated. The only time guarantee is that it will be repeated after at least this much time, but it can be significantly longer until it is repeated, function of the message queue length.- Parameters:
millis
- milliseconds in the future
-
compareTo
public int compareTo(@Nonnull java.util.concurrent.Delayed o)
Comparing two queued message for refreshing the function calls, based on their expected execution time.- Specified by:
compareTo
in interfacejava.lang.Comparable<java.util.concurrent.Delayed>
-
getDelay
public long getDelay(java.util.concurrent.TimeUnit unit)
From theDelayed
interface, how long this message still has until it should be executed.- Specified by:
getDelay
in interfacejava.util.concurrent.Delayed
-
-