Class StructDef
- java.lang.Object
-
- com.automation_pros.odva.cip.data.StructDef
-
- Direct Known Subclasses:
PermStructDef
public class StructDef extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStructDef.Alignerprotected static classStructDef.ForceAlignerprotected static classStructDef.LogixAlignerprotected static classStructDef.SimpleAligner
-
Field Summary
Fields Modifier and Type Field Description protected static StructDef.AlignerALIGN1protected static StructDef.AlignerALIGN2protected static StructDef.AlignerALIGN2Cprotected static StructDef.AlignerALIGN4protected static StructDef.AlignerALIGN4Lprotected static StructDef.AlignerALIGN8protected static StructDef.AlignerALIGN8LStructDef.AligneralignerbooleanaltAlignprotected java.lang.IntegerapplicationCRCprotected java.util.Map<StructDef,int[]>copyCachejava.lang.StringCRCstringDataContextcreateCtxintdepthprotected java.lang.Stringdocumentationprotected java.util.Map<PathSegment,StructMember>indexbooleanlogixCompatibleprotected intlogixCRCintmaxAlignintmaxSizejava.util.List<? extends StructMember>membersintminSizeprotected StructDefSegnestingSegintsizestatic org.slf4j.LoggersLoggerprotected AnonStructSegstructSegprotected inttemplateInstancejava.lang.StringtypeName
-
Constructor Summary
Constructors Constructor Description StructDef(java.lang.String typeName, int alignment, java.util.List<? extends StructMember> members)StructDef(java.lang.String typeName, AnonStructSeg anon, DataContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckCircular(java.lang.String[] excludes)Implementations that use named types must call this before any attempt to instantiate in order to verify no circular type reference would be established.intgetAlignment()java.lang.IntegergetApplicationCRC()StructMembergetBooleanAt(int bitOffset)Locate the hosted boolean member that exactly matches the given bit offset, or the alias member that resolves to the same.int[]getCopyMap(StructDef other)java.lang.StringgetDocumentation()intgetEffectiveCRC()intgetLogixCRC()StructMembergetMember(PathSegment seg)Look up a structure member by path segment selector.StructMembergetMember(java.lang.String name)Look up a named member.java.util.List<StructMember>getMemberAt(int offset, int bytes)Locate the concrete member(s) that contain(s) the given byte offset.StructDefSeggetNestingSeg()Get an abbreviated form, if possible.AnonStructSeggetStructSeg()Get the full definition of this structure.intgetTemplateInstance()voidsetApplicationCRC(java.lang.Integer applicationCRC)voidsetDocumentation(java.lang.String documentation)voidsetTemplateInstance(int templateInstance)java.lang.StringtoDetailString()java.lang.StringtoString()
-
-
-
Field Detail
-
sLogger
public static final org.slf4j.Logger sLogger
-
ALIGN1
protected static StructDef.Aligner ALIGN1
-
ALIGN2C
protected static StructDef.Aligner ALIGN2C
-
ALIGN2
protected static StructDef.Aligner ALIGN2
-
ALIGN4
protected static StructDef.Aligner ALIGN4
-
ALIGN8
protected static StructDef.Aligner ALIGN8
-
ALIGN4L
protected static StructDef.Aligner ALIGN4L
-
ALIGN8L
protected static StructDef.Aligner ALIGN8L
-
typeName
public final java.lang.String typeName
-
CRCstring
public final java.lang.String CRCstring
-
members
public final java.util.List<? extends StructMember> members
-
index
protected final java.util.Map<PathSegment,StructMember> index
-
copyCache
protected final java.util.Map<StructDef,int[]> copyCache
-
depth
public final int depth
-
maxAlign
public final int maxAlign
-
altAlign
public final boolean altAlign
-
aligner
public final StructDef.Aligner aligner
-
size
public final int size
-
minSize
public final int minSize
-
maxSize
public final int maxSize
-
logixCompatible
public final boolean logixCompatible
-
structSeg
protected final AnonStructSeg structSeg
-
nestingSeg
protected final StructDefSeg nestingSeg
-
logixCRC
protected final int logixCRC
-
applicationCRC
protected java.lang.Integer applicationCRC
-
templateInstance
protected int templateInstance
-
documentation
protected java.lang.String documentation
-
createCtx
public DataContext createCtx
-
-
Constructor Detail
-
StructDef
public StructDef(java.lang.String typeName, AnonStructSeg anon, DataContext ctx)
-
StructDef
public StructDef(java.lang.String typeName, int alignment, java.util.List<? extends StructMember> members)
-
-
Method Detail
-
getAlignment
public int getAlignment()
-
getLogixCRC
public int getLogixCRC()
-
getApplicationCRC
public java.lang.Integer getApplicationCRC()
-
getEffectiveCRC
public int getEffectiveCRC()
-
setApplicationCRC
public void setApplicationCRC(java.lang.Integer applicationCRC)
-
getNestingSeg
public StructDefSeg getNestingSeg()
Get an abbreviated form, if possible. Name is preferred, then application CRC. If neither is available, deliver the anonymous definition.The abbreviated forms are overridden to return this StructDef without regard to a supplied context. See
getStructSeg()for more details.- Returns:
- A self-referential named or abbreviated StructDefSeg if possible. Otherwise returns the full definition.
-
getStructSeg
public AnonStructSeg getStructSeg()
Get the full definition of this structure. This segment is overridden to return this StructDef without regard to any supplied context.This contains all of the finalized type segments for the members. (Assembled in the constructor.)
This captures those type segments that have context overrides for inner structures. The net result is that
DataDefinitionSeg.follow(PathSegment, DataContext)andDataDefinitionSeg.followOffsets(Integer, PathSegment, DataContext)will consistently use theStructDefs that are embedded in this one.- Returns:
-
getTemplateInstance
public int getTemplateInstance()
-
setTemplateInstance
public void setTemplateInstance(int templateInstance)
-
getDocumentation
public java.lang.String getDocumentation()
-
setDocumentation
public void setDocumentation(java.lang.String documentation)
-
checkCircular
public void checkCircular(java.lang.String[] excludes)
Implementations that use named types must call this before any attempt to instantiate in order to verify no circular type reference would be established.- Parameters:
excludes- Array of strings of the named types that must not be defined in any nested type.
-
getMember
public StructMember getMember(PathSegment seg)
Look up a structure member by path segment selector.Throws a CipPathException if not present.
- Parameters:
seg- Path Segment selector to interpret.- Returns:
- Structure member that corresponds.
-
getMember
public StructMember getMember(java.lang.String name)
Look up a named member.- Parameters:
name- The member name.- Returns:
- The structure member, or null if not present.
-
getMemberAt
public java.util.List<StructMember> getMemberAt(int offset, int bytes)
Locate the concrete member(s) that contain(s) the given byte offset. Used to resolve aliases in probe operations.- Parameters:
offset- Byte location.bytes- Required minimum size to consider.- Returns:
- A list of possible structure members that contain that offset and have that minimum size. Ordered from smallest to largest, then by byte offset. This puts matching aliases first. Hosted bits and Aliases that resolve to booleans are skipped. Those would have already been searched.
-
getBooleanAt
public StructMember getBooleanAt(int bitOffset)
Locate the hosted boolean member that exactly matches the given bit offset, or the alias member that resolves to the same.- Parameters:
bitOffset-- Returns:
-
getCopyMap
public int[] getCopyMap(StructDef other)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toDetailString
public java.lang.String toDetailString()
-
-