Class CipBOOL
- java.lang.Object
-
- com.automation_pros.odva.cip.data.BaseDataType<java.lang.Boolean>
-
- com.automation_pros.odva.cip.data.CipBOOL
-
- Direct Known Subclasses:
CipBOOL.CipBOOL16
,CipBOOL.CipBOOL32
,CipBOOL.CipBOOL64
public class CipBOOL extends BaseDataType<java.lang.Boolean>
Rockwell's processors don't actually use BOOL variables in arrays. The instance exposed to the world is really an array of DWORDs.Unlike other types, bit arrays are packed into a single-dimensional storage array, of a selected primitive type. (Byte, short, integer, long.)
Multi-dimensional arrays are translated to/from a linear subscript as needed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CipBOOL.CipBOOL16
Functionally identical, but uses 16-bit storage by default.static class
CipBOOL.CipBOOL32
Functionally identical, but uses 32-bit storage by default.static class
CipBOOL.CipBOOL64
Functionally identical, but uses 64-bit storage by default.
-
Field Summary
Fields Modifier and Type Field Description int
storageBits
-
Fields inherited from class com.automation_pros.odva.cip.data.BaseDataType
dimensions, memberOffsets, sLogger, variantContext, varyingDimension
-
-
Constructor Summary
Constructors Modifier Constructor Description CipBOOL(boolean state)
Construct a stand-alone CIP BOOL data value with the given initial value.CipBOOL(boolean state, int storageBits)
CipBOOL(int[] dimensions)
Construct a stand-alone array CIP BOOL data value with the given dimensions, all initialized to false.CipBOOL(int[] dimensions, int storageBits)
protected
CipBOOL(CipBOOL data, int[] indices)
CipBOOL(PathSegment parentSeg, BoolHost parent, int bitnum)
Construct a BOOL structure member from a specific bit of a host member of the same structure.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
alignment()
Obtain the natural alignment of this data type.int
bytes(int... indices)
Arrays of booleans require special payload handling, as bits are packed into bytes, shorts, integers, or longs.int
bytesEach()
Obtain the bytes-per-element of this object's payload encoding.protected int
bytesImpl(int[] indices)
Retrieve the bytes payload size of a single array element (or sole element).CipBOOL
copy()
Produce a deep clone of the object.protected void
copyToImpl(BaseDataType<?> dest, int[] indices)
Support deep copy operations one element at a time.protected void
copyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)
Support slice copy operations one element at a time.java.lang.String
crcName()
Obtain the name of this type as used for computing structure CRCs.java.lang.Boolean
get(int[] indices)
Application-side value retrieval.DataDefinitionSeg
getNestingDef()
Return the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.short
getSymbolType()
The BOOL data type must include the host bit number in bits 8-10 of the symbol type.int
intValue(int... indices)
For data types 32-bits wide or less, return the best available 32-bit representation.byte[]
leftShiftBytes(byte[] source, int by)
static void
main(java.lang.String[] args)
int
maxEach()
Obtain the largest number of bytes a single item can occupy in encoded form.int
minEach()
Obtain the smallest number of bytes a single item can occupy in encoded form.int
nestedBytes(boolean asStruct, int... indices)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.void
putAbbrevType(java.nio.ByteBuffer dest)
Many subclasses will be data elements supported by Logix processors.void
putPayload(java.nio.ByteBuffer dest, int... indices)
Arrays of booleans require special payload handling, as bits are * packed into an array of primitive types.protected void
putPayloadImpl(java.nio.ByteBuffer dest, int[] indices)
All concrete implementations must supply their per-element encoder here.byte[]
rightShiftBytes(byte[] source, int by)
void
set(int[] indices, java.lang.Boolean val)
Application-side value storage.void
setDimensions(int[] newDimensions)
Update the lengths of the array dimensions to the given values.void
setPayload(java.nio.ByteBuffer source, int... indices)
Arrays of booleans require special payload handling, as bits are packed into an array of primitive types.protected void
setPayloadImpl(java.nio.ByteBuffer source, int[] indices)
All concrete implementations must supply their per-element decoder here.protected java.lang.String
singleToString(int[] indices)
java.lang.String
structCRCString()
Logix processors don't follow CIP Volume 1 Table C-6.9 in their tag read/write routines for structures.CipBOOL
wrap(int[] indices)
Application-side wrapper for inner dimensions.-
Methods inherited from class com.automation_pros.odva.cip.data.BaseDataType
browseInner, browseInnerImpl, checkDimensions, chkAbbrevType, concatIndices, conditionalSuffix, copyTo, CRC16, CRC16, CRC16, dim2linear, dim2linear, dim2qty, dim2suffix, dimensionToString, doubleValue, extendIntArray, fillIntArray, get, getCompleteDef, getDimensions, getMemberOffsets, getTypeCode, getVariantContext, getVaryingDimension, hasOffset, incIdx, intArray, linear2dim, linear2dim, longValue, makeInstance, nestedBytesEach, nestedBytesImpl, nestedPutPayload, nestedPutPayloadImpl, nestedSetPayload, nestedSetPayloadImpl, range2suffix, rawCRC16, set, setFromTokenImpl, setFromTokenizer, setFromTokenizerImpl, setFromTokenString, setInt, setLong, setMemberOffsets, setupTokenizer, setVariantContext, setVariantDimension, setVariantDimension, sliceTo, toString
-
-
-
-
Constructor Detail
-
CipBOOL
public CipBOOL(PathSegment parentSeg, BoolHost parent, int bitnum)
Construct a BOOL structure member from a specific bit of a host member of the same structure.- Parameters:
parent
- The host member containing this BOOL.bitnum
- The bit number, starting with zero as the least significant bit.
-
CipBOOL
public CipBOOL(int[] dimensions)
Construct a stand-alone array CIP BOOL data value with the given dimensions, all initialized to false. Default is storage in bytes.- Parameters:
dimensions
-
-
CipBOOL
public CipBOOL(int[] dimensions, int storageBits)
-
CipBOOL
public CipBOOL(boolean state)
Construct a stand-alone CIP BOOL data value with the given initial value. Default to storage in bytes.- Parameters:
state
- Initial value
-
CipBOOL
public CipBOOL(boolean state, int storageBits)
-
CipBOOL
protected CipBOOL(CipBOOL data, int[] indices)
-
-
Method Detail
-
setDimensions
public void setDimensions(int[] newDimensions)
Description copied from class:BaseDataType
Update the lengths of the array dimensions to the given values. The number of subscripts must match the current number of subscripts. The operation must be data-preserving.This implementation handles pure Object storage types. Anything else must override.
- Overrides:
setDimensions
in classBaseDataType<java.lang.Boolean>
-
getNestingDef
public DataDefinitionSeg getNestingDef()
Description copied from class:BaseDataType
Return the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.- Specified by:
getNestingDef
in classBaseDataType<java.lang.Boolean>
-
crcName
public java.lang.String crcName()
Description copied from class:BaseDataType
Obtain the name of this type as used for computing structure CRCs. Can be different from the name(s) used by the CipPath parser.- Overrides:
crcName
in classBaseDataType<java.lang.Boolean>
- Returns:
-
get
public java.lang.Boolean get(int[] indices)
Description copied from class:BaseDataType
Application-side value retrieval. Subclasses must implement this function to retrieve elements of the storage array in the application data type.- Specified by:
get
in classBaseDataType<java.lang.Boolean>
- Parameters:
indices
- Array subscripts. Missing subscripts not allowed.- Returns:
-
intValue
public int intValue(int... indices)
Description copied from class:BaseDataType
For data types 32-bits wide or less, return the best available 32-bit representation. If the subscripts are incomplete, return the element with the remaining subscripts set to zero.- Overrides:
intValue
in classBaseDataType<java.lang.Boolean>
- Parameters:
indices
- Array subscripts.- Returns:
-
set
public void set(int[] indices, java.lang.Boolean val)
Description copied from class:BaseDataType
Application-side value storage. Subclasses must implement this function to store one value or complex element into the storage array.- Specified by:
set
in classBaseDataType<java.lang.Boolean>
- Parameters:
indices
- Array subscripts. Missing subscripts not allowed.
-
bytesEach
public int bytesEach()
Description copied from class:BaseDataType
Obtain the bytes-per-element of this object's payload encoding. Objects with variable length encodings must return zero and implement the bytesImpl(), minEach(), maxEach(), and alignment() methods instead.- Specified by:
bytesEach
in classBaseDataType<java.lang.Boolean>
- Returns:
- encoded bytes per element
-
minEach
public int minEach()
Description copied from class:BaseDataType
Obtain 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:
minEach
in classBaseDataType<java.lang.Boolean>
- Returns:
-
maxEach
public int maxEach()
Description copied from class:BaseDataType
Obtain 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:
maxEach
in classBaseDataType<java.lang.Boolean>
- Returns:
-
alignment
public int alignment()
Description copied from class:BaseDataType
Obtain 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:
alignment
in classBaseDataType<java.lang.Boolean>
- Returns:
-
leftShiftBytes
public byte[] leftShiftBytes(byte[] source, int by)
-
rightShiftBytes
public byte[] rightShiftBytes(byte[] source, int by)
-
setPayload
public void setPayload(java.nio.ByteBuffer source, int... indices)
Arrays of booleans require special payload handling, as bits are packed into an array of primitive types.- Overrides:
setPayload
in classBaseDataType<java.lang.Boolean>
-
setPayloadImpl
protected void setPayloadImpl(java.nio.ByteBuffer source, int[] indices)
Description copied from class:BaseDataType
All concrete implementations must supply their per-element decoder here.- Specified by:
setPayloadImpl
in classBaseDataType<java.lang.Boolean>
-
putPayload
public void putPayload(java.nio.ByteBuffer dest, int... indices)
Arrays of booleans require special payload handling, as bits are * packed into an array of primitive types.- Overrides:
putPayload
in classBaseDataType<java.lang.Boolean>
-
putPayloadImpl
protected void putPayloadImpl(java.nio.ByteBuffer dest, int[] indices)
Description copied from class:BaseDataType
All concrete implementations must supply their per-element encoder here.- Specified by:
putPayloadImpl
in classBaseDataType<java.lang.Boolean>
-
structCRCString
public java.lang.String structCRCString()
Description copied from class:BaseDataType
Logix processors don't follow CIP Volume 1 Table C-6.9 in their tag read/write routines for structures. Instead, they run the CRC over comma-separated ASCII type strings that make up the structure. This is referred to in the Logix Data Access Programming Manual as the "Structure Handle".- Overrides:
structCRCString
in classBaseDataType<java.lang.Boolean>
- Returns:
-
putAbbrevType
public void putAbbrevType(java.nio.ByteBuffer dest)
Description copied from class:BaseDataType
Many 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:
putAbbrevType
in classBaseDataType<java.lang.Boolean>
-
getSymbolType
public short getSymbolType()
The BOOL data type must include the host bit number in bits 8-10 of the symbol type. Not applicable to arrays of BOOL. (Only applicable to Logix singleton tags). They must be hosted in a primitive type.- Overrides:
getSymbolType
in classBaseDataType<java.lang.Boolean>
-
bytes
public int bytes(int... indices)
Arrays of booleans require special payload handling, as bits are packed into bytes, shorts, integers, or longs.- Overrides:
bytes
in classBaseDataType<java.lang.Boolean>
- Returns:
-
nestedBytes
public int nestedBytes(boolean asStruct, int... indices)
Description copied from class:BaseDataType
Certain types (Omron strings and booleans) can have different encodings when packed into structures. CipStruct will always call this method with asStruct set true so that such types can report the correct size.- Overrides:
nestedBytes
in classBaseDataType<java.lang.Boolean>
- Returns:
-
bytesImpl
protected int bytesImpl(int[] indices)
Description copied from class:BaseDataType
Retrieve the bytes payload size of a single array element (or sole element). Objects with fixed element sizes may simply return bytesEach() here.- Specified by:
bytesImpl
in classBaseDataType<java.lang.Boolean>
- Returns:
-
copy
public CipBOOL copy()
Description copied from class:BaseDataType
Produce a deep clone of the object.- Specified by:
copy
in classBaseDataType<java.lang.Boolean>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] indices)
Description copied from class:BaseDataType
Support deep copy operations one element at a time.- Specified by:
copyToImpl
in classBaseDataType<java.lang.Boolean>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)
Description copied from class:BaseDataType
Support slice copy operations one element at a time.- Specified by:
copyToImpl
in classBaseDataType<java.lang.Boolean>
-
wrap
public CipBOOL wrap(int[] indices)
Description copied from class:BaseDataType
Application-side wrapper for inner dimensions. Implementations must update memberOffsets if not not using the protected constructor.- Specified by:
wrap
in classBaseDataType<java.lang.Boolean>
- Parameters:
indices
- Array subscripts. Missing subscripts are allowed.
-
singleToString
protected java.lang.String singleToString(int[] indices)
- Overrides:
singleToString
in classBaseDataType<java.lang.Boolean>
-
main
public static void main(java.lang.String[] args)
-
-