Class CipStruct
- java.lang.Object
-
- com.automation_pros.odva.cip.data.BaseDataType<BaseDataType<?>[]>
-
- com.automation_pros.odva.cip.data.CipStruct
-
- All Implemented Interfaces:
DataContext
public class CipStruct extends BaseDataType<BaseDataType<?>[]> implements DataContext
-
-
Field Summary
Fields Modifier and Type Field Description protected int
bytesEachCache
protected StructDef
definition
-
Fields inherited from class com.automation_pros.odva.cip.data.BaseDataType
dimensions, memberOffsets, sLogger, variantContext, varyingDimension
-
Fields inherited from interface com.automation_pros.odva.cip.data.DataContext
emptyContext
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CipStruct(CipStruct data, int[] indices)
CipStruct(StructDef definition)
CipStruct(StructDef definition, int[] dimensions)
CipStruct(java.lang.String typeName, StructMember... members)
CipStruct(java.lang.String typeName, java.util.List<? extends StructMember> members)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
alignment()
Obtain the natural alignment of this data type.java.util.List<PathSegment>
browseInnerImpl()
Complex types that have nested data understood by the DataResolver must enumerate the path segments that are appropriate for the current instance's content.int
bytesEach()
Compute the fixed number of bytes per member.protected int
bytesImpl(int[] indices)
Retrieve the bytes payload size of a single array element (or sole element).CipStruct
copy()
Produce a deep clone of the object.protected void
copyToImpl(BaseDataType<?> dest, int[] indices)
Support deep copy operations one element at a time.protected void
copyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)
Support slice copy operations one element at a time.java.lang.String
crcName()
Obtain the name of this type as used for computing structure CRCs.BaseDataType<?>[]
get(int[] indices)
Application-side value retrieval.DecoratedDefSeg
getCompleteDef()
BaseDataType<?>
getCtxDataImpl(java.util.List<PathSegment> reference)
Look up reference data within this current context for use in indirection of various kinds, as described for getCtxData(), which uses this implementation and handles delegation to outer contexts.StructDef
getDefinition()
StructMember
getMember(int idx)
StructMember
getMember(java.lang.String name)
BaseDataType<?>
getMemberData(java.lang.String name, int... indices)
int
getMemberIndex(java.lang.String name)
java.util.List<? extends StructMember>
getMembers()
AnonStructSeg
getNamedDef(java.lang.String typeName)
Look up a named type for use expanding a stub definition or to apply to a different context.DataDefinitionSeg
getNestingDef()
Return the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.DataContext
getParentDataCtx()
Get the next outer DataContext from the current context.java.lang.String
getTypeByCRC(int crc)
Look up a named type by CRC for use directly by a StructureDefSeg or indirectly by an AnonTypeSeg.StructDef
getTypeByName(java.lang.String typeName)
Look up a named type for use constructing nested elements of a structure.java.util.ArrayList<StructDef>
getTypesImpl()
protected BaseDataType<?>[]
makeStorage()
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.void
putAbbrevType(java.nio.ByteBuffer dest)
Many subclasses will be data elements supported by Logix processors.protected void
putPayloadImpl(java.nio.ByteBuffer dest, int[] indices)
Unlike simple data types, the Struct types may take one subscript more than there are dimensions -- selecting a specific member from the structure.void
set(int[] indices, BaseDataType<?>[] val)
Application-side value storage.void
setFromTokenizer(java.io.StreamTokenizer st, int... indices)
Common implementation for setting values from a potentially customized string tokenizer.protected void
setPayloadImpl(java.nio.ByteBuffer source, int[] indices)
Unlike simple data types, the Struct types may take one subscript more than there are dimensions -- selecting a specific member from the structure.protected java.lang.String
singleToString(int[] indices)
CipStruct
wrap(int[] indices)
Application-side wrapper for inner dimensions.-
Methods inherited from class com.automation_pros.odva.cip.data.BaseDataType
browseInner, bytes, checkDimensions, chkAbbrevType, concatIndices, conditionalSuffix, copyTo, CRC16, CRC16, CRC16, dim2linear, dim2linear, dim2qty, dim2suffix, dimensionToString, doubleValue, extendIntArray, fillIntArray, get, getDimensions, getMemberOffsets, getSymbolType, getTypeCode, getVariantContext, getVaryingDimension, hasOffset, incIdx, intArray, intValue, linear2dim, linear2dim, longValue, makeInstance, nestedBytes, nestedBytesEach, nestedBytesImpl, nestedPutPayload, nestedPutPayloadImpl, nestedSetPayload, nestedSetPayloadImpl, putPayload, range2suffix, rawCRC16, set, setDimensions, setFromTokenImpl, setFromTokenizerImpl, setFromTokenString, setInt, setLong, setMemberOffsets, setPayload, setupTokenizer, setVariantContext, setVariantDimension, setVariantDimension, sliceTo, structCRCString, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.automation_pros.odva.cip.data.DataContext
fromEnum, getCtxData, getCtxDataOrNull, getTypes, makeHosted, makeUnhosted, toEnum
-
-
-
-
Field Detail
-
definition
protected final StructDef definition
-
bytesEachCache
protected int bytesEachCache
-
-
Constructor Detail
-
CipStruct
public CipStruct(java.lang.String typeName, StructMember... members)
-
CipStruct
public CipStruct(java.lang.String typeName, java.util.List<? extends StructMember> members)
-
CipStruct
public CipStruct(StructDef definition)
-
CipStruct
public CipStruct(StructDef definition, int[] dimensions)
-
CipStruct
protected CipStruct(CipStruct data, int[] indices)
-
-
Method Detail
-
makeStorage
protected BaseDataType<?>[] makeStorage()
-
getNestingDef
public DataDefinitionSeg getNestingDef()
Description copied from class:BaseDataType
Return the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.- Specified by:
getNestingDef
in classBaseDataType<BaseDataType<?>[]>
-
getCompleteDef
public DecoratedDefSeg getCompleteDef()
- Overrides:
getCompleteDef
in classBaseDataType<BaseDataType<?>[]>
-
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 classBaseDataType<BaseDataType<?>[]>
- Returns:
-
browseInnerImpl
public java.util.List<PathSegment> browseInnerImpl()
Description copied from class:BaseDataType
Complex types that have nested data understood by the DataResolver must enumerate the path segments that are appropriate for the current instance's content. This is typically static for structure members, but dynamic for international string languages.- Overrides:
browseInnerImpl
in classBaseDataType<BaseDataType<?>[]>
- Returns:
- A list of currently valid path selector segments.
-
getDefinition
public StructDef getDefinition()
-
getMember
public StructMember getMember(int idx)
-
getMember
public StructMember getMember(java.lang.String name)
-
getMemberIndex
public int getMemberIndex(java.lang.String name)
-
getMemberData
public BaseDataType<?> getMemberData(java.lang.String name, int... indices)
-
getMembers
public java.util.List<? extends StructMember> getMembers()
-
get
public BaseDataType<?>[] get(int[] indices)
Description copied from class:BaseDataType
Application-side value retrieval. Subclasses must implement this function to retrieve elements of the storage array in the application data type.- Specified by:
get
in classBaseDataType<BaseDataType<?>[]>
- Parameters:
indices
- Array subscripts. Missing subscripts not allowed.- Returns:
-
set
public void set(int[] indices, BaseDataType<?>[] val)
Description copied from class:BaseDataType
Application-side value storage. Subclasses must implement this function to store one value or complex element into the storage array.- Specified by:
set
in classBaseDataType<BaseDataType<?>[]>
- Parameters:
indices
- Array subscripts. Missing subscripts not allowed.
-
setPayloadImpl
protected void setPayloadImpl(java.nio.ByteBuffer source, int[] indices)
Unlike simple data types, the Struct types may take one subscript more than there are dimensions -- selecting a specific member from the structure. For booleans attached to a host member, this will read one byte from the source.- Specified by:
setPayloadImpl
in classBaseDataType<BaseDataType<?>[]>
-
setFromTokenizer
public void setFromTokenizer(java.io.StreamTokenizer st, int... indices)
Description copied from class:BaseDataType
Common implementation for setting values from a potentially customized string tokenizer.- Overrides:
setFromTokenizer
in classBaseDataType<BaseDataType<?>[]>
-
putPayloadImpl
protected void putPayloadImpl(java.nio.ByteBuffer dest, int[] indices)
Unlike simple data types, the Struct types may take one subscript more than there are dimensions -- selecting a specific member from the structure. For booleans attached to a host member, this will write one byte to the destination.- Specified by:
putPayloadImpl
in classBaseDataType<BaseDataType<?>[]>
-
putAbbrevType
public void putAbbrevType(java.nio.ByteBuffer dest)
Description copied from class:BaseDataType
Many subclasses will be data elements supported by Logix processors. The LogixTagType interface requires this routine, which is identical for all types with a compact representation.- Overrides:
putAbbrevType
in classBaseDataType<BaseDataType<?>[]>
-
bytesEach
public int bytesEach()
Compute the fixed number of bytes per member. If any member indicates a variable number of bytes, the entire structure is variable length.- Specified by:
bytesEach
in classBaseDataType<BaseDataType<?>[]>
- 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 classBaseDataType<BaseDataType<?>[]>
- 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 classBaseDataType<BaseDataType<?>[]>
- 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 classBaseDataType<BaseDataType<?>[]>
- Returns:
-
bytesImpl
protected int bytesImpl(int[] indices)
Description copied from class:BaseDataType
Retrieve the bytes payload size of a single array element (or sole element). Objects with fixed element sizes may simply return bytesEach() here.- Specified by:
bytesImpl
in classBaseDataType<BaseDataType<?>[]>
- Returns:
-
copy
public CipStruct copy()
Description copied from class:BaseDataType
Produce a deep clone of the object.- Specified by:
copy
in classBaseDataType<BaseDataType<?>[]>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] indices)
Description copied from class:BaseDataType
Support deep copy operations one element at a time.- Specified by:
copyToImpl
in classBaseDataType<BaseDataType<?>[]>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)
Description copied from class:BaseDataType
Support slice copy operations one element at a time.- Specified by:
copyToImpl
in classBaseDataType<BaseDataType<?>[]>
-
wrap
public CipStruct 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.- Specified by:
wrap
in classBaseDataType<BaseDataType<?>[]>
- Parameters:
indices
- Array subscripts. Missing subscripts are allowed.
-
getParentDataCtx
public DataContext getParentDataCtx()
Description copied from interface:DataContext
Get the next outer DataContext from the current context.- Specified by:
getParentDataCtx
in interfaceDataContext
- Returns:
- The containing DataContext, or null if the current context is the root context.
-
getNamedDef
public AnonStructSeg getNamedDef(java.lang.String typeName)
Description copied from interface:DataContext
Look up a named type for use expanding a stub definition or to apply to a different context.- Specified by:
getNamedDef
in interfaceDataContext
-
getTypeByName
public StructDef getTypeByName(java.lang.String typeName)
Description copied from interface:DataContext
Look up a named type for use constructing nested elements of a structure.- Specified by:
getTypeByName
in interfaceDataContext
- Parameters:
typeName
- The type name to look up in the predefined names.- Returns:
- The type suitable for use with CipStruct and/or StructMember.
-
getTypesImpl
public java.util.ArrayList<StructDef> getTypesImpl()
- Specified by:
getTypesImpl
in interfaceDataContext
-
getTypeByCRC
public java.lang.String getTypeByCRC(int crc)
Description copied from interface:DataContext
Look up a named type by CRC for use directly by a StructureDefSeg or indirectly by an AnonTypeSeg.- Specified by:
getTypeByCRC
in interfaceDataContext
- Returns:
- The type suitable for use with CipStruct and/or StructMember.
-
getCtxDataImpl
public BaseDataType<?> getCtxDataImpl(java.util.List<PathSegment> reference)
Description copied from interface:DataContext
Look up reference data within this current context for use in indirection of various kinds, as described for getCtxData(), which uses this implementation and handles delegation to outer contexts.- Specified by:
getCtxDataImpl
in interfaceDataContext
- Parameters:
reference
- The path to a data item.- Returns:
- A data object
-
singleToString
protected java.lang.String singleToString(int[] indices)
- Overrides:
singleToString
in classBaseDataType<BaseDataType<?>[]>
-
-