Class OmronSTRING
- java.lang.Object
-
- com.automation_pros.odva.cip.data.BaseDataType<java.lang.String>
-
- com.automation_pros.odva.cip.data.BaseString
-
- com.automation_pros.odva.cip.data.CipSTRING
-
- com.automation_pros.odva.cip.data.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 Summary
Fields Modifier and Type Field Description protected int
allocation
-
Fields inherited from class com.automation_pros.odva.cip.data.BaseDataType
dimensions, memberOffsets, sLogger, variantContext, varyingDimension
-
-
Constructor Summary
Constructors Constructor Description OmronSTRING(int allocation)
OmronSTRING(int allocation, int[] dimensions)
OmronSTRING(int allocation, int[] dimensions, java.nio.charset.Charset enc)
OmronSTRING(int allocation, java.lang.String s)
OmronSTRING(int allocation, java.lang.String s, java.nio.charset.Charset enc)
OmronSTRING(OmronSTRING data, int[] indices)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
alignment()
Obtain the natural alignment of this data type.protected void
checkAllocation()
OmronSTRING
copy()
Produce a deep clone of the object.java.lang.String
crcName()
Obtain the name of this type as used for computing structure CRCs.int
maxEach()
Obtain the largest number of bytes a single item can occupy in encoded form.int
minEach()
Obtain the smallest number of bytes a single item can occupy in encoded form.int
nestedBytesEach()
Certain types (Omron strings and booleans) can have different encodings when packed into structures.protected int
nestedBytesImpl(int[] indices)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.protected void
nestedPutPayloadImpl(java.nio.ByteBuffer dest, int[] indices)
Omron strings, when accessed nested with multiple other elements, use a non-standard encoding.protected void
nestedSetPayloadImpl(java.nio.ByteBuffer source, int[] indices)
Omron strings, when accessed nested with multiple other elements, uses a non-standard encoding.OmronSTRING
wrap(int[] indices)
Application-side wrapper for inner dimensions.-
Methods inherited from class com.automation_pros.odva.cip.data.CipSTRING
bytesImpl, getCharset, getNestingDef, putPayloadImpl, setPayloadImpl
-
Methods inherited from class com.automation_pros.odva.cip.data.BaseString
bytesEach, copyToImpl, copyToImpl, dataToRawString, get, rawStringToData, set, setDimensions, setFromTokenImpl, singleToString
-
Methods inherited from class com.automation_pros.odva.cip.data.BaseDataType
browseInner, browseInnerImpl, bytes, checkDimensions, chkAbbrevType, concatIndices, conditionalSuffix, copyTo, CRC16, CRC16, CRC16, dim2linear, dim2linear, dim2qty, dim2suffix, dimensionToString, doubleValue, extendIntArray, fillIntArray, get, getCompleteDef, getDimensions, getMemberOffsets, getSymbolType, getTypeCode, getVariantContext, getVaryingDimension, hasOffset, incIdx, intArray, intValue, linear2dim, linear2dim, longValue, makeInstance, nestedBytes, nestedPutPayload, nestedSetPayload, putAbbrevType, putPayload, range2suffix, rawCRC16, set, setFromTokenizer, setFromTokenizerImpl, setFromTokenString, setInt, setLong, setMemberOffsets, setPayload, setupTokenizer, setVariantContext, setVariantDimension, setVariantDimension, sliceTo, structCRCString, toString
-
-
-
-
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 classBaseDataType<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 classBaseDataType<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 classBaseDataType<java.lang.String>
- Parameters:
dest
-indices
-
-
nestedBytesEach
public int nestedBytesEach()
Description copied from class:BaseDataType
Certain types (Omron strings and booleans) can have different encodings when packed into structures. CipStruct will use this method instead ofBaseDataType.bytesEach()
when computing its own bytesEach.The supplied
BaseDataType.nestedBytes(boolean, int...)
implementation will also call this version for arrays.- Overrides:
nestedBytesEach
in classBaseDataType<java.lang.String>
- Returns:
-
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.
-
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.
-
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.
-
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.
-
copy
public OmronSTRING copy()
Description copied from class:BaseDataType
Produce a deep clone of the object.
-
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.
-
-