Class DCCppMessage
- All Implemented Interfaces:
Comparable<Delayed>
,Delayed
,Message
public class DCCppMessage extends AbstractMRMessage implements Delayed
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
-
Constructor Summary
Constructors Modifier Constructor Description protected
DCCppMessage(char c)
protected
DCCppMessage(char c, String regex)
DCCppMessage(int len)
Create a new object, representing a specific-length message.DCCppMessage(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
Modifier and Type Method Description int
compareTo(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(Object obj)
This implementation of equals is targeted to the background function refreshing in SerialDCCppPacketizer.int
getAccessoryAddrInt()
String
getAccessoryAddrString()
int
getAccessoryStateInt()
String
getAccessoryStateString()
int
getAccessorySubInt()
String
getAccessorySubString()
int
getAddressInt()
String
getAddressString()
int
getBitInt()
String
getBitString()
int
getCallbackNumInt()
String
getCallbackNumString()
int
getCallbackSubInt()
String
getCallbackSubString()
int
getCVInt()
String
getCVString()
long
getDelay(TimeUnit unit)
From theDelayed
interface, how long this message still has until it should be executed.int
getDirectionInt()
String
getDirectionString()
int
getElement(int n)
Get a particular element in a Message.int
getFuncAddressInt()
String
getFuncAddressString()
int
getFuncByte1Int()
String
getFuncByte1String()
int
getFuncByte2Int()
String
getFuncByte2String()
int
getNumDataElements()
Get the number of data elements in a Message.int
getOpCode()
char
getOpCodeChar()
String
getOpCodeString()
Deprecated.int
getOpsWriteAddrInt()
String
getOpsWriteAddrString()
int
getOpsWriteBitInt()
String
getOpsWriteBitString()
int
getOpsWriteCVInt()
String
getOpsWriteCVString()
int
getOpsWriteValueInt()
String
getOpsWriteValueString()
int
getOutputIDInt()
String
getOutputIDString()
int
getOutputIFlagInt()
String
getOutputIFlagString()
int
getOutputPinInt()
String
getOutputPinString()
boolean
getOutputStateBool()
int
getOutputStateInt()
String
getOutputStateString()
String
getPacketString()
int
getProgValueInt()
String
getProgValueString()
int
getRegisterInt()
String
getRegisterString()
int
getSensorIDInt()
String
getSensorIDString()
int
getSensorPinInt()
String
getSensorPinString()
boolean
getSensorPullupBool()
int
getSensorPullupInt()
String
getSensorPullupString()
int
getSpeedInt()
String
getSpeedString()
int
getTOAddressInt()
String
getTOAddressString()
int
getTOIDInt()
String
getTOIDString()
int
getTOStateInt()
String
getTOStateString()
int
getTOSubAddressInt()
String
getTOSubAddressString()
boolean
getValueBool(int idx)
int
getValueInt(int idx)
String
getValueString(int idx)
int
hashCode()
Hash code from base data.boolean
isAccessoryMessage()
boolean
isEEPROMClearMessage()
boolean
isEEPROMWriteMessage()
boolean
isFunctionMessage()
boolean
isListOutputsMessage()
boolean
isListSensorsMessage()
boolean
isListTurnoutsMessage()
boolean
isOpsWriteBitMessage()
boolean
isOpsWriteByteMessage()
boolean
isOutputAddMessage()
boolean
isOutputCmdMessage()
boolean
isOutputDeleteMessage()
boolean
isProgReadMessage()
boolean
isProgWriteBitMessage()
boolean
isProgWriteByteMessage()
boolean
isQuerySensorStatesMessage()
boolean
isSensorAddMessage()
boolean
isSensorDeleteMessage()
boolean
isSensorMessage()
boolean
isThrottleMessage()
boolean
isTurnoutAddMessage()
boolean
isTurnoutCmdMessage()
boolean
isTurnoutDeleteMessage()
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 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
makeBitWriteOpsModeCVMsg(int address, int cv, int bit, int val)
Write Direct CV Bit to Main Track.static DCCppMessage
makeCSMaxNumSlotsMsg()
Get number of supported slots for this DCC++ Base Station Statusstatic DCCppMessage
makeCSStatusMsg()
Read DCC++ Base Station Statusstatic 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
makeListRegisterContentsMsg()
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 register, int address, float speed, boolean isForward)
Generate a Speed and Direction Request messagestatic 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
makeTurnoutListMsg()
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
makeWriteOpsModeCVMsg(int address, int cv, int val)
Write Direct CV Byte to Main Trackstatic DCCppMessage
parseDCCppMessage(String s)
Parse a string and generate/return a DCCppMessage object.boolean
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)
String
toMonitorString()
Generate text translations of messages for use in the DCCpp monitor.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 Details
-
DCCppProgrammingTimeout
- See Also:
- Constant Field Values
-
-
Constructor Details
-
DCCppMessage
Create a new object, representing a specific-length message.- Parameters:
len
- Total bytes in message, including opcode and error-detection byte.
-
DCCppMessage
Create a new object, that is a copy of an existing message.- Parameters:
message
- existing message.
-
DCCppMessage
Create an DCCppMessage from an DCCppReply. Not used. Really, not even possible. Consider removing.- Parameters:
message
- existing reply to replicate.
-
DCCppMessage
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
-
DCCppMessage
-
-
Method Details
-
parseDCCppMessage
Parse a string and generate/return a DCCppMessage object.- Parameters:
s
- String of DCC++ message without the < > brackets- Returns:
- DCCppMessage
-
toString
Converts DCCppMessage to String format (without the<>
brackets)- Specified by:
toString
in interfaceMessage
- Overrides:
toString
in classAbstractMRMessage
- Returns:
- String form of message.
-
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
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
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
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
- Overrides:
setOpCode
in classAbstractMRMessage
-
getOpCode
- Overrides:
getOpCode
in classAbstractMRMessage
-
getOpCodeChar
-
getOpCodeString
Deprecated. -
getValueString
-
getValueInt
-
getValueBool
-
length
- Returns:
- the message length
-
setDCCppMessageRetries
Change the default number of retries for an DCC++ message.- Parameters:
t
- number of retries to attempt
-
setDCCppMessageTimeout
Change the default timeout for a DCC++ message.- Parameters:
t
- Timeout in milliseconds
-
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
-
isAccessoryMessage
-
isFunctionMessage
-
isTurnoutMessage
-
isSensorMessage
-
isEEPROMWriteMessage
-
isEEPROMClearMessage
-
isOpsWriteByteMessage
-
isOpsWriteBitMessage
-
isProgWriteByteMessage
-
isProgWriteBitMessage
-
isProgReadMessage
-
isTurnoutCmdMessage
-
isTurnoutAddMessage
-
isTurnoutDeleteMessage
-
isListTurnoutsMessage
-
isSensorAddMessage
-
isSensorDeleteMessage
-
isListSensorsMessage
-
isOutputCmdMessage
-
isOutputAddMessage
-
isOutputDeleteMessage
-
isListOutputsMessage
-
isQuerySensorStatesMessage
-
isWriteDccPacketMessage
-
getOutputIDString
-
getOutputIDInt
-
getOutputPinString
-
getOutputPinInt
-
getOutputIFlagString
-
getOutputIFlagInt
-
getOutputStateString
-
getOutputStateInt
-
getOutputStateBool
-
getSensorIDString
-
getSensorIDInt
-
getSensorPinString
-
getSensorPinInt
-
getSensorPullupString
-
getSensorPullupInt
-
getSensorPullupBool
-
getAccessoryAddrString
-
getAccessoryAddrInt
-
getAccessorySubString
-
getAccessorySubInt
-
getAccessoryStateString
-
getAccessoryStateInt
-
getRegisterString
-
getRegisterInt
-
getAddressString
-
getAddressInt
-
getSpeedString
-
getSpeedInt
-
getDirectionString
-
getDirectionInt
-
getFuncAddressString
-
getFuncAddressInt
-
getFuncByte1String
-
getFuncByte1Int
-
getFuncByte2String
-
getFuncByte2Int
-
getTOIDString
-
getTOIDInt
-
getTOStateString
-
getTOStateInt
-
getTOAddressString
-
getTOAddressInt
-
getTOSubAddressString
-
getTOSubAddressInt
-
getOpsWriteAddrString
-
getOpsWriteAddrInt
-
getOpsWriteCVString
-
getOpsWriteCVInt
-
getOpsWriteBitString
-
getOpsWriteBitInt
-
getOpsWriteValueString
-
getOpsWriteValueInt
-
getCVString
-
getCVInt
-
getCallbackNumString
-
getCallbackNumInt
-
getCallbackSubString
-
getCallbackSubInt
-
getProgValueString
-
getProgValueInt
-
getBitString
-
getBitInt
-
getPacketString
-
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
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
-
makeTurnoutCommandMsg
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
-
makeOutputAddMsg
-
makeOutputDeleteMsg
-
makeOutputListMsg
-
makeTurnoutAddMsg
-
makeTurnoutDeleteMsg
-
makeTurnoutListMsg
-
makeSensorAddMsg
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
-
makeSensorListMsg
-
makeQuerySensorStatesMsg
Query All Sensors States.- Returns:
- message to query all sensor states.
-
makeWriteDirectCVMsg
Write Direct CV Byte to Programming TrackFormat:
<W CV VALUE CALLBACKNUM CALLBACKSUB>
ID: the numeric ID (0-32767) of the turnout to control THROW: 0 (unthrown) or 1 (thrown) 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 verificaiton read fails- Parameters:
cv
- CV index, 1-1024.val
- new CV value, 0-255.- Returns:
- message to write Direct CV.
-
makeWriteDirectCVMsg
-
makeBitWriteDirectCVMsg
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 verificaiton read fails- Parameters:
cv
- CV index, 1-1024.bit
- bit index, 0-7val
- bit value, 0-1.- Returns:
- message to write driect CV bit.
-
makeBitWriteDirectCVMsg
public static DCCppMessage makeBitWriteDirectCVMsg(int cv, int bit, int val, int callbacknum, int callbacksub) -
makeReadDirectCVMsg
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
-
makeWriteOpsModeCVMsg
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
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
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
-
makeTrackPowerOffMsg
-
makeReadTrackCurrentMsg
Read main operations track currentFormat:
<c>
reads current being drawn on main operations track
- Returns:
<a CURRENT>
where CURRENT = 0-1024, based on exponentially-smoothed weighting scheme
-
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
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.
-
makeAddressedEmergencyStop
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.
-
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 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
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
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
-
equals
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
Description copied from class:AbstractMessage
Hash code from base data.- Overrides:
hashCode
in classAbstractMessage
- Returns:
- hashcode from sum of elements.
-
delayFor
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
Comparing two queued message for refreshing the function calls, based on their expected execution time.- Specified by:
compareTo
in interfaceComparable<Delayed>
-
getDelay
From theDelayed
interface, how long this message still has until it should be executed.
-