Class Frame

  • All Implemented Interfaces:

    
    public final class Frame
    
                        

    RSCP data frame that can be sent to or received from an E3DC home power plant.

    A frame always consists of 3 logical parts: Timestamp reflecting the creation time of the frame Control area, contains the protocol version and a control information whether the checksum feature is used or not. Data, the RSCP data itself.

    Since:

    2.0

    2.1 new functions:

    • Constructor Detail

      • Frame

        Frame(Instant timestamp, ByteArray controlBytes, List<Data> data, DataParser parser)
        Parameters:
        timestamp - Creation time of the frame
        controlBytes - Control functions.
        data - The data itself.
        parser - The parser to use for parsing container data
    • Method Detail

      • asByteArray

         final ByteArray asByteArray()

        Provides the byte representation of the frame as it may be sent to or received from the home power plant.

        A frame is structured according to the following pattern:

        • Byte 0 - 1: So-called magic bytes. Are fixed on the byte value of the hex string E3DC.

        • Byte 2 - 3: Control area. The first byte is always 00 and is reserved for the future according to E3DC. The second byte contains the protocol version (currently always 1) and a 0 (without checksum) or 1 (with checksum).

        • Byte 4 - 15: Contain the timestamp. 4 - 11 in seconds since 01.01.1970, and 12 - 15 the nanoseconds.

        • Byte 16 - 17: Length in bytes for the following data block

        • Bytes 18 - n: Data range

        • Bytes n+1 - n + 4: CRC32 Checksum of the frame when bytes 0 - n are considered. This block is omitted if the checksum bit is set to 0 in the control area.

        Returns:

        ByteArray of the whole frame

        Since:

        2.0

      • dataByTag

         final Data dataByTag(Tag tag, Tag containerPath)

        Searches for a data block with the specified tag

        Parameters:
        tag - To be searched Tag
        containerPath - Path, if the block is to be searched nested in container blocks
        Returns:

        Data block or null if not found

        Since:

        2.0

      • intByTag

         final Integer intByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as Int.

        If the block is not found, or is not a valid Int type (see DataType.isIntType, the value 0 is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as Int or 0 if the data block does not exist or is not a valid Int type.

        Since:

        2.0

      • shortByTag

         final Short shortByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as Short.

        If the block is not found, or is not a valid Short type (see DataType.isShortType, the value 0 is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as Short or 0 if the data block does not exist or is not a valid Short type.

        Since:

        2.0

      • byteByTag

         final Byte byteByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as Byte.

        If the block is not found, or is not a valid Byte type (see DataType.isByteType, the value 0 is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as Byte or 0 if the data block does not exist or is not a valid Byte type.

        Since:

        2.0

      • longByTag

         final Long longByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as Long.

        If the block is not found, or is not a valid Long type (see DataType.isLongType, the value 0 is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as Long or 0 if the data block does not exist or is not a valid Long type.

        Since:

        2.0

      • floatByTag

         final Float floatByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as Float.

        If the block is not found, or is not a valid Float type (see DataType.FLOAT32), the value 0.0f is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as Float or 0.0f if the data block does not exist or is not a valid Float type.

        Since:

        2.0

      • doubleByTag

         final Double doubleByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as Double.

        If the block is not found, or is not a valid Double type (see DataType.DOUBLE64), the value 0.0 is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as Double or 0.0 if the data block does not exist or is not a valid Double type.

        Since:

        2.0

      • booleanByTag

         final Boolean booleanByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as Boolean.

        If the block is not found, or is not a valid Boolean type (see DataType.BOOL), the value false is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as Boolean or false if the data block does not exist or is not a valid Boolean type.

        Since:

        2.0

      • stringByTag

         final String stringByTag(Tag tag, Tag containerPath)

        Searches for a data block of type tag and returns the value as String.

        If the block is not found, the empty String is returned.

        Parameters:
        tag - The Tag to search for
        containerPath - Optional path through datablocks of type DataType.CONTAINER.
        Returns:

        Value of the data block as String or the empty String if the data block does not exist.

        Since:

        2.0

      • isChecksumEnabled

         final Boolean isChecksumEnabled()

        Query whether the frame calculates the checksum or not.

        Returns:

        true wenn ja, ansonsten false

        Since:

        2.0