Package jmri.jmrix.bidib
Class BiDiBAddress
- java.lang.Object
-
- jmri.jmrix.bidib.BiDiBAddress
-
public class BiDiBAddress extends java.lang.Object
Utilities for handling BiDiB adresses
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
addrRegex
-
Constructor Summary
Constructors Constructor Description BiDiBAddress(java.lang.String systemName, char typeLetter, BiDiBSystemConnectionMemo memo)
Construct from system name - needs prefix and type letter
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAddr()
Get the address inside the node.java.lang.String
getAddrString()
Get the address as string exactly as given when the instance has been createdprotected java.lang.String
getAddrtype()
Get the address type as a lowercase single letter: t - DCC address of decoder (t stands for "Track") a - BiDiB Accessory Number p - BiDiB Port f - BiDiB Feedback Number (BM) Not a public method since we want to hide this letter, use isPortAddr() or isAccessoryAddr() instead.org.bidib.jbidibc.messages.Node
getNode()
Get the BiDiB Node object.byte[]
getNodeAddr()
Get the BiDiB Node address.long
getNodeUID()
Get the 40 bit unique ID of the found nodeorg.bidib.jbidibc.messages.enums.LcOutputType
getPortType()
Get the port type as an LcOutputType object (SWITCHPORT, LIGHTPORT, ...)void
invalidate()
Invalidate this BiDiBAddress by removing the node.boolean
isAccessoryAddr()
Check if the address is a BiDiB Accessory address.boolean
isAddressEqual(BiDiBAddress other)
Check address against a BiDiBAddress object.boolean
isAddressEqual(org.bidib.jbidibc.messages.BidibPort bidibPort)
Check address against a BiDiBAddress object.boolean
isAddressEqual(org.bidib.jbidibc.messages.LcConfig lcConfig)
Check address against a LcConfig object.boolean
isAddressEqual(org.bidib.jbidibc.messages.LcConfigX lcConfigX)
Check address against a LcConfigX object.boolean
isFeedbackAddr()
Check if the address is a BiDiB feedback Number (BM).boolean
isPortAddr()
Check if the address is a BiDiB Port address (LC)boolean
isPortTypeBasedModel()
Check if the object contains an address in the BiDiB type based address model.boolean
isTrackAddr()
Check if the address is a BiDiB track address (i.e. a DCC accessory address).boolean
isValid()
Check if the object contains a valid BiDiB address The object is invalied the the system is syntactically wrong or if the requested node is not availablestatic boolean
isValidAddress(java.lang.String systemName, char typeLetter, BiDiBSystemConnectionMemo memo)
Static method to parse a system Name.static boolean
isValidSystemNameFormat(java.lang.String systemName, char typeLetter, BiDiBSystemConnectionMemo memo)
Static method to check system name syntax.org.bidib.jbidibc.messages.BidibPort
makeBidibPort()
Create a BiDiBPort object from this objectjava.lang.String
toString()
-
-
-
Field Detail
-
addrRegex
static final java.lang.String addrRegex
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BiDiBAddress
public BiDiBAddress(java.lang.String systemName, char typeLetter, BiDiBSystemConnectionMemo memo)
Construct from system name - needs prefix and type letter- Parameters:
systemName
- the JMRI system name for which the adress object is to be createdtypeLetter
- the type letter from the calling manager (T, L, S, R)memo
- connection memo object
-
-
Method Detail
-
isValidSystemNameFormat
public static boolean isValidSystemNameFormat(java.lang.String systemName, char typeLetter, BiDiBSystemConnectionMemo memo)
Static method to check system name syntax. Does not check if the node is available- Parameters:
systemName
- the JMRI system name for which the adress object is to be createdtypeLetter
- the type letter from the calling manager (T, L, S, R)memo
- connection memo object- Returns:
- true if the system name is syntactically valid.
-
invalidate
public void invalidate()
Invalidate this BiDiBAddress by removing the node. Used when the node gets lost.
-
isValid
public boolean isValid()
Check if the object contains a valid BiDiB address The object is invalied the the system is syntactically wrong or if the requested node is not available- Returns:
- true if valid
-
isPortAddr
public boolean isPortAddr()
Check if the address is a BiDiB Port address (LC)- Returns:
- true if the object represents a BiDiB Port address
-
isAccessoryAddr
public boolean isAccessoryAddr()
Check if the address is a BiDiB Accessory address.- Returns:
- true if the object represents a BiDiB Accessory address
-
isFeedbackAddr
public boolean isFeedbackAddr()
Check if the address is a BiDiB feedback Number (BM).- Returns:
- true if the object represents a BiDiB feedback Number
-
isTrackAddr
public boolean isTrackAddr()
Check if the address is a BiDiB track address (i.e. a DCC accessory address).- Returns:
- true if the object represents a BiDiB track address
-
getNodeUID
public long getNodeUID()
Get the 40 bit unique ID of the found node- Returns:
- the 40 bit node unique ID
-
getAddr
public int getAddr()
Get the address inside the node. This may be a DCC address (for DCC-Accessories), an accessory number (for BiDiB accessories) or a port number (for LC ports)- Returns:
- address inside node
-
getAddrString
public java.lang.String getAddrString()
Get the address as string exactly as given when the instance has been created- Returns:
- address as string
-
getNode
public org.bidib.jbidibc.messages.Node getNode()
Get the BiDiB Node object. If the node is not available, null is returned.- Returns:
- Node object or null, if node is not available
-
getNodeAddr
public byte[] getNodeAddr()
Get the BiDiB Node address. If the node is not available, an empty address array is returned. Note: The BiDiB node address is dynamically created address from the BiDiBbus and is not suitable as a node ID. Use the Unique ID for that purpose.- Returns:
- Node address (byte array) or empty address array, if node is not available
-
getPortType
public org.bidib.jbidibc.messages.enums.LcOutputType getPortType()
Get the port type as an LcOutputType object (SWITCHPORT, LIGHTPORT, ...)- Returns:
- LcOutputType object
-
getAddrtype
protected java.lang.String getAddrtype()
Get the address type as a lowercase single letter: t - DCC address of decoder (t stands for "Track") a - BiDiB Accessory Number p - BiDiB Port f - BiDiB Feedback Number (BM) Not a public method since we want to hide this letter, use isPortAddr() or isAccessoryAddr() instead.- Returns:
- single letter address type
-
isPortTypeBasedModel
public boolean isPortTypeBasedModel()
Check if the object contains an address in the BiDiB type based address model. Returns false if the address is in the flat address model.- Returns:
- true if address is in the BiDiB type based address model.
-
isAddressEqual
public boolean isAddressEqual(BiDiBAddress other)
Check address against a BiDiBAddress object.- Parameters:
other
- as BiDiBAddress- Returns:
- true if same
-
isAddressEqual
public boolean isAddressEqual(org.bidib.jbidibc.messages.LcConfig lcConfig)
Check address against a LcConfig object.- Parameters:
lcConfig
- as LcConfig- Returns:
- true if the address contained in the LcConfig object is the same
-
isAddressEqual
public boolean isAddressEqual(org.bidib.jbidibc.messages.LcConfigX lcConfigX)
Check address against a LcConfigX object.- Parameters:
lcConfigX
- as LcConfig- Returns:
- true if the address contained in the LcConfigX object is the same
-
isAddressEqual
public boolean isAddressEqual(org.bidib.jbidibc.messages.BidibPort bidibPort)
Check address against a BiDiBAddress object.- Parameters:
bidibPort
- as BiDiBPort- Returns:
- true if same
-
makeBidibPort
public org.bidib.jbidibc.messages.BidibPort makeBidibPort()
Create a BiDiBPort object from this object- Returns:
- new BiDiBPort object
-
isValidAddress
public static boolean isValidAddress(java.lang.String systemName, char typeLetter, BiDiBSystemConnectionMemo memo) throws java.lang.IllegalArgumentException
Static method to parse a system Name. A temporary BiDiDAdress object is created.- Parameters:
systemName
- the JMRI system name for which the adress object is to be createdtypeLetter
- the type letter from the calling manager (T, L, S, R)memo
- connection memo object- Returns:
- true if the system name is valid and the BiDiB Node is available
- Throws:
java.lang.IllegalArgumentException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-