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 !!

    • Constructor Detail

      • Address

        Address(AddressClass addressClass, Integer physicalAddress)
        Creates a new immutable Modbus Address instance.
    • Method Detail

      • 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

      • distance

         final Integer distance(Address address)
        Parameters:
        address - The address to compare to
        Returns:

        The "Increment" difference to get from this Address to the provided Address. Returns null if not the same address class

      • 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