Package jmri.jmrix.loconet.uhlenbrock
Class LncvMessageContents
java.lang.Object
jmri.jmrix.loconet.uhlenbrock.LncvMessageContents
Supporting class for Uhlenbrock LocoNet LNCV Programming and Direct Format messaging.
Structure adapted from
Lnsv2MessageContents
Some of the message formats used in this class are Copyright Uhlenbrock.de
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 Uhlenbrock.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumLNCV Commands mapped to unique sets of 3 parts in message. -
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 int -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new LncvMessageContents object from a LocoNet message. -
Method Summary
Modifier and TypeMethodDescriptionstatic LocoNetMessagecreateAllProgEndRequest(int articleNum) Create LocoNet broadcast message to end LNCV programming.static LocoNetMessagecreateAllProgStartRequest(int articleNum) Create LocoNet broadcast message to start LNCV programming.static LocoNetMessagecreateCvReadRequest(int articleNum, int moduleAddress, int cvNum) Create LocoNet message for a query of a CV of this object.static LocoNetMessagecreateCvWriteRequest(int articleNum, int cvNum, int newValue) Create LocoNet message for a write to a CV of this object.static LocoNetMessagecreateDirectWriteRequest(int moduleAddress, int ledValue, boolean range2) Create LocoNet message to set aseries of Track-Control module display LEDs.static LocoNetMessagecreateLncvMessage(int opc, int source, int destination, int command, int articleNum, int cvNum, int moduleNum, int cmdData) Create a LocoNet message containing an LNCV Programming Format message.static LocoNetMessagecreateLncvMessage(int source, int destination, LncvMessageContents.LncvCommand command, int articleNum, int cvNum, int moduleNum) Create LNCV message fromLncvMessageContents.LncvCommandenum plus specific parameter values.static LocoNetMessageIn Hexfile simulation mode, mock a ProgStart reply message back to the CS.static LocoNetMessageIn Hexfile simulation mode, mock a ReadReply message back to the CS (when simulate replies is ON).static LocoNetMessagecreateModProgEndRequest(int articleNum, int moduleAddress) Create LocoNet message to leave programming of this module.static LocoNetMessagecreateModProgStartRequest(int articleNum, int moduleAddress) Create LocoNet message for first query of a CV of this module.Interpret a LocoNet message to determine its LNCV compound Programming Format.intgetCmd()intgetCvNum()intintintstatic booleanCompare reply message against a specific LNCV Programming Format message type.booleanConfirm a message corresponds with a valid (known) LNCV Programming Format command.static booleanisSupportedLncvCommand(int command, int opc, int cmdData) Check set of parameters against compoundLncvMessageContents.LncvCommandenum set.static booleanCheck a LocoNet message to determine if it is a valid LNCV Programming Format message.booleantoString()Interpret the LNCV Programming Format message into a human-readable string.Interpret the LNCV Programming Format message into a human-readable string.
-
Field Details
-
LNCV_LENGTH_ELEMENT_VALUE
- See Also:
-
LNCV_LNMODULE_VALUE
- See Also:
-
LNCV_CS_SRC_VALUE
- See Also:
-
LNCV_PC_SRC_VALUE
- See Also:
-
LNCV_CSDEST_VALUE
- See Also:
-
LNCV_ALL
- See Also:
-
LNCV_ALL_MASK
- See Also:
-
LNCV_MIN_MODULEADDR
- See Also:
-
LNCV_MAX_MODULEADDR
- See Also:
-
LNCV_LENGTH_ELEMENT_INDEX
- See Also:
-
LNCV_SRC_ELEMENT_INDEX
- See Also:
-
LNCV_DST_L_ELEMENT_INDEX
- See Also:
-
LNCV_DST_H_ELEMENT_INDEX
- See Also:
-
LNCV_CMD_ELEMENT_INDEX
- See Also:
-
PXCT1_ELEMENT_INDEX
- See Also:
-
LNCV_ART_L_ELEMENT_INDEX
- See Also:
-
LNCV_ART_H_ELEMENT_INDEX
- See Also:
-
LNCV_CVN_L_ELEMENT_INDEX
- See Also:
-
LNCV_CVN_H_ELEMENT_INDEX
- See Also:
-
LNCV_MOD_L_ELEMENT_INDEX
- See Also:
-
LNCV_MOD_H_ELEMENT_INDEX
- See Also:
-
LNCV_CMDDATA_ELEMENT_INDEX
- See Also:
-
LNCV_SRC_ELEMENT_MASK
- See Also:
-
PXCT1_ELEMENT_VALIDITY_CHECK_MASK
- See Also:
-
LNCV_ART_L_ARTL7_CHECK_MASK
- See Also:
-
LNCV_ART_H_ARTH7_CHECK_MASK
- See Also:
-
LNCV_CVN_L_CVNL7_CHECK_MASK
- See Also:
-
LNCV_CVN_H_CVNH7_CHECK_MASK
- See Also:
-
LNCV_MOD_L_MODL7_CHECK_MASK
- See Also:
-
LNCV_MOD_H_MODH7_CHECK_MASK
- See Also:
-
LNCV_CMDDATA_DAT7_CHECK_MASK
- See Also:
-
LNCV_DATA_PROFF_MASK
- See Also:
-
LNCV_DATA_PRON_MASK
- See Also:
-
LNCV_DATA_LED1_MASK
- See Also:
-
LNCV_DATA_LED2_MASK
- See Also:
-
LNCV_DATA_RO_MASK
- See Also:
-
LNCV_CMD_WRITE
- See Also:
-
LNCV_CMD_READ
- See Also:
-
LNCV_CMD_READ_REPLY
- See Also:
-
-
Constructor Details
-
LncvMessageContents
Create a new LncvMessageContents object from a LocoNet message.- Parameters:
m- LocoNet message containing an LNCV Programming Format message- Throws:
IllegalArgumentException- if the LocoNet message is not a valid, supported LNCV Programming Format message
-
-
Method Details
-
isSupportedLncvMessage
Check a LocoNet message to determine if it is a valid LNCV Programming Format message.- Parameters:
m- LocoNet message to check- Returns:
- true if LocoNet message m is a supported LNCV Programming Format message, else false.
-
isLnMessageASpecificLncvCommand
public static boolean isLnMessageASpecificLncvCommand(LocoNetMessage m, LncvMessageContents.LncvCommand lncvCmd) Compare reply message against a specific LNCV Programming Format message type.- Parameters:
m- LocoNet message to be verified as an LNCV Programming Format message with the specified <LNCV_CMD> valuelncvCmd- LNCV Programming Format command to check against- Returns:
- true if message is an LNCV Programming Format message of the specified <LNCV_CMD>, else false.
-
extractMessageType
Interpret a LocoNet message to determine its LNCV compound Programming Format. If the message is not an LNCV Programming/Direct Format message, returns null.- Parameters:
m- LocoNet message containing LNCV Programming Format message- Returns:
- LncvCommand found in the LNCV Programming Format message or null if not found
-
toString
Interpret the LNCV Programming Format message into a human-readable string. -
toString
Interpret the LNCV Programming Format 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 LNCV Programming Format message, in the language specified by the Locale, if the properties have been translated to that Locale, else in the default English language.
-
isSupportedLncvCommand
Check set of parameters against compoundLncvMessageContents.LncvCommandenum set.- Parameters:
command- LNCV CMD valueopc- OPC valuecmdData- LNCV cmdData value- Returns:
- true if the possibleCmd value is one of the supported (simple) LNCV Programming Format commands
-
isSupportedLncvCommand
Confirm a message corresponds with a valid (known) LNCV Programming Format command.- Returns:
- true if the LNCV message specifies a valid (known) LNCV Programming Format command.
-
isSupportedLncvReadReply
- Returns:
- true if the LNCV message is an LNCV ReadReply message
-
createLncvMessage
public static LocoNetMessage createLncvMessage(int opc, int source, int destination, int command, int articleNum, int cvNum, int moduleNum, int cmdData) throws IllegalArgumentException Create a LocoNet message containing an LNCV Programming Format message.- Parameters:
opc- Opcode (<OPC>), see LnConstantssource- source device (<SRC>)destination- destination address (for <DST_L> and <DST_H>)command- LNCV Programming simple command (for <LNCV_CMD>), part of complex commandLncvMessageContents.LncvCommandarticleNum- manufacturer's hardware class/article code as per specs (4 decimal digits)cvNum- CV number (for <LNCV_CVN_L> and <LNCV_CVN_H>)moduleNum- module address (for <LNCV_MOD_L> and <LNCV_MOD_H>), same field is used for CV Value in WRITE to and READ_REPLY from ModulecmdData- signals programming start/stop: LNCV_DATA_PRON/LNCV_DATA_PROFF- Returns:
- LocoNet message for the requested instruction
- Throws:
IllegalArgumentException- of command is not a valid LNCV Programming Format <LNCV_CMD> value
-
createLncvMessage
public static LocoNetMessage createLncvMessage(int source, int destination, LncvMessageContents.LncvCommand command, int articleNum, int cvNum, int moduleNum) Create LNCV message fromLncvMessageContents.LncvCommandenum plus specific parameter values.- Parameters:
source- source device (<SRC>)destination- destination address (for <DST_L> and <DST_H>)command- one of the composite LncvCommand'sarticleNum- manufacturer's hardware class/article code as per specscvNum- 16-bit CV number (for <LNCV_CVN_L> and <LNCV_CVN_H>)moduleNum- module address (for <LNCV_MOD_L> and <LNCV_MOD_H>), same field is used for CV Value in WRITE to and READ_REPLY from Module- Returns:
- LocoNet message for the requested instruction
-
getCmd
-
getCvNum
-
getCvValue
-
getLncvArticleNum
-
getLncvModuleNum
-
createAllProgStartRequest
Create LocoNet broadcast message to start LNCV programming.- Parameters:
articleNum- LNCV device type number used as filter to respond. Leave this out to 'broadcast' to all connected devices (which works for discovery purpose only)- Returns:
- LocoNet message
-
createAllProgEndRequest
Create LocoNet broadcast message to end LNCV programming. (expect no reply from module)- Parameters:
articleNum- LNCV device type number used as filter to respond. Leave out to 'broadcast' to all connected devices (which works for discovery purpose only). Best to use same value as used while opening the session.- Returns:
- LocoNet message
-
createModProgStartRequest
Create LocoNet message for first query of a CV of this module.- Parameters:
articleNum- address of the modulemoduleAddress- address of the module- Returns:
- LocoNet message
-
createModProgEndRequest
Create LocoNet message to leave programming of this module. (expect no reply from module)- Parameters:
articleNum- address of the modulemoduleAddress- address of the module- Returns:
- LocoNet message
-
createCvWriteRequest
Create LocoNet message for a write to a CV of this object.- Parameters:
articleNum- address of the modulecvNum- CV number to querynewValue- new value to store in CV- Returns:
- LocoNet message
-
createCvReadRequest
Create LocoNet message for a query of a CV of this object.- Parameters:
articleNum- address of the modulecvNum- CV number to querymoduleAddress- address of the module- Returns:
- LocoNet message
-
createLncvReadReply
In Hexfile simulation mode, mock a ReadReply message back to the CS (when simulate replies is ON).- Parameters:
m- the LocoNet message to respond to- Returns:
- LocoNet message containing the reply, or null if preceding message isn't a query
-
createLncvProgStartReply
In Hexfile simulation mode, mock a ProgStart reply message back to the CS.- Parameters:
m- the LocoNet message to respond to- Returns:
- LocoNet message containing the reply, or null if preceding message isn't a query
-
createDirectWriteRequest
public static LocoNetMessage createDirectWriteRequest(int moduleAddress, int ledValue, boolean range2) Create LocoNet message to set aseries of Track-Control module display LEDs.- Parameters:
moduleAddress- address of the moduleledValue- CV number to queryrange2- true if intended for LED2 Command (leds 16-31), fasle for LED1 (0-15)- Returns:
- LocoNet message
-