Class Address
-
- All Implemented Interfaces:
-
kotlin.Comparable
public final class Address implements Comparable<Address>
The ModBus Address of a single register. An Address instance is IMMUTABLE !!
-
-
Field Summary
Fields Modifier and Type Field Description private final IntegerregisterNumberprivate final AddressClassaddressClassprivate final IntegerphysicalAddress
-
Constructor Summary
Constructors Constructor Description Address(AddressClass addressClass, Integer physicalAddress)Creates a new immutable Modbus Address instance.
-
Method Summary
Modifier and Type Method Description final IntegergetRegisterNumber()final AddressClassgetAddressClass()The kind of the address (which limits the allowed function codes) final IntegergetPhysicalAddress()The technical wire address. final Addressincrement(Integer step)Increment the address by stepfinal Addressincrement()Increment the address by stepStringtoString()final StringtoCleanFormat()final StringtoModicon5()final StringtoModicon6()final StringtoModiconX()IntegercompareTo(Address other)Booleanequals(Object other)IntegerhashCode()final static Addressof(AddressClass addressClass, Integer physicalAddress)Creates a new Modbus Address instance. final static Addressof(String registerTag)Create the address by parsing the provided register format. final static AddressofModicon5(Integer modicon5RegisterTag)Create the address by parsing the provided numerical register format. final static AddressofModicon6(Integer modicon6RegisterTag)Create the address by parsing the provided numerical register format. -
-
Constructor Detail
-
Address
Address(AddressClass addressClass, Integer physicalAddress)
Creates a new immutable Modbus Address instance.
-
-
Method Detail
-
getRegisterNumber
final Integer getRegisterNumber()
-
getAddressClass
final AddressClass getAddressClass()
The kind of the address (which limits the allowed function codes)
-
getPhysicalAddress
final Integer getPhysicalAddress()
The technical wire address. Always in the 0-65535 range.
-
increment
@JvmOverloads() final Address increment(Integer step)
Increment the address by
step- Parameters:
step- The desired address increase (step=1 if unspecified).- Returns:
A NEW (incremented) immutable instance
-
increment
@JvmOverloads() final Address increment()
Increment the address by
step- Returns:
A NEW (incremented) immutable instance
-
toString
String toString()
- Returns:
The stored address as cleanly parsable format without the "off by one" problem. For example "hr:00123".
-
toCleanFormat
final String toCleanFormat()
- Returns:
The stored address as cleanly parsable format without the "off by one" problem. For example "hr:00123".
-
toModicon5
final String toModicon5()
- Returns:
The stored address as an original modicon 5 digit value (or null if the register number is 9999). For example "40124".
-
toModicon6
final String toModicon6()
- Returns:
The stored address as a modicon 6 digit value. For example "400124".
-
toModiconX
final String toModiconX()
- Returns:
The stored address as a modicon variant with an 'x' separator. For example "4x00124".
-
of
final static Address of(AddressClass addressClass, Integer physicalAddress)
Creates a new Modbus Address instance.
- Returns:
A new immutable instance of Address with the given values
-
of
final static Address of(String registerTag)
Create the address by parsing the provided register format.
- Parameters:
registerTag- The register's tag in one of the supported formats (for example: "40124", "400124", "4x124", "4x000124", "hr:123").- Returns:
A new immutable instance of Address with the given values
-
ofModicon5
final static Address ofModicon5(Integer modicon5RegisterTag)
Create the address by parsing the provided numerical register format. This ONLY allows the original Modicon 5 digit format.
- Parameters:
modicon5RegisterTag- The register's tag in the original Modicon 5 digit format.- Returns:
A new immutable instance of Address with the given values
-
ofModicon6
final static Address ofModicon6(Integer modicon6RegisterTag)
Create the address by parsing the provided numerical register format. This ONLY allows the Modicon 6 digit format.
- Parameters:
modicon6RegisterTag- The register's tag in the Modicon 6 digit format.- Returns:
a new immutable instance of Address with the given values
-
-
-
-