Class OmronBOOL


  • public class OmronBOOL
    extends CipBOOL.CipBOOL16
    Omron Booleans are chameleons for transfer on the wire. They are documented to occupy one or more 16 bit words in an NJ or NX processor. When accessed individually, you get or supply a 16-bit word with the boolean encoded in the low bit.

    When an array, they are documented to occupy consecutive 16 bit words, where all of the dimensions are unrolled and the bits are packed linearly in the words, from lowest bit to highest bit. However, encoding on the wire varies:

    When accessing a structure that contains a boolean array, the structure's payload on the wire contains the boolean array in this packed format.

    When directly accessing an array (qty>1) of booleans, whether a global variable or as a named element of a structure, the booleans are instead encoded in the low bit of as many bytes.

    • Constructor Detail

      • OmronBOOL

        public OmronBOOL​(int[] dimensions)
      • OmronBOOL

        public OmronBOOL​(boolean state)
    • Method Detail

      • bytesEach

        public int bytesEach()
        Description copied from class: BaseDataType
        Obtain the bytes-per-element of this object's payload encoding. Objects with variable length encodings must return zero and implement the bytesImpl(), minEach(), maxEach(), and alignment() methods instead.
        Overrides:
        bytesEach in class CipBOOL
        Returns:
        encoded bytes per element
      • minEach

        public int minEach()
        Description copied from class: BaseDataType
        Obtain the smallest number of bytes a single item can occupy in encoded form. Used in structures to compute min/max offset and total structure size range.

        Types where bytesEach is a constant should override this to return that constant too, as a performance optimization.

        Overrides:
        minEach in class CipBOOL
        Returns:
      • maxEach

        public int maxEach()
        Description copied from class: BaseDataType
        Obtain the largest number of bytes a single item can occupy in encoded form. Used in structures to compute min/max offset and total structure size range.

        Types where bytesEach is a constant should override this to return that constant too, as a performance optimization.

        Overrides:
        maxEach in class CipBOOL
        Returns:
      • alignment

        public int alignment()
        Description copied from class: BaseDataType
        Obtain the natural alignment of this data type. Used in structures to compute min/max offset and alignment.

        Types where bytesEach is a constant should override this to return a suitable constant too, as a performance optimization.

        Overrides:
        alignment in class CipBOOL
        Returns:
      • bytes

        public int bytes​(int... indices)
        Description copied from class: CipBOOL
        Arrays of booleans require special payload handling, as bits are packed into bytes, shorts, integers, or longs.
        Overrides:
        bytes in class CipBOOL
        Returns:
      • nestedBytes

        public int nestedBytes​(boolean asStruct,
                               int... indices)
        Description copied from class: BaseDataType
        Certain types (Omron strings and booleans) can have different encodings when packed into structures. CipStruct will always call this method with asStruct set true so that such types can report the correct size.
        Overrides:
        nestedBytes in class CipBOOL
        Returns:
      • nestedSetPayload

        public void nestedSetPayload​(int startpos,
                                     boolean asStruct,
                                     java.nio.ByteBuffer source,
                                     int... indices)
        Description copied from class: BaseDataType
        Certain types (Omron strings and booleans) can have different encodings when packed into structures. CipStruct will always call this method with asStruct set true so that such types can perform the correct decoding.
        Overrides:
        nestedSetPayload in class BaseDataType<java.lang.Boolean>
        asStruct - True to invoke nestedSetPayloadImpl for each member.
      • setPayload

        public void setPayload​(java.nio.ByteBuffer source,
                               int... indices)
        Description copied from class: CipBOOL
        Arrays of booleans require special payload handling, as bits are packed into an array of primitive types.
        Overrides:
        setPayload in class CipBOOL
      • nestedPutPayload

        public void nestedPutPayload​(boolean asStruct,
                                     java.nio.ByteBuffer dest,
                                     int... indices)
        Description copied from class: BaseDataType
        Variable-length types (Omron strings) can have different encodings when members of structures or arrays. CipStruct will always call this method with asStruct set true so that such types can perform the correct encoding.
        Overrides:
        nestedPutPayload in class BaseDataType<java.lang.Boolean>
        Parameters:
        asStruct - True to invoke structPutPayloadImpl for each member.
      • putPayload

        public void putPayload​(java.nio.ByteBuffer dest,
                               int... indices)
        Description copied from class: CipBOOL
        Arrays of booleans require special payload handling, as bits are * packed into an array of primitive types.
        Overrides:
        putPayload in class CipBOOL
      • crcName

        public java.lang.String crcName()
        Description copied from class: BaseDataType
        Obtain the name of this type as used for computing structure CRCs. Can be different from the name(s) used by the CipPath parser.
        Overrides:
        crcName in class CipBOOL.CipBOOL16
        Returns: