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 interface
StructDef.Aligner
protected static class
StructDef.ForceAligner
protected static class
StructDef.LogixAligner
protected static class
StructDef.SimpleAligner
-
Field Summary
Fields Modifier and Type Field Description protected static StructDef.Aligner
ALIGN1
protected static StructDef.Aligner
ALIGN2
protected static StructDef.Aligner
ALIGN2C
protected static StructDef.Aligner
ALIGN4
protected static StructDef.Aligner
ALIGN4L
protected static StructDef.Aligner
ALIGN8
protected static StructDef.Aligner
ALIGN8L
StructDef.Aligner
aligner
boolean
altAlign
protected java.lang.Integer
applicationCRC
protected java.util.Map<StructDef,int[]>
copyCache
java.lang.String
CRCstring
DataContext
createCtx
int
depth
protected java.lang.String
documentation
protected java.util.Map<PathSegment,StructMember>
index
boolean
logixCompatible
protected int
logixCRC
int
maxAlign
int
maxSize
java.util.List<? extends StructMember>
members
int
minSize
protected StructDefSeg
nestingSeg
int
size
static org.slf4j.Logger
sLogger
protected AnonStructSeg
structSeg
protected int
templateInstance
java.lang.String
typeName
-
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 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.int
getAlignment()
java.lang.Integer
getApplicationCRC()
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.int[]
getCopyMap(StructDef other)
java.lang.String
getDocumentation()
int
getEffectiveCRC()
int
getLogixCRC()
StructMember
getMember(PathSegment seg)
Look up a structure member by path segment selector.StructMember
getMember(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.StructDefSeg
getNestingSeg()
Get an abbreviated form, if possible.AnonStructSeg
getStructSeg()
Get the full definition of this structure.int
getTemplateInstance()
void
setApplicationCRC(java.lang.Integer applicationCRC)
void
setDocumentation(java.lang.String documentation)
void
setTemplateInstance(int templateInstance)
java.lang.String
toDetailString()
java.lang.String
toString()
-
-
-
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 theStructDef
s 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:
toString
in classjava.lang.Object
-
toDetailString
public java.lang.String toDetailString()
-
-