Class StructMember
- java.lang.Object
-
- com.automation_pros.odva.cip.data.StructMember
-
- Direct Known Subclasses:
PermStructMbr
public class StructMember extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classStructMember.MemberTypeSegmentImplement a decorated type segment for members that is implicitly tied to the StructMember (see the beginning of the ultimate private StructMember constructor).
-
Field Summary
Fields Modifier and Type Field Description intalignDataDefinitionSegbareSegmentjava.lang.StringCRCstringprotected java.lang.Stringdocumentationbooleanhiddenbooleanhostedprotected StructMemberhostrefprotected intindexprotected StructDefinnerstructprotected intmaxOffsetintmaxSizeprotected intminOffsetintminSizejava.lang.Stringnameprotected intoffsetprotected BaseDataType<?>singletonintsizeprotected inttypeCodeprotected java.lang.StringtypeNameStructMember.MemberTypeSegmenttypeSegmentprotected java.lang.LongunusedParasiteBits
-
Constructor Summary
Constructors Modifier Constructor Description StructMember(DataDefinitionSeg seg, DataContext ctx)Construct a StructMember given a type definition segment and a context with which to construct a nested structure if necessary.protectedStructMember(DecoratedDefSeg seg, StructDef inner, BaseDataType<?> singleton)StructMember(java.lang.String name, BaseDataType<?> data)Construct a StructMember from a Singleton data item.StructMember(java.lang.String name, StructDef innerstruct, int[] innerdim)Construct a StructMember that will be a nested structure.StructMember(java.lang.String name, java.lang.Class<? extends BaseDataType<?>> element, int... innerdim)Construct a StructMember using an elementary or constructed data type, or a subclass thereof.StructMember(java.lang.String name, java.lang.String host, int bitnum)Construct a boolean StructMember that points at a specific bit in another (named) StructMember.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckCircular(java.lang.String[] excludes)protected voidcheckParasite(int parasiteBit, int qty)java.lang.StringdocString(boolean fullDoc)StructMemberduplicate()intgetBitOffset()intgetDepth()int[]getDimensions()java.lang.StringgetDocumentation()StructMembergetHostref()intgetIndex()shortgetInfo()Where the member datatype permits, support Logix-style type discovery for this member's type.int[]getInnerOffsets()StructDefgetInnerStruct()BaseDataType<?>getInstance(DataContext ctx)Provide a method for CipStruct to assemble its storage array element for this member.BaseDataType<?>getInstance(DataContext ctx, BaseDataType<?> hostInst)Provide a method for CipStruct to assemble its storage array element for this hosted member.intgetMaxOffset()intgetMinOffset()java.lang.StringgetName()intgetOffset()StructDefgetOwner()BaseDataType<?>getSingleton()intgetStructByteOffset()shortgetSymbolType()java.lang.StringgetTypeName()java.lang.LonggetUnusedParasites()CipPathgetVariant()voidlock(StructDef owner)voidsetDocumentation(java.lang.String documentation)voidsetHostref(StructMember hostref)voidsetIndex(int index)voidsetInnerOffsets(int[] offsets)voidsetMinMaxOffset(int minOfs, int maxOfs)voidsetOffset(int offset)voidsetVariantDimension(CipPath variantDimension)java.lang.StringtoString()
-
-
-
Field Detail
-
name
public final java.lang.String name
-
typeName
protected final java.lang.String typeName
-
CRCstring
public final java.lang.String CRCstring
-
typeCode
protected final int typeCode
-
typeSegment
public final StructMember.MemberTypeSegment typeSegment
-
bareSegment
public final DataDefinitionSeg bareSegment
-
hosted
public final boolean hosted
-
size
public final int size
-
minSize
public final int minSize
-
maxSize
public final int maxSize
-
align
public final int align
-
hostref
protected StructMember hostref
-
unusedParasiteBits
protected java.lang.Long unusedParasiteBits
-
innerstruct
protected final StructDef innerstruct
-
singleton
protected final BaseDataType<?> singleton
-
index
protected int index
-
offset
protected int offset
-
minOffset
protected int minOffset
-
maxOffset
protected int maxOffset
-
documentation
protected java.lang.String documentation
-
hidden
public boolean hidden
-
-
Constructor Detail
-
StructMember
public StructMember(java.lang.String name, BaseDataType<?> data)Construct a StructMember from a Singleton data item. All actual CipStruct instances created containing this member will share this same data instance.- Parameters:
name- The name of this structure field.data- The singleton to supply for all structure instances.
-
StructMember
public StructMember(java.lang.String name, java.lang.String host, int bitnum)Construct a boolean StructMember that points at a specific bit in another (named) StructMember. Validation of this relationship occurs when the list of members is assembled into a StructDef.- Parameters:
name- The name of this structure field.host- The name of the host field. Must be an integer or word type. Suitable types implement the BoolHost interface.bitnum- The offset into the host field.
-
StructMember
public StructMember(java.lang.String name, java.lang.Class<? extends BaseDataType<?>> element, int... innerdim)Construct a StructMember using an elementary or constructed data type, or a subclass thereof.- Parameters:
name- The name of this structure field.element- The class to instantiate in new CipStruct instances. Must not be CipStruct.class.innerdim- The array dimension(s) for this member in new CipStruct instances. May not have more than one dimension if to be exposed to Logix-style tag/type browse operations.
-
StructMember
public StructMember(java.lang.String name, StructDef innerstruct, int[] innerdim)Construct a StructMember that will be a nested structure. Circular references will be detected and rejected when the list of members is assembled into a StructDef.- Parameters:
name- The name of this structure field.innerstruct- The structure definition to nest. Must have MaxAlign 4 or 8 to be exposed to Logix-style tag/type browse operations.innerdim- The array dimension(s) for this member in new CipStruct instances. May not have more than one dimension if to be exposed to Logix-style tag/type browse operations.
-
StructMember
public StructMember(DataDefinitionSeg seg, DataContext ctx)
Construct a StructMember given a type definition segment and a context with which to construct a nested structure if necessary. May also be decorated to have a member name.- Parameters:
seg- Member data type, possibly decorated.ctx- Construction context if seg is, or contains, a StructDefSeg.
-
StructMember
protected StructMember(DecoratedDefSeg seg, StructDef inner, BaseDataType<?> singleton)
-
-
Method Detail
-
duplicate
public StructMember duplicate()
-
getDocumentation
public java.lang.String getDocumentation()
-
setDocumentation
public void setDocumentation(java.lang.String documentation)
-
getInnerOffsets
public int[] getInnerOffsets()
-
setInnerOffsets
public void setInnerOffsets(int[] offsets)
-
checkCircular
public void checkCircular(java.lang.String[] excludes)
-
getName
public java.lang.String getName()
-
getInnerStruct
public StructDef getInnerStruct()
-
getDimensions
public int[] getDimensions()
-
getOwner
public StructDef getOwner()
-
getHostref
public StructMember getHostref()
-
setHostref
public void setHostref(StructMember hostref)
-
checkParasite
protected void checkParasite(int parasiteBit, int qty)
-
getUnusedParasites
public java.lang.Long getUnusedParasites()
-
getIndex
public int getIndex()
-
getDepth
public int getDepth()
-
setIndex
public void setIndex(int index)
-
getVariant
public CipPath getVariant()
-
setVariantDimension
public void setVariantDimension(CipPath variantDimension)
-
getInfo
public short getInfo()
Where the member datatype permits, support Logix-style type discovery for this member's type. This method provides the 16-bit "Info" field needed to reply to a template read service.- Returns:
-
getInstance
public BaseDataType<?> getInstance(DataContext ctx)
Provide a method for CipStruct to assemble its storage array element for this member. This form is for non-hosted members.- Parameters:
ctx- Reference for looking up other structure types, if necessary. Actually the enclosing CipStruct, which delegates to its variant context.- Returns:
- A space-occupying member instance, with its variant context set to the given context.
-
getSingleton
public BaseDataType<?> getSingleton()
-
getInstance
public BaseDataType<?> getInstance(DataContext ctx, BaseDataType<?> hostInst)
Provide a method for CipStruct to assemble its storage array element for this hosted member. CipStruct will present the hosting instance to ensure the entire object is tied together correctly.- Parameters:
ctx- Reference for passing to a DataResolver.hostInst- The pre-selected host instance for this hosted member.- Returns:
- A hosted member instance, with its variant context set to the given context.
-
getTypeName
public java.lang.String getTypeName()
-
getOffset
public int getOffset()
-
getMinOffset
public int getMinOffset()
-
getMaxOffset
public int getMaxOffset()
-
lock
public void lock(StructDef owner)
-
setOffset
public void setOffset(int offset)
-
setMinMaxOffset
public void setMinMaxOffset(int minOfs, int maxOfs)
-
getBitOffset
public int getBitOffset()
-
getStructByteOffset
public int getStructByteOffset()
-
getSymbolType
public short getSymbolType()
-
docString
public java.lang.String docString(boolean fullDoc)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-