Package jmri.jmrix.loconet.lnsvf1
Class Lnsv1MessageContents
java.lang.Object
jmri.jmrix.loconet.lnsvf1.Lnsv1MessageContents
Supporting class for LocoNet SV Programming Format 1 (LocoIO) 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.
Uses the LOCONETSV1MODE programming mode.
Uses LnProgrammer LOCOIO_PEER_CODE_SV_VER1 message format, comparable to DecoderPro LOCONETSV1MODE The DecoderPro decoder definition is recommended for all LocoIO versions. Requires JMRI 4.12 or later.
-
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 int -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new Lnsv1MessageContents object from a LocoNet message. -
Method Summary
Modifier and TypeMethodDescriptionstatic LocoNetMessageCreate a message to probe all connected LocoIO (LNSV1) units on a given LocoNet connection.static LocoNetMessage[]createBroadcastSetAddress(int address, int subAddress) Compose a message that changes the hardware board address of ALL connected LNSV1 (LocoIO) boards.static LocoNetMessagecreateSv0Message(int source, int destination, int subAddress, int command, int svNum, int version, int newVal, int d6, int d7, int d8) Create a LocoNet message containing an SV Programming Format 0 message.static LocoNetMessagecreateSv1Message(int source, int destination, int subAddress, int command, int svNum, int version, int newVal, int d6, int d7, int d8) Create a LocoNet message containing an SV Programming Format 1 message.static LocoNetMessagecreateSv1ReadReply(int src, int dst, int subAddress, int version, int svNum, int returnValue) Simulate a read/probe reply for testing/developing.static LocoNetMessagecreateSv1ReadRequest(int dst, int subAddress, int svNum) Create LocoNet message for a query of an SV of this object.static LocoNetMessagecreateSv1WriteReply(int src, int dst, int subAddress, int version, int svNum, int returnValue) Simulate a read/probe reply for testing/developing.static LocoNetMessagecreateSv1WriteRequest(int dst, int subAddress, int svNum, int newValue) Interpret a LocoNet message to extract its SV Programming Format 1 <SV_CMD>.static intInterpret a LocoNet message to extract its SV Programming Format 1 <SV_CMD>.intgetCmd()intNot returning a valid address because LNSV1 messages do not use the DST_H field for high address.intgetDstH()Used to check message.intgetDstL()intGet the data from a SVs READ_ONE Reply message.intgetSrcL()intintgetSv1D4()Get the d4 valueintgetSv1D6()Get the d6 valueintgetSv1D7()Get the d7 valueintgetSv1D8()Get the d8 valueintgetSvNum()intintstatic booleanCompare reply message against a specific SV Programming Format 1 message type.booleanConfirm a message specifies a valid (known) SV Programming Format 1 command.static booleanisSupportedSv1Command(int possibleCmd) static booleanCheck a LocoNet message to determine if it is a valid SV Programming Format 1 message.booleanstatic StringtoHexComposite(int low, int high) Format byte for hex displaystatic StringtoHexStr(int value) Format byte for decimal + (optional) hex displaytoString()Interpret the SV Programming Format 1 message into a human-readable string.Interpret the SV Programming Format 1 message into a human-readable string.
-
Field Details
-
LNSV1_BROADCAST_ADDRESS
- See Also:
-
LNSV1_LOCOBUFFER_ADDRESS
- See Also:
-
LNSV1_PEER_CODE_SV_VER0
- See Also:
-
LNSV1_PEER_CODE_SV_VER1
- See Also:
-
SV1_SV_SRC_L_ELEMENT_INDEX
- See Also:
-
SV1_SV_DST_L_ELEMENT_INDEX
- See Also:
-
SV1_SV_DST_H_ELEMENT_INDEX
- See Also:
-
SV1_SVX1_ELEMENT_INDEX
- See Also:
-
SV1_SV_CMD_ELEMENT_INDEX
- See Also:
-
SV1_SVX2_ELEMENT_INDEX
- See Also:
-
SV1_SVX1_ELEMENT_VALIDITY_CHECK_MASK
- See Also:
-
SV1_SVX1_ELEMENT_VALIDITY_CHECK_VALUE
- See Also:
-
SV1_SVX2_ELEMENT_VALIDITY_CHECK_MASK
- See Also:
-
SV0_SVX2_ELEMENT_VALIDITY_CHECK_VALUE
- See Also:
-
SV1_SVX2_ELEMENT_VALIDITY_CHECK_VALUE
- See Also:
-
SV_CMD_WRITE_ONE
- See Also:
-
SV_CMD_READ_ONE
- See Also:
-
-
Constructor Details
-
Lnsv1MessageContents
Create a new Lnsv1MessageContents object from a LocoNet message.- Parameters:
m- LocoNet message containing an SV Programming Format 1 message- Throws:
IllegalArgumentException- if the LocoNet message is not a valid, supported SV Programming Format 1 message
-
-
Method Details
-
isSupportedSv1Message
Check a LocoNet message to determine if it is a valid SV Programming Format 1 message.- Parameters:
m- LocoNet message to check- Returns:
- true if LocoNet message m is a supported SV Programming Format 1 message, else false.
-
isLnMessageASpecificSv1Command
public static boolean isLnMessageASpecificSv1Command(LocoNetMessage m, Lnsv1MessageContents.Sv1Command svCmd) Compare reply message against a specific SV Programming Format 1 message type.- Parameters:
m- LocoNet message to be verified as an SV Programming Format 1 message with the specified <SV_CMD> valuesvCmd- SV Programming Format 1 command to expect- Returns:
- true if message is an SV Programming Format 1 message of the specified <SV_CMD>, else false.
-
extractMessageType
Interpret a LocoNet message to extract its SV Programming Format 1 <SV_CMD>. If the message is not an SV Programming Format 1 message, returns null.- Parameters:
m- LocoNet message containing SV Programming Format 1 message- Returns:
- Sv1Command found in the SV Programming Format 1 message or null if not found
-
extractMessageVersion
Interpret a LocoNet message to extract its SV Programming Format 1 <SV_CMD>. If the message is not an SV Programming Format 1 message, return null.- Parameters:
m- LocoNet message containing SV Programming Format 1 version field- Returns:
- Version found in the SV Programming Format 1 message or -1 if not found
-
toString
Interpret the SV Programming Format 1 message into a human-readable string. -
toString
Interpret the SV Programming Format 1 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 1 message, in the language specified by the Locale if the properties have been translated to that Locale, else in the default English language.
-
toHexStr
Format byte for decimal + (optional) hex display -
toHexComposite
Format byte for hex display -
isSupportedSv1Command
- Parameters:
possibleCmd- integer to be compared to the command list- Returns:
- true if the possibleCmd value is one of the supported SV Programming Format 1 commands
-
isSupportedSv1Command
Confirm a message specifies a valid (known) SV Programming Format 1 command.- Returns:
- true if the SV1 message specifies a valid (known) SV Programming Format 1 command.
-
isSupportedSv1ReadOneReply
- Returns:
- true if the SV1 message is a SV1 Read One Reply message
-
getSingleReadReportData
Get the data from a SVs READ_ONE Reply message. May also be used to return the effective SV value reported in an SV1 WRITE_ONE Reply message (or is that returned in d8?).- Returns:
- the
<D6>value from the SV1 message
-
getSrcL
-
getDstL
-
getDstH
Used to check message. LNSV1 messages do not use the DST_H field for high address -
getDestAddr
Not returning a valid address because LNSV1 messages do not use the DST_H field for high address. and a composite address is not used. - LocoBuffer subaddress is always 1. - LocoIO subaddress is stored and fetched from PEER_XFER element SV1_SV_SUBADR_ELEMENT_INDEX (11). - JMRI LocoIO decoder address as stored in the Roster is calculated as a 14-bit number in jmri.jmrix.loconet.swing.lnsv1prog.Lnsv1ProgPane -
getSubAddress
-
getCmd
-
getSvNum
-
getSvValue
-
getVersionNum
-
getSv1D4
Get the d4 value- Returns:
- d4 element contents
-
getSv1D6
Get the d6 value- Returns:
- d6 element contents
-
getSv1D7
Get the d7 value- Returns:
- d7 element contents
-
getSv1D8
Get the d8 value- Returns:
- d8 element contents
-
createSv0Message
public static LocoNetMessage createSv0Message(int source, int destination, int subAddress, int command, int svNum, int version, int newVal, int d6, int d7, int d8) throws IllegalArgumentException Create a LocoNet message containing an SV Programming Format 0 message. Used only to simulate replies from LocoIO. Uses LNSV1_PEER_CODE_SV_VER0.See Programmer message code in
LnOpsModeProgrammerloadSV1MessageFormat- Parameters:
source- source device address (for <SRC_L>)destination- = SV format 1 7-bit destination address (for <DST_L>)subAddress- = SV format 1 7-bit destination subaddress (for <DST_H>)command- SV Programming Format 1 command number (for <SV_CMD>)svNum- SV Programming Format 1 8-bit SV numbernewVal- (d4) SV first 8-bit data value to write (for <D4>)version- Programming Format 1 8-bit firmware version number; 0 in request,>0 in repliesd6- second 8-bit data value (for <D6>)d7- third 8-bit data value (for <D7>)d8- fourth 8-bit data value (for <D8>)- Returns:
- LocoNet message for the requested message
- Throws:
IllegalArgumentException- if command is not a valid SV Programming Format 1 <SV_CMD> value
-
createSv1Message
public static LocoNetMessage createSv1Message(int source, int destination, int subAddress, int command, int svNum, int version, int newVal, int d6, int d7, int d8) throws IllegalArgumentException Create a LocoNet message containing an SV Programming Format 1 message.See Programmer message code in
LnOpsModeProgrammerloadSV1MessageFormat- Parameters:
source- source device address (for <SRC_L>)destination- = SV format 1 7-bit destination address (for <DST_L>)subAddress- = SV format 1 7-bit destination subaddress (for <DST_H>)command- SV Programming Format 1 command number (for <SV_CMD>)svNum- SV Programming Format 1 8-bit SV numbernewVal- (d4) SV first 8-bit data value to write (for <D4>)version- Programming Format 1 8-bit firmware version number; 0 in request,>0 in repliesd6- second 8-bit data value (for <D6>)d7- third 8-bit data value (for <D7>)d8- fourth 8-bit data value (for <D8>)- Returns:
- LocoNet message for the requested message
- Throws:
IllegalArgumentException- if command is not a valid SV Programming Format 1 <SV_CMD> value
-
createSv1ReadRequest
Create LocoNet message for a query of an SV of this object.- Parameters:
dst- address of the device to read fromsubAddress- subaddress of the device to read fromsvNum- SV number to read- Returns:
- LocoNet message
-
createSv1ReadReply
public static LocoNetMessage createSv1ReadReply(int src, int dst, int subAddress, int version, int svNum, int returnValue) Simulate a read/probe reply for testing/developing.- Parameters:
src- board low addressdst- dest high address, usually 0x50 for LocoBuffer/PCsubAddress- board high addressversion- fictional firmware version number to addsvNum- SV read- Returns:
- LocoNet message containing the reply
-
createSv1WriteRequest
public static LocoNetMessage createSv1WriteRequest(int dst, int subAddress, int svNum, int newValue) -
createSv1WriteReply
public static LocoNetMessage createSv1WriteReply(int src, int dst, int subAddress, int version, int svNum, int returnValue) Simulate a read/probe reply for testing/developing.- Parameters:
src- board low addresssubAddress- board high addressdst- dest high address, usually 0x1050 for LocoBuffer/PCversion- fictional firmware version number to addsvNum- SV read- Returns:
- LocoNet message containing the reply
-
createBroadcastSetAddress
Compose a message that changes the hardware board address of ALL connected LNSV1 (LocoIO) boards.- Parameters:
address- the new base address of the LocoIO board to changesubAddress- the new subAddress of the board- Returns:
- an array containing one or two LocoNet messages
-
createBroadcastProbeAll
Create a message to probe all connected LocoIO (LNSV1) units on a given LocoNet connection.- Returns:
- the complete LocoNet message
-