Package jmri.jmrix.sprog
Class SprogReply
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRReply
-
- jmri.jmrix.sprog.SprogReply
-
- All Implemented Interfaces:
Message
public class SprogReply extends AbstractMRReply
Carries the reply to a SprogMessage.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_id
static int
maxSize
-
Fields inherited from class jmri.jmrix.AbstractMRReply
DEFAULTMAXSIZE
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description SprogReply()
SprogReply(java.lang.String replyString)
SprogReply(java.lang.String replyString, boolean isBoot)
Create a SprogReply from a String.SprogReply(SprogReply m)
Create a new SprogReply as a deep copy of an existing SprogReply.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
endBootReply()
Bootloader will end with ETX with no preceding DLE.boolean
endNormalReply()
Normal SPROG replies will end with the prompt for the next command.boolean
getChecksum()
Check and strip checksum from a SPROG bootloader reply.int
getId()
boolean
isError()
Is this reply indicating that a general error has occurred?boolean
isOverload()
Is this reply indicating that an overload condition was detected?int
match(java.lang.String s)
Find a specific string in the reply.void
setId(int id)
protected int
skipPrefix(int index)
boolean
strip()
Check and strip framing characters and DLE from a SPROG bootloader reply.java.lang.String
toString()
Return a string representation of this SprogReply.int
value()
Extract Read-CV returned value from a message.-
Methods inherited from class jmri.jmrix.AbstractMRReply
flush, getOpCode, isBinary, isRetransmittableErrorMsg, isUnsolicited, maxSize, pollValue, setBinary, setElement, setOpCode, setUnsolicited, skipWhiteSpace
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.Message
toMonitorString
-
-
-
-
Field Detail
-
maxSize
public static final int maxSize
- See Also:
- Constant Field Values
-
_id
protected int _id
-
-
Constructor Detail
-
SprogReply
public SprogReply()
-
SprogReply
public SprogReply(SprogReply m)
Create a new SprogReply as a deep copy of an existing SprogReply.- Parameters:
m
- the SprogReply to copy
-
SprogReply
public SprogReply(java.lang.String replyString, boolean isBoot)
Create a SprogReply from a String.- Parameters:
replyString
- a String containing the contents of the replyisBoot
- a boolean indicating if this is a boot reply
-
SprogReply
public SprogReply(java.lang.String replyString)
-
-
Method Detail
-
setId
public void setId(int id)
-
getId
public int getId()
-
skipPrefix
protected int skipPrefix(int index)
- Specified by:
skipPrefix
in classAbstractMRReply
-
isOverload
public boolean isOverload()
Is this reply indicating that an overload condition was detected?- Returns:
- boolean true for overload
-
isError
public boolean isError()
Is this reply indicating that a general error has occurred?- Returns:
- boolean true for error message
-
strip
public boolean strip()
Check and strip framing characters and DLE from a SPROG bootloader reply.- Returns:
- boolean result of message validation
-
getChecksum
public boolean getChecksum()
Check and strip checksum from a SPROG bootloader reply.Assumes framing and DLE chars have been stripped
- Returns:
- boolean result of checksum validation
-
toString
public java.lang.String toString()
Return a string representation of this SprogReply.- Specified by:
toString
in interfaceMessage
- Overrides:
toString
in classAbstractMRReply
- Returns:
- String The string representation
-
value
public int value()
Extract Read-CV returned value from a message.SPROG is assumed to not be echoing commands. A reply to a command may include the prompt that was printed after the previous command.
Reply to a CV read is of the form " = hvv" where vv is the CV value in hex
- Overrides:
value
in classAbstractMRReply
- Returns:
- -1 if message can't be parsed
-
match
public int match(java.lang.String s)
Find a specific string in the reply.- Overrides:
match
in classAbstractMRReply
- Parameters:
s
- string to look for- Returns:
- index of String s in the reply
-
endNormalReply
public boolean endNormalReply()
Normal SPROG replies will end with the prompt for the next command.- Returns:
- true if end of normal reply is found
-
endBootReply
public boolean endBootReply()
Bootloader will end with ETX with no preceding DLE.- Returns:
- true if end of bootloader reply is found
-
-