Class ConstructedDefSeg
- java.lang.Object
-
- com.automation_pros.odva.cip.path.PathSegment
-
- com.automation_pros.odva.cip.path.DataDefinitionSeg
-
- com.automation_pros.odva.cip.path.ConstructedDefSeg
-
- All Implemented Interfaces:
java.lang.Comparable<PathSegment>
public class ConstructedDefSeg extends DataDefinitionSeg
Encapsulates an elementary data type annotation within a CIP Path definition. Type annotations are generally not passed on the wire, but delimit the path fragment that will go on the wire (before the data type) from the path fragment that will be applied to the payload on the wire.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstructedDefSeg.DecoderDecode bytes expected to contain one encoded path segment.static classConstructedDefSeg.Parser-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
DataDefinitionSeg.DataDefinitionFragment
-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.path.PathSegment
PathSegment.HasAlternateHex
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanlockedprotected BaseDataType<?>sampleprotected inttypeCode-
Fields inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
sLogger
-
Fields inherited from class com.automation_pros.odva.cip.path.PathSegment
identifierChars, segtype
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConstructedDefSeg()protectedConstructedDefSeg(int typeCode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(PathSegment o)protected BaseDataType<?>construct(int[] dimensions, DataContext ctx)Construct an instance of the type represented by this definition, using the given dimensions.booleanequals(java.lang.Object o)intgetBytes()Obtain the number of bytes needed to encode this segment instance in packed format.static ConstructedDefSeggetCached(int typeCode)BaseDataType<?>getSample()intgetSize(DataContext ctx, int... dims)Return the number of bytes occupied by the given data type.intgetSizeImpl(DataContext ctx)Return the number of bytes occupied by a single instance of the given data type.java.util.List<java.lang.String>getTokens()intgetTypeCode()inthashCode()booleanisBoolImpl()Size calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.ConstructedDefSeglock()static ConstructedDefSeglookup(java.lang.Class<?> clazz)static ConstructedDefSeglookup(java.lang.String token)protected voidmakeSample()intnestedSize(DataContext ctx, int... dims)Certain types (Omron strings and booleans) can have different encodings when packed into structures.voidput(java.nio.ByteBuffer dest, boolean padded)Encode the current instance to the given destination.PathSegmentset(java.nio.ByteBuffer source, boolean padded)Replace the current instance content with the decoded source bytes.java.lang.StringsimpleString()Supply s simple descriptive name usable when browsing a hierarchy.-
Methods inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
alignment, browseInner, construct, follow, followOffsets, fromClass, fromData, getPermItem, isBoolHost, isStringData, maxSize, minSize, nestedMaxSize, nestedMinSize, nestedSizeImpl
-
Methods inherited from class com.automation_pros.odva.cip.path.PathSegment
decode, decodeAll, getSegtype, getWords, hexString, mergeTokens, registerHandler, setSegtype, toString
-
-
-
-
Field Detail
-
locked
protected boolean locked
-
typeCode
protected int typeCode
-
sample
protected BaseDataType<?> sample
-
-
Method Detail
-
getCached
public static ConstructedDefSeg getCached(int typeCode)
-
lookup
public static ConstructedDefSeg lookup(java.lang.Class<?> clazz)
-
lookup
public static ConstructedDefSeg lookup(java.lang.String token)
-
lock
public ConstructedDefSeg lock()
-
getTypeCode
public int getTypeCode()
-
getSample
public BaseDataType<?> getSample()
-
getSizeImpl
public int getSizeImpl(DataContext ctx)
Description copied from class:DataDefinitionSegReturn the number of bytes occupied by a single instance of the given data type. When the data is indirect, size is zero. When the data is variable length, size is -1;- Specified by:
getSizeImplin classDataDefinitionSeg- Returns:
- Number of bytes.
-
isBoolImpl
public boolean isBoolImpl()
Description copied from class:DataDefinitionSegSize calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.- Overrides:
isBoolImplin classDataDefinitionSeg- Returns:
-
getSize
public int getSize(DataContext ctx, int... dims)
Description copied from class:DataDefinitionSegReturn the number of bytes occupied by the given data type. When the data is indirect (hosted elsewhere), or variable length, size is -1.When dimensions are provided, compute the bytes the complete array will occupy. Otherwise report the size of a singleton.
- Overrides:
getSizein classDataDefinitionSeg- Returns:
- Number of bytes.
-
nestedSize
public int nestedSize(DataContext ctx, int... dims)
Description copied from class:DataDefinitionSegCertain types (Omron strings and booleans) can have different encodings when packed into structures.- Overrides:
nestedSizein classDataDefinitionSeg
-
construct
protected BaseDataType<?> construct(int[] dimensions, DataContext ctx)
Description copied from class:DataDefinitionSegConstruct an instance of the type represented by this definition, using the given dimensions. This is an implementation detail that permits a DecoratedDefSeg to create arrays.Use the provided context to look up any ambiguous data types.
- Specified by:
constructin classDataDefinitionSeg- Returns:
-
makeSample
protected void makeSample()
-
compareTo
public int compareTo(PathSegment o)
- Specified by:
compareToin interfacejava.lang.Comparable<PathSegment>- Overrides:
compareToin classPathSegment
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classPathSegment
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
simpleString
public java.lang.String simpleString()
Description copied from class:PathSegmentSupply s simple descriptive name usable when browsing a hierarchy. A simple type name for elementary types, a non-detailed description for complex types.- Specified by:
simpleStringin classPathSegment- Returns:
-
set
public PathSegment set(java.nio.ByteBuffer source, boolean padded)
Description copied from class:PathSegmentReplace the current instance content with the decoded source bytes.The caller must ensure that the instance is appropriate for the bytes supplied. This permits instance re-use in optimized applications.
- Specified by:
setin classPathSegment- Parameters:
source- The bytes to be decoded. The position will be left after the last byte of the decoded segment.padded- Alternate format selection. Packed format when false.- Returns:
- The same instance.
-
put
public void put(java.nio.ByteBuffer dest, boolean padded)Description copied from class:PathSegmentEncode the current instance to the given destination.- Specified by:
putin classPathSegment- Parameters:
dest- The buffer receiving the complete encoded instance.padded- Alternate format selection. Packed format when false.
-
getBytes
public int getBytes()
Description copied from class:PathSegmentObtain the number of bytes needed to encode this segment instance in packed format.- Specified by:
getBytesin classPathSegment- Returns:
- Number of bytes, assuming put() will be called with padded false.
-
getTokens
public java.util.List<java.lang.String> getTokens()
- Specified by:
getTokensin classPathSegment
-
-