Package jmri.jmrix.roco.z21
Class Z21XNetMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.lenz.XNetMessage
-
- jmri.jmrix.roco.z21.Z21XNetMessage
-
- All Implemented Interfaces:
java.io.Serializable
,Message
public class Z21XNetMessage extends XNetMessage
Represents a single command or response on the XpressNet.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.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class jmri.jmrix.lenz.XNetMessage
XNetProgrammingTimeout
-
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description Z21XNetMessage(int len)
Constructor, just pass on to the superclass.Z21XNetMessage(java.lang.String s)
Create an XNetMessage from a String containing bytes.Z21XNetMessage(Z21Message m)
Constructor from a Z21Message.Z21XNetMessage(Z21XNetMessage message)
Create a new object, that is a copy of an existing message.Z21XNetMessage(Z21XNetReply message)
Create an Z21XNetMessage from an Z21XNetReply.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static XNetMessage
getZ21LanXSetLocoDriveMsg(int address, SpeedStepMode speedMode, float speed, boolean isForward)
Generate a Z21 message to change the speed/direction of a locomotive.static Z21XNetMessage
getZ21LocomotiveFunctionOperationMsg(int address, int functionno, boolean state)
Given a locomotive address, a function number, and its value, generate a message to change the state.static Z21XNetMessage
getZ21LocomotiveInfoRequestMsg(int address)
Given a locomotive address, request its status.static Z21XNetMessage
getZ21ReadDirectCVMsg(int cv)
Create messages of a particular form.static Z21XNetMessage
getZ21SetTurnoutRequestMessage(int address, boolean thrown, boolean active, boolean queue)
Given a turnout address and whether or not it is thrown, generate a message to operate the turnout.static Z21XNetMessage
getZ21TurnoutInfoRequestMessage(int address)
Given a turnout address, generate a message to request the state.static Z21XNetMessage
getZ21WriteDirectCVMsg(int cv, int val)
java.lang.String
toMonitorString()
Generate text translations of messages for use in the XpressNet monitor.-
Methods inherited from class jmri.jmrix.lenz.XNetMessage
checkParity, getAddLocoToConsistMsg, getAddressedEmergencyStop, getBitVerifyOpsModeCVMsg, getBitWriteOpsModeCVMsg, getBuildDoubleHeaderMsg, getCSAutoStartMessage, getCSStatusRequestMessage, getCSVersionRequestMessage, getDBSearchMsgConsistAddress, getDBSearchMsgNextMULoco, getDeleteAddressOnStackMsg, getDisolveDoubleHeaderMsg, getElementBCD, getEmergencyOffMsg, getEmergencyStopMsg, getExitProgModeMsg, getFeedbackRequestMsg, getFunctionGroup10OpsMsg, getFunctionGroup10SetMomMsg, getFunctionGroup1OpsMsg, getFunctionGroup1SetMomMsg, getFunctionGroup2OpsMsg, getFunctionGroup2SetMomMsg, getFunctionGroup3OpsMsg, getFunctionGroup3SetMomMsg, getFunctionGroup4OpsMsg, getFunctionGroup4SetMomMsg, getFunctionGroup5OpsMsg, getFunctionGroup5SetMomMsg, getFunctionGroup6OpsMsg, getFunctionGroup6SetMomMsg, getFunctionGroup7OpsMsg, getFunctionGroup7SetMomMsg, getFunctionGroup8OpsMsg, getFunctionGroup8SetMomMsg, getFunctionGroup9OpsMsg, getFunctionGroup9SetMomMsg, getLIAddressRequestMsg, getLISpeedRequestMsg, getLIVersionRequestMessage, getLocomotiveFunctionHighMomStatusMsg, getLocomotiveFunctionHighOnStatusMsg, getLocomotiveFunctionStatusMsg, getLocomotiveInfoRequestMsg, getNextAddressOnStackMsg, getNMRAXNetMsg, getOpCode, getOpCodeHex, getReadDirectCVMsg, getReadPagedCVMsg, getReadRegisterMsg, getRemoveLocoFromConsistMsg, getResumeOperationsMsg, getServiceModeResultsMsg, getSpeedAndDirectionMsg, getTurnoutCommandMsg, getVerifyOpsModeCVMsg, getWriteDirectCVMsg, getWriteOpsModeCVMsg, getWritePagedCVMsg, getWriteRegisterMsg, length, replyExpected, setBroadcastReply, setOpCode, setParity, setXNetMessageRetries, setXNetMessageTimeout
-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getRetries, getTimeout, isBinary, setBinary, setNeededMode, setRetries, setTimeout, toString
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElement
-
-
-
-
Constructor Detail
-
Z21XNetMessage
public Z21XNetMessage(int len)
Constructor, just pass on to the superclass.- Parameters:
len
- message length.
-
Z21XNetMessage
public Z21XNetMessage(Z21Message m)
Constructor from a Z21Message.- Parameters:
m
- the Z21Message.
-
Z21XNetMessage
public Z21XNetMessage(Z21XNetMessage message)
Create a new object, that is a copy of an existing message.- Parameters:
message
- an existing Z21XpressNet message
-
Z21XNetMessage
public Z21XNetMessage(Z21XNetReply message)
Create an Z21XNetMessage from an Z21XNetReply.- Parameters:
message
- the existing Z21XNetReply.
-
Z21XNetMessage
public Z21XNetMessage(java.lang.String s)
Create an XNetMessage from a String containing bytes.- Parameters:
s
- byte string.
-
-
Method Detail
-
toMonitorString
public java.lang.String toMonitorString()
Description copied from class:XNetMessage
Generate text translations of messages for use in the XpressNet monitor.- Specified by:
toMonitorString
in interfaceMessage
- Overrides:
toMonitorString
in classXNetMessage
- Returns:
- representation of the XNetMessage as a string.
-
getZ21ReadDirectCVMsg
public static Z21XNetMessage getZ21ReadDirectCVMsg(int cv)
Create messages of a particular form.- Parameters:
cv
- CV index- Returns:
- message to send.
-
getZ21WriteDirectCVMsg
public static Z21XNetMessage getZ21WriteDirectCVMsg(int cv, int val)
-
getZ21LocomotiveInfoRequestMsg
public static Z21XNetMessage getZ21LocomotiveInfoRequestMsg(int address)
Given a locomotive address, request its status.- Parameters:
address
- is the locomotive address- Returns:
- message to send.
-
getZ21LocomotiveFunctionOperationMsg
public static Z21XNetMessage getZ21LocomotiveFunctionOperationMsg(int address, int functionno, boolean state)
Given a locomotive address, a function number, and its value, generate a message to change the state.- Parameters:
address
- is the locomotive addressfunctionno
- is the function to changestate
- is boolean representing whether the function is to be on or off- Returns:
- message to send.
-
getZ21LanXSetLocoDriveMsg
public static XNetMessage getZ21LanXSetLocoDriveMsg(int address, SpeedStepMode speedMode, float speed, boolean isForward)
Generate a Z21 message to change the speed/direction of a locomotive.- Parameters:
address
- the locomotive addressspeedMode
- the speedstep mode see @jmri.DccThrottle for possible values.speed
- 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.- Returns:
- message to send.
-
getZ21TurnoutInfoRequestMessage
public static Z21XNetMessage getZ21TurnoutInfoRequestMessage(int address)
Given a turnout address, generate a message to request the state.- Parameters:
address
- the turnout address- Returns:
- message to send.
-
getZ21SetTurnoutRequestMessage
public static Z21XNetMessage getZ21SetTurnoutRequestMessage(int address, boolean thrown, boolean active, boolean queue)
Given a turnout address and whether or not it is thrown, generate a message to operate the turnout.- Parameters:
address
- is the turnout addressthrown
- boolean value representing whether the turnout is thrown.active
- boolean value representing whether the output is being set to active.queue
- boolean value representing whehter or not the message is added to the queue.- Returns:
- message to send.
-
-