Package jmri.jmrix.loconet.lnsvf2
Class Lnsv2MessageContents
java.lang.Object
jmri.jmrix.loconet.lnsvf2.Lnsv2MessageContents
Supporting class for LocoNet SV Programming Format 2 messaging.
Some of the message formats used in this class are Copyright Digitrax, Inc.
and used with permission as part of the JMRI project. That permission does
not extend to uses in other software products. If you wish to use this code,
algorithm or these message formats outside of JMRI, please contact Digitrax
Inc for separate permission.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new Lnsv2MessageContents object from a LocoNet message. -
Method Summary
Modifier and TypeMethodDescriptionstatic LocoNetMessagecreateSv2ChangeAddressReply(int ida, int destAddr) Create a LocoNet message for the reply for an SV2 "Change Address" message where the device requires a reconfigure.static LocoNetMessagecreateSv2ChangeAddressReply(int ida, int newDestAddr, int mfg, int developer, int productId, int serialNum) Create a LocoNet message for the reply for an SV2 "Change Address" message where the device requires a reconfigure.static LocoNetMessagecreateSv2DeviceDiscoveryReply(int ida, int currentDest, int mfg, int devel, int prodID, int serial) static LocoNetMessagecreateSv2Message(int source, int command, int destination, int svNum, int d1, int d2, int d3, int d4) Create a LocoNet message containing an SV Programming Format 2 message.static LocoNetMessagecreateSv2ReconfigureReply(int ida, int newDestAddr, int mfg, int developer, int productId, int serialNum) Create a LocoNet message for the reply for an SV2 "Reconfigure Reply"static LocoNetMessagestatic LocoNetMessagecreateSvReadReply(LocoNetMessage m, int svValue) static LocoNetMessagecreateSvReadReply(LocoNetMessage m, int[] svValues) static LocoNetMessagestatic LocoNetMessagecreateSvReadRequest(int deviceAddress, int svNum) Create LocoNet message for another query of an SV of this object.Interpret a LocoNet message to determine its SV Programming Format 2 <SV_CMD>.intintGet the data from a SVs Single Read Reply message.intgetSv2D1()Get the d1 valueintgetSv2D2()Get the d2 valueintgetSv2D3()Get the d3 valueintgetSv2D4()Get the d4 valueintintintintintgetSvNum()static booleanCompare reply message against a specific SV Programming Format 2 message type.booleanConfirm a message specifies a valid (known) SV Programming Format 2 command.static booleanisSupportedSv2Command(int possibleCmd) static booleanCheck a LocoNet message to determine if it is a valid SV Programming Format 2 message.booleanbooleanbooleanbooleanbooleantoString()Interpret the SV Programming Format 2 message into a human-readable string.Interpret the SV Programming Format 2 message into a human-readable string.
-
Field Details
-
SV2_LENGTH_ELEMENT_VALUE
- See Also:
-
SV2_LENGTH_ELEMENT_INDEX
- See Also:
-
SV2_SRC_ELEMENT_INDEX
- See Also:
-
SV2_SV_CMD_ELEMENT_INDEX
- See Also:
-
SV2_SV_TYPE_ELEMENT_INDEX
- See Also:
-
SV2_SVX1_ELEMENT_INDEX
- See Also:
-
SV2_SV_DST_L_ELEMENT_INDEX
- See Also:
-
SV2_SV_DST_H_ELEMENT_INDEX
- See Also:
-
SV2_SV_ADRL_ELEMENT_INDEX
- See Also:
-
SV2_SV_ADRH_ELEMENT_INDEX
- See Also:
-
SV2_SVX2_ELEMENT_INDEX
- See Also:
-
SV2_SVD1_ELEMENT_INDEX
- See Also:
-
SV2_SVD2_ELEMENT_INDEX
- See Also:
-
SV2_SVD3_ELEMENT_INDEX
- See Also:
-
SV2_SVD4_ELEMENT_INDEX
- See Also:
-
SV2_SRC_ELEMENT_MASK
- See Also:
-
SV2_SVX1_ELEMENT_VALIDITY_CHECK_MASK
- See Also:
-
SV2_SVX1_ELEMENT_VALIDITY_CHECK_VALUE
- See Also:
-
SV2_SV_DST_L_DSTLX7_CHECK_MASK
- See Also:
-
SV2_SV_DST_H_DSTHX7_CHECK_MASK
- See Also:
-
SV2_SV_ADRL_SVADRL7_CHECK_MASK
- See Also:
-
SV2_SV_ADRH_SVADRH7_CHECK_MASK
- See Also:
-
SV2_SVX2_ELEMENT_VALIDITY_CHECK_MASK
- See Also:
-
SV2_SVX2_ELEMENT_VALIDITY_CHECK_VALUE
- See Also:
-
SV2_SV_D1_D1X7_CHECK_MASK
- See Also:
-
SV2_SV_D2_D2X7_CHECK_MASK
- See Also:
-
SV2_SV_D3_D3X7_CHECK_MASK
- See Also:
-
SV2_SV_D4_D4X7_CHECK_MASK
- See Also:
-
SV2_SV_TYPE_ELEMENT_VALIDITY_CHECK_MASK
- See Also:
-
SV2_SV_TYPE_ELEMENT_VALIDITY_CHECK_VALUE
- See Also:
-
SV_CMD_WRITE_ONE
- See Also:
-
SV_CMD_WRITE_ONE_REPLY
- See Also:
-
SV_CMD_QUERY_ONE
- See Also:
-
SV_CMD_REPORT_ONE
- See Also:
-
SV_CMD_WRITE_ONE_MASKED
- See Also:
-
SV_CMD_WRITE_ONE_MASKED_REPLY
- See Also:
-
SV_CMD_WRITE_FOUR
- See Also:
-
SV_CMD_WRITE_FOUR_REPLY
- See Also:
-
SV_CMD_QUERY_FOUR
- See Also:
-
SV_CMD_REPORT_FOUR
- See Also:
-
SV_CMD_DISCOVER_DEVICES_QUERY
- See Also:
-
SV_CMD_DISCOVER_DEVICE_REPORT
- See Also:
-
SV_CMD_IDENTIFY_DEVICE_BY_DEVICE_ADDRESS
- See Also:
-
SV_CMD_IDENTIFY_DEVICE_BY_DEVICE_ADDRESS_REPLY
- See Also:
-
SV_CMD_CHANGE_ADDRESS_REQUEST
- See Also:
-
SV_CMD_CHANGE_ADDRESS_REPLY
- See Also:
-
SV_CMD_RECONFIGURE_REQUEST
- See Also:
-
SV_CMD_RECONFIGURE_REPLY
- See Also:
-
SV2_SV_CMD_REPLY_BIT_NUMBER
- See Also:
-
SV2_SV_CMD_REPLY_BIT_MASK
- See Also:
-
SV2_SV_DATA_INDEX_EEPROM_SIZE
- See Also:
-
SV2_SV_DATA_INDEX_SOFTWARE_VERSION
- See Also:
-
SV2_SV_DATA_INDEX_SERIAL_NUMBER_LOW
- See Also:
-
SV2_SV_DATA_INDEX_SERIAL_NUMBER_HIGH
- See Also:
-
-
Constructor Details
-
Lnsv2MessageContents
Create a new Lnsv2MessageContents object from a LocoNet message.- Parameters:
m- LocoNet message containing an SV Programming Format 2 message- Throws:
IllegalArgumentException- if the LocoNet message is not a valid, supported SV Programming Format 2 message
-
-
Method Details
-
isSupportedSv2Message
Check a LocoNet message to determine if it is a valid SV Programming Format 2 message.- Parameters:
m- LocoNet message to check- Returns:
- true if LocoNet message m is a supported SV Programming Format 2 message, else false.
-
isLnMessageASpecificSv2Command
public static boolean isLnMessageASpecificSv2Command(LocoNetMessage m, Lnsv2MessageContents.Sv2Command svCmd) Compare reply message against a specific SV Programming Format 2 message type.- Parameters:
m- LocoNet message to be verified as an SV Programming Format 2 message with the specified <SV_CMD> valuesvCmd- SV Programming Format 2 command to expect- Returns:
- true if message is an SV Programming Format 2 message of the specified <SV_CMD>, else false.
-
extractMessageType
Interpret a LocoNet message to determine its SV Programming Format 2 <SV_CMD>. If the message is not an SV Programming Format 2 message, returns null.- Parameters:
m- LocoNet message containing SV Programming Format 2 message- Returns:
- Sv2Command found in the SV Programming Format 2 message or null if not found
-
toString
Interpret the SV Programming Format 2 message into a human-readable string. -
toString
Interpret the SV Programming Format 2 message into a human-readable string.- Parameters:
locale- locale to use for the human-readable string- Returns:
- String containing a human-readable version of the SV Programming Format 2 message, in the language specified by the Locale if the properties have been translated to that Locale, else in the default English language.
-
isSupportedSv2Command
- Parameters:
possibleCmd- integer to be compared to the command list- Returns:
- true if the possibleCmd value is one of the supported SV Programming Format 2 commands
-
isSupportedSv2Command
Confirm a message specifies a valid (known) SV Programming Format 2 command.- Returns:
- true if the SV2 message specifies a valid (known) SV Programming Format 2 command.
-
isSupportedSv2ReadOneReply
- Returns:
- true if the SV2 message is a SV2 Read One Reply message
-
isSupportedSv2ReadFourReply
- Returns:
- true if the SV2 message is a SV2 Read Four Reply message
-
isSupportedSv2ReadOneReplyOrSv2ReadFourReply
- Returns:
- true if the SV2 message is a SV2 Read One Reply message or a SV2 Read Four Reply message
-
getSingleReadReportData
Get the data from a SVs Single Read Reply message. May also be used to return the effective SV value reported in a SV2 Single Write Reply message.- Returns:
- the
<D1>value from the SV2 message
-
createSv2Message
public static LocoNetMessage createSv2Message(int source, int command, int destination, int svNum, int d1, int d2, int d3, int d4) throws IllegalArgumentException Create a LocoNet message containing an SV Programming Format 2 message. See Programmer message code inLnOpsModeProgrammerloadSV2MessageFormat- Parameters:
source- source device address (7 bit, for <SRC>)command- SV Programming Format 2 command number (for <SV_CMD>)destination- = SV format 2 destination address (for <DST_L> and <DST_H>)svNum- SV Programming Format 2 16-bit SV number (for <SVN_L> and <SVN_H>)d1- SV Programming Format 2 first data value (for <D1>)d2- SV Programming Format 2 second data value (for <D2>)d3- SV Programming Format 2 third data value (for <D3>)d4- SV Programming Format 2 fourth data value (for <D4>)- Returns:
- LocoNet message for the requested message
- Throws:
IllegalArgumentException- if command is not a valid SV Programming Format 2 <SV_CMD> value
-
getDestAddr
-
getSvNum
-
getSv2ManufacturerID
-
isSvReconfigureReply
-
getSv2DeveloperID
-
getSv2ProductID
-
getSv2SerialNum
-
createSv2DeviceDiscoveryReply
public static LocoNetMessage createSv2DeviceDiscoveryReply(int ida, int currentDest, int mfg, int devel, int prodID, int serial) - Parameters:
ida- IDA number for "SRC" field of OPC_PEER_XFERcurrentDest- the destination address of the devicemfg- the Manufacturer IDdevel- the developer IDprodID- the product IDserial- the serial number- Returns:
- a LocoNet message containing the formatted reply
-
createSv2ChangeAddressReply
Create a LocoNet message for the reply for an SV2 "Change Address" message where the device requires a reconfigure.- Parameters:
ida- IDA value, for the SRC field of the OPC_PEER_XFERdestAddr- the "old" SV2 destination address- Returns:
- a LocoNet message
-
createSv2ChangeAddressReply
public static LocoNetMessage createSv2ChangeAddressReply(int ida, int newDestAddr, int mfg, int developer, int productId, int serialNum) Create a LocoNet message for the reply for an SV2 "Change Address" message where the device requires a reconfigure.- Parameters:
ida- IDA value, for the SRC field of the OPC_PEER_XFERnewDestAddr- the "new" SV2 destination addressmfg- manufacturer IDdeveloper- device IDproductId- product IDserialNum- serial Number- Returns:
- a LocoNet message
-
createSv2ReconfigureReply
public static LocoNetMessage createSv2ReconfigureReply(int ida, int newDestAddr, int mfg, int developer, int productId, int serialNum) Create a LocoNet message for the reply for an SV2 "Reconfigure Reply"- Parameters:
ida- IDA value, for the SRC field of the OPC_PEER_XFERnewDestAddr- the "new" SV2 destination addressmfg- manufacturer IDdeveloper- device IDproductId- product IDserialNum- serial Number- Returns:
- a LocoNet message
-
createSvReadReply
- Parameters:
m- the preceding LocoNet messagesvValues- array containing the SV values; only one value is used when m contains an SV_QUERY_ONE, else contains 4 values.- Returns:
- LocoNet message containing the reply, or null if preceding message isn't a query
-
createSvReadReply
- Parameters:
m- the preceding LocoNet messagesvValue- value of one SV register- Returns:
- LocoNet message containing the reply, or null if preceding message isn't a query
-
getSv2D1
Get the d1 value- Returns:
- d1 element contents
-
getSv2D2
Get the d2 value- Returns:
- d2 element contents
-
getSv2D3
Get the d3 value- Returns:
- d3 element contents
-
getSv2D4
Get the d4 value- Returns:
- d4 element contents
-
isSvChangeAddressReply
-
createSvDiscoverQueryMessage
-
createSvReadRequest
-
createSvReadRequest
Create LocoNet message for another query of an SV of this object.- Parameters:
deviceAddress- address of the devicesvNum- SV number- Returns:
- LocoNet message
-