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 classCipBOOL.CipBOOL16Functionally identical, but uses 16-bit storage by default.static classCipBOOL.CipBOOL32Functionally identical, but uses 32-bit storage by default.static classCipBOOL.CipBOOL64Functionally identical, but uses 64-bit storage by default.
-
Field Summary
Fields Modifier and Type Field Description intstorageBits-
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)protectedCipBOOL(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 intalignment()Obtain the natural alignment of this data type.intbytes(int... indices)Arrays of booleans require special payload handling, as bits are packed into bytes, shorts, integers, or longs.intbytesEach()Obtain the bytes-per-element of this object's payload encoding.protected intbytesImpl(int[] indices)Retrieve the bytes payload size of a single array element (or sole element).CipBOOLcopy()Produce a deep clone of the object.protected voidcopyToImpl(BaseDataType<?> dest, int[] indices)Support deep copy operations one element at a time.protected voidcopyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)Support slice copy operations one element at a time.java.lang.StringcrcName()Obtain the name of this type as used for computing structure CRCs.java.lang.Booleanget(int[] indices)Application-side value retrieval.DataDefinitionSeggetNestingDef()Return the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.shortgetSymbolType()The BOOL data type must include the host bit number in bits 8-10 of the symbol type.intintValue(int... indices)For data types 32-bits wide or less, return the best available 32-bit representation.byte[]leftShiftBytes(byte[] source, int by)static voidmain(java.lang.String[] args)intmaxEach()Obtain the largest number of bytes a single item can occupy in encoded form.intminEach()Obtain the smallest number of bytes a single item can occupy in encoded form.intnestedBytes(boolean asStruct, int... indices)Certain types (Omron strings and booleans) can have different encodings when packed into structures.voidputAbbrevType(java.nio.ByteBuffer dest)Many subclasses will be data elements supported by Logix processors.voidputPayload(java.nio.ByteBuffer dest, int... indices)Arrays of booleans require special payload handling, as bits are * packed into an array of primitive types.protected voidputPayloadImpl(java.nio.ByteBuffer dest, int[] indices)All concrete implementations must supply their per-element encoder here.byte[]rightShiftBytes(byte[] source, int by)voidset(int[] indices, java.lang.Boolean val)Application-side value storage.voidsetDimensions(int[] newDimensions)Update the lengths of the array dimensions to the given values.voidsetPayload(java.nio.ByteBuffer source, int... indices)Arrays of booleans require special payload handling, as bits are packed into an array of primitive types.protected voidsetPayloadImpl(java.nio.ByteBuffer source, int[] indices)All concrete implementations must supply their per-element decoder here.protected java.lang.StringsingleToString(int[] indices)java.lang.StringstructCRCString()Logix processors don't follow CIP Volume 1 Table C-6.9 in their tag read/write routines for structures.CipBOOLwrap(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:BaseDataTypeUpdate 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:
setDimensionsin classBaseDataType<java.lang.Boolean>
-
getNestingDef
public DataDefinitionSeg getNestingDef()
Description copied from class:BaseDataTypeReturn the element (not including array) type definition as a Path Segment, using the abbreviated form if a composite data type.- Specified by:
getNestingDefin classBaseDataType<java.lang.Boolean>
-
crcName
public java.lang.String crcName()
Description copied from class:BaseDataTypeObtain the name of this type as used for computing structure CRCs. Can be different from the name(s) used by the CipPath parser.- Overrides:
crcNamein classBaseDataType<java.lang.Boolean>- Returns:
-
get
public java.lang.Boolean get(int[] indices)
Description copied from class:BaseDataTypeApplication-side value retrieval. Subclasses must implement this function to retrieve elements of the storage array in the application data type.- Specified by:
getin classBaseDataType<java.lang.Boolean>- Parameters:
indices- Array subscripts. Missing subscripts not allowed.- Returns:
-
intValue
public int intValue(int... indices)
Description copied from class:BaseDataTypeFor 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:
intValuein classBaseDataType<java.lang.Boolean>- Parameters:
indices- Array subscripts.- Returns:
-
set
public void set(int[] indices, java.lang.Boolean val)Description copied from class:BaseDataTypeApplication-side value storage. Subclasses must implement this function to store one value or complex element into the storage array.- Specified by:
setin classBaseDataType<java.lang.Boolean>- Parameters:
indices- Array subscripts. Missing subscripts not allowed.
-
bytesEach
public int bytesEach()
Description copied from class:BaseDataTypeObtain 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:
bytesEachin classBaseDataType<java.lang.Boolean>- Returns:
- encoded bytes per element
-
minEach
public int minEach()
Description copied from class:BaseDataTypeObtain 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:
minEachin classBaseDataType<java.lang.Boolean>- Returns:
-
maxEach
public int maxEach()
Description copied from class:BaseDataTypeObtain 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:
maxEachin classBaseDataType<java.lang.Boolean>- Returns:
-
alignment
public int alignment()
Description copied from class:BaseDataTypeObtain 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:
alignmentin 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:
setPayloadin classBaseDataType<java.lang.Boolean>
-
setPayloadImpl
protected void setPayloadImpl(java.nio.ByteBuffer source, int[] indices)Description copied from class:BaseDataTypeAll concrete implementations must supply their per-element decoder here.- Specified by:
setPayloadImplin 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:
putPayloadin classBaseDataType<java.lang.Boolean>
-
putPayloadImpl
protected void putPayloadImpl(java.nio.ByteBuffer dest, int[] indices)Description copied from class:BaseDataTypeAll concrete implementations must supply their per-element encoder here.- Specified by:
putPayloadImplin classBaseDataType<java.lang.Boolean>
-
structCRCString
public java.lang.String structCRCString()
Description copied from class:BaseDataTypeLogix 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:
structCRCStringin classBaseDataType<java.lang.Boolean>- Returns:
-
putAbbrevType
public void putAbbrevType(java.nio.ByteBuffer dest)
Description copied from class:BaseDataTypeMany 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:
putAbbrevTypein 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:
getSymbolTypein 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:
bytesin classBaseDataType<java.lang.Boolean>- Returns:
-
nestedBytes
public int nestedBytes(boolean asStruct, int... indices)Description copied from class:BaseDataTypeCertain 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:
nestedBytesin classBaseDataType<java.lang.Boolean>- Returns:
-
bytesImpl
protected int bytesImpl(int[] indices)
Description copied from class:BaseDataTypeRetrieve the bytes payload size of a single array element (or sole element). Objects with fixed element sizes may simply return bytesEach() here.- Specified by:
bytesImplin classBaseDataType<java.lang.Boolean>- Returns:
-
copy
public CipBOOL copy()
Description copied from class:BaseDataTypeProduce a deep clone of the object.- Specified by:
copyin classBaseDataType<java.lang.Boolean>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] indices)
Description copied from class:BaseDataTypeSupport deep copy operations one element at a time.- Specified by:
copyToImplin classBaseDataType<java.lang.Boolean>
-
copyToImpl
protected void copyToImpl(BaseDataType<?> dest, int[] toIndices, int[] fromIndices)
Description copied from class:BaseDataTypeSupport slice copy operations one element at a time.- Specified by:
copyToImplin classBaseDataType<java.lang.Boolean>
-
wrap
public CipBOOL wrap(int[] indices)
Description copied from class:BaseDataTypeApplication-side wrapper for inner dimensions. Implementations must update memberOffsets if not not using the protected constructor.- Specified by:
wrapin classBaseDataType<java.lang.Boolean>- Parameters:
indices- Array subscripts. Missing subscripts are allowed.
-
singleToString
protected java.lang.String singleToString(int[] indices)
- Overrides:
singleToStringin classBaseDataType<java.lang.Boolean>
-
main
public static void main(java.lang.String[] args)
-
-