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 intbytesEachCacheprotected StructDefdefinition-
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 protectedCipStruct(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 intalignment()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.intbytesEach()Compute the fixed number of bytes per member.protected intbytesImpl(int[] indices)Retrieve the bytes payload size of a single array element (or sole element).CipStructcopy()Produce a deep clone of the object.protected voidcopyToImpl(BaseDataType<?> dest, int[] indices)Support deep copy operations one element at a time.protected voidcopyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)Support slice copy operations one element at a time.java.lang.StringcrcName()Obtain the name of this type as used for computing structure CRCs.BaseDataType<?>[]get(int[] indices)Application-side value retrieval.DecoratedDefSeggetCompleteDef()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.StructDefgetDefinition()StructMembergetMember(int idx)StructMembergetMember(java.lang.String name)BaseDataType<?>getMemberData(java.lang.String name, int... indices)intgetMemberIndex(java.lang.String name)java.util.List<? extends StructMember>getMembers()AnonStructSeggetNamedDef(java.lang.String typeName)Look up a named type for use expanding a stub definition or to apply to a different context.DataDefinitionSeggetNestingDef()Return the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.DataContextgetParentDataCtx()Get the next outer DataContext from the current context.java.lang.StringgetTypeByCRC(int crc)Look up a named type by CRC for use directly by a StructureDefSeg or indirectly by an AnonTypeSeg.StructDefgetTypeByName(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()intmaxEach()Obtain the largest number of bytes a single item can occupy in encoded form.intminEach()Obtain the smallest number of bytes a single item can occupy in encoded form.voidputAbbrevType(java.nio.ByteBuffer dest)Many subclasses will be data elements supported by Logix processors.protected voidputPayloadImpl(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.voidset(int[] indices, BaseDataType<?>[] val)Application-side value storage.voidsetFromTokenizer(java.io.StreamTokenizer st, int... indices)Common implementation for setting values from a potentially customized string tokenizer.protected voidsetPayloadImpl(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.StringsingleToString(int[] indices)CipStructwrap(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:BaseDataTypeReturn the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.- Specified by:
getNestingDefin classBaseDataType<BaseDataType<?>[]>
-
getCompleteDef
public DecoratedDefSeg getCompleteDef()
- Overrides:
getCompleteDefin classBaseDataType<BaseDataType<?>[]>
-
crcName
public java.lang.String crcName()
Description copied from class:BaseDataTypeObtain the name of this type as used for computing structure CRCs. Can be different from the name(s) used by the CipPath parser.- Overrides:
crcNamein classBaseDataType<BaseDataType<?>[]>- Returns:
-
browseInnerImpl
public java.util.List<PathSegment> browseInnerImpl()
Description copied from class:BaseDataTypeComplex 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:
browseInnerImplin 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:BaseDataTypeApplication-side value retrieval. Subclasses must implement this function to retrieve elements of the storage array in the application data type.- Specified by:
getin classBaseDataType<BaseDataType<?>[]>- Parameters:
indices- Array subscripts. Missing subscripts not allowed.- Returns:
-
set
public void set(int[] indices, BaseDataType<?>[] val)Description copied from class:BaseDataTypeApplication-side value storage. Subclasses must implement this function to store one value or complex element into the storage array.- Specified by:
setin 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:
setPayloadImplin classBaseDataType<BaseDataType<?>[]>
-
setFromTokenizer
public void setFromTokenizer(java.io.StreamTokenizer st, int... indices)Description copied from class:BaseDataTypeCommon implementation for setting values from a potentially customized string tokenizer.- Overrides:
setFromTokenizerin 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:
putPayloadImplin classBaseDataType<BaseDataType<?>[]>
-
putAbbrevType
public void putAbbrevType(java.nio.ByteBuffer dest)
Description copied from class:BaseDataTypeMany 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:
putAbbrevTypein 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:
bytesEachin classBaseDataType<BaseDataType<?>[]>- Returns:
- encoded bytes per element
-
minEach
public int minEach()
Description copied from class:BaseDataTypeObtain 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:
minEachin classBaseDataType<BaseDataType<?>[]>- Returns:
-
maxEach
public int maxEach()
Description copied from class:BaseDataTypeObtain 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:
maxEachin classBaseDataType<BaseDataType<?>[]>- Returns:
-
alignment
public int alignment()
Description copied from class:BaseDataTypeObtain 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:
alignmentin classBaseDataType<BaseDataType<?>[]>- Returns:
-
bytesImpl
protected int bytesImpl(int[] indices)
Description copied from class:BaseDataTypeRetrieve the bytes payload size of a single array element (or sole element). Objects with fixed element sizes may simply return bytesEach() here.- Specified by:
bytesImplin classBaseDataType<BaseDataType<?>[]>- Returns:
-
copy
public CipStruct copy()
Description copied from class:BaseDataTypeProduce a deep clone of the object.- Specified by:
copyin classBaseDataType<BaseDataType<?>[]>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] indices)
Description copied from class:BaseDataTypeSupport deep copy operations one element at a time.- Specified by:
copyToImplin classBaseDataType<BaseDataType<?>[]>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)
Description copied from class:BaseDataTypeSupport slice copy operations one element at a time.- Specified by:
copyToImplin classBaseDataType<BaseDataType<?>[]>
-
wrap
public CipStruct wrap(int[] indices)
Description copied from class:BaseDataTypeApplication-side wrapper for inner dimensions. Implementations must update memberOffsets if not not using the protected constructor.- Specified by:
wrapin classBaseDataType<BaseDataType<?>[]>- Parameters:
indices- Array subscripts. Missing subscripts are allowed.
-
getParentDataCtx
public DataContext getParentDataCtx()
Description copied from interface:DataContextGet the next outer DataContext from the current context.- Specified by:
getParentDataCtxin 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:DataContextLook up a named type for use expanding a stub definition or to apply to a different context.- Specified by:
getNamedDefin interfaceDataContext
-
getTypeByName
public StructDef getTypeByName(java.lang.String typeName)
Description copied from interface:DataContextLook up a named type for use constructing nested elements of a structure.- Specified by:
getTypeByNamein 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:
getTypesImplin interfaceDataContext
-
getTypeByCRC
public java.lang.String getTypeByCRC(int crc)
Description copied from interface:DataContextLook up a named type by CRC for use directly by a StructureDefSeg or indirectly by an AnonTypeSeg.- Specified by:
getTypeByCRCin 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:DataContextLook 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:
getCtxDataImplin interfaceDataContext- Parameters:
reference- The path to a data item.- Returns:
- A data object
-
singleToString
protected java.lang.String singleToString(int[] indices)
- Overrides:
singleToStringin classBaseDataType<BaseDataType<?>[]>
-
-