Class OmronSTRING


  • public class OmronSTRING
    extends CipSTRING
    The Omron NJ/NX processor family implements its STRING datatype with varying semantics on the wire. When such a string is accessed directly in a symbolic read or write operation, it behaves as described for the native CIP STRING datatype: 16-bit little-endian length prefix followed by the actual bytes in use in the variable. The type code 0xd0 (with zero pad) is reported for reads and required for writes. The EtherNet/IP interface User Manual W506 §8-7-4 indicates that the format changes when accessing multiple consecutive elements of an array by including "number of elements" not equal to one in the read or write service. The docs indicate that the entire allocation for each string is transmitted, null padded instead of with a length prefix. It also indicates that the bytes are to be swapped per word for this case. However, attempts to use the services as documented fail with general error 0x1f (on my lab NJ501-1300), which itself is undocumented (for Omron). The byte swapping is also suspect because the same document, in §A-5-1, indicates that STRINGs are byte-aligned and allocated in byte increments. Byte swapping is not appropriate/applicable when not word aligned or not length padded to a word boundary. Further, §8-7-4 later states that structures are read in contiguous blocks of bytes. Testing demonstrates that bytes, byte arrays, and STRINGs are indeed byte aligned in structures, and that STRINGs are transferred by allocated bytes without length prefix, and that their bytes are not swapped. Arrays of strings embedded in structures will transfer in this fashion when the containing structure is requested, even though access to multiple elements of that string array is refused.
    • Field Detail

      • allocation

        protected final int allocation
    • Constructor Detail

      • OmronSTRING

        public OmronSTRING​(int allocation)
      • OmronSTRING

        public OmronSTRING​(int allocation,
                           java.lang.String s)
      • OmronSTRING

        public OmronSTRING​(int allocation,
                           java.lang.String s,
                           java.nio.charset.Charset enc)
      • OmronSTRING

        public OmronSTRING​(int allocation,
                           int[] dimensions)
      • OmronSTRING

        public OmronSTRING​(int allocation,
                           int[] dimensions,
                           java.nio.charset.Charset enc)
      • OmronSTRING

        public OmronSTRING​(OmronSTRING data,
                           int[] indices)
    • Method Detail

      • checkAllocation

        protected void checkAllocation()
      • nestedBytesImpl

        protected int nestedBytesImpl​(int[] indices)
        Description copied from class: BaseDataType
        Certain types (Omron strings and booleans) can have different encodings when packed into structures. Such types must override this method to substitute the correct encoding length for that case.
        Overrides:
        nestedBytesImpl in class BaseDataType<java.lang.String>
        Returns:
      • nestedSetPayloadImpl

        protected void nestedSetPayloadImpl​(java.nio.ByteBuffer source,
                                            int[] indices)
        Omron strings, when accessed nested with multiple other elements, uses a non-standard encoding. It is a byte array of the defined storage size. No length header, ASCII NUL terminated.
        Overrides:
        nestedSetPayloadImpl in class BaseDataType<java.lang.String>
        Parameters:
        source -
        indices -
      • nestedPutPayloadImpl

        protected void nestedPutPayloadImpl​(java.nio.ByteBuffer dest,
                                            int[] indices)
        Omron strings, when accessed nested with multiple other elements, use a non-standard encoding. It is a byte array of the defined storage size. No length header, ASCII NUL terminated.
        Overrides:
        nestedPutPayloadImpl in class BaseDataType<java.lang.String>
        Parameters:
        dest -
        indices -
      • 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 CipSTRING
        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 CipSTRING
        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 CipSTRING
        Returns:
      • 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 CipSTRING
        Returns:
      • wrap

        public OmronSTRING wrap​(int[] indices)
        Description copied from class: BaseDataType
        Application-side wrapper for inner dimensions. Implementations must update memberOffsets if not not using the protected constructor.
        Overrides:
        wrap in class CipSTRING
        Parameters:
        indices - Array subscripts. Missing subscripts are allowed.