Package jmri.jmrix.can.cbus
Class CbusAddress
java.lang.Object
jmri.jmrix.can.cbus.CbusAddress
Utilities for handling CBUS addresses.
CBUS frames have a one byte command and length, optionally followed by data bytes. JMRI maps these into address strings.
Forms:
- Full hex string preceeded by "X"
- Needs to be pairs of digits: 0123, not 123
- +/-ddd
- ddd is node*100,000 (a.k.a NODEFACTOR) + event
- +/-nNNNeEEE
- where NNN is a node number and EEE is an event number
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[](package private) static final int(package private) static final String -
Constructor Summary
ConstructorsConstructorDescriptionConstruct from string without leading system or type letters. -
Method Summary
Modifier and TypeMethodDescriptionbooleancheck()booleanUsed in Testing.(package private) int[]elements()booleanTwo addresses are equal if they result in the same numeric contents.static StringgetIncrement(String testAddr) Increments a CBUS address by 1 eg +123 to +124 eg -N123E456 to -N123E457inthashCode()makeMessage(int header) booleanDoes the CbusAddress match.booleanDoes the CbusAddress match a CanReply event request.split()Split a string containing one or more addresses into individual ones.eg.x9801D203A4 or x90007B01C8toString()eg.static StringvalidateSysName(String address) Validate a CBUS hardware address validation.
-
Field Details
-
SINGLE_ADDRESS_PATTERN
- See Also:
-
aFrame
-
NODEFACTOR
- See Also:
-
-
Constructor Details
-
CbusAddress
Construct from string without leading system or type letters.- Parameters:
s- CBUS Hardware Address format
-
-
Method Details
-
equals
Two addresses are equal if they result in the same numeric contents. -
hashCode
-
makeMessage
-
check
-
match
Does the CbusAddress match.- Parameters:
r- CanReply or CanMessage being tested- Returns:
- true if matches
-
matchRequest
Does the CbusAddress match a CanReply event request.- Parameters:
r- CanReply being tested- Returns:
- true if matches
-
split
Split a string containing one or more addresses into individual ones.- Returns:
- 0 length if entire string can't be parsed.
-
getIncrement
Increments a CBUS address by 1 eg +123 to +124 eg -N123E456 to -N123E457- Parameters:
testAddr- initial CbusAddress String, eg -N123E456- Returns:
- incremented address.
- Throws:
JmriException- if unable to make the address
-
validateSysName
Validate a CBUS hardware address validation.- Parameters:
address- the hardware address to check, excluding both system prefix and type letter.- Returns:
- same address if all OK.
- Throws:
IllegalArgumentException- when address is not validated. or contains too many parts
-
checkSplit
Used in Testing.- Returns:
- true if split length is 1 or 2, else false.
-
elements
int[] elements() -
toString
eg. X9801D203A4 or +N123E456 -
toCanonicalString
eg.x9801D203A4 or x90007B01C8- Returns:
- x followed by Can Frame Data
-